1 #ifndef MENU_H 2 #define MENU_H 3 4 5 #include "textobj.h" 6 7 #define MAX_MENU_ENTRY_NUM 50 8 9 enum entryType { 10 ENTRY_TYPE_ID, 11 ENTRY_TYPE_SUBMENU, 12 ENTRY_TYPE_TEXTFIELD, 13 ENTRY_TYPE_EXIT 14 }; 15 16 17 struct menu_entry_struct; 18 struct menu_struct; 19 20 typedef struct menu_entry_struct menuEntry; 21 typedef struct menu_struct menuType; 22 23 /*typedef*/ struct menu_entry_struct{ 24 25 char text[256]; 26 char settingtext[256]; 27 enum entryType type; 28 menuType * submenu; 29 int id; 30 char * fontname; 31 int fontsize; 32 textObj * text_obj; 33 // textObj * settingtext_obj; 34 int show_subsetting; 35 void * arg; 36 int fixedlen; /* fixed length that may not be changed in textfields */ 37 38 }/* menuEntry*/; 39 40 41 /*typedef */struct menu_struct{ 42 43 menuEntry entry[MAX_MENU_ENTRY_NUM]; 44 int nr; 45 void (* callback)( int, void * ); 46 int select_index; 47 int select_id; 48 int * p_select_id; 49 char * fontname; 50 int fontsize; 51 int textedit_mode; 52 menuType * parent; 53 menuEntry * parent_entry; 54 55 }/* menuType*/; 56 57 58 menuType * menu_new( void (* callback)( int, void * ) ); 59 void menu_add_submenu( menuType * menu, char * text, menuType * submenu, int show_subsetting ); 60 void menu_add_entry( menuType * menu, char * text, int id ); 61 void menu_add_arg_entry( menuType * menu, char * text, int id, void * arg ); 62 void menu_add_textfield( menuType * menu, char * text, int id, int fixedlen ); 63 void menu_add_exit( menuType * menu, char * text ); 64 void menu_select_by_coord( menuType * menu, int x, int y ); 65 void menu_select_next( menuType * menu ); 66 void menu_select_prev( menuType * menu ); 67 void menu_choose(menuType ** menu); 68 void menu_exit(menuType ** menu); 69 void menu_text_keystroke( menuType * menu, int key ); 70 void menu_draw( menuType * menu ); 71 void menu_texObj_cleanup(menuType * menu); 72 73 74 #endif /* MENU_H */ 75