📄 menus.h
字号:
/* return prevoius item from "item" */
p_menuitem (*prev_item) ( p_menuview o, p_menuitem item );
/* return next item from "item" */
p_menuitem (*next_item) ( p_menuview o, p_menuitem item );
/* return next / previous item from "item", whenever is
forward=true / forward=false
*/
p_menuitem (*get_next_item) ( p_menuview o, p_menuitem item, l_bool forward );
/* create new sub-menu defined by items in "menu" in rect (r) and "action" will
contain last action from sub-menu. return message if sub-menu was pressed,
otherwise it returns MSG_NOTHING
*/
l_dword (*run_new_menu) ( p_menuview o, t_rect r, l_int *action, p_menu menu );
/* get item of menuview, where's the mouse pointer is under it. */
p_menuitem (*get_item_from_mouse) ( p_menuview o, t_point p );
/* return true, if mouse pointer is in parent menu */
l_bool (*is_mouse_in_one_of_parent_menu) ( p_menuview o, t_point p );
/* return true, if mouse pointer is in parent item, the item from where this
or prant, .... menu were created
*/
l_bool (*is_mouse_in_one_of_parent_item) ( p_menuview o, t_point p );
/* return true, if one of sub-menus has state (st) */
l_bool (*is_one_of_subs_state) ( p_menuview o, l_dword st );
/* return oldest parent menuview. the menuview from others were created */
p_menuview (*top_menuview) ( p_menuview o );
/* if horizontal parent exists, this returns pointer to horizontal menu, otherwise
returns NULL
*/
p_menuview (*is_hor_menu_one_of_parents) ( p_menuview o );
} t_menuview;
#define MENUVIEW(o) ((p_menuview)(o))
/* t_hormenu functions */
void hormenu_draw ( p_view o );
l_dword hormenu_execute ( p_object o );
t_rect hormenu_get_item_box_ex ( p_menuview o, p_menuitem item, t_rect r );
void hormenu_save_desktop ( p_menuview o );
void hormenu_draw_item ( p_menuview o, p_menuitem item );
extern p_menuview (*hormenu_init) ( p_menuview o, t_rect r, p_menu menu );
p_menuview _hormenu_init ( p_menuview o, t_rect r, p_menu menu );
extern p_menuview (*hormenu_init_ex) ( p_menuview o, t_rect r, l_rect item_size, l_rect icon_size, p_menu menu );
p_menuview _hormenu_init_ex ( p_menuview o, t_rect r, l_rect item_size, l_rect icon_size, p_menu menu );
/* t_menuview functions */
l_bool menuview_done ( p_object o );
l_dword menuview_execute ( p_object o );
void menuview_translate_event ( p_object o, t_event *event );
void menuview_set_state ( p_object o, l_dword st, l_bool set );
t_rect menuview_size_limits ( p_view o );
void menuview_draw ( p_view o );
void menuview_draw_under_rect ( p_view o, t_rect r );
void menuview_save_desktop ( p_menuview o );
p_menuview menuview_is_hor_menu_one_of_parents ( p_menuview o );
p_menuitem menuview_index_of ( p_menuview o, l_int item );
l_int menuview_at ( p_menuview o, p_menuitem p );
void menuview_draw_item ( p_menuview o, p_menuitem item );
void menuview_draw_current_item ( p_menuview o );
t_rect menuview_get_item_box_ex ( p_menuview o, p_menuitem item, t_rect r );
t_rect menuview_get_mousitem_box ( p_menuview o, p_menuitem item );
t_rect menuview_get_item_box ( p_menuview o, p_menuitem item );
p_menuitem menuview_prev_item ( p_menuview o, p_menuitem item );
p_menuitem menuview_next_item ( p_menuview o, p_menuitem item );
p_menuitem menuview_get_next_item ( p_menuview o, p_menuitem item, l_bool forward );
l_dword menuview_run_new_menu ( p_menuview o, t_rect r, l_int *action, p_menu menu );
p_menuitem menuview_get_item_from_mouse ( p_menuview o, t_point p );
l_bool menuview_is_mouse_in_one_of_parent_menu ( p_menuview o, t_point p );
l_bool menuview_is_mouse_in_one_of_parent_item ( p_menuview o, t_point p );
l_bool menuview_is_one_of_subs_state ( p_menuview o, l_dword st );
p_menuview menuview_top_menuview ( p_menuview o );
/*
this function initialize menu to rect (r).
Information about menu are stored in (menu) pointer we explained under.
If r.b.x < r.a.x, it automaticaly set r.b.x to minimum width of menu,
r.b.y is set automaticaly to minimum height.
example :
t_rect r = rect_assign(100, 100, 0, 0);
p_menu p = new_menu(
new_menu_item_ex("Hello", NULL, 0, MSG_CLOSE, true,
"Info about Hello", MIF_NONE, font_system_bi, NULL, NULL, 0,
new_menu_line(
new_menu_item_ex("Quit", NULL, 0, MSG_QUIT, true,
"This quit Seal", MIF_NONE, font_system_bd, NULL, NULL, 0,
NULL)))
);
p_object menu = OBJECT(menuview_init(
malloc(sizeof(t_menuview)),
r,
p)
);
---show menu into the desktop
desktop->execute_view(desktop, VIEW(menu));
*/
extern p_menuview (*menuview_init) ( p_menuview o, t_rect r, p_menu menu );
p_menuview _menuview_init ( p_menuview o, t_rect r, p_menu menu );
/*
function is same like menuview_init function but was optimalized for
the horizontal menu.
*/
extern p_menuview (*menuview_init_ex) ( p_menuview o, t_rect r, l_rect item_size, l_rect icon_size, p_menu menu );
p_menuview _menuview_init_ex ( p_menuview o, t_rect r, l_rect item_size, l_rect icon_size, p_menu menu );
/* t_menu and t_menuitem functions */
#define menu_clear_lastitem_called(m) menu_get_lastitem_called(m)
l_long menu_get_item_pos ( p_menu m, p_menuitem x );
/*
When you have get some action from the menu, you can use the following functions
for more information about the action. An Action may be difference by messages,
but sometimes you need to distinguish two items that have the same message.
The best example is the desktop menu, that contains same messages for file running.
You can use these two function for distinguish it:
*/
/*
returns pointer t_menuitem structure, that contains information about last
pushed item. When menu was closed without pushing, this return NULL. (m)
is pointer to menu, from where you want to check the state.
*/
p_menuitem menu_get_lastitem_called ( p_menu m );
/* returns (flags) from the item that's defined by the message (message).*/
l_int menu_get_item_flags ( p_menu m, l_dword message );
l_dword menu_get_hotkey_message ( p_menu m, l_int keycode );
l_int menu_get_max_item ( p_menu m );
t_point menu_get_ver_size ( p_menu menu, l_int h );
t_point menu_get_hor_size ( p_menu menu, l_int h, l_int icon_size );
/* adds new item (src) at the end of (dst) item array. if (dst) is NULL, this
return (src).
*/
p_menuitem add_menu_item_to_menuitem ( p_menuitem dst, p_menuitem src );
/* adds items (items) into the position (pos) in menu (p) and returns true if all
was successfull.
*/
l_bool add_menu_item_to_menu ( p_menu p, l_int pos, p_menuitem items );
/*
create new menu-line. Returns pointer to information about menu line.
*/
p_menuitem new_menu_line ( p_menuitem next ); /* make new line */
/* free one menu item */
void free_menu_item ( p_menuitem i );
/* free menu and all items */
void free_menu ( p_menu i );
/* create new section for the menu. (item) is the first item of the menu.
returns pointer you will use in initalization menuview function.
*/
p_menu new_menu ( p_menuitem item ); /* make new menu */
/*
create new submenu. Returns pointer to info about this submenu
( to new t_menuitem structure ). (name) is name of the item, (enable) is set
to true if the item is enable and can be pushed, otherwise is set to false.
(info_text) is text that will be showed whenever CTRL+F1 and mouse cursor is
under this menu-item. (font) is font that will be used for this item.
(icon) is icon of the item. (font_symbol) - sometimes you need to use some of
the font symbols instead of the icon. (chr) is character of the symbol.
If you not use it, simple set zero. (menu) is new menu that contains
other menu-items. (next) is next item in this hierarchy.
*/
p_menuitem new_sub_menu_ex ( l_text name, l_bool enable, l_text info_text,
l_font *font, BITMAP *icon, l_font *font_symbol, l_byte chr,
p_menu menu, p_menuitem next );
/*
create new menuitem. Returns pointer to info about this item
( to new t_menuitem structure ). (name) is the name of the item, (param) is
text that will be showed for (hotkey)-what's keycode of the item.(message) is
the message that is called even when the item is pushed down.(enable) is set
to true if the item is enable and can be pushed, otherwise is set to false.
(info_text) is text that will be showed whenever CTRL+F1 and mouse cursor is
under this menu-item. (font) is font that will be used for this item. (icon)
is icon of the item. (font_symbol) - sometimes you need to use some of the font
symbols instead of the icon. (chr) is character of the symbol.
If you don't use it, simple set zero. (menu) is new menu that contains other
menu-items. (next) is next item in this hierarchy.
*/
t_rect menuview_get_mouseitem_box ( p_menuview o, p_menuitem item );
p_menuitem new_menu_item_ex ( l_text name, l_text param, l_int hotkey, l_dword message,
l_bool enable, l_text info_text, l_int flags,
l_font *font, BITMAP *icon, l_font *font_symbol, l_byte chr,
p_menuitem next );
/* it's short version of new_sub_menu_ex function. */
#define new_sub_menu(name,menu,next) \
new_sub_menu_ex(name, true, NULL, NULL, NULL, NULL, 0, menu, next)
/* it's short version of new_menu_item_ex function. */
#define new_menu_item(name,param,hk,msg,it,next) \
new_menu_item_ex(name, param, hk, msg, true, it, 0, NULL, NULL, NULL, 0, next)
/*
create new check menu item. This item is same like menuitem, but when you hit it,
it shows (\/) - checkbox symbol.
*/
#define new_menu_check_item(name,param,is_check,hk,msg,it,next) \
new_menu_item_ex(name, param, hk, msg, true, it, MIF_CHECK+(is_check*MIF_CHECKOK), NULL, NULL, NULL, 0, next)
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -