Rev 6535 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8581 | rgimad | 1 | #ifndef KOLIBRI_MENUBAR_H |
2 | #define KOLIBRI_MENUBAR_H |
||
3 | |||
6482 | siemargl | 4 | typedef struct |
5 | { |
||
8581 | rgimad | 6 | uint32_t type; // 1 ���� ��� �������, ������ ����� |
6482 | siemargl | 7 | |
8581 | rgimad | 8 | uint32_t x_w; // ������� ����� |
6482 | siemargl | 9 | uint32_t y_h; |
10 | |||
11 | char* text_pointer; |
||
12 | char* pos_pointer; |
||
13 | char* text_end; |
||
14 | uint32_t mouse_pos; |
||
15 | uint32_t mouse_keys; |
||
16 | |||
8581 | rgimad | 17 | uint32_t x_w1; // ������� |
6482 | siemargl | 18 | uint32_t y_h1; |
19 | |||
8581 | rgimad | 20 | color_t bckg_col; // ��� �������� ����� |
21 | color_t frnt_col; // ��� ���������� �������� ������ |
||
22 | color_t menu_col; // ��� ���������� ����� (��������) |
||
6482 | siemargl | 23 | uint32_t select; |
24 | uint32_t out_select; |
||
25 | char* buf_adress; |
||
26 | char* procinfo; |
||
27 | uint32_t click; |
||
28 | uint32_t cursor; |
||
29 | uint32_t cursor_old; |
||
30 | uint32_t interval; |
||
31 | uint32_t cursor_max; |
||
32 | uint32_t extended_key; |
||
8581 | rgimad | 33 | color_t menu_sel_col; // ���� ���� ���������� ��������� |
34 | color_t bckg_text_col; // ���� ������ ������������ ������ |
||
35 | color_t frnt_text_col; // ���� ������ ���������� ������ |
||
6482 | siemargl | 36 | uint32_t mouse_keys_old; |
37 | uint32_t font_height; |
||
38 | uint32_t cursor_out; |
||
39 | uint32_t get_mouse_flag; |
||
40 | } menubar; |
||
41 | |||
8581 | rgimad | 42 | |
6535 | siemargl | 43 | static inline menubar* kolibri_menubar(menubar* bar, uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char **menutext, |
6482 | siemargl | 44 | color_t sel_font, color_t unsel_font, color_t top_bg, color_t top_select, color_t sub_bg, color_t sub_select) |
45 | { |
||
46 | static char procinfo[1024]; |
||
47 | memset(bar, 0, sizeof(menubar)); |
||
8581 | rgimad | 48 | bar->type = 0; |
49 | bar->x_w = x_w; |
||
6482 | siemargl | 50 | bar->y_h = y_h; |
51 | |||
6489 | siemargl | 52 | // count summary length |
53 | char *pc, **mitem; |
||
54 | int len = 0; |
||
55 | for(mitem = menutext; *mitem; mitem++) len += strlen(*mitem) + 1; |
||
56 | |||
8581 | rgimad | 57 | // copy menu items in needed format |
6489 | siemargl | 58 | bar->text_pointer = malloc(len + 1); // need to be freed manual at closing secondary windows with menu |
59 | for (pc = bar->text_pointer, mitem = menutext; *mitem; pc += strlen(*mitem++) + 1) |
||
60 | strcpy(pc, *mitem); |
||
61 | *pc = 0; |
||
6482 | siemargl | 62 | bar->text_end = pc; |
6489 | siemargl | 63 | bar->pos_pointer = strchr(bar->text_pointer, 0) + 1; |
64 | |||
6482 | siemargl | 65 | bar->x_w1 = X_Y(x_w >> 16, sub_w); |
6489 | siemargl | 66 | bar->y_h1 = X_Y((y_h >> 16) + (y_h & 0xFFFF), sub_h); |
6482 | siemargl | 67 | |
8581 | rgimad | 68 | bar->interval = 16; |
69 | bar->font_height = 8; |
||
6482 | siemargl | 70 | |
71 | bar->bckg_col = top_bg; |
||
72 | bar->frnt_col = top_select; |
||
73 | bar->menu_col = sub_bg; |
||
74 | bar->menu_sel_col = sub_select; |
||
75 | bar->bckg_text_col = unsel_font; |
||
76 | bar->frnt_text_col = sel_font; |
||
77 | bar->procinfo = procinfo; |
||
78 | |||
79 | return bar; |
||
8581 | rgimad | 80 | } |
81 | |||
82 | static inline menubar* kolibri_new_menubar(uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char **menutext, |
||
6482 | siemargl | 83 | color_t sel_font, color_t unsel_font, color_t top_bg, color_t top_select, color_t sub_bg, color_t sub_select) |
84 | { |
||
8581 | rgimad | 85 | menubar *new_bar = (menubar*)malloc(sizeof(menubar)); |
86 | return kolibri_menubar(new_bar, x_w, y_h, sub_w, sub_h, menutext, sel_font, unsel_font, top_bg, top_select, sub_bg, sub_select); |
||
6482 | siemargl | 87 | } |
88 | |||
8581 | rgimad | 89 | static inline menubar* kolibri_menubar_def(menubar* bar, uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char **menutext) |
6482 | siemargl | 90 | { |
6489 | siemargl | 91 | return kolibri_menubar(bar, x_w, y_h, sub_w, sub_h, menutext, |
6482 | siemargl | 92 | kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, |
6489 | siemargl | 93 | kolibri_color_table.color_work_button, kolibri_color_table.color_grab_bar_button, kolibri_color_table.color_work_button); |
6482 | siemargl | 94 | } |
95 | |||
8581 | rgimad | 96 | static inline menubar* kolibri_new_menubar_def(uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char **menutext) |
6482 | siemargl | 97 | { |
6489 | siemargl | 98 | return kolibri_new_menubar(x_w, y_h, sub_w, sub_h, menutext, |
6482 | siemargl | 99 | kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, |
6489 | siemargl | 100 | kolibri_color_table.color_work_button, kolibri_color_table.color_grab_bar_button, kolibri_color_table.color_work_button); |
6482 | siemargl | 101 | } |
102 | |||
8581 | rgimad | 103 | static inline void gui_add_menubar(kolibri_window *wnd, menubar* bar) |
6482 | siemargl | 104 | { |
8581 | rgimad | 105 | kolibri_window_add_element(wnd, KOLIBRI_MENU_BAR, bar); |
6482 | siemargl | 106 | } |
8581 | rgimad | 107 | |
108 | |||
109 | extern void (*menu_bar_draw)(menubar *) __attribute__((__stdcall__)); |
||
110 | extern void (*menu_bar_mouse)(menubar *) __attribute__((__stdcall__)); |
||
111 | extern void (*menu_bar_activate)(menubar *) __attribute__((__stdcall__)); |
||
112 | |||
113 | #endif /* KOLIBRI_MENUBAR_H */ |