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

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  CMenuStacked
 

Makrodefinitionen

#define MENUSTACK_MAXDEPTH   4
 
#define MAX(a, b)   ((a>=b)?a:b)
 

Funktionen

CMenuItemfind_menu_item (CMenu *curr_menu, int itemid)
 
int menu_get_increment_factor ()
 
void menu_set_increment_factor (int n)
 
char * menu_increment_factor_string ()
 
int menu_calc_max_increment_factor (int max_value)
 
static int increment_factor ()
 
static int decrement_factor ()
 
static void gui_menu_set_curr_menu (CMenu *menu_ptr, int top_item, int curr_item)
 
CMenuget_curr_menu ()
 
void gui_menu_init (CMenu *menu_ptr)
 
static int gui_menu_rows ()
 
void gui_menu_erase_and_redraw ()
 
void gui_menu_cancel_redraw ()
 
static void gui_menu_color_selected (chdkColor clr)
 
void gui_menu_back ()
 
static void do_callback (const CMenuItem *mi)
 
static void update_int_value (const CMenuItem *mi, int direction)
 
static void update_bool_value (const CMenuItem *mi)
 
static void update_enum_value (const CMenuItem *mi, int direction)
 
static int isText (int n)
 
void gui_activate_sub_menu (CMenu *sub_menu)
 
static void select_sub_menu ()
 
static void select_proc ()
 
static void gui_menu_updown (int increment)
 
static int gui_menu_touch_handler (int tx, int ty)
 
int gui_menu_kbd_process ()
 
void gui_menu_draw_initial ()
 
static void gui_menu_draw_symbol (int num_symbols)
 
static void gui_set_int_cursor (int offset)
 
static void gui_menu_draw_value (const char *str, int len_str)
 
static void gui_menu_draw_text (char *str, int num_symbols)
 
static int factor_disp_len ()
 
static void get_int_disp_string (int value, int dlen)
 
static void gui_menu_draw_state_value (CMenuItem *c)
 
static void menu_text (color c)
 
void gui_menu_draw (int enforce_redraw)
 
void gui_menu_kbd_process_menu_btn ()
 

Variablen

static CMenucurr_menu
 
static CMenuStacked gui_menu_stack [MENUSTACK_MAXDEPTH]
 
static unsigned int gui_menu_stack_ptr
 
static int gui_menu_curr_item
 
static int gui_menu_top_item
 
static int gui_menu_redraw
 
static int count
 
static int x
 
static int y
 
static int w
 
static int wplus
 
static int num_lines
 
static int len_bool
 
static int len_int
 
static int len_enum
 
static int len_space
 
static int len_br1
 
static int len_br2
 
static int cl_rect
 
static int int_incr = 1
 
static confColoritem_color
 
static int item_color_type
 
static int imenu
 
static int yy
 
static int xx
 
static int symbol_width
 
static twoColors cl
 
static twoColors cl_symbol
 
static char tbuf [64]
 
gui_handler menuGuiHandler = { GUI_MODE_MENU, gui_menu_draw, gui_menu_kbd_process, gui_menu_kbd_process_menu_btn, gui_menu_touch_handler, 0 }
 

Makro-Dokumentation

#define MAX (   a,
 
)    ((a>=b)?a:b)

Definiert in Zeile 113 der Datei gui_menu.c.

#define MENUSTACK_MAXDEPTH   4

Definiert in Zeile 16 der Datei gui_menu.c.

Dokumentation der Funktionen

static int decrement_factor ( )
static

Definiert in Zeile 186 der Datei gui_menu.c.

187 {
188  // Decrease int_incr
189  // Returns 1 if value changed.
190 
191  if (int_incr > 1)
192  {
193  int_incr /= 10;
194  return 1;
195  }
196  return 0;
197 }
static void do_callback ( const CMenuItem mi)
static

Definiert in Zeile 300 der Datei gui_menu.c.

301 {
302  if ((mi->type & MENUITEM_ARG_MASK) == MENUITEM_ARG_CALLBACK && mi->arg)
303  {
304  ((void (*)())(mi->arg))();
305  }
306 }
static int factor_disp_len ( )
static

Definiert in Zeile 835 der Datei gui_menu.c.

836 {
837  int l = 0;
839  {
840  l = -1;
841  int n = int_incr;
842  while (n > 0)
843  {
844  l++;
845  n /= 10;
846  }
847  }
848  return l;
849 }
CMenuItem* find_menu_item ( CMenu curr_menu,
int  itemid 
)

Definiert in Zeile 43 der Datei gui_menu.c.

44 {
46  CMenuItem* rv=0;
47 
48  if ( itemid==0 )
49  return 0;
50 
51  gui_menu_curr_item = 0;
52  while(curr_menu->menu[gui_menu_curr_item].text) {
53  if ( lang_strhash31(curr_menu->menu[gui_menu_curr_item].text) == (unsigned)itemid){
54  return (CMenuItem*) &(curr_menu->menu[gui_menu_curr_item]);
55  }
56  if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) == MENUITEM_SUBMENU)
57  {
58  if (curr_menu->menu[gui_menu_curr_item].text != LANG_MENU_USER_MENU) {
59  rv = find_menu_item((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), itemid);
60  if ( rv )
61  return rv;
62  }
63  }
64  gui_menu_curr_item++;
65  }
66  return 0;
67 }
CMenu* get_curr_menu ( )

Definiert in Zeile 206 der Datei gui_menu.c.

207 {
208  return curr_menu;
209 }
static void get_int_disp_string ( int  value,
int  dlen 
)
static

Definiert in Zeile 855 der Datei gui_menu.c.

856 {
857  if (dlen == 6)
858  sprintf(tbuf, "%7d", value);
859  else
860  sprintf(tbuf, "%5d", value);
861  if (value < 0)
862  {
863  int spos, cpos;
864  for (spos=0; spos<5; spos++) if (tbuf[spos] == '-') break;
865  cpos = dlen - factor_disp_len();
866  if ((cpos > 0) && (cpos <= spos))
867  {
868  tbuf[spos] = ' ';
869  tbuf[cpos-1] = '-';
870  }
871  }
872 }
void gui_activate_sub_menu ( CMenu sub_menu)

Definiert in Zeile 413 der Datei gui_menu.c.

414 {
415  // push current menu on stack
419 
420  // Select first item in menu, (or none)
422  {
423  gui_menu_set_curr_menu(sub_menu, 0, 0);
425  {
426  //++gui_menu_top_item;
428  }
429  }
430  else
431  gui_menu_set_curr_menu(sub_menu, 0, -1);
432 
434 
435  // FIXME check on stack overrun;
437  {
439  gui_menu_stack_ptr = 0;
440  }
441 
442  // Set active Tv override menu entry if present
443  extern void set_tv_override_menu(CMenu *menu);
445 
446  // Force full redraw
448 }
void gui_menu_back ( )

Definiert in Zeile 278 der Datei gui_menu.c.

279 {
280  if (gui_menu_stack_ptr > 0)
281  {
285  }
286  else
287  {
288  // 'Back' selected; but no menu to go back to
289  // Occurs when script menu opened using 'Func/Set' button
290  // Return to normal <ALT> mode.
292  }
293 }
void gui_menu_cancel_redraw ( )

Definiert in Zeile 254 der Datei gui_menu.c.

255 {
256  gui_menu_redraw = 0;
258 }
static void gui_menu_color_selected ( chdkColor  clr)
static

Definiert in Zeile 263 der Datei gui_menu.c.

264 {
266  {
267  item_color->fg = clr;
268  }
269  else
270  {
271  item_color->bg = clr;
272  }
274 }
void gui_menu_draw ( int  enforce_redraw)

Definiert in Zeile 965 der Datei gui_menu.c.

966 {
967  int i, j;
968  const char *ch = "";
969 
970  if ( enforce_redraw )
971  gui_menu_redraw = 2;
972 
973  if (gui_menu_redraw)
974  {
975  if (gui_menu_redraw==2)
977 
978  gui_menu_redraw=0;
979 
981  {
983  /*
984  * When cursor is over a symbol, force symbol background color to be the menu cursor color but
985  * keep the symbol color user defined.
986  * old method was to set the symbol color to the symbol background color when the cursor highlighted it.
987  * This method allows the user to have any symbol color and background color they want with the restriction
988  * that the symbol background color will match the rest of the line when the cursor highlights it.
989  * It creates a nice consistent look especially when the symbol color matches the menu text color.
990  * without this mod, there is no way to ever make the symbol color match the color of the rest of text menu line
991  * when the cursor highlights a line.
992  */
994 
995  xx = x;
996 
997  switch (curr_menu->menu[imenu].type & MENUITEM_MASK)
998  {
1001  break;
1002  case MENUITEM_BOOL:
1003  gui_menu_draw_value((*(curr_menu->menu[imenu].value))?"\x95":" ", len_bool);
1004  break;
1005  case MENUITEM_INT:
1008  break;
1009  case MENUITEM_SUBMENU_PROC:
1010  case MENUITEM_SUBMENU:
1013  break;
1014  case MENUITEM_UP:
1015  sprintf(tbuf, "%s%s", (conf.menu_symbol_enable)?"":"<- ", lang_str(curr_menu->menu[imenu].text));
1017  break;
1018  case MENUITEM_ERROR:
1020  break;
1021  case MENUITEM_WARNING:
1023  break;
1024  case MENUITEM_PROC:
1025  case MENUITEM_TEXT:
1027  break;
1028  case MENUITEM_SEPARATOR:
1029  rbf_draw_char(x, yy, ' ', cl);
1030 
1031  if (lang_str(curr_menu->menu[imenu].text)[0])
1033  else
1034  tbuf[0] = 0;
1035 
1036  j = rbf_str_width(tbuf);
1037  xx += ((w - j) >> 1);
1038 
1039  if (xx > (x + len_space))
1040  {
1044  }
1045  else
1046  {
1047  xx = x;
1048  }
1049 
1050  if (j) xx += rbf_draw_clipped_string(xx, yy, tbuf, cl, 0, w);
1051 
1052  if (xx < (x+w-len_space))
1053  {
1057  }
1058 
1059  rbf_draw_char(x+w-len_space, yy, ' ', cl);
1060  break;
1061  case MENUITEM_COLOR_FG:
1062  {
1067  }
1068  break;
1069  case MENUITEM_COLOR_BG:
1070  {
1075  }
1076  break;
1077  case MENUITEM_ENUM:
1078  if (curr_menu->menu[imenu].value)
1079  ch = ((const char* (*)(int change, int arg))(curr_menu->menu[imenu].value))(0, curr_menu->menu[imenu].arg);
1081  break;
1082  case MENUITEM_ENUM2:
1083  if (curr_menu->menu[imenu].value)
1084  {
1085  extern const char* gui_change_enum2(const CMenuItem *menu_item, int change);
1086  ch = gui_change_enum2(&curr_menu->menu[imenu], 0);
1087  }
1089  break;
1090  }
1091  }
1092 
1093  // scrollbar
1094  if (count > num_lines)
1095  {
1096  i = num_lines*rbf_font_height()-1 -1; // full height
1097  j = i*num_lines/count; // bar height
1098  if (j<20) j=20;
1099  i = (i-j)*((gui_menu_curr_item<0)?0:gui_menu_curr_item)/(count-1); // top pos
1103  }
1104  }
1105 }
void gui_menu_draw_initial ( )

Definiert in Zeile 728 der Datei gui_menu.c.

729 {
730  count = gui_menu_rows();
731 
732  // Setup screen size
734  y = (camera_screen.height - ((num_lines - 1) * rbf_font_height())) >> 1;
737 
738  // Adjust top line to fit in case display size changes
739  if ((count - gui_menu_top_item) < num_lines) {
740  // Screen is larger, move top line up
743  }
745  // Screen is smaller, move top line down
746  gui_menu_top_item = gui_menu_curr_item - num_lines + 1;
747  }
748 
749  if (count > num_lines)
750  {
751  wplus = 8;
752  // scrollbar background
754  }
755  else
756  {
757  wplus = 0;
758  if (conf.menu_center)
759  {
760  y = (camera_screen.height - ((count - 1) * rbf_font_height())) >> 1;
761  }
762  }
763 
765 }
static void gui_menu_draw_state_value ( CMenuItem c)
static

Definiert in Zeile 875 der Datei gui_menu.c.

876 {
877  const char *ch = "";
878 
879  int text = curr_menu->menu[imenu].text;
880  if (c[0].text != 0)
881  text = c[0].text;
882 
884  if ((c[1].type & MENUITEM_MASK) == MENUITEM_ENUM)
885  wid -= len_space*3;
886  else
887  wid -= len_bool;
888 
890  xx += rbf_draw_string_len(xx, yy, wid, lang_str(text), cl);
891  xx += rbf_draw_string(xx, yy, " [", cl);
892  if ((c[1].type & MENUITEM_MASK) == MENUITEM_ENUM)
893  xx += rbf_draw_string_len(xx, yy, len_space*3, ((const char* (*)(int change, int arg))(c[1].value))(0, c[1].arg), cl);
894  else
895  xx += rbf_draw_string_len(xx, yy, len_bool, (*(c[1].value))?"\x95":"", cl);
896  xx += rbf_draw_string(xx, yy, "][", cl);
897 
898  switch (c[0].type & MENUITEM_MASK)
899  {
900  case MENUITEM_INT:
901  get_int_disp_string(*(c[0].value), (c[0].type & MENUITEM_SD_INT)?6:4);
902  gui_set_int_cursor((c[0].type & MENUITEM_SD_INT)?6:4);
903  ch = tbuf;
904  break;
905  case MENUITEM_ENUM:
906  if (c[0].value)
907  ch = ((const char* (*)(int change, int arg))(c[0].value))(0, c[0].arg);
908  if ((c[0].type & MENUITEM_HHMMSS) && (gui_menu_curr_item==imenu))
909  {
910  switch (int_incr)
911  {
912  case 1:
913  rbf_enable_cursor(5,6);
914  break;
915  case 10:
916  rbf_enable_cursor(2,3);
917  break;
918  default:
919  rbf_enable_cursor(0,0);
920  break;
921  }
922  }
923  else if (c[0].type & MENUITEM_DECIMAL)
924  {
925  if (int_incr == 100000)
926  rbf_enable_cursor(0,0); // Skip decimal point if incrementing leftmost digit
927  else
929  }
930  else if (c[0].type & MENUITEM_SD_INT)
931  {
932  if (isdigit(ch[strlen(ch)-1]))
934  }
935  else if (gui_menu_curr_item==imenu)
936  {
937  rbf_enable_cursor(0,6);
938  }
939  break;
940  case MENUITEM_ENUM2:
941  if (c[0].value)
942  {
943  extern const char* gui_change_enum2(const CMenuItem *menu_item, int change);
944  ch = gui_change_enum2(c, 0);
946  rbf_enable_cursor(0,6);
947  }
948  break;
949  }
950 
953  rbf_draw_string(xx, yy, "] ", cl);
954 }
static void gui_menu_draw_symbol ( int  num_symbols)
static

Definiert in Zeile 774 der Datei gui_menu.c.

775 {
777  {
778  xx += rbf_draw_char(xx, yy, ' ', cl_symbol);
780  symbol_width = (symbol_width * num_symbols) + len_space;
781  }
782  else
783  {
784  symbol_width = 0;
785  }
786 
787  xx += rbf_draw_char(xx, yy, ' ', cl);
788 }
static void gui_menu_draw_text ( char *  str,
int  num_symbols 
)
static

Definiert in Zeile 825 der Datei gui_menu.c.

826 {
827  gui_menu_draw_symbol(num_symbols);
829  if ((num_symbols == 2) && conf.menu_symbol_enable)
830  xx += rbf_draw_symbol(xx, yy, 0x52, cl_symbol);
831  rbf_draw_char(xx, yy, ' ', cl);
832 }
static void gui_menu_draw_value ( const char *  str,
int  len_str 
)
static

Definiert in Zeile 805 der Datei gui_menu.c.

806 {
809  xx += rbf_draw_string(xx, yy, " [", cl);
811  {
812  if (len_str == len_int)
814  else if (curr_menu->menu[imenu].type & MENUITEM_SD_INT)
816  else
817  rbf_enable_cursor(0,6);
818  }
819  xx += rbf_draw_string_right_len(xx, yy, len_str, str, cl);
821  rbf_draw_string(xx, yy, "] ", cl);
822 }
void gui_menu_erase_and_redraw ( )

Definiert in Zeile 249 der Datei gui_menu.c.

250 {
251  gui_menu_redraw = 2;
253 }
void gui_menu_init ( CMenu menu_ptr)

Definiert in Zeile 212 der Datei gui_menu.c.

212  {
213 
214  if (menu_ptr) {
216  gui_menu_set_curr_menu(menu_ptr, 0, 0);
217  else
218  gui_menu_set_curr_menu(menu_ptr, 0, -1);
219  gui_menu_stack_ptr = 0;
220 
221  // Set active Tv override menu entry if present
222  extern void set_tv_override_menu(CMenu *menu);
224  }
225 
226  len_bool = rbf_str_width("\x95");
227  len_int = rbf_str_width("99999");
228  len_enum = rbf_str_width("WUBfS3a");
229  len_space = rbf_char_width(' ');
230  len_br1 = rbf_char_width('[');
231  len_br2 = rbf_char_width(']');
232  cl_rect = rbf_font_height() - 4;
233  int_incr = 1;
234 
235  gui_menu_redraw=2;
236 }
int gui_menu_kbd_process ( )

Definiert in Zeile 543 der Datei gui_menu.c.

543  {
544 
546  {
547  case KEY_ERASE:
548  case KEY_SHOOT_HALF:
549  if (!increment_factor())
550  int_incr = 1;
551  gui_menu_redraw=1;
552  break;
553  case JOGDIAL_LEFT:
554  case KEY_UP:
555  gui_menu_updown(-1);
556  break;
557  case JOGDIAL_RIGHT:
558  case KEY_DOWN:
559  gui_menu_updown(1);
560  break;
561  case FRONTDIAL_LEFT:
562  case KEY_LEFT:
563  if (gui_menu_curr_item >= 0) {
565  case MENUITEM_INT:
567  break;
568  case MENUITEM_BOOL:
570  break;
571  case MENUITEM_ENUM:
572  case MENUITEM_ENUM2:
574  break;
575  case MENUITEM_UP:
576  gui_menu_back();
577  break;
579  {
581  if (*(c[1].value) == 0)
582  update_bool_value(&c[1]);
583  switch (c[0].type & MENUITEM_MASK)
584  {
585  case MENUITEM_INT:
586  update_int_value(&c[0],-1);
587  break;
588  case MENUITEM_ENUM:
589  case MENUITEM_ENUM2:
590  update_enum_value(&c[0],-1);
591  break;
592  }
593  }
594  break;
595  }
596  } else {
597  gui_menu_back();
598  }
599  break;
600  case FRONTDIAL_RIGHT:
601  case KEY_RIGHT:
602  if (gui_menu_curr_item >= 0) {
603  switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK){
604  case MENUITEM_INT:
606  break;
607  case MENUITEM_BOOL:
609  break;
610  case MENUITEM_ENUM:
611  case MENUITEM_ENUM2:
613  break;
615  select_proc();
616  break;
617  case MENUITEM_SUBMENU:
618  select_sub_menu();
619  break;
621  {
623  if (*(c[1].value) == 0)
624  update_bool_value(&c[1]);
625  switch (c[0].type & MENUITEM_MASK)
626  {
627  case MENUITEM_INT:
628  update_int_value(&c[0],1);
629  break;
630  case MENUITEM_ENUM:
631  case MENUITEM_ENUM2:
632  update_enum_value(&c[0],1);
633  break;
634  }
635  }
636  break;
637  }
638  }
639  break;
640  case KEY_SET:
641  if (gui_menu_curr_item >= 0) {
642  switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK){
643  case MENUITEM_INT:
645  {
647  gui_menu_redraw=1;
648  }
649  break;
650  case MENUITEM_BOOL:
652  break;
654  case MENUITEM_PROC:
655  select_proc();
656  break;
657  case MENUITEM_SUBMENU:
658  select_sub_menu();
659  break;
660  case MENUITEM_UP:
661  gui_menu_back();
662  break;
663  case MENUITEM_COLOR_FG:
667  gui_menu_redraw=2;
668  break;
669  case MENUITEM_COLOR_BG:
673  gui_menu_redraw=2;
674  break;
675  case MENUITEM_ENUM:
676  case MENUITEM_ENUM2:
678  gui_menu_redraw=1;
679  break;
681  {
683  if ((c[1].type & MENUITEM_MASK) == MENUITEM_ENUM)
684  update_enum_value(&c[1],1);
685  else
686  update_bool_value(&c[1]);
687  }
688  break;
689  }
690  }
691  break;
692  case KEY_SHOOT_FULL: // run script directly from User Menu ?
693  if( (gui_menu_curr_item >= 0)
694  && ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) == MENUITEM_PROC)
696  select_proc();
697  break;
698  case KEY_ZOOM_IN:
699  if (decrement_factor())
700  gui_menu_redraw = 1;
701  break;
702 
703  case KEY_ZOOM_OUT:
704  if (increment_factor())
705  gui_menu_redraw = 1;
706  break;
707 
708  case KEY_DISPLAY:
710  {
711  gui_menu_back();
712  }
713  else
714  {
715  // For cams without zoom lever, DISP adjusts increment factor
716  if (!increment_factor())
717  int_incr = 1;
718  gui_menu_redraw=1;
719  }
720  break;
721  }
722 
723  return 0;
724 }
void gui_menu_kbd_process_menu_btn ( )

Definiert in Zeile 1109 der Datei gui_menu.c.

1110 {
1111  extern int gui_user_menu_flag;
1112 
1113  conf_save();
1114 
1115  if ( gui_user_menu_flag )
1116  {
1118  gui_user_menu_flag = 0;
1120  }
1121  else
1123 }
static int gui_menu_rows ( )
static

Definiert in Zeile 239 der Datei gui_menu.c.

240 {
241  int n;
242  // Count the number of rows in current menu
243  for(n = 0; curr_menu->menu[n].text; n++);
244  return n;
245 }
static void gui_menu_set_curr_menu ( CMenu menu_ptr,
int  top_item,
int  curr_item 
)
static

Definiert in Zeile 200 der Datei gui_menu.c.

200  {
201  curr_menu = menu_ptr;
202  gui_menu_top_item = top_item;
204 }
static int gui_menu_touch_handler ( int  tx,
int  ty 
)
static

Definiert in Zeile 521 der Datei gui_menu.c.

522 {
523  int h = ((count > num_lines) ? num_lines : count) * rbf_font_height();
524  if ((tx >= x) && (ty >= y) && (tx < (x + w)) && (ty < (y + h)))
525  {
526  int r = ((ty - y) / rbf_font_height()) + gui_menu_top_item;
527  if (!isText(r))
528  {
529  if (gui_menu_curr_item != r)
530  {
531  gui_menu_curr_item = r;
532  // Redraw menu if needed
533  if (gui_menu_redraw == 0) gui_menu_redraw = 1;
534  }
535  return KEY_SET;
536  }
537  }
538  return 0;
539 }
static void gui_menu_updown ( int  increment)
static

Definiert in Zeile 469 der Datei gui_menu.c.

470 {
471  int c, j;
472 
473  // Determine number of rows to move (1 or 4)
475 
476  for (j = 0; j < c; ++j)
477  {
478  do
479  {
480  // Move to next or previous row
481  gui_menu_curr_item += increment;
482 
483  if (gui_menu_curr_item < 0) // Off top, move to bottom
484  {
487  }
488  else if (gui_menu_curr_item >= gui_menu_rows()) // Off bottom, move to top
489  {
491  }
492  else if (increment == 1) // Still in menu, if moving down adjust scroll if needed
493  {
495  {
498  }
499  }
500  else // Still in menu, and moving up, adjust scroll
501  {
504  }
505 
506  // Check in case scroll moved off top of menu
508  } while (isText(gui_menu_curr_item));
509 
510  // Reset amount to increment integer values by
511  int_incr = 1;
515 
516  // Redraw menu if needed
517  if (gui_menu_redraw == 0) gui_menu_redraw=1;
518  }
519 }
static void gui_set_int_cursor ( int  offset)
static

Definiert in Zeile 790 der Datei gui_menu.c.

791 {
793  {
794  int n = int_incr;
795  while (n > 1)
796  {
797  n /= 10;
798  offset--;
799  }
801  }
802 }
static int increment_factor ( )
static

Definiert in Zeile 115 der Datei gui_menu.c.

116 {
117  // Increase int_incr
118  // Returns 1 if value changed.
119 
120  // Get info about the current menu item
121  int item_flags = curr_menu->menu[gui_menu_curr_item].type;
122  int item_type = item_flags & MENUITEM_MASK;
123  int item_arg = curr_menu->menu[gui_menu_curr_item].arg;
124  int item_val = *(curr_menu->menu[gui_menu_curr_item].value);
125  // If state / value menu pair get info from value entry
126  if (item_type == MENUITEM_STATE_VAL_PAIR)
127  {
129  item_flags = c[0].type;
130  item_type = item_flags & MENUITEM_MASK;
131  item_arg = c[0].arg;
132  item_val = *(c[0].value);
133  }
134 
135  // Calculate max allowed value for int_incr
136  // Default is 1000000 for DECIMAL, 10000 for positive int values, 1000 for negative values or 1 otherwise
137  int max = (item_flags & MENUITEM_DECIMAL) ? 100000 : (item_type == MENUITEM_INT) ? ((item_val < 0) ? 1000 : 10000) : 1;
138 
139  // If an int value has a defined MIN / MAX range then adjust int_incr max to fit the range
140  int vmax = 0;
141  if ( item_flags & MENUITEM_F_MINMAX )
142  {
143  if ( item_flags & MENUITEM_F_UNSIGNED )
144  {
145  vmax = MAX(MENU_MIN_UNSIGNED(item_arg),MENU_MAX_UNSIGNED(item_arg));
146  }
147  else
148  {
149  vmax = MAX(abs(MENU_MIN_SIGNED(item_arg)),abs(MENU_MAX_SIGNED(item_arg)));
150  }
151  }
152 
153  // Default for SD type (item_arg holds max allowed value)
154  if (item_flags & MENUITEM_SD_INT)
155  {
156  vmax = item_arg;
157  }
158 
159  // If a max value has been set adjust accordingly
160  if (vmax > 0)
161  {
162  max = menu_calc_max_increment_factor(vmax);
163  }
164 
165  // Default for HH:MM:SS type
166  if (item_flags & MENUITEM_HHMMSS)
167  {
168  max = 100;
169  }
170 
171  // Adjust value
172  if (int_incr < max)
173  {
174  int_incr *= 10;
175  return 1;
176  }
177  if (int_incr > max)
178  {
179  int_incr = max;
180  return 1;
181  }
182 
183  return 0;
184 }
static int isText ( int  n)
static

Definiert in Zeile 402 der Datei gui_menu.c.

403 {
404  return (
406  (curr_menu->menu[n].type & MENUITEM_MASK) == MENUITEM_ERROR ||
407  (curr_menu->menu[n].type & MENUITEM_MASK) == MENUITEM_WARNING ||
408  (curr_menu->menu[n].type & MENUITEM_MASK) == MENUITEM_SEPARATOR
409  );
410 }
int menu_calc_max_increment_factor ( int  max_value)

Definiert in Zeile 98 der Datei gui_menu.c.

99 {
100  int max = 1;
101  while (max_value/10 != 0)
102  {
103  max *= 10;
104  max_value /= 10;
105  }
106  return max;
107 }
int menu_get_increment_factor ( )

Definiert in Zeile 73 der Datei gui_menu.c.

74 {
75  return int_incr;
76 }
char* menu_increment_factor_string ( )

Definiert in Zeile 84 der Datei gui_menu.c.

85 {
86  static char buf[8];
87  buf[0] = 0;
88  if (int_incr >= 1000000)
89  sprintf(buf, "\xb1%dM",int_incr/1000000);
90  else if (int_incr >= 1000)
91  sprintf(buf, "\xb1%dK",int_incr/1000);
92  else
93  sprintf(buf, "\xb1%d",int_incr);
94  return buf;
95 }
void menu_set_increment_factor ( int  n)

Definiert in Zeile 78 der Datei gui_menu.c.

79 {
80  int_incr = n;
81 }
static void menu_text ( color  c)
static

Definiert in Zeile 957 der Datei gui_menu.c.

958 {
959  twoColors save = cl;
960  cl = MAKE_COLOR(BG_COLOR(cl), c);
962  cl = save;
963 }
static void select_proc ( )
static

Definiert in Zeile 457 der Datei gui_menu.c.

458 {
460  {
462  //gui_menu_set_curr_menu(curr_menu, 0, 0); // restore this if it causes problems
463  gui_menu_redraw=2;
464  }
465 }
static void select_sub_menu ( )
static

Definiert in Zeile 451 der Datei gui_menu.c.

static void update_bool_value ( const CMenuItem mi)
static

Definiert in Zeile 367 der Datei gui_menu.c.

368 {
369  // update value
370  *(mi->value) = !(*(mi->value));
371 
372  // execute custom callback and on_change functions
373  do_callback(mi);
374 
375  // force menu redraw
376  gui_menu_redraw=1;
377 }
static void update_enum_value ( const CMenuItem mi,
int  direction 
)
static

Definiert in Zeile 380 der Datei gui_menu.c.

381 {
382  // update value
383  if (mi->value)
384  {
386  direction *= int_incr;
387  if ((mi->type & MENUITEM_MASK) == MENUITEM_ENUM)
388  {
389  ((const char* (*)(int change, int arg))(mi->value))(direction, mi->arg);
390  }
391  else
392  {
393  extern const char* gui_change_enum2(const CMenuItem *menu_item, int change);
395  }
396  }
397 
398  // force menu redraw
399  gui_menu_redraw=1;
400 }
static void update_int_value ( const CMenuItem mi,
int  direction 
)
static

Definiert in Zeile 309 der Datei gui_menu.c.

310 {
311  // do update
312  *(mi->value) += int_incr * direction;
313 
314  // Limit new value to defined bounds
315  if ((mi->type & MENUITEM_F_UNSIGNED) || (mi->type & MENUITEM_SD_INT))
316  {
317  if (*(mi->value) < 0)
318  *(mi->value) = 0;
319 
320  if ( mi->type & MENUITEM_F_MIN)
321  {
322  if (*(mi->value) < MENU_MIN_UNSIGNED(mi->arg))
323  *(mi->value) = MENU_MIN_UNSIGNED(mi->arg);
324  }
325  }
326  else
327  {
328  if (*(mi->value) < -9999)
329  *(mi->value) = -9999;
330 
331  if ( mi->type & MENUITEM_F_MIN)
332  {
333  if (*(mi->value) < MENU_MIN_SIGNED(mi->arg))
334  *(mi->value) = MENU_MIN_SIGNED(mi->arg);
335  }
336  }
337 
338  int maxval = (mi->type & MENUITEM_SD_INT) ? 9999999 : 99999;
339  if (*(mi->value) > maxval)
340  *(mi->value) = maxval;
341 
342  if (mi->type & MENUITEM_F_UNSIGNED)
343  {
344  if ( mi->type & MENUITEM_F_MAX)
345  {
346  if (*(mi->value) > MENU_MAX_UNSIGNED(mi->arg))
347  *(mi->value) = MENU_MAX_UNSIGNED(mi->arg);
348  }
349  }
350  else
351  {
352  if (mi->type & MENUITEM_F_MAX)
353  {
354  if (*(mi->value) > MENU_MAX_SIGNED(mi->arg))
355  *(mi->value) = MENU_MAX_SIGNED(mi->arg);
356  }
357  }
358 
359  // execute custom callback and on_change functions
360  do_callback(mi);
361 
362  // force menu redraw
363  gui_menu_redraw=1;
364 }

Variablen-Dokumentation

twoColors cl
static

Definiert in Zeile 771 der Datei gui_menu.c.

int cl_rect
static

Definiert in Zeile 37 der Datei gui_menu.c.

twoColors cl_symbol
static

Definiert in Zeile 771 der Datei gui_menu.c.

int count
static

Definiert in Zeile 34 der Datei gui_menu.c.

CMenu* curr_menu
static

Definiert in Zeile 27 der Datei gui_menu.c.

int gui_menu_curr_item
static

Definiert in Zeile 30 der Datei gui_menu.c.

int gui_menu_redraw
static

Definiert in Zeile 32 der Datei gui_menu.c.

CMenuStacked gui_menu_stack[MENUSTACK_MAXDEPTH]
static

Definiert in Zeile 28 der Datei gui_menu.c.

unsigned int gui_menu_stack_ptr
static

Definiert in Zeile 29 der Datei gui_menu.c.

int gui_menu_top_item
static

Definiert in Zeile 31 der Datei gui_menu.c.

int imenu
static

Definiert in Zeile 770 der Datei gui_menu.c.

int int_incr = 1
static

Definiert in Zeile 38 der Datei gui_menu.c.

confColor* item_color
static

Definiert in Zeile 39 der Datei gui_menu.c.

int item_color_type
static

Definiert in Zeile 40 der Datei gui_menu.c.

int len_bool
static

Definiert in Zeile 37 der Datei gui_menu.c.

int len_br1
static

Definiert in Zeile 37 der Datei gui_menu.c.

int len_br2
static

Definiert in Zeile 37 der Datei gui_menu.c.

int len_enum
static

Definiert in Zeile 37 der Datei gui_menu.c.

int len_int
static

Definiert in Zeile 37 der Datei gui_menu.c.

int len_space
static

Definiert in Zeile 37 der Datei gui_menu.c.

int num_lines
static

Definiert in Zeile 36 der Datei gui_menu.c.

int symbol_width
static

Definiert in Zeile 770 der Datei gui_menu.c.

char tbuf[64]
static

Definiert in Zeile 851 der Datei gui_menu.c.

int w
static

Definiert in Zeile 36 der Datei gui_menu.c.

int wplus
static

Definiert in Zeile 36 der Datei gui_menu.c.

int x
static

Definiert in Zeile 35 der Datei gui_menu.c.

int xx
static

Definiert in Zeile 770 der Datei gui_menu.c.

int y
static

Definiert in Zeile 35 der Datei gui_menu.c.

int yy
static

Definiert in Zeile 770 der Datei gui_menu.c.