From bb682b53c18f8efa44a657324c2c0647ce1bf954 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Thu, 11 Oct 2018 14:32:24 +0000 Subject: [PATCH] cmm: fix regression which increased all app size git-svn-id: svn://kolibrios.org@7450 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/Calypte/Calypte.c | 8 +++--- programs/cmm/aelia/aelia.c | 27 ++++++++++--------- programs/cmm/appearance/appearance.c | 8 +++--- programs/cmm/browser/WebView.c | 6 ++--- programs/cmm/examples/menu.c | 4 +-- programs/cmm/iconedit/iconedit.c | 8 +++--- programs/cmm/lib/gui.h | 9 ++++++- programs/cmm/lib/gui/checkbox.h | 5 ++++ programs/cmm/lib/gui/menu.h | 39 ++++++++++++++-------------- programs/cmm/lib/patterns/rgb.h | 9 ++++--- programs/cmm/txtread/txtread.c | 6 ++--- 11 files changed, 71 insertions(+), 58 deletions(-) diff --git a/programs/cmm/Calypte/Calypte.c b/programs/cmm/Calypte/Calypte.c index b52abe2690..f9a033bec6 100644 --- a/programs/cmm/Calypte/Calypte.c +++ b/programs/cmm/Calypte/Calypte.c @@ -196,7 +196,7 @@ void main() break; case evReDraw: - if (menu.list.cur_y) + if (menu.cur_y) { EventMenuClick(); } @@ -396,7 +396,7 @@ void DrawVerticalScroll() void EventMenuClick() { - switch(menu.list.cur_y) + switch(menu.cur_y) { //File case FILE_SUBMENU_ID_OPEN: @@ -413,7 +413,7 @@ void EventMenuClick() break; //Encoding case MENU_ID_ENCODING...MENU_ID_ENCODING+9: - EventChangeEncoding(menu.list.cur_y-MENU_ID_ENCODING); + EventChangeEncoding(menu.cur_y-MENU_ID_ENCODING); break; //Reopen case FILE_SUBMENU_ID_TINYPAD: @@ -435,7 +435,7 @@ void EventMenuClick() EventOpenFileInAnotherProgram("/sys/develop/heed"); break; } - menu.list.cur_y = 0; + 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 87d75dd395..6727847315 100644 --- a/programs/cmm/aelia/aelia.c +++ b/programs/cmm/aelia/aelia.c @@ -1,9 +1,9 @@ #define MEMSIZE 4096*100 +#include "../lib/gui.h" #include "../lib/kfont.h" #include "../lib/io.h" -#include "../lib/gui.h" -#include "../lib/list_box.h" +#include "../lib/cursor.h" #include "../lib/obj/box_lib.h" #include "../lib/obj/libini.h" @@ -11,7 +11,6 @@ #include "../lib/obj/libimg.h" #include "../lib/obj/proc_lib.h" #include "../lib/obj/http.h" -#include "../lib/cursor.h" #include "../lib/patterns/simple_open_dialog.h" #include "../lib/patterns/history.h" @@ -111,19 +110,19 @@ void main() break; case evReDraw: draw_window(); - if (menu.list.cur_y>=10) && (menu.list.cur_y<20) { - encoding = menu.list.cur_y - 10; + if (menu.cur_y>=10) && (menu.cur_y<20) { + encoding = menu.cur_y - 10; EventPageRefresh(); - menu.list.cur_y = 0; + menu.cur_y = 0; } - if (menu.list.cur_y>=20) { - menu.list.cur_y-=20; - if (menu.list.cur_y==0) EventPageRefresh(); - if (menu.list.cur_y==1) EventRunEdit(); - if (menu.list.cur_y==2) EventShowHistory(); - if (menu.list.cur_y==3) EventShowDownloader(); - if (menu.list.cur_y==4) EventShowInfo(); - menu.list.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; } } } diff --git a/programs/cmm/appearance/appearance.c b/programs/cmm/appearance/appearance.c index 47cb70831b..ab58b19cb0 100644 --- a/programs/cmm/appearance/appearance.c +++ b/programs/cmm/appearance/appearance.c @@ -152,10 +152,10 @@ void main() case evReDraw: draw_window(); - if (menu.list.cur_y) { - if (menu.list.cur_y == 10) EventOpenFile(); - if (menu.list.cur_y == 11) EventDeleteFile(); - menu.list.cur_y = 0; + if (menu.cur_y) { + if (menu.cur_y == 10) EventOpenFile(); + if (menu.cur_y == 11) EventDeleteFile(); + menu.cur_y = 0; }; } } diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index b10df33455..25a3a58d60 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -176,9 +176,9 @@ void main() break; case evReDraw: - if (menu.list.cur_y) { - ProcessEvent(menu.list.cur_y); - menu.list.cur_y = 0; + if (menu.cur_y) { + ProcessEvent(menu.cur_y); + menu.cur_y = 0; } DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0); GetProcessInfo(#Form, SelfInfo); diff --git a/programs/cmm/examples/menu.c b/programs/cmm/examples/menu.c index dd084ef992..a3ef54bc50 100644 --- a/programs/cmm/examples/menu.c +++ b/programs/cmm/examples/menu.c @@ -55,8 +55,8 @@ void main() break; case evReDraw: - if (menu.list.cur_y) { - if (menu.list.cur_y > butv.id) && (menu.list.cur_y < buta.id) category = menu.list.cur_y - butv.id; + if (menu.cur_y) { + if (menu.cur_y > butv.id) && (menu.cur_y < buta.id) category = menu.cur_y - butv.id; } DefineAndDrawWindow(215,100,350,300,0x34,0xFFFFFF,"Window header",0); GetProcessInfo(#Form, SelfInfo); diff --git a/programs/cmm/iconedit/iconedit.c b/programs/cmm/iconedit/iconedit.c index 4835c7efc3..6278f4095f 100644 --- a/programs/cmm/iconedit/iconedit.c +++ b/programs/cmm/iconedit/iconedit.c @@ -862,10 +862,10 @@ void EventShowImageMenu() void EventCheckMenuItemSelected() { - if (menu.list.cur_y) { - if (20 == menu.list.cur_y) EventCountColorsUsed(); - if (21 == menu.list.cur_y) EventReplaceImageColors(color1, color2); - menu.list.cur_y = 0; + if (menu.cur_y) { + if (20 == menu.cur_y) EventCountColorsUsed(); + if (21 == menu.cur_y) EventReplaceImageColors(color1, color2); + menu.cur_y = 0; } } diff --git a/programs/cmm/lib/gui.h b/programs/cmm/lib/gui.h index b50fc2e95b..75007394d0 100644 --- a/programs/cmm/lib/gui.h +++ b/programs/cmm/lib/gui.h @@ -1,4 +1,4 @@ - #ifndef INCLUDE_GUI_H +#ifndef INCLUDE_GUI_H #define INCLUDE_GUI_H #ifndef INCLUDE_KOLIBRI_H @@ -19,10 +19,17 @@ #include "../lib/gui/tabs.h" #include "../lib/gui/more_less_box.h" + +#ifndef INCLUDE_CHECKBOX #include "../lib/gui/checkbox.h" +#endif + #include "../lib/gui/child_window.h" #include "../lib/gui/text_view_area.h" + +#ifndef INCLUDE_MENU_H #include "../lib/gui/menu.h" +#endif :int last_free_button_id = 1000; :int GetFreeButtonId() diff --git a/programs/cmm/lib/gui/checkbox.h b/programs/cmm/lib/gui/checkbox.h index 91e44f6cdd..81b780e064 100644 --- a/programs/cmm/lib/gui/checkbox.h +++ b/programs/cmm/lib/gui/checkbox.h @@ -1,3 +1,6 @@ +#ifndef INCLUDE_CHECKBOX +#define INCLUDE_CHECKBOX + :unsigned char checkbox_flag[507] = { 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, @@ -86,3 +89,5 @@ struct checkbox { draw(x,y); } + +#endif \ No newline at end of file diff --git a/programs/cmm/lib/gui/menu.h b/programs/cmm/lib/gui/menu.h index cbd1882bec..8202d4bc50 100644 --- a/programs/cmm/lib/gui/menu.h +++ b/programs/cmm/lib/gui/menu.h @@ -1,30 +1,31 @@ #ifndef INCLUDE_MENU_H #define INCLUDE_MENU_H +#ifndef INCLUDE_LIST_BOX #include "../lib/list_box.h" +#endif :dword menu_process_id; -:struct _menu +:struct _menu : llist { dword appear_x, appear_y, text, identifier, selected; - llist list; void show(); char stak[4096]; } menu; -void _menu::show(dword _appear_x, _appear_y, _menu_width, _text, _identifier) +: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 = _text; + text = _menu_text; identifier = _identifier; - list.cur_y = -1; - list.ClearList(); - list.count = chrnum(text, '\n')+1; - list.SetSizes(2,2,_menu_width,list.count*ITEM_H,ITEM_H); + 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); } @@ -39,18 +40,18 @@ void _menu::show(dword _appear_x, _appear_y, _menu_width, _text, _identifier) GetProcessInfo(#MenuForm, SelfInfo); if (!CheckActiveProcess(MenuForm.ID)) _menu_no_item_click(); mouse.get(); - if (menu.list.ProcessMouse(mouse.x, mouse.y)) _menu_draw_list(); + if (menu.ProcessMouse(mouse.x, mouse.y)) _menu_draw_list(); if (mouse.lkm)&&(mouse.up) _menu_item_click(); break; case evKey: GetKeys(); if (key_scancode==SCAN_CODE_ESC) _menu_no_item_click(); if (key_scancode==SCAN_CODE_ENTER) _menu_item_click(); - if (menu.list.ProcessKey(key_scancode)) _menu_draw_list(); + if (menu.ProcessKey(key_scancode)) _menu_draw_list(); break; case evReDraw: - DefineAndDrawWindow(menu.appear_x,menu.appear_y,menu.list.w+2,menu.list.h+4,0x01, 0, 0, 0x01fffFFF); - DrawPopup(0,0,menu.list.w,menu.list.h+3,0, 0xE4DFE1,0x9098B0); + 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(); } } @@ -58,24 +59,24 @@ void _menu::show(dword _appear_x, _appear_y, _menu_width, _text, _identifier) :void _menu_draw_list() { int N, bgcol; - for (N=0; N255) { - debug("Wrong alpha param in MixColors()!"); - debugval("alpha", a); - } rgb1.DwordToRgb(_base); rgb2.DwordToRgb(_overlying); diff --git a/programs/cmm/txtread/txtread.c b/programs/cmm/txtread/txtread.c index 4d7374d77f..fa82ca167c 100644 --- a/programs/cmm/txtread/txtread.c +++ b/programs/cmm/txtread/txtread.c @@ -97,11 +97,11 @@ void main() HandleButtonEvent(); break; case evReDraw: - if (menu.list.cur_y) { - encoding = menu.list.cur_y - 10; + if (menu.cur_y) { + encoding = menu.cur_y - 10; OpenFile(#param); PreparePage(); - menu.list.cur_y = NULL; + menu.cur_y = NULL; }; draw_window(); }