finally switch all apps into lmenu and remove old implementation

git-svn-id: svn://kolibrios.org@7782 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-04-13 14:47:37 +00:00
parent 17f2ee8344
commit f9bdb60722
6 changed files with 54 additions and 114 deletions

View File

@ -433,7 +433,6 @@ void EventMenuClick()
EventOpenFileInAnotherProgram("/sys/develop/heed"); EventOpenFileInAnotherProgram("/sys/develop/heed");
break; break;
} }
menu.cur_y = 0;
} }
void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected) void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected)

View File

@ -4,6 +4,7 @@
#include "../lib/kfont.h" #include "../lib/kfont.h"
#include "../lib/io.h" #include "../lib/io.h"
#include "../lib/cursor.h" #include "../lib/cursor.h"
#include "../lib/list_box.h"
#include "../lib/obj/box_lib.h" #include "../lib/obj/box_lib.h"
#include "../lib/obj/libini.h" #include "../lib/obj/libini.h"
@ -71,6 +72,8 @@ bool debug_mode=false;
#include "prepare_page.h" #include "prepare_page.h"
//#include "special.h" //#include "special.h"
int menu_id=0;
#define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nDownloader\nAbout" #define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nDownloader\nAbout"
void InitDlls() void InitDlls()
@ -112,20 +115,7 @@ void main()
break; break;
case evReDraw: case evReDraw:
draw_window(); draw_window();
if (menu.cur_y>=10) && (menu.cur_y<20) { if (CheckActiveProcess(Form.ID)) EventMenuClick();
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;
}
} }
} }
} }
@ -407,8 +397,34 @@ void EventRunEdit()
void EventChangeEncoding() void EventChangeEncoding()
{ {
menu.selected = encoding + 1; menu_id = 10;
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); 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() { void EventShowInfo() {
@ -430,12 +446,6 @@ void EventGoForward()
if (history.forward()) EventOpenAddress(history.current()); 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() void EventPageRefresh()
{ {
EventOpenAddress(history.current()); EventOpenAddress(history.current());
@ -547,3 +557,4 @@ void DrawStatusBar(dword _status_text)
PathShow_draw stdcall(#status_text); PathShow_draw stdcall(#status_text);
} }
} }

View File

@ -3,36 +3,38 @@
#include "../lib/io.h" #include "../lib/io.h"
#include "../lib/list_box.h" #include "../lib/list_box.h"
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/fs.h"
struct _object struct _object
{ {
int x,y,w,h,id; int x,y,w,h,id;
}; };
_object butv = { 20, 20, 100, 30, 10}; _object butv = { 20, 20, 100, 20, 10};
_object buta = {150, 20, 100, 30, 20}; _object buta = {150, 20, 100, 20, 20};
char vegetables[] = char vegetables[] =
"Onion "Onion
Melon Melon
Tomato Tomato
Squash Squash
Salad"; Salad";
char animals[] = char animals[] =
"Cat "Cat
Dog Dog
Pig Pig
Cow Cow
Goat Goat
Rabbit"; Rabbit";
byte category;
void main() void main()
{ {
dword menu_id=0, click_id;
proc_info Form; proc_info Form;
byte current_animal=1, current_veg=3;
int id; int id;
loop() switch(WaitEvent()) loop() switch(WaitEvent())
@ -41,12 +43,14 @@ void main()
id=GetButtonID(); id=GetButtonID();
if (id==1) ExitProcess(); if (id==1) ExitProcess();
if (id==butv.id) { if (id==butv.id) {
menu.selected = category+1; menu_id = butv.id;
menu.show(Form.left+5 + butv.x, Form.top+skin_height + butv.y + butv.h, 140, #vegetables, 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) { if (id==buta.id) {
menu.selected = 0; menu_id = buta.id;
menu.show(Form.left+5 + buta.x, Form.top+skin_height + buta.y + buta.h, 140, #animals, 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; break;
@ -55,8 +59,10 @@ void main()
break; break;
case evReDraw: case evReDraw:
if (menu.cur_y) { if (click_id = get_menu_click()) {
if (menu.cur_y > butv.id) && (menu.cur_y < buta.id) category = menu.cur_y - butv.id; 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); DefineAndDrawWindow(215,100,350,300,0x34,0xFFFFFF,"Window header",0);
GetProcessInfo(#Form, SelfInfo); GetProcessInfo(#Form, SelfInfo);

View File

@ -1,84 +1,8 @@
#ifndef INCLUDE_MENU_H #ifndef INCLUDE_MENU_H
#define INCLUDE_MENU_H #define INCLUDE_MENU_H
#ifndef INCLUDE_LIST_BOX
#include "../lib/list_box.h"
#endif
:dword menu_process_id; :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<menu.count; N++;)
{
if (N==menu.cur_y) bgcol=0xFFFfff; else bgcol=0xE4DFE1;
DrawBar(menu.x, N*menu.item_h+menu.y, menu.w-3, menu.item_h, bgcol);
}
WriteTextLines(13, menu.item_h-8/2+menu.y, 0x80, 0, menu.text, menu.item_h);
if (menu.selected) WriteText(5, menu.selected-1*menu.item_h+8, 0x80, 0xEE0000, "\x10");
}
:void _menu_item_click()
{
menu.cur_y = menu.identifier + menu.cur_y;
KillProcess(menu_process_id);
}
:void _menu_exit()
{
menu.cur_y = 0;
KillProcess(menu_process_id);
}
#define MENU_ALIGN_TOP_LEFT 0 #define MENU_ALIGN_TOP_LEFT 0
#define MENU_ALIGN_TOP_RIGHT 1 #define MENU_ALIGN_TOP_RIGHT 1
#define MENU_ALIGN_BOT_LEFT 2 #define MENU_ALIGN_BOT_LEFT 2
@ -86,7 +10,7 @@
:dword shared_mem = NULL; :dword shared_mem = NULL;
:char shared_name[] = "LMENU"; :char shared_name[] = "LMENU";
:void open_lmenu(dword _x, _y, _position, _selected, _text) :void open_lmenu(dword _x, _y, _position, _selected, _text1)
{ {
if (!shared_mem) { if (!shared_mem) {
shared_mem = memopen(#shared_name, 16, SHM_CREATE + SHM_WRITE); shared_mem = memopen(#shared_name, 16, SHM_CREATE + SHM_WRITE);
@ -96,7 +20,7 @@
ESDWORD[shared_mem + 4] = _x; ESDWORD[shared_mem + 4] = _x;
ESDWORD[shared_mem + 8] = _y; ESDWORD[shared_mem + 8] = _y;
ESDWORD[shared_mem + 12] = _position; ESDWORD[shared_mem + 12] = _position;
menu_process_id = RunProgram("/sys/develop/menu", _text); menu_process_id = RunProgram("/sys/develop/menu", _text1);
} }
:dword get_menu_click() :dword get_menu_click()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 984 B

After

Width:  |  Height:  |  Size: 700 B

View File

@ -297,8 +297,8 @@ void EventMagnifyMinus()
void EventShowEncodingList() void EventShowEncodingList()
{ {
open_lmenu(Form.left+5 + charsets_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT, encoding+1, open_lmenu(Form.left+5 + charsets_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT,
"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); encoding+1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
menu_id = 10; menu_id = 10;
} }