Rev 6482 | Rev 6535 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6482 | siemargl | 1 | #ifndef KOLIBRI_MENUBAR_H |
2 | #define KOLIBRI_MENUBAR_H |
||
3 | |||
4 | typedef struct |
||
5 | { |
||
6489 | siemargl | 6 | uint32_t type; // 1 если нет подменю, просто пункт |
6482 | siemargl | 7 | |
8 | uint32_t x_w; // верхний пункт |
||
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 | |||
17 | uint32_t x_w1; // подменю |
||
18 | uint32_t y_h1; |
||
19 | |||
20 | color_t bckg_col; // фон верхнего пукта |
||
21 | color_t frnt_col; // фон выбранного верхнего пункта |
||
22 | color_t menu_col; // фон выпадающей части (подпукты) |
||
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; |
||
33 | color_t menu_sel_col; // цвет фона выбранного подпункта |
||
34 | color_t bckg_text_col; // цвет шрифта невыбранного пункта |
||
35 | color_t frnt_text_col; // цвет шрифта выбранного пункта |
||
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 | |||
42 | |||
6489 | siemargl | 43 | 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)); |
||
48 | bar->type = 0; |
||
49 | bar->x_w = x_w; |
||
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 | |||
57 | // copy menu items in needed format |
||
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 | |
68 | bar->interval = 16; |
||
69 | bar->font_height = 8; |
||
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; |
||
80 | } |
||
81 | |||
6489 | siemargl | 82 | 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 | { |
||
85 | menubar *new_bar = (menubar*)malloc(sizeof(menubar)); |
||
6489 | siemargl | 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 | |||
6489 | siemargl | 89 | 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 | |||
6489 | siemargl | 96 | 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 | |||
103 | inline void gui_add_menubar(kolibri_window *wnd, menubar* bar) |
||
104 | { |
||
105 | kolibri_window_add_element(wnd, KOLIBRI_MENU_BAR, bar); |
||
106 | } |
||
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 */ |