diff --git a/programs/cmm/Calypte/Calypte.c b/programs/cmm/Calypte/Calypte.c index 3698754cb3..d648478127 100644 --- a/programs/cmm/Calypte/Calypte.c +++ b/programs/cmm/Calypte/Calypte.c @@ -433,7 +433,6 @@ void EventMenuClick() EventOpenFileInAnotherProgram("/sys/develop/heed"); break; } - menu.cur_y = 0; } void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected) diff --git a/programs/cmm/aelia/aelia.c b/programs/cmm/aelia/aelia.c index c80e44de84..54dcdedcdc 100644 --- a/programs/cmm/aelia/aelia.c +++ b/programs/cmm/aelia/aelia.c @@ -4,6 +4,7 @@ #include "../lib/kfont.h" #include "../lib/io.h" #include "../lib/cursor.h" +#include "../lib/list_box.h" #include "../lib/obj/box_lib.h" #include "../lib/obj/libini.h" @@ -71,6 +72,8 @@ bool debug_mode=false; #include "prepare_page.h" //#include "special.h" +int menu_id=0; + #define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nDownloader\nAbout" void InitDlls() @@ -112,20 +115,7 @@ void main() break; case evReDraw: draw_window(); - if (menu.cur_y>=10) && (menu.cur_y<20) { - encoding = menu.cur_y - 10; - EventPageRefresh(); - menu.cur_y = 0; - } - if (menu.cur_y>=20) { - menu.cur_y-=20; - if (menu.cur_y==0) EventPageRefresh(); - if (menu.cur_y==1) EventRunEdit(); - if (menu.cur_y==2) EventShowHistory(); - if (menu.cur_y==3) EventShowDownloader(); - if (menu.cur_y==4) EventShowInfo(); - menu.cur_y = 0; - } + if (CheckActiveProcess(Form.ID)) EventMenuClick(); } } } @@ -407,8 +397,34 @@ void EventRunEdit() void EventChangeEncoding() { - menu.selected = encoding + 1; - menu.show(Form.left+Form.cwidth-97,Form.top+TOOLBAR_H+skin_height-6, 130, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10); + menu_id = 10; + open_lmenu(Form.left+Form.cwidth-36,Form.top+TOOLBAR_H+skin_height-6, MENU_ALIGN_TOP_RIGHT, + encoding+1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); +} + +void EventShowSandwichMenu() +{ + menu_id = 20; + open_lmenu(Form.left+Form.cwidth+3,Form.top+TOOLBAR_H+skin_height-6, + MENU_ALIGN_TOP_RIGHT, 0, SANDWICH_MENU); +} + +void EventMenuClick() +{ + dword click_id = get_menu_click(); + + if (menu_id == 10) && (click_id) { + encoding = click_id-1; + EventPageRefresh(); + menu_id = 0; + } + if (menu_id == 20) {switch(click_id) { + case 1: EventPageRefresh(); break; + case 2: EventRunEdit(); break; + case 3: EventShowHistory(); break; + case 4: EventShowDownloader(); break; + case 5: EventShowInfo(); break; + } menu_id = 0;} } void EventShowInfo() { @@ -430,12 +446,6 @@ void EventGoForward() if (history.forward()) EventOpenAddress(history.current()); } -void EventShowSandwichMenu() -{ - menu.selected = 0; - menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20); -} - void EventPageRefresh() { EventOpenAddress(history.current()); @@ -547,3 +557,4 @@ void DrawStatusBar(dword _status_text) PathShow_draw stdcall(#status_text); } } + diff --git a/programs/cmm/examples/menu.c b/programs/cmm/examples/menu.c index a3ef54bc50..417eceb45c 100644 --- a/programs/cmm/examples/menu.c +++ b/programs/cmm/examples/menu.c @@ -3,36 +3,38 @@ #include "../lib/io.h" #include "../lib/list_box.h" #include "../lib/gui.h" +#include "../lib/fs.h" struct _object { int x,y,w,h,id; }; -_object butv = { 20, 20, 100, 30, 10}; -_object buta = {150, 20, 100, 30, 20}; +_object butv = { 20, 20, 100, 20, 10}; +_object buta = {150, 20, 100, 20, 20}; char vegetables[] = -"Onion +"Onion Melon Tomato Squash Salad"; char animals[] = -"Cat +"Cat Dog Pig Cow Goat Rabbit"; -byte category; void main() { + dword menu_id=0, click_id; proc_info Form; + byte current_animal=1, current_veg=3; int id; loop() switch(WaitEvent()) @@ -41,12 +43,14 @@ void main() id=GetButtonID(); if (id==1) ExitProcess(); if (id==butv.id) { - menu.selected = category+1; - menu.show(Form.left+5 + butv.x, Form.top+skin_height + butv.y + butv.h, 140, #vegetables, butv.id); + menu_id = butv.id; + open_lmenu(Form.left+3 + butv.x, Form.top+skin_height + butv.y + butv.h, + MENU_ALIGN_TOP_LEFT, current_veg, #vegetables); } if (id==buta.id) { - menu.selected = 0; - menu.show(Form.left+5 + buta.x, Form.top+skin_height + buta.y + buta.h, 140, #animals, buta.id); + menu_id = buta.id; + open_lmenu(Form.left+5 + buta.x + buta.w, Form.top+skin_height + buta.y + buta.h, + MENU_ALIGN_TOP_RIGHT, current_animal, #animals); } break; @@ -55,8 +59,10 @@ void main() break; case evReDraw: - if (menu.cur_y) { - if (menu.cur_y > butv.id) && (menu.cur_y < buta.id) category = menu.cur_y - butv.id; + if (click_id = get_menu_click()) { + if (menu_id == butv.id) current_veg = click_id; + if (menu_id == buta.id) current_animal = click_id; + menu_id = 0; } DefineAndDrawWindow(215,100,350,300,0x34,0xFFFFFF,"Window header",0); GetProcessInfo(#Form, SelfInfo); diff --git a/programs/cmm/lib/gui/menu.h b/programs/cmm/lib/gui/menu.h index 1bd4be1b34..bf44617419 100644 --- a/programs/cmm/lib/gui/menu.h +++ b/programs/cmm/lib/gui/menu.h @@ -1,84 +1,8 @@ #ifndef INCLUDE_MENU_H #define INCLUDE_MENU_H -#ifndef INCLUDE_LIST_BOX -#include "../lib/list_box.h" -#endif - :dword menu_process_id; -:struct _menu : llist -{ - dword appear_x, appear_y, text, identifier, selected; - void show(); - char stak[4096]; -} menu; - -:void _menu::show(dword _appear_x, _appear_y, _menu_width, _menu_text, _identifier) -{ - #define ITEM_H 21 - appear_x = _appear_x; - appear_y = _appear_y; - text = _menu_text; - identifier = _identifier; - - cur_y = -1; - ClearList(); - count = chrnum(text, '\n')+1; - SetSizes(2,2,_menu_width,count*ITEM_H,ITEM_H); - - menu_process_id = CreateThread(#_menu_thread,#stak+4092); -} - -:void _menu_thread() -{ - MOUSE m; - DefineAndDrawWindow(menu.appear_x,menu.appear_y,menu.w+2,menu.h+4,0x01, 0, 0, 0x01fffFFF); - DrawPopup(0,0,menu.w,menu.h+3,0, 0xE4DFE1,0x9098B0); - _menu_draw_list(); - SetEventMask(EVM_REDRAW + EVM_KEY + EVM_MOUSE + EVM_MOUSE_FILTER); - loop() switch(WaitEvent()) - { - case evMouse: - m.get(); - if (menu.ProcessMouse(m.x, m.y)) _menu_draw_list(); - if (m.lkm)&&(m.up) _menu_item_click(); - break; - case evKey: - GetKeys(); - if (key_scancode==SCAN_CODE_ESC) _menu_exit(); - if (key_scancode==SCAN_CODE_ENTER) _menu_item_click(); - if (menu.ProcessKey(key_scancode)) _menu_draw_list(); - break; - case evReDraw: - _menu_exit(); - } -} - -:void _menu_draw_list() -{ - int N, bgcol; - for (N=0; N