CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
gui_calendar.c-Dateireferenz
#include "camera_info.h"
#include "keyboard.h"
#include "conf.h"
#include "lang.h"
#include "gui.h"
#include "gui_draw.h"
#include "gui_lang.h"
#include "time.h"
#include "module_def.h"
#include "simple_module.c"
+ Include-Abhängigkeitsdiagramm für gui_calendar.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define TITLE_COLOR   (MAKE_COLOR(COLOR_BLACK, COLOR_WHITE))
 
#define CALENDAR_COLOR   (MAKE_COLOR(COLOR_GREY, COLOR_WHITE))
 
#define WEEKEND_COLOR   (MAKE_COLOR(COLOR_YELLOW, COLOR_RED))
 

Funktionen

void gui_module_menu_kbd_process ()
 
int gui_calendar_kbd_process ()
 
void gui_calendar_draw ()
 
static void calendar_goto_today ()
 
static int calendar_days_in_month (int month, int year)
 
static int calendar_day_of_week (int day, int month, int year)
 
static void gui_calendar_initial_draw ()
 
int basic_module_init ()
 

Variablen

gui_handler GUI_MODE_CALENDAR
 
static int need_redraw
 
static int cal_year
 
static int cal_month
 
static coord cal_x
 
static coord cal_y
 
static coord cal_w
 
static coord cal_h
 
static int months []
 
static int days []
 
ModuleInfo _module_info
 

Makro-Dokumentation

#define CALENDAR_COLOR   (MAKE_COLOR(COLOR_GREY, COLOR_WHITE))

Definiert in Zeile 21 der Datei gui_calendar.c.

#define TITLE_COLOR   (MAKE_COLOR(COLOR_BLACK, COLOR_WHITE))

Definiert in Zeile 20 der Datei gui_calendar.c.

#define WEEKEND_COLOR   (MAKE_COLOR(COLOR_YELLOW, COLOR_RED))

Definiert in Zeile 22 der Datei gui_calendar.c.

Dokumentation der Funktionen

int basic_module_init ( )

Definiert in Zeile 82 der Datei gui_calendar.c.

82  {
83 
85 
87  cal_w = FONT_WIDTH*4*7;
88  cal_h = 4+FONT_HEIGHT+4+4+FONT_HEIGHT+4+(FONT_HEIGHT+4)*6;
91  need_redraw = 2;
92  return 1;
93 }
static int calendar_day_of_week ( int  day,
int  month,
int  year 
)
static

Definiert in Zeile 55 der Datei gui_calendar.c.

55  {
56  register int a;
57 
58  a = (14 - month) / 12;
59  year -= a;
60  month += a*12 - 2;
61 
62  return (((7000 + day + year + year/4 - year/100 + year/400 + 31*month/12) % 7) + 6) % 7;
63 }
static int calendar_days_in_month ( int  month,
int  year 
)
static

Definiert in Zeile 44 der Datei gui_calendar.c.

44  {
45  switch (month) {
46  case 2:
47  return ((year%4==0 && year%100!=0) || year%400==0)?29:28;
48  case 4: case 6: case 9: case 11:
49  return 30;
50  default:
51  return 31;
52  }
53 }
static void calendar_goto_today ( )
static

Definiert in Zeile 35 der Datei gui_calendar.c.

35  {
36  struct tm *ttm;
37 
38  ttm = get_localtime();
39  cal_year = 1900+ttm->tm_year;
40  cal_month = ttm->tm_mon;
41 }
void gui_calendar_draw ( )

Definiert in Zeile 130 der Datei gui_calendar.c.

130  {
131  int x, y;
132  static char str[32];
133  int w, d, i;
134  static struct tm *ttm;
135 
136  if (need_redraw == 2)
138 
139  ttm = get_localtime();
140  sprintf(str, " %2u %s %04u %2u:%02u:%02u ", ttm->tm_mday, lang_str(months[ttm->tm_mon]), 1900+ttm->tm_year, ttm->tm_hour, ttm->tm_min, ttm->tm_sec);
142 
143  if (need_redraw) {
144  need_redraw = 0;
145 
148  y = cal_y + 4;
151 
152  sprintf(str, "%04d", cal_year);
154 
157 
158  y += FONT_HEIGHT+4+4;
159 
160  y += FONT_HEIGHT+4;
161  for (x=0; x<w; ++x) {
163  }
164 
165  for (i=1; i<=d; ++i) {
166  sprintf(str, " %2d ", i);
168 
169  if (++x>6) {
170  x=0;
171  y += FONT_HEIGHT+4;
172  }
173  }
174  for (; y<cal_y+cal_h; y += FONT_HEIGHT+4, x=0) {
175  for (; x<7; ++x) {
176  draw_string(cal_x+x*FONT_WIDTH*4, y, " ", (x<5)?CALENDAR_COLOR:WEEKEND_COLOR);
177  }
178  }
179  }
180 }
int gui_calendar_kbd_process ( )

Definiert in Zeile 96 der Datei gui_calendar.c.

96  {
97  switch (kbd_get_autoclicked_key()) {
98  case KEY_UP:
99  ++cal_year;
100  need_redraw = 1;
101  break;
102  case KEY_DOWN:
103  if (cal_year>1) --cal_year;
104  need_redraw = 1;
105  break;
106  case KEY_LEFT:
107  if (--cal_month<0) {
108  cal_month=11;
109  --cal_year;
110  }
111  need_redraw = 1;
112  break;
113  case KEY_RIGHT:
114  if (++cal_month>11) {
115  cal_month=0;
116  ++cal_year;
117  }
118  need_redraw = 1;
119  break;
120  case KEY_ERASE:
121  case KEY_DISPLAY:
123  need_redraw = 1;
124  break;
125  }
126  return 0;
127 }
void gui_module_menu_kbd_process ( )

Definiert in Zeile 463 der Datei gui_sokoban.c.

464 {
465  running = 0;
467 }

Variablen-Dokumentation

coord cal_h
static

Definiert in Zeile 27 der Datei gui_calendar.c.

int cal_month
static

Definiert in Zeile 26 der Datei gui_calendar.c.

coord cal_w
static

Definiert in Zeile 27 der Datei gui_calendar.c.

coord cal_x
static

Definiert in Zeile 27 der Datei gui_calendar.c.

coord cal_y
static

Definiert in Zeile 27 der Datei gui_calendar.c.

int cal_year
static

Definiert in Zeile 26 der Datei gui_calendar.c.

int need_redraw
static

Definiert in Zeile 25 der Datei gui_calendar.c.