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