Subversion Repositories Kolibri OS

Rev

Rev 6466 | Rev 6482 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6466 Rev 6470
1
#ifndef KOLIBRI_GUI_ELEMENTS_H
1
#ifndef KOLIBRI_GUI_ELEMENTS_H
2
#define KOLIBRI_GUI_ELEMENTS_H
2
#define KOLIBRI_GUI_ELEMENTS_H
3
 
3
 
4
/* GUI Elements being used */
4
/* GUI Elements being used */
5
#include "kolibri_editbox.h"
5
#include "kolibri_editbox.h"
6
#include "kolibri_checkbox.h"
6
#include "kolibri_checkbox.h"
7
#include "kolibri_button.h"
7
#include "kolibri_button.h"
8
#include "kolibri_progressbar.h"
8
#include "kolibri_progressbar.h"
9
#include "kolibri_frame.h"
9
#include "kolibri_frame.h"
-
 
10
#include "kolibri_scrollbar.h"
-
 
11
#include "kolibri_statictext.h"
-
 
12
 
-
 
13
#define X_Y(x,y) (((x)<<16)|(y))
10
 
14
 
11
/* enum KOLIBRI_GUI_ELEMENT_TYPE contains all available GUI items from box_lib */
15
/* enum KOLIBRI_GUI_ELEMENT_TYPE contains all available GUI items from box_lib */
12
/* More elements can be added from other libraries as required */
16
/* More elements can be added from other libraries as required */
13
enum KOLIBRI_GUI_ELEMENT_TYPE {
17
enum KOLIBRI_GUI_ELEMENT_TYPE {
14
  KOLIBRI_EDIT_BOX,
18
  KOLIBRI_EDIT_BOX,
15
  KOLIBRI_CHECK_BOX,
19
  KOLIBRI_CHECK_BOX,
16
  KOLIBRI_RADIO_BUTTON,
20
  KOLIBRI_RADIO_BUTTON,
-
 
21
  KOLIBRI_SCROLL_BAR_H,
17
  KOLIBRI_SCROLL_BAR,
22
  KOLIBRI_SCROLL_BAR_V,
18
  KOLIBRI_DYNAMIC_BUTTON,
23
  KOLIBRI_DYNAMIC_BUTTON,
19
  KOLIBRI_MENU_BAR,
24
  KOLIBRI_MENU_BAR,
20
  KOLIBRI_FILE_BROWSER,
25
  KOLIBRI_FILE_BROWSER,
21
  KOLIBRI_TREE_LIST,
26
  KOLIBRI_TREE_LIST,
22
  KOLIBRI_PATH_SHOW,
27
  KOLIBRI_PATH_SHOW,
23
  KOLIBRI_TEXT_EDITOR,
28
  KOLIBRI_TEXT_EDITOR,
24
  KOLIBRI_FRAME,
29
  KOLIBRI_FRAME,
25
  KOLIBRI_PROGRESS_BAR,
30
  KOLIBRI_PROGRESS_BAR,
-
 
31
  KOLIBRI_STATICTEXT,
-
 
32
  KOLIBRI_STATICNUM,
26
 
33
 
27
  KOLIBRI_BUTTON,
34
  KOLIBRI_BUTTON,
28
 
35
 
29
  /* Add elements above this element in order to let KOLIBRI_NUM_GUI_ELEMENTS */
36
  /* Add elements above this element in order to let KOLIBRI_NUM_GUI_ELEMENTS */
30
  /* stay at correct value */
37
  /* stay at correct value */
31
 
38
 
32
  KOLIBRI_NUM_GUI_ELEMENTS
39
  KOLIBRI_NUM_GUI_ELEMENTS
33
};
40
};
34
 
41
 
35
/* Linked list which connects together all the elements drawn inside a GUI window */
42
/* Linked list which connects together all the elements drawn inside a GUI window */
36
typedef struct{
43
typedef struct{
37
  enum KOLIBRI_GUI_ELEMENT_TYPE type;
44
  enum KOLIBRI_GUI_ELEMENT_TYPE type;
38
  void *element;
45
  void *element;
39
  void *next, *prev;
46
  void *next, *prev;
40
}kolibri_window_element;
47
}kolibri_window_element;
41
 
48
 
42
typedef void (*cb_elem_boxlib)(void *) __attribute__((__stdcall__));
49
typedef void (*cb_elem_boxlib)(void *) __attribute__((__stdcall__));
43
 
50
 
44
/* Generic structure for supporting functions on various elements of Kolibri's GUI */
51
/* Generic structure for supporting functions on various elements of Kolibri's GUI */
45
typedef struct {
52
typedef struct {
46
 	cb_elem_boxlib 	redraw_fn;
53
 	cb_elem_boxlib 	redraw_fn;
47
 	cb_elem_boxlib 	mouse_fn;
54
 	cb_elem_boxlib 	mouse_fn;
48
 	cb_elem_boxlib 	key_fn;
55
 	cb_elem_boxlib 	key_fn;
49
}kolibri_element_operations;
56
}kolibri_element_operations;
50
 
57
 
51
/* Structure for a GUI Window on Kolibri. It also contains all the elements drawn in window */
58
/* Structure for a GUI Window on Kolibri. It also contains all the elements drawn in window */
52
typedef struct{
59
typedef struct{
53
  unsigned int topleftx, toplefty;
60
  unsigned int topleftx, toplefty;
54
  unsigned int sizex, sizey;
61
  unsigned int sizex, sizey;
55
  char *window_title;
62
  char *window_title;
56
 
63
 
57
  /* Refer to sysfuncs, value to be stored in EDX (Function 0) */
64
  /* Refer to sysfuncs, value to be stored in EDX (Function 0) */
58
  unsigned int XY;
65
  unsigned int XY;
59
 
66
 
60
  kolibri_window_element *elements;
67
  kolibri_window_element *elements;
61
}kolibri_window;
68
}kolibri_window;
62
 
69
 
63
/*---------------------End of Structure and enum definitions---------------*/
70
/*---------------------End of Structure and enum definitions---------------*/
64
/*---------------------Define various functions for initializing GUI-------*/
71
/*---------------------Define various functions for initializing GUI-------*/
65
 
72
 
66
/* Master table containing operations for various GUI elements in one place */
73
/* Master table containing operations for various GUI elements in one place */
67
kolibri_element_operations kolibri_gui_op_table[KOLIBRI_NUM_GUI_ELEMENTS];
74
kolibri_element_operations kolibri_gui_op_table[KOLIBRI_NUM_GUI_ELEMENTS];
68
 
75
 
69
void kolibri_init_gui_op_table(void)
76
void kolibri_init_gui_op_table(void)
70
{
77
{
71
/* Setting up functions for edit box GUI elements*/
78
/* Setting up functions for edit box GUI elements*/
72
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].redraw_fn = (cb_elem_boxlib)edit_box_draw;
79
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].redraw_fn = (cb_elem_boxlib)edit_box_draw;
73
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].mouse_fn = (cb_elem_boxlib)edit_box_mouse;
80
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].mouse_fn = (cb_elem_boxlib)edit_box_mouse;
74
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].key_fn = (cb_elem_boxlib)editbox_key;
81
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].key_fn = (cb_elem_boxlib)editbox_key;
75
 
82
 
76
/* Setting up functions for check box GUI elements*/
83
/* Setting up functions for check box GUI elements*/
77
kolibri_gui_op_table[KOLIBRI_CHECK_BOX].redraw_fn = (cb_elem_boxlib)check_box_draw2;
84
kolibri_gui_op_table[KOLIBRI_CHECK_BOX].redraw_fn = (cb_elem_boxlib)check_box_draw2;
78
kolibri_gui_op_table[KOLIBRI_CHECK_BOX].mouse_fn = (cb_elem_boxlib)check_box_mouse2;
85
kolibri_gui_op_table[KOLIBRI_CHECK_BOX].mouse_fn = (cb_elem_boxlib)check_box_mouse2;
79
kolibri_gui_op_table[KOLIBRI_CHECK_BOX].key_fn = NULL;
86
kolibri_gui_op_table[KOLIBRI_CHECK_BOX].key_fn = NULL;
80
 
87
 
81
/* Setting up functions for Kolibri Buttons ( SysFunc 8 )*/
88
/* Setting up functions for Kolibri Buttons ( SysFunc 8 )*/
82
kolibri_gui_op_table[KOLIBRI_BUTTON].redraw_fn = (cb_elem_boxlib)draw_button;
89
kolibri_gui_op_table[KOLIBRI_BUTTON].redraw_fn = (cb_elem_boxlib)draw_button;
83
kolibri_gui_op_table[KOLIBRI_BUTTON].mouse_fn = NULL;
90
kolibri_gui_op_table[KOLIBRI_BUTTON].mouse_fn = NULL;
84
kolibri_gui_op_table[KOLIBRI_BUTTON].key_fn = NULL;
91
kolibri_gui_op_table[KOLIBRI_BUTTON].key_fn = NULL;
85
 
92
 
86
/* Setting up functions for progress bar GUI elements*/
93
/* Setting up functions for progress bar GUI elements*/
87
kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].redraw_fn = (cb_elem_boxlib)progressbar_draw;
94
kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].redraw_fn = (cb_elem_boxlib)progressbar_draw;
88
kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].mouse_fn = NULL;
95
kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].mouse_fn = NULL;
89
kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].key_fn = NULL;
96
kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].key_fn = NULL;
-
 
97
debug_board_printf("PROGRESS (%x,%x,%x)\n", progressbar_draw,0,0);
90
 
98
 
91
/* Setting up functions for frame GUI elements*/
99
/* Setting up functions for frame GUI elements*/
92
kolibri_gui_op_table[KOLIBRI_FRAME].redraw_fn = (cb_elem_boxlib)frame_draw;
100
kolibri_gui_op_table[KOLIBRI_FRAME].redraw_fn = (cb_elem_boxlib)frame_draw;
93
kolibri_gui_op_table[KOLIBRI_FRAME].mouse_fn = NULL;
101
kolibri_gui_op_table[KOLIBRI_FRAME].mouse_fn = NULL;
94
kolibri_gui_op_table[KOLIBRI_FRAME].key_fn = NULL;
102
kolibri_gui_op_table[KOLIBRI_FRAME].key_fn = NULL;
-
 
103
 
-
 
104
debug_board_printf("FRAME (%x,%x,%x)\n", frame_draw,0,0);
-
 
105
 
-
 
106
 
-
 
107
/* scrollbars */
-
 
108
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_H].redraw_fn = (cb_elem_boxlib)scrollbar_h_draw;
-
 
109
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_H].mouse_fn = (cb_elem_boxlib)scrollbar_h_mouse;
-
 
110
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_H].key_fn = NULL;
-
 
111
debug_board_printf("SCROLL_H (%x,%x,%x)\n", scrollbar_h_draw,scrollbar_h_mouse,0);
-
 
112
 
-
 
113
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_V].redraw_fn = (cb_elem_boxlib)scrollbar_v_draw;
-
 
114
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_V].mouse_fn = (cb_elem_boxlib)scrollbar_v_mouse;
-
 
115
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_V].key_fn = NULL;
-
 
116
debug_board_printf("SCROLL_V (%x,%x,%x)\n", scrollbar_v_draw,scrollbar_v_mouse,0);
-
 
117
 
-
 
118
kolibri_gui_op_table[KOLIBRI_STATICTEXT].redraw_fn = (cb_elem_boxlib)statictext_draw;
-
 
119
kolibri_gui_op_table[KOLIBRI_STATICTEXT].mouse_fn = NULL;
-
 
120
kolibri_gui_op_table[KOLIBRI_STATICTEXT].key_fn = NULL;
-
 
121
 
-
 
122
kolibri_gui_op_table[KOLIBRI_STATICNUM].redraw_fn = (cb_elem_boxlib)staticnum_draw;
-
 
123
kolibri_gui_op_table[KOLIBRI_STATICNUM].mouse_fn = NULL;
-
 
124
kolibri_gui_op_table[KOLIBRI_STATICNUM].key_fn = NULL;
95
 
125
debug_board_printf("STATICNUM (%x,%x,%x)\n", staticnum_draw,0,0);
96
}
126
}
97
 
127
 
98
/* Create a new main GUI window for KolibriOS */
128
/* Create a new main GUI window for KolibriOS */
99
/* tl stands for TOP LEFT. x and y are coordinates. */
129
/* tl stands for TOP LEFT. x and y are coordinates. */
100
 
130
 
101
kolibri_window * kolibri_new_window(int tlx, int tly, int sizex, int sizey, char *title)
131
kolibri_window * kolibri_new_window(int tlx, int tly, int sizex, int sizey, char *title)
102
{
132
{
103
  kolibri_window *new_win = (kolibri_window *)malloc(sizeof(kolibri_window));
133
  kolibri_window *new_win = (kolibri_window *)malloc(sizeof(kolibri_window));
104
 
134
 
105
  new_win->topleftx = tlx;
135
  new_win->topleftx = tlx;
106
  new_win->toplefty = tly;
136
  new_win->toplefty = tly;
107
  new_win->sizex = sizex;
137
  new_win->sizex = sizex;
108
  new_win->sizey = sizey;
138
  new_win->sizey = sizey;
109
  new_win->window_title = title;
139
  new_win->window_title = title;
110
  new_win->XY = 0x00000013; /* All windows are skinned windows with caption for now */
140
  new_win->XY = 0x00000013; /* All windows are skinned windows with caption for now */
111
  new_win->elements = NULL;
141
  new_win->elements = NULL;
112
 
142
 
113
  return new_win;
143
  return new_win;
114
}
144
}
115
 
145
 
116
/* Add an element to an existing window */
146
/* Add an element to an existing window */
117
void kolibri_window_add_element(kolibri_window *some_window, enum KOLIBRI_GUI_ELEMENT_TYPE element_type, void *some_gui_element)
147
void kolibri_window_add_element(kolibri_window *some_window, enum KOLIBRI_GUI_ELEMENT_TYPE element_type, void *some_gui_element)
118
{
148
{
119
  kolibri_window_element *new_element = (kolibri_window_element *)malloc(sizeof(kolibri_window_element));
149
  kolibri_window_element *new_element = (kolibri_window_element *)malloc(sizeof(kolibri_window_element));
120
 
150
 
121
  new_element -> type = element_type;
151
  new_element -> type = element_type;
122
  new_element -> element = some_gui_element;
152
  new_element -> element = some_gui_element;
123
 
153
 
124
  if(!(some_window->elements)) /* No elements in window yet */
154
  if(!(some_window->elements)) /* No elements in window yet */
125
    {
155
    {
126
      some_window->elements = new_element;
156
      some_window->elements = new_element;
127
      some_window->elements -> prev = some_window->elements;
157
      some_window->elements -> prev = some_window->elements;
128
      some_window->elements -> next = some_window->elements;
158
      some_window->elements -> next = some_window->elements;
129
    }
159
    }
130
  else
160
  else
131
    {
161
    {
132
      kolibri_window_element *last_element = some_window -> elements -> prev;
162
      kolibri_window_element *last_element = some_window -> elements -> prev;
133
 
163
 
134
      last_element -> next = new_element;
164
      last_element -> next = new_element;
135
      new_element -> next = some_window -> elements; /* start of linked list  */
165
      new_element -> next = some_window -> elements; /* start of linked list  */
136
      some_window -> elements -> prev = new_element;
166
      some_window -> elements -> prev = new_element;
137
      new_element -> prev = last_element;
167
      new_element -> prev = last_element;
138
    }
168
    }
139
}
169
}
140
 
170
 
141
#endif /* KOLIBRI_GUI_ELEMENTS_H */
171
#endif /* KOLIBRI_GUI_ELEMENTS_H */
-
 
172
 
-
 
173
/*>
-
 
174
 
-
 
175
/*>