CHDK_DE Vorschauversion  Trunk Rev. 5234
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
gui_read.c-Dateireferenz
#include "camera_info.h"
#include "stdlib.h"
#include "keyboard.h"
#include "clock.h"
#include "conf.h"
#include "gui.h"
#include "font.h"
#include "gui_draw.h"
#include "gui_batt.h"
#include "gui_lang.h"
#include "gui_read.h"
#include "module_def.h"
+ Include-Abhängigkeitsdiagramm für gui_read.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define READ_BUFFER_SIZE   100
 

Funktionen

void gui_read_kbd_process_menu_btn ()
 
int gui_read_kbd_process ()
 
void gui_read_draw ()
 
void gui_read_kbd_leave ()
 
static void gui_read_draw_batt ()
 
static void gui_read_draw_clock ()
 
static void gui_read_draw_scroll_indicator ()
 
int gui_read_init (const char *file)
 
static void read_goto_next_line ()
 
static int read_fit_next_char (int ch)
 
void gui_read_draw (int force_redraw)
 
int _module_unloader ()
 
int _module_can_unload ()
 
int _module_exit_alt ()
 

Variablen

gui_handler GUI_MODE_READ
 
gui_handlerold_mode
 
static int running = 0
 
static int read_file
 
static int read_file_size
 
static int read_on_screen
 
static int read_to_draw
 
static coord x
 
static coord y
 
static coord h
 
static coord w
 
static char buffer [READ_BUFFER_SIZE+1]
 
static long last_time
 
static int xx
 
static int yy
 
static int pause
 
static int busy_drawing = 0
 
static int do_not_draw = 0
 
static int reader_is_active
 
libtxtread_sym _libtxtread
 
ModuleInfo _module_info
 

Makro-Dokumentation

#define READ_BUFFER_SIZE   100

Definiert in Zeile 34 der Datei gui_read.c.

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 340 der Datei gui_read.c.

341 {
342  return running == 0;
343 }
int _module_exit_alt ( )

Definiert in Zeile 345 der Datei gui_read.c.

346 {
347  running = 0;
348  return 0;
349 }
int _module_unloader ( )

Definiert in Zeile 332 der Datei gui_read.c.

333 {
334  // We should make "leave sequence" to restore font settings
336 
337  return 0;
338 }
void gui_read_draw ( )
void gui_read_draw ( int  force_redraw)

Definiert in Zeile 111 der Datei gui_read.c.

112 {
113  if (do_not_draw)
114  return;
115  busy_drawing = 1;
117 
118  static int first_draw = 1;
119  if (first_draw || force_redraw)
120  {
121  if (first_draw)
122  {
123  // font has to be loaded from here (SpyTask)
125  }
131  read_to_draw = 1;
132  first_draw = 0;
133  }
134 
136  {
138  read_to_draw = 1;
139  }
140  if (read_to_draw)
141  {
142  int n, m, i, ii, ll, new_word=1;
143 
144  xx=x; yy=y;
145 
147  read_on_screen=0;
148 
149  while (yy<=y+h-rbf_font_height()) {
151  if (n==0) {
153  if (yy < y+h)
155  break;
156  }
157  else if (n<0) {
158  // read failed
159  do_not_draw = 1;
160  busy_drawing = 0;
161  return;
162  }
163  i=0;
164  while (i<n && yy<=y+h-rbf_font_height()) {
165  switch (buffer[i]) {
166  case '\r':
167  new_word = 1;
168  break;
169  case '\n':
171  new_word = 1;
172  break;
173  case '\t':
174  buffer[i] = ' ';
175  // no break here
176  default:
178  if (buffer[i] == ' ') {
179  new_word = 1;
180  if (xx==x) //ignore leading spaces
181  break;
182  } else if (new_word) {
183  new_word = 0;
184  for (ii=i, ll=0; ii<n && buffer[ii]!=' ' && buffer[ii]!='\t' && buffer[ii]!='\r' && buffer[ii]!='\n'; ++ii) {
185  ll+=rbf_char_width(buffer[ii]);
186  }
187  if (ii==n) {
188  memcpy(buffer, buffer+i, n-i);
189  n=ii=n-i;
190  read_on_screen+=i;
191  i=0;
193  if (m<0) {
194  // read failed
195  do_not_draw = 1;
196  busy_drawing = 0;
197  return;
198  }
199  n+=m;
200  for (; ii<n && buffer[ii]!=' ' && buffer[ii]!='\t' && buffer[ii]!='\r' && buffer[ii]!='\n'; ++ii) {
201  ll+=rbf_char_width(buffer[ii]);
202  }
203  }
204  if (xx+ll>=x+w && ll<w) {
206  continue;
207  }
208  }
209  }
210  if (!read_fit_next_char(buffer[i])) {
212  continue;
213  }
214  xx+=rbf_draw_char(xx, yy, buffer[i], col);
215  break;
216  }
217  ++i;
218  if (xx >= x+w) {
219  xx = x;
220  yy += rbf_font_height();
221  }
222  }
223  read_on_screen+=i;
224  }
225 
228 
229  // scrollbar
230  if (read_file_size) {
231  i=h-1 -1; // full height
232  n=i*read_on_screen/read_file_size; // bar height
233  if (n<20) n=20;
234  i=(i-n)*conf.reader_pos/read_file_size; // top pos
238  } else {
241  }
242 
243  read_to_draw = 0;
245  }
248  busy_drawing = 0;
249 }
static void gui_read_draw_batt ( )
static

Definiert in Zeile 46 der Datei gui_read.c.

static void gui_read_draw_clock ( )
static

Definiert in Zeile 52 der Datei gui_read.c.

52  {
53  static struct tm *ttm;
54 
55  ttm = get_localtime();
56  sprintf(buffer, "%2u:%02u", ttm->tm_hour, ttm->tm_min);
58 }
static void gui_read_draw_scroll_indicator ( )
static

Definiert in Zeile 61 der Datei gui_read.c.

61  {
63  (conf.reader_autoscroll)?((pause)?'\x05':'\x04'):'\x03', MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline
64 }
int gui_read_init ( const char *  file)

Definiert in Zeile 67 der Datei gui_read.c.

68 {
69  running = 1;
70 
71  static struct stat st;
72 
73  read_file = open(file, O_RDONLY, 0777);
74  if (strcmp(file, conf.reader_file)!=0) {
75  conf.reader_pos = 0;
76  strcpy(conf.reader_file, file);
77  }
78  read_on_screen = 0;
79  read_file_size = (read_file>=0 && stat((char*)file, &st)==0)?st.st_size:0;
81  conf.reader_pos = 0;
82  }
83  pause = 0;
84  read_to_draw = 1;
86  y=FONT_HEIGHT;
90 
93 
94  return (read_file >= 0);
95 }
void gui_read_kbd_leave ( )

Definiert in Zeile 298 der Datei gui_read.c.

299 {
300  if ( !reader_is_active )
301  return;
302 
303  reader_is_active = 0;
304 
305  do_not_draw = 1;
306 
307  while (busy_drawing)
308  {
309  msleep(10);
310  }
311 
312  if (read_file >= 0)
313  {
314  close(read_file);
315  read_file=-1;
316  }
318 
319  running = 0;
320 }
int gui_read_kbd_process ( )

Definiert in Zeile 252 der Datei gui_read.c.

252  {
254  case JOGDIAL_LEFT:
255  case KEY_ZOOM_OUT:
256  case KEY_UP:
257  case KEY_LEFT:
258  if (conf.reader_pos>0) {
259  conf.reader_pos -= 45*15;
260  if (conf.reader_pos<0) conf.reader_pos=0;
261  read_to_draw = 1;
262  }
263  break;
264  case JOGDIAL_RIGHT:
265  case KEY_ZOOM_IN:
266  case KEY_DOWN:
267  case KEY_RIGHT:
268  case KEY_SHOOT_HALF:
271  read_to_draw = 1;
272  }
273  break;
274  case KEY_SET:
275  break;
276  case KEY_DISPLAY:
277  pause = !pause;
280  break;
281  case KEY_MENU:
283  break;
284  }
285  return 0;
286 }
void gui_read_kbd_process_menu_btn ( )

Definiert in Zeile 292 der Datei gui_read.c.

293 {
296 }
static int read_fit_next_char ( int  ch)
static

Definiert in Zeile 106 der Datei gui_read.c.

106  {
107  return (xx+rbf_char_width(ch) < x+w);
108 }
static void read_goto_next_line ( )
static

Definiert in Zeile 98 der Datei gui_read.c.

98  {
101  xx = x;
102  yy += rbf_font_height();
103 }

Variablen-Dokumentation

libtxtread_sym _libtxtread
Initialisierung:

Definiert in Zeile 353 der Datei gui_read.c.

ModuleInfo _module_info
Initialisierung:

Definiert in Zeile 362 der Datei gui_read.c.

char buffer[READ_BUFFER_SIZE+1]
static

Definiert in Zeile 35 der Datei gui_read.c.

int busy_drawing = 0
static

Definiert in Zeile 39 der Datei gui_read.c.

int do_not_draw = 0
static

Definiert in Zeile 40 der Datei gui_read.c.

gui_handler GUI_MODE_READ
Initialisierung:

Definiert in Zeile 22 der Datei gui_read.c.

coord h
static

Definiert in Zeile 33 der Datei gui_read.c.

long last_time
static

Definiert in Zeile 36 der Datei gui_read.c.

gui_handler* old_mode

Definiert in Zeile 25 der Datei gui_read.c.

int pause
static

Definiert in Zeile 38 der Datei gui_read.c.

int read_file
static

Definiert in Zeile 29 der Datei gui_read.c.

int read_file_size
static

Definiert in Zeile 30 der Datei gui_read.c.

int read_on_screen
static

Definiert in Zeile 31 der Datei gui_read.c.

int read_to_draw
static

Definiert in Zeile 32 der Datei gui_read.c.

int reader_is_active
static

Definiert in Zeile 42 der Datei gui_read.c.

int running = 0
static

Definiert in Zeile 28 der Datei gui_read.c.

coord w
static

Definiert in Zeile 33 der Datei gui_read.c.

coord x
static

Definiert in Zeile 33 der Datei gui_read.c.

int xx
static

Definiert in Zeile 37 der Datei gui_read.c.

coord y
static

Definiert in Zeile 33 der Datei gui_read.c.

int yy
static

Definiert in Zeile 37 der Datei gui_read.c.