From f9bdb60722ccc6ae510a5e3965b6d286cee9036e Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Mon, 13 Apr 2020 14:47:37 +0000 Subject: [PATCH] finally switch all apps into lmenu and remove old implementation git-svn-id: svn://kolibrios.org@7782 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/Calypte/Calypte.c | 1 - programs/cmm/aelia/aelia.c | 55 ++++++++++++--------- programs/cmm/examples/menu.c | 28 ++++++----- programs/cmm/lib/gui/menu.h | 80 +------------------------------ programs/cmm/txtread/toolbar.png | Bin 984 -> 700 bytes programs/cmm/txtread/txtread.c | 4 +- 6 files changed, 54 insertions(+), 114 deletions(-) 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@Y72PCsCjj7DYAA+#P}~+=%clnkm((`R5$Z%WxqIY_ZjuX1O>14-TN?+Js(7QB zOX8MRdJyHVbR$(1lU&wo*bE(OL=B{;0F2iroknw)v|$dYs`P-m(<|0Z(kw2|PleY& zssXI&yWkOIk$)z4v9=;ht8!n-#PcPWZ!sZ}AZsAy;ORRF;t?c~X6C4^%${34Zs$)E zW)qNGOcY4OQy|pNSA0m4Q@610b48@Kdh3ec z{}yfn#1I)F<@*XSiws&7lfQlo@822aK!j5YI2Gx!vtSY#&QVOZ?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RND3jRsaA107*qoM6N<$f`-}83jhEB diff --git a/programs/cmm/txtread/txtread.c b/programs/cmm/txtread/txtread.c index 3ad655248c..d1665a4a47 100644 --- a/programs/cmm/txtread/txtread.c +++ b/programs/cmm/txtread/txtread.c @@ -297,8 +297,8 @@ void EventMagnifyMinus() void EventShowEncodingList() { - open_lmenu(Form.left+5 + charsets_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT, encoding+1, - "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); + open_lmenu(Form.left+5 + charsets_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT, + encoding+1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); menu_id = 10; }