Subversion Repositories Kolibri OS

Rev

Rev 6482 | Rev 6535 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6482 Rev 6489
Line 1... Line 1...
1
#ifndef KOLIBRI_MENUBAR_H
1
#ifndef KOLIBRI_MENUBAR_H
2
#define KOLIBRI_MENUBAR_H
2
#define KOLIBRI_MENUBAR_H
Line 3... Line 3...
3
 
3
 
4
typedef struct
4
typedef struct
5
{
5
{
Line 6... Line 6...
6
	uint32_t type;   // 1 åñëè íåò ïîäìåíþ ??
6
	uint32_t type;   // 1 åñëè íåò ïîäìåíþ, ïðîñòî ïóíêò
7
 
7
 
Line 8... Line 8...
8
	uint32_t x_w;   // âåðõíèé ïóíêò
8
	uint32_t x_w;   // âåðõíèé ïóíêò
Line 38... Line 38...
38
	uint32_t cursor_out;
38
	uint32_t cursor_out;
39
	uint32_t get_mouse_flag;
39
	uint32_t get_mouse_flag;
40
} menubar;
40
} menubar;
Line 41... Line 41...
41
 
41
 
42
 
42
 
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, char *subitems,
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,
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)
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
{
45
{
46
    static char procinfo[1024];
46
    static char procinfo[1024];
47
    memset(bar, 0, sizeof(menubar));
47
    memset(bar, 0, sizeof(menubar));
48
    bar->type = 0;
48
    bar->type = 0;
49
    bar->x_w = x_w;
-
 
50
    bar->y_h = y_h;
-
 
Line 51... Line 49...
51
    bar->text_pointer = menutext;
49
    bar->x_w = x_w;
52
    bar->pos_pointer = subitems;
50
    bar->y_h = y_h;
-
 
51
 
-
 
52
    // count summary length
-
 
53
    char *pc, **mitem;
-
 
54
    int len = 0;
-
 
55
    for(mitem = menutext; *mitem; mitem++) len += strlen(*mitem) + 1;
-
 
56
 
53
 
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
54
    // search last item - double zero
59
    for (pc = bar->text_pointer, mitem = menutext; *mitem; pc += strlen(*mitem++) + 1)
-
 
60
        strcpy(pc, *mitem);
-
 
61
    *pc = 0;
55
    char *pc = subitems;
62
    bar->text_end = pc;
56
    while (*pc) pc = strchr(pc, 0) + 1;
63
    bar->pos_pointer = strchr(bar->text_pointer, 0) + 1;
Line 57... Line 64...
57
    bar->text_end = pc;
64
 
58
    bar->x_w1 = X_Y(x_w >> 16, sub_w);
65
    bar->x_w1 = X_Y(x_w >> 16, sub_w);
Line 70... Line 77...
70
    bar->procinfo = procinfo;
77
    bar->procinfo = procinfo;
Line 71... Line 78...
71
 
78
 
72
    return bar;
79
    return bar;
Line 73... Line 80...
73
}
80
}
74
 
81
 
75
inline menubar* kolibri_new_menubar(uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char *menutext, char *subitems,
82
inline menubar* kolibri_new_menubar(uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char **menutext,
76
                                color_t sel_font, color_t unsel_font, color_t top_bg, color_t top_select, color_t sub_bg, color_t sub_select)
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)
77
{
84
{
78
    menubar *new_bar = (menubar*)malloc(sizeof(menubar));
85
    menubar *new_bar = (menubar*)malloc(sizeof(menubar));
Line 79... Line 86...
79
    return kolibri_menubar(new_bar, x_w, y_h, sub_w, sub_h, menutext, subitems, sel_font, unsel_font, top_bg, top_select, sub_bg, sub_select);
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);
80
}
87
}
81
 
88
 
82
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, char *subitems)
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)
83
{
90
{
84
    return kolibri_menubar(bar, x_w, y_h, sub_w, sub_h, menutext, subitems,
91
    return kolibri_menubar(bar, x_w, y_h, sub_w, sub_h, menutext,
Line 85... Line 92...
85
                           kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area,
92
                           kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area,
86
                           kolibri_color_table.color_work_button, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button);
93
                           kolibri_color_table.color_work_button, kolibri_color_table.color_grab_bar_button, kolibri_color_table.color_work_button);
87
}
94
}
88
 
95
 
89
inline menubar* kolibri_new_menubar_def(uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char *menutext, char *subitems)
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)
90
{
97
{
Line 91... Line 98...
91
    return kolibri_new_menubar(x_w, y_h, sub_w, sub_h, menutext, subitems,
98
    return kolibri_new_menubar(x_w, y_h, sub_w, sub_h, menutext,
92
                           kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area,
99
                           kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area,
93
                           kolibri_color_table.color_work_button, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button);
100
                           kolibri_color_table.color_work_button, kolibri_color_table.color_grab_bar_button, kolibri_color_table.color_work_button);