forked from KolibriOS/kolibrios
Menubar
git-svn-id: svn://kolibrios.org@6482 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
14a9fabc5a
commit
b7abf42dc1
@ -150,3 +150,7 @@ public scrollbar_h_mouse as '_scrollbar_h_mouse'
|
|||||||
|
|
||||||
public option_box_draw as '_option_box_draw'
|
public option_box_draw as '_option_box_draw'
|
||||||
public option_box_mouse as '_option_box_mouse'
|
public option_box_mouse as '_option_box_mouse'
|
||||||
|
|
||||||
|
public menu_bar_draw as '_menu_bar_draw'
|
||||||
|
public menu_bar_mouse as '_menu_bar_mouse'
|
||||||
|
public menu_bar_activate as '_menu_bar_activate'
|
||||||
|
@ -64,6 +64,25 @@ int main()
|
|||||||
int option_index1 = 0; // index of selected option
|
int option_index1 = 0; // index of selected option
|
||||||
int option_index2 = 0;
|
int option_index2 = 0;
|
||||||
|
|
||||||
|
static char *menu1t = "Menu1";
|
||||||
|
static char *menu11t = "Set RED";
|
||||||
|
static char *menu12t = "Set GREEN";
|
||||||
|
static char *menu13t = "Set BLUE";
|
||||||
|
static char *menu14t = "";
|
||||||
|
menubar* menu1 = kolibri_new_menubar_def(X_Y(20, 40), X_Y(25, 15), 80, 100, menu1t, menu11t);
|
||||||
|
gui_add_menubar(main_window, menu1);
|
||||||
|
|
||||||
|
static char *menu2t = "Menu2";
|
||||||
|
static char *menu21t = "Set Option 1";
|
||||||
|
static char *menu22t = "Set Option 2";
|
||||||
|
static char *menu23t = "Set Option 3";
|
||||||
|
static char *menu24t = "";
|
||||||
|
menubar* menu2 = kolibri_new_menubar_def(X_Y(60, 40), X_Y(25, 15), 80, 100, menu2t, menu21t);
|
||||||
|
gui_add_menubar(main_window, menu2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
do /* Start of main activity loop */
|
do /* Start of main activity loop */
|
||||||
{
|
{
|
||||||
if(option_index1 != option1sel - opts1)
|
if(option_index1 != option1sel - opts1)
|
||||||
|
@ -39,7 +39,7 @@ check_box* kolibri_new_check_box(unsigned int tlx, unsigned int tly, unsigned in
|
|||||||
new_checkbox -> left_s = (tlx << 16) + sizex;
|
new_checkbox -> left_s = (tlx << 16) + sizex;
|
||||||
new_checkbox -> top_s = (tly << 16) + sizey;
|
new_checkbox -> top_s = (tly << 16) + sizey;
|
||||||
new_checkbox -> ch_text_margin = 10;
|
new_checkbox -> ch_text_margin = 10;
|
||||||
new_checkbox -> color = 0xFFFFFFFF; // 0x80AABBCC, 31-bit mus be set asciiz
|
new_checkbox -> color = kolibri_color_table.color_work_area; // 0xFFFFFFFF; // 0x80AABBCC, 31-bit mus be set asciiz
|
||||||
new_checkbox -> border_color = kolibri_color_table.color_work_graph;
|
new_checkbox -> border_color = kolibri_color_table.color_work_graph;
|
||||||
new_checkbox -> text_color = kolibri_color_table.color_work_text;
|
new_checkbox -> text_color = kolibri_color_table.color_work_text;
|
||||||
new_checkbox -> text = label_text;
|
new_checkbox -> text = label_text;
|
||||||
|
@ -30,6 +30,8 @@ enum KOLIBRI_GUI_ELEMENT_TYPE {
|
|||||||
KOLIBRI_NUM_GUI_ELEMENTS
|
KOLIBRI_NUM_GUI_ELEMENTS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define X_Y(x,y) (((x)<<16)|(y))
|
||||||
|
|
||||||
/* Linked list which connects together all the elements drawn inside a GUI window */
|
/* Linked list which connects together all the elements drawn inside a GUI window */
|
||||||
typedef struct{
|
typedef struct{
|
||||||
enum KOLIBRI_GUI_ELEMENT_TYPE type;
|
enum KOLIBRI_GUI_ELEMENT_TYPE type;
|
||||||
@ -71,8 +73,8 @@ void kolibri_window_add_element(kolibri_window *some_window, enum KOLIBRI_GUI_EL
|
|||||||
#include "kolibri_scrollbar.h"
|
#include "kolibri_scrollbar.h"
|
||||||
#include "kolibri_statictext.h"
|
#include "kolibri_statictext.h"
|
||||||
#include "kolibri_optionbox.h"
|
#include "kolibri_optionbox.h"
|
||||||
|
#include "kolibri_menubar.h"
|
||||||
|
|
||||||
#define X_Y(x,y) (((x)<<16)|(y))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -129,7 +131,11 @@ kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].redraw_fn = (cb_elem_boxlib)option_box
|
|||||||
kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].mouse_fn = (cb_elem_boxlib)option_box_mouse;
|
kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].mouse_fn = (cb_elem_boxlib)option_box_mouse;
|
||||||
kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].key_fn = NULL;
|
kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].key_fn = NULL;
|
||||||
|
|
||||||
debug_board_printf("KOLIBRI_OPTIONGROUP (%x,%x,%x)\n", option_box_draw,option_box_mouse,0);
|
kolibri_gui_op_table[KOLIBRI_MENU_BAR].redraw_fn = (cb_elem_boxlib)menu_bar_draw;
|
||||||
|
kolibri_gui_op_table[KOLIBRI_MENU_BAR].mouse_fn = (cb_elem_boxlib)menu_bar_mouse;
|
||||||
|
kolibri_gui_op_table[KOLIBRI_MENU_BAR].key_fn = NULL;
|
||||||
|
|
||||||
|
debug_board_printf("KOLIBRI_MENU_BAR (%x,%x,%x)\n", menu_bar_draw,menu_bar_mouse,menu_bar_activate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a new main GUI window for KolibriOS */
|
/* Create a new main GUI window for KolibriOS */
|
||||||
|
106
contrib/C_Layer/INCLUDE/kolibri_menubar.h
Normal file
106
contrib/C_Layer/INCLUDE/kolibri_menubar.h
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
#ifndef KOLIBRI_MENUBAR_H
|
||||||
|
#define KOLIBRI_MENUBAR_H
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t type; // 1 åñëè íåò ïîäìåíþ ??
|
||||||
|
|
||||||
|
uint32_t x_w; // âåðõíèé ïóíêò
|
||||||
|
uint32_t y_h;
|
||||||
|
|
||||||
|
char* text_pointer;
|
||||||
|
char* pos_pointer;
|
||||||
|
char* text_end;
|
||||||
|
uint32_t mouse_pos;
|
||||||
|
uint32_t mouse_keys;
|
||||||
|
|
||||||
|
uint32_t x_w1; // ïîäìåíþ
|
||||||
|
uint32_t y_h1;
|
||||||
|
|
||||||
|
color_t bckg_col; // ôîí âåðõíåãî ïóêòà
|
||||||
|
color_t frnt_col; // ôîí âûáðàííîãî âåðõíåãî ïóíêòà
|
||||||
|
color_t menu_col; // ôîí âûïàäàþùåé ÷àñòè (ïîäïóêòû)
|
||||||
|
uint32_t select;
|
||||||
|
uint32_t out_select;
|
||||||
|
char* buf_adress;
|
||||||
|
char* procinfo;
|
||||||
|
uint32_t click;
|
||||||
|
uint32_t cursor;
|
||||||
|
uint32_t cursor_old;
|
||||||
|
uint32_t interval;
|
||||||
|
uint32_t cursor_max;
|
||||||
|
uint32_t extended_key;
|
||||||
|
color_t menu_sel_col; // öâåò ôîíà âûáðàííîãî ïîäïóíêòà
|
||||||
|
color_t bckg_text_col; // öâåò øðèôòà íåâûáðàííîãî ïóíêòà
|
||||||
|
color_t frnt_text_col; // öâåò øðèôòà âûáðàííîãî ïóíêòà
|
||||||
|
uint32_t mouse_keys_old;
|
||||||
|
uint32_t font_height;
|
||||||
|
uint32_t cursor_out;
|
||||||
|
uint32_t get_mouse_flag;
|
||||||
|
} menubar;
|
||||||
|
|
||||||
|
|
||||||
|
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,
|
||||||
|
color_t sel_font, color_t unsel_font, color_t top_bg, color_t top_select, color_t sub_bg, color_t sub_select)
|
||||||
|
{
|
||||||
|
static char procinfo[1024];
|
||||||
|
memset(bar, 0, sizeof(menubar));
|
||||||
|
bar->type = 0;
|
||||||
|
bar->x_w = x_w;
|
||||||
|
bar->y_h = y_h;
|
||||||
|
bar->text_pointer = menutext;
|
||||||
|
bar->pos_pointer = subitems;
|
||||||
|
|
||||||
|
// search last item - double zero
|
||||||
|
char *pc = subitems;
|
||||||
|
while (*pc) pc = strchr(pc, 0) + 1;
|
||||||
|
bar->text_end = pc;
|
||||||
|
bar->x_w1 = X_Y(x_w >> 16, sub_w);
|
||||||
|
bar->y_h1 = X_Y((y_h >> 16) + (y_h & 0xFFFF), sub_h);
|
||||||
|
|
||||||
|
bar->interval = 16;
|
||||||
|
bar->font_height = 8;
|
||||||
|
|
||||||
|
bar->bckg_col = top_bg;
|
||||||
|
bar->frnt_col = top_select;
|
||||||
|
bar->menu_col = sub_bg;
|
||||||
|
bar->menu_sel_col = sub_select;
|
||||||
|
bar->bckg_text_col = unsel_font;
|
||||||
|
bar->frnt_text_col = sel_font;
|
||||||
|
bar->procinfo = procinfo;
|
||||||
|
|
||||||
|
return bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
color_t sel_font, color_t unsel_font, color_t top_bg, color_t top_select, color_t sub_bg, color_t sub_select)
|
||||||
|
{
|
||||||
|
menubar *new_bar = (menubar*)malloc(sizeof(menubar));
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return kolibri_menubar(bar, x_w, y_h, sub_w, sub_h, menutext, subitems,
|
||||||
|
kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area,
|
||||||
|
kolibri_color_table.color_work_button, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return kolibri_new_menubar(x_w, y_h, sub_w, sub_h, menutext, subitems,
|
||||||
|
kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area,
|
||||||
|
kolibri_color_table.color_work_button, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void gui_add_menubar(kolibri_window *wnd, menubar* bar)
|
||||||
|
{
|
||||||
|
kolibri_window_add_element(wnd, KOLIBRI_MENU_BAR, bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern void (*menu_bar_draw)(menubar *) __attribute__((__stdcall__));
|
||||||
|
extern void (*menu_bar_mouse)(menubar *) __attribute__((__stdcall__));
|
||||||
|
extern void (*menu_bar_activate)(menubar *) __attribute__((__stdcall__));
|
||||||
|
|
||||||
|
#endif /* KOLIBRI_MENUBAR_H */
|
@ -33,11 +33,11 @@ typedef struct {
|
|||||||
uint32_t ar_offset;
|
uint32_t ar_offset;
|
||||||
} scrollbar;
|
} scrollbar;
|
||||||
|
|
||||||
scrollbar* kolibri_new_scrollbar(uint32_t x_w, uint32_t y_h, uint32_t btn_height, uint32_t max_area,
|
inline scrollbar* kolibri_scrollbar(scrollbar* sb, uint32_t x_w, uint32_t y_h, uint32_t btn_height, uint32_t max_area,
|
||||||
uint32_t cur_area, uint32_t position, uint32_t back_color, uint32_t front_color, uint32_t line_color)
|
uint32_t cur_area, uint32_t position, uint32_t back_color, uint32_t front_color, uint32_t line_color)
|
||||||
{
|
{
|
||||||
scrollbar *sb = (scrollbar *)calloc(1, sizeof(scrollbar));
|
memset(sb, 0, sizeof(scrollbar));
|
||||||
|
|
||||||
sb->x_w = x_w;
|
sb->x_w = x_w;
|
||||||
sb->y_h = y_h;
|
sb->y_h = y_h;
|
||||||
sb->btn_height = btn_height;
|
sb->btn_height = btn_height;
|
||||||
@ -45,16 +45,42 @@ scrollbar* kolibri_new_scrollbar(uint32_t x_w, uint32_t y_h, uint32_t btn_height
|
|||||||
sb->max_area = max_area;
|
sb->max_area = max_area;
|
||||||
sb->cur_area = cur_area;
|
sb->cur_area = cur_area;
|
||||||
sb->position = position;
|
sb->position = position;
|
||||||
sb->line_color = 0; //line_color; // 0
|
sb->line_color = line_color;
|
||||||
sb->back_color = 0xeeeeee; // back_color; // 0xeeeeee
|
sb->back_color = back_color; // 0xeeeeee
|
||||||
sb->front_color = 0xbbddff; //front_color; // 0xbbddff
|
sb->front_color = front_color; // 0xbbddff
|
||||||
sb->ar_offset = max_area / 30; // temporary step 3%
|
sb->ar_offset = max_area / 30; // temporary step 3%
|
||||||
sb->all_redraw = 1;
|
sb->all_redraw = 1;
|
||||||
return sb;
|
return sb;
|
||||||
};
|
};
|
||||||
|
|
||||||
//use_optionbox_driver
|
inline scrollbar* kolibri_new_scrollbar(uint32_t x_w, uint32_t y_h, uint32_t btn_height, uint32_t max_area,
|
||||||
|
uint32_t cur_area, uint32_t position, uint32_t back_color, uint32_t front_color, uint32_t line_color)
|
||||||
|
{
|
||||||
|
scrollbar *sb = (scrollbar *)malloc(sizeof(scrollbar));
|
||||||
|
|
||||||
|
return kolibri_scrollbar(sb, x_w, y_h, btn_height, max_area, cur_area, position, back_color, front_color, line_color);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline scrollbar* kolibri_scrollbar_def(scrollbar* sb, uint32_t x_w, uint32_t y_h, uint32_t max_area, uint32_t cur_area, uint32_t position)
|
||||||
|
{
|
||||||
|
return kolibri_scrollbar(sb, x_w, y_h, 15, max_area, cur_area, position, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button, kolibri_color_table.color_work_button_text);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline scrollbar* kolibri_new_scrollbar_def(uint32_t x_w, uint32_t y_h, uint32_t max_area, uint32_t cur_area, uint32_t position)
|
||||||
|
{
|
||||||
|
return kolibri_new_scrollbar(x_w, y_h, 15, max_area, cur_area, position, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button, kolibri_color_table.color_work_button_text);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void gui_add_scrollbar_h(kolibri_window *wnd, scrollbar* sb)
|
||||||
|
{
|
||||||
|
kolibri_window_add_element(wnd, KOLIBRI_SCROLL_BAR_H, sb);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void gui_add_scrollbar_v(kolibri_window *wnd, scrollbar* sb)
|
||||||
|
{
|
||||||
|
kolibri_window_add_element(wnd, KOLIBRI_SCROLL_BAR_V, sb);
|
||||||
|
}
|
||||||
|
|
||||||
extern void (*scrollbar_h_draw)(scrollbar*) __attribute__((__stdcall__));
|
extern void (*scrollbar_h_draw)(scrollbar*) __attribute__((__stdcall__));
|
||||||
extern void (*scrollbar_h_mouse)(scrollbar*) __attribute__((__stdcall__));
|
extern void (*scrollbar_h_mouse)(scrollbar*) __attribute__((__stdcall__));
|
||||||
extern void (*scrollbar_v_draw)(scrollbar*) __attribute__((__stdcall__));
|
extern void (*scrollbar_v_draw)(scrollbar*) __attribute__((__stdcall__));
|
||||||
|
Loading…
Reference in New Issue
Block a user