Rev 6601 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6391 | ashmew2 | 1 | #ifndef KOLIBRI_GUI_ELEMENTS_H |
2 | #define KOLIBRI_GUI_ELEMENTS_H |
||
3 | |||
6479 | siemargl | 4 | #include "kolibri_colors.h" |
6470 | siemargl | 5 | |
6391 | ashmew2 | 6 | /* enum KOLIBRI_GUI_ELEMENT_TYPE contains all available GUI items from box_lib */ |
7 | /* More elements can be added from other libraries as required */ |
||
8 | enum KOLIBRI_GUI_ELEMENT_TYPE { |
||
9 | KOLIBRI_EDIT_BOX, |
||
10 | KOLIBRI_CHECK_BOX, |
||
6479 | siemargl | 11 | KOLIBRI_OPTIONGROUP, |
6470 | siemargl | 12 | KOLIBRI_SCROLL_BAR_H, |
13 | KOLIBRI_SCROLL_BAR_V, |
||
6391 | ashmew2 | 14 | KOLIBRI_DYNAMIC_BUTTON, |
15 | KOLIBRI_MENU_BAR, |
||
16 | KOLIBRI_FILE_BROWSER, |
||
17 | KOLIBRI_TREE_LIST, |
||
18 | KOLIBRI_PATH_SHOW, |
||
19 | KOLIBRI_TEXT_EDITOR, |
||
20 | KOLIBRI_FRAME, |
||
21 | KOLIBRI_PROGRESS_BAR, |
||
6470 | siemargl | 22 | KOLIBRI_STATICTEXT, |
23 | KOLIBRI_STATICNUM, |
||
6391 | ashmew2 | 24 | KOLIBRI_BUTTON, |
6524 | siemargl | 25 | KOLIBRI_D_BUTTON, |
26 | KOLIBRI_PATHSHOW, |
||
6560 | siemargl | 27 | KOLIBRI_FILEBROWSE, |
6589 | siemargl | 28 | KOLIBRI_EDITOR, |
6601 | siemargl | 29 | KOLIBRI_TREELIST, |
6391 | ashmew2 | 30 | |
31 | /* Add elements above this element in order to let KOLIBRI_NUM_GUI_ELEMENTS */ |
||
32 | /* stay at correct value */ |
||
6396 | siemargl | 33 | |
34 | KOLIBRI_NUM_GUI_ELEMENTS |
||
6391 | ashmew2 | 35 | }; |
6479 | siemargl | 36 | |
6482 | siemargl | 37 | #define X_Y(x,y) (((x)<<16)|(y)) |
38 | |||
6391 | ashmew2 | 39 | /* Linked list which connects together all the elements drawn inside a GUI window */ |
6457 | punk_joker | 40 | typedef struct{ |
6391 | ashmew2 | 41 | enum KOLIBRI_GUI_ELEMENT_TYPE type; |
42 | void *element; |
||
6457 | punk_joker | 43 | void *next, *prev; |
44 | }kolibri_window_element; |
||
6479 | siemargl | 45 | |
6396 | siemargl | 46 | typedef void (*cb_elem_boxlib)(void *) __attribute__((__stdcall__)); |
6612 | siemargl | 47 | typedef void (*cbkey_elem_boxlib)(void *, oskey_t) __attribute__((__stdcall__)); |
6396 | siemargl | 48 | |
6391 | ashmew2 | 49 | /* Generic structure for supporting functions on various elements of Kolibri's GUI */ |
6457 | punk_joker | 50 | typedef struct { |
6396 | siemargl | 51 | cb_elem_boxlib redraw_fn; |
52 | cb_elem_boxlib mouse_fn; |
||
6612 | siemargl | 53 | cbkey_elem_boxlib key_fn; |
6457 | punk_joker | 54 | }kolibri_element_operations; |
6391 | ashmew2 | 55 | |
56 | /* Structure for a GUI Window on Kolibri. It also contains all the elements drawn in window */ |
||
6457 | punk_joker | 57 | typedef struct{ |
6391 | ashmew2 | 58 | unsigned int topleftx, toplefty; |
59 | unsigned int sizex, sizey; |
||
60 | char *window_title; |
||
61 | |||
62 | /* Refer to sysfuncs, value to be stored in EDX (Function 0) */ |
||
63 | unsigned int XY; |
||
64 | |||
6457 | punk_joker | 65 | kolibri_window_element *elements; |
66 | }kolibri_window; |
||
6391 | ashmew2 | 67 | |
68 | /*---------------------End of Structure and enum definitions---------------*/ |
||
6479 | siemargl | 69 | |
70 | void kolibri_window_add_element(kolibri_window *some_window, enum KOLIBRI_GUI_ELEMENT_TYPE element_type, void *some_gui_element); // forward declaration |
||
71 | |||
72 | /* GUI Elements being used */ |
||
6524 | siemargl | 73 | #include "kolibri_button.h" |
74 | #include "kolibri_checkbox.h" |
||
75 | #include "kolibri_d_button.h" |
||
6479 | siemargl | 76 | #include "kolibri_editbox.h" |
6524 | siemargl | 77 | #include "kolibri_frame.h" |
78 | #include "kolibri_menubar.h" |
||
79 | #include "kolibri_optionbox.h" |
||
80 | #include "kolibri_pathshow.h" |
||
6479 | siemargl | 81 | #include "kolibri_progressbar.h" |
82 | #include "kolibri_scrollbar.h" |
||
83 | #include "kolibri_statictext.h" |
||
6560 | siemargl | 84 | #include "kolibri_filebrowse.h" |
6589 | siemargl | 85 | #include "kolibri_editor.h" |
6601 | siemargl | 86 | #include "kolibri_treelist.h" |
6524 | siemargl | 87 | |
6479 | siemargl | 88 | |
6391 | ashmew2 | 89 | /*---------------------Define various functions for initializing GUI-------*/ |
90 | |||
91 | /* Master table containing operations for various GUI elements in one place */ |
||
6457 | punk_joker | 92 | kolibri_element_operations kolibri_gui_op_table[KOLIBRI_NUM_GUI_ELEMENTS]; |
6391 | ashmew2 | 93 | |
94 | void kolibri_init_gui_op_table(void) |
||
95 | { |
||
96 | /* Setting up functions for edit box GUI elements*/ |
||
6396 | siemargl | 97 | kolibri_gui_op_table[KOLIBRI_EDIT_BOX].redraw_fn = (cb_elem_boxlib)edit_box_draw; |
98 | kolibri_gui_op_table[KOLIBRI_EDIT_BOX].mouse_fn = (cb_elem_boxlib)edit_box_mouse; |
||
6612 | siemargl | 99 | kolibri_gui_op_table[KOLIBRI_EDIT_BOX].key_fn = (cbkey_elem_boxlib)editbox_key; |
6391 | ashmew2 | 100 | |
101 | /* Setting up functions for check box GUI elements*/ |
||
6396 | siemargl | 102 | kolibri_gui_op_table[KOLIBRI_CHECK_BOX].redraw_fn = (cb_elem_boxlib)check_box_draw2; |
103 | kolibri_gui_op_table[KOLIBRI_CHECK_BOX].mouse_fn = (cb_elem_boxlib)check_box_mouse2; |
||
6391 | ashmew2 | 104 | kolibri_gui_op_table[KOLIBRI_CHECK_BOX].key_fn = NULL; |
105 | |||
106 | /* Setting up functions for Kolibri Buttons ( SysFunc 8 )*/ |
||
6396 | siemargl | 107 | kolibri_gui_op_table[KOLIBRI_BUTTON].redraw_fn = (cb_elem_boxlib)draw_button; |
6391 | ashmew2 | 108 | kolibri_gui_op_table[KOLIBRI_BUTTON].mouse_fn = NULL; |
109 | kolibri_gui_op_table[KOLIBRI_BUTTON].key_fn = NULL; |
||
6396 | siemargl | 110 | |
6449 | punk_joker | 111 | /* Setting up functions for progress bar GUI elements*/ |
112 | kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].redraw_fn = (cb_elem_boxlib)progressbar_draw; |
||
113 | kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].mouse_fn = NULL; |
||
114 | kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].key_fn = NULL; |
||
115 | |||
116 | /* Setting up functions for frame GUI elements*/ |
||
117 | kolibri_gui_op_table[KOLIBRI_FRAME].redraw_fn = (cb_elem_boxlib)frame_draw; |
||
118 | kolibri_gui_op_table[KOLIBRI_FRAME].mouse_fn = NULL; |
||
119 | kolibri_gui_op_table[KOLIBRI_FRAME].key_fn = NULL; |
||
120 | |||
6470 | siemargl | 121 | /* scrollbars */ |
122 | kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_H].redraw_fn = (cb_elem_boxlib)scrollbar_h_draw; |
||
123 | kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_H].mouse_fn = (cb_elem_boxlib)scrollbar_h_mouse; |
||
124 | kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_H].key_fn = NULL; |
||
125 | |||
126 | kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_V].redraw_fn = (cb_elem_boxlib)scrollbar_v_draw; |
||
127 | kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_V].mouse_fn = (cb_elem_boxlib)scrollbar_v_mouse; |
||
128 | kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_V].key_fn = NULL; |
||
129 | |||
130 | kolibri_gui_op_table[KOLIBRI_STATICTEXT].redraw_fn = (cb_elem_boxlib)statictext_draw; |
||
131 | kolibri_gui_op_table[KOLIBRI_STATICTEXT].mouse_fn = NULL; |
||
132 | kolibri_gui_op_table[KOLIBRI_STATICTEXT].key_fn = NULL; |
||
133 | |||
134 | kolibri_gui_op_table[KOLIBRI_STATICNUM].redraw_fn = (cb_elem_boxlib)staticnum_draw; |
||
135 | kolibri_gui_op_table[KOLIBRI_STATICNUM].mouse_fn = NULL; |
||
136 | kolibri_gui_op_table[KOLIBRI_STATICNUM].key_fn = NULL; |
||
6479 | siemargl | 137 | |
138 | kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].redraw_fn = (cb_elem_boxlib)option_box_draw; |
||
139 | kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].mouse_fn = (cb_elem_boxlib)option_box_mouse; |
||
140 | kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].key_fn = NULL; |
||
141 | |||
6482 | siemargl | 142 | kolibri_gui_op_table[KOLIBRI_MENU_BAR].redraw_fn = (cb_elem_boxlib)menu_bar_draw; |
143 | kolibri_gui_op_table[KOLIBRI_MENU_BAR].mouse_fn = (cb_elem_boxlib)menu_bar_mouse; |
||
144 | kolibri_gui_op_table[KOLIBRI_MENU_BAR].key_fn = NULL; |
||
145 | |||
6524 | siemargl | 146 | kolibri_gui_op_table[KOLIBRI_D_BUTTON].redraw_fn = (cb_elem_boxlib)dynamic_button_draw; |
147 | kolibri_gui_op_table[KOLIBRI_D_BUTTON].mouse_fn = (cb_elem_boxlib)dynamic_button_mouse; |
||
148 | kolibri_gui_op_table[KOLIBRI_D_BUTTON].key_fn = NULL; |
||
149 | |||
150 | kolibri_gui_op_table[KOLIBRI_PATHSHOW].redraw_fn = (cb_elem_boxlib)path_show_draw; |
||
151 | kolibri_gui_op_table[KOLIBRI_PATHSHOW].mouse_fn = NULL; |
||
152 | kolibri_gui_op_table[KOLIBRI_PATHSHOW].key_fn = NULL; |
||
6560 | siemargl | 153 | |
154 | kolibri_gui_op_table[KOLIBRI_FILEBROWSE].redraw_fn = (cb_elem_boxlib)filebrowse_draw; |
||
155 | kolibri_gui_op_table[KOLIBRI_FILEBROWSE].mouse_fn = (cb_elem_boxlib)filebrowse_mouse; |
||
6612 | siemargl | 156 | kolibri_gui_op_table[KOLIBRI_FILEBROWSE].key_fn = (cbkey_elem_boxlib)filebrowser_key; |
6589 | siemargl | 157 | |
158 | kolibri_gui_op_table[KOLIBRI_EDITOR].redraw_fn = (cb_elem_boxlib)ted_draw; |
||
159 | kolibri_gui_op_table[KOLIBRI_EDITOR].mouse_fn = (cb_elem_boxlib)ted_mouse; |
||
6612 | siemargl | 160 | kolibri_gui_op_table[KOLIBRI_EDITOR].key_fn = (cbkey_elem_boxlib)editor_key; |
6601 | siemargl | 161 | |
6612 | siemargl | 162 | kolibri_gui_op_table[KOLIBRI_TREELIST].redraw_fn = (cb_elem_boxlib)treelist_draw; |
6601 | siemargl | 163 | kolibri_gui_op_table[KOLIBRI_TREELIST].mouse_fn = (cb_elem_boxlib)tl_mouse; |
6612 | siemargl | 164 | kolibri_gui_op_table[KOLIBRI_TREELIST].key_fn = (cbkey_elem_boxlib)treelist_key; |
165 | debug_board_printf("KOLIBRI_TREELIST (%x,%x,%x)\n", treelist_draw, tl_mouse, treelist_key); |
||
6391 | ashmew2 | 166 | } |
167 | |||
168 | /* Create a new main GUI window for KolibriOS */ |
||
169 | /* tl stands for TOP LEFT. x and y are coordinates. */ |
||
170 | |||
6457 | punk_joker | 171 | kolibri_window * kolibri_new_window(int tlx, int tly, int sizex, int sizey, char *title) |
6391 | ashmew2 | 172 | { |
6457 | punk_joker | 173 | kolibri_window *new_win = (kolibri_window *)malloc(sizeof(kolibri_window)); |
6391 | ashmew2 | 174 | |
175 | new_win->topleftx = tlx; |
||
176 | new_win->toplefty = tly; |
||
177 | new_win->sizex = sizex; |
||
178 | new_win->sizey = sizey; |
||
179 | new_win->window_title = title; |
||
6490 | punk_joker | 180 | new_win->XY = 0x33; |
6391 | ashmew2 | 181 | new_win->elements = NULL; |
6396 | siemargl | 182 | |
6391 | ashmew2 | 183 | return new_win; |
184 | } |
||
185 | |||
186 | /* Add an element to an existing window */ |
||
6457 | punk_joker | 187 | void kolibri_window_add_element(kolibri_window *some_window, enum KOLIBRI_GUI_ELEMENT_TYPE element_type, void *some_gui_element) |
6391 | ashmew2 | 188 | { |
6457 | punk_joker | 189 | kolibri_window_element *new_element = (kolibri_window_element *)malloc(sizeof(kolibri_window_element)); |
6396 | siemargl | 190 | |
6391 | ashmew2 | 191 | new_element -> type = element_type; |
192 | new_element -> element = some_gui_element; |
||
193 | |||
194 | if(!(some_window->elements)) /* No elements in window yet */ |
||
195 | { |
||
196 | some_window->elements = new_element; |
||
197 | some_window->elements -> prev = some_window->elements; |
||
198 | some_window->elements -> next = some_window->elements; |
||
199 | } |
||
200 | else |
||
201 | { |
||
6457 | punk_joker | 202 | kolibri_window_element *last_element = some_window -> elements -> prev; |
6396 | siemargl | 203 | |
6391 | ashmew2 | 204 | last_element -> next = new_element; |
205 | new_element -> next = some_window -> elements; /* start of linked list */ |
||
206 | some_window -> elements -> prev = new_element; |
||
207 | new_element -> prev = last_element; |
||
208 | } |
||
209 | } |
||
210 | |||
211 | #endif /* KOLIBRI_GUI_ELEMENTS_H */16)|(y)) |