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

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  gline
 

Makrodefinitionen

#define GRID_REDRAW_INTERVAL   4
 

Aufzählungen

enum  grid_elem_type {
  GRID_ELEM_LINE, GRID_ELEM_RECT, GRID_ELEM_FILLED_RECT, GRID_ELEM_ELLIPSE,
  GRID_ELEM_FILLED_ELLIPSE
}
 

Funktionen

static void grid_lines_free_data ()
 
static void process_title (const char *title)
 
static void process_element (const char *str, int n, grid_elem_type type)
 
static int parse_grid_file (char *ptr, int size)
 
void grid_lines_load (const char *fn)
 
void gui_grid_draw_osd (int force)
 
int _module_loader (unsigned int *chdk_export_list)
 
int _module_unloader ()
 
int _module_can_unload ()
 

Variablen

static int grid_loading = 0
 
static int interval = GRID_REDRAW_INTERVAL
 
static struct glinehead =NULL
 
static struct glinetop =NULL
 
libgrids_sym _libgrids
 
ModuleInfo _module_info
 

Makro-Dokumentation

#define GRID_REDRAW_INTERVAL   4

Definiert in Zeile 14 der Datei gui_grid.c.

Dokumentation der Aufzählungstypen

Aufzählungswerte
GRID_ELEM_LINE 
GRID_ELEM_RECT 
GRID_ELEM_FILLED_RECT 
GRID_ELEM_ELLIPSE 
GRID_ELEM_FILLED_ELLIPSE 

Definiert in Zeile 17 der Datei gui_grid.c.

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 218 der Datei gui_grid.c.

219 {
220  return (conf.show_grid_lines == 0 && !grid_loading);
221 }
int _module_loader ( unsigned int *  chdk_export_list)

Definiert in Zeile 202 der Datei gui_grid.c.

203 {
205  return 0;
206 }
int _module_unloader ( )

Definiert in Zeile 212 der Datei gui_grid.c.

213 {
215  return 0;
216 }
static void grid_lines_free_data ( )
static

Definiert in Zeile 44 der Datei gui_grid.c.

44  {
45  struct gline *ptr = head, *prev;
46 
47  while (ptr) {
48  prev=ptr;
49  ptr=ptr->next;
50  free(prev);
51  }
52  head=top=NULL;
53 }
void grid_lines_load ( const char *  fn)

Definiert in Zeile 143 der Datei gui_grid.c.

144 {
145  grid_loading = 1;
146  if (process_file(fn, parse_grid_file, 1) > 0) // non-zero length file found?
147  {
148  if (conf.grid_title[0]==0) // use filename if no @title string found
149  {
150  char* c = strrchr(fn, '/');
151  strncpy(conf.grid_title, (c)?c+1:fn, sizeof(conf.grid_title));
152  conf.grid_title[sizeof(conf.grid_title)-1] = 0;
153  }
155  }
156  grid_loading = 0;
157 }
void gui_grid_draw_osd ( int  force)

Definiert in Zeile 160 der Datei gui_grid.c.

161 {
163  {
164  struct gline *ptr;
166 
167  if (force || --interval==0) {
168  for (ptr=head; ptr; ptr=ptr->next) {
169  switch (ptr->type) {
170  case GRID_ELEM_LINE:
171  draw_line(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (conf.grid_force_color)?FG_COLOR(col):ptr->clf);
172  break;
173  case GRID_ELEM_RECT:
174  draw_rectangle(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (conf.grid_force_color)?col:MAKE_COLOR(ptr->clb, ptr->clf), RECT_BORDER1);
175  break;
177  draw_rectangle(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (conf.grid_force_color)?col:MAKE_COLOR(ptr->clb, ptr->clf), RECT_BORDER1|DRAW_FILLED);
178  break;
179  case GRID_ELEM_ELLIPSE:
180  draw_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (conf.grid_force_color)?FG_COLOR(col):ptr->clf, 0);
181  break;
183  draw_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (conf.grid_force_color)?BG_COLOR(col):ptr->clf, DRAW_FILLED);
184  break;
185  }
186  }
188  }
189  }
190 }
static int parse_grid_file ( char *  ptr,
int  size 
)
static

Definiert in Zeile 101 der Datei gui_grid.c.

102 {
103  conf.grid_title[0]=0;
104 
105  if (size > 0)
106  {
108 
109  while (ptr[0])
110  {
111  while (ptr[0]==' ' || ptr[0]=='\t') ++ptr; // whitespaces
112  if (ptr[0]=='@')
113  {
114  if (strncmp("@title", ptr, 6)==0) {
115  ptr+=6;
117  } else if (strncmp("@line", ptr, 5)==0) {
118  ptr+=5;
120  } else if (strncmp("@rectf", ptr, 6)==0) {
121  ptr+=6;
123  } else if (strncmp("@rect", ptr, 5)==0) {
124  ptr+=5;
126  } else if (strncmp("@elpsf", ptr, 6)==0) {
127  ptr+=6;
129  } else if (strncmp("@elps", ptr, 5)==0) {
130  ptr+=5;
132  }
133  }
134  while (ptr[0] && ptr[0]!='\n') ++ptr; // unless end of line
135  if (ptr[0]) ++ptr;
136  }
137  }
138 
139  return size;
140 }
static void process_element ( const char *  str,
int  n,
grid_elem_type  type 
)
static

Definiert in Zeile 69 der Datei gui_grid.c.

69  {
70  register const char *ptr = str;
71  char *nptr;
72  register int i;
73  long nums[6];
74  struct gline *gptr;
75 
76  for (i=0; i<(sizeof(nums)/sizeof(nums[0])) && i<n; ++i) {
77  while (ptr[0]==' ' || ptr[0]=='\t' || ptr[0]==',') ++ptr; // whitespaces
78  nums[i] = strtol(ptr, &nptr, 0);
79  if (nptr == ptr) { // error
80  return;
81  } else {
82  ptr = nptr;
83  }
84  }
85 
86  gptr = malloc(sizeof(struct gline));
87 
88  if (gptr) {
89  gptr->type=type;
90  gptr->x0=nums[0]; gptr->y0=nums[1];
91  gptr->x1=nums[2]; gptr->y1=nums[3];
92  gptr->clf=nums[4]; gptr->clb=nums[5];
93  if (!head) head=gptr;
94  if (top) top->next=gptr;
95  gptr->next=NULL;
96  top=gptr;
97  }
98 }
static void process_title ( const char *  title)
static

Definiert in Zeile 56 der Datei gui_grid.c.

56  {
57  register const char *ptr = title;
58  register int i=0;
59 
60  while (ptr[0]==' ' || ptr[0]=='\t') ++ptr; // whitespaces
61  while (i<(sizeof(conf.grid_title)-1) && ptr[i] && ptr[i]!='\r' && ptr[i]!='\n') {
62  conf.grid_title[i]=ptr[i];
63  ++i;
64  }
65  conf.grid_title[i]=0;
66 }

Variablen-Dokumentation

libgrids_sym _libgrids
Initialisierung:

Definiert in Zeile 225 der Datei gui_grid.c.

ModuleInfo _module_info
Initialisierung:

Definiert in Zeile 235 der Datei gui_grid.c.

int grid_loading = 0
static

Definiert in Zeile 32 der Datei gui_grid.c.

struct gline* head =NULL
static

Definiert in Zeile 34 der Datei gui_grid.c.

int interval = GRID_REDRAW_INTERVAL
static

Definiert in Zeile 33 der Datei gui_grid.c.

struct gline * top =NULL
static

Definiert in Zeile 34 der Datei gui_grid.c.