From 162d120bc42ef5470e75df2ed7e7f2b7d98551ed Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Mon, 13 Apr 2020 11:51:56 +0000 Subject: [PATCH] lmenu: use fix permissions of shared memory; thanks a lot to tsdima WebView: use lmenu git-svn-id: svn://kolibrios.org@7780 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 7 ++- programs/cmm/browser/WebView.c | 47 ++++++++------ programs/cmm/browser/build.bat | 12 ++++ programs/cmm/browser/compile_en.bat | 3 +- programs/cmm/browser/compile_ru.bat | 3 +- programs/cmm/browser/texts.h | 22 +++---- programs/cmm/eolite/include/menu.h | 6 +- programs/cmm/eolite/include/settings.h | 36 +++++------ programs/cmm/iconedit/iconedit.c | 2 +- programs/cmm/lib/gui.h | 13 +++- programs/cmm/lib/gui/menu.h | 23 ++++--- programs/cmm/lib/patterns/toolbar_button.h | 8 +-- programs/cmm/menu/menu.c | 61 ++++++++----------- .../cmm/software_widget/software_widget.c | 14 ++--- 14 files changed, 143 insertions(+), 114 deletions(-) create mode 100644 programs/cmm/browser/build.bat diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index a8701b95bf..5c5d910d56 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -346,7 +346,10 @@ void TWebBrowser::SetStyle() { return; } if (tag.is("br")) { NewLine(); return; } - if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) { style.b = tag.opened; return; } + if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) { + style.b = tag.opened; + return; + } if (tag.is("a")) { if (tag.opened) { @@ -393,7 +396,7 @@ void TWebBrowser::SetStyle() { NewLine(); return; } - if (tag.is("p")) { + if (tag.is("p")) || (tag.is("w:p")) { IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return; NewLine(); return; diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 0f400e8cff..1cda513de5 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -62,6 +62,8 @@ progress_bar wv_progress_bar; char stak[4096]; proc_info Form; +int menu_id=NULL; + enum { NEW_TAB=600, ENCODINGS=700, @@ -203,9 +205,10 @@ void main() break; case evReDraw: - DefineAndDrawWindow(40, //GetScreenWidth()-800/2-random(80), + DefineAndDrawWindow(GetScreenWidth()-800/2-random(80), //40 GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); GetProcessInfo(#Form, SelfInfo); + ProcessMenuClick(); system.color.get(); if (Form.status_window>2) break; if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } @@ -300,11 +303,6 @@ void SetElementSizes() void draw_window() { int i; - if (menu.cur_y) { - EAX = menu.cur_y; - menu.cur_y = 0; - ProcessEvent(EAX); - } SetElementSizes(); DrawBar(0,0, Form.cwidth,PADDING, system.color.work); @@ -710,27 +708,38 @@ void DrawProgress() void EventShowPageMenu() { - menu.selected = 0; - menu.show(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, 220, #rmb_menu, VIEW_SOURCE); + open_lmenu(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, MENU_ALIGN_TOP_LEFT, NULL, #rmb_menu); + menu_id = VIEW_SOURCE; } void EventShowLinkMenu() { - menu.selected = 0; - menu.show(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, 220, #link_menu, COPY_LINK_URL); -} - -void EventShowEncodingsList() -{ - menu.selected = WB1.cur_encoding + 1; - menu.show(Form.left + Form.cwidth - 95, Form.top + skin_height + status_text.start_y - 121, 90, - "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", ENCODINGS); + open_lmenu(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, MENU_ALIGN_TOP_LEFT, NULL, #link_menu); + menu_id = COPY_LINK_URL; } void EventShowMainMenu() { - menu.selected = 0; - menu.show(Form.left + Form.cwidth - 150, Form.top + skin_height + TOOLBAR_H-8, 140, #main_menu, OPEN_FILE); + open_lmenu(Form.left + Form.cwidth - PADDING, Form.top + skin_height + PADDING + TSZE + 3, + MENU_ALIGN_TOP_RIGHT, NULL, #main_menu); + menu_id = OPEN_FILE; +} + +void EventShowEncodingsList() +{ + open_lmenu(Form.left + Form.cwidth, Form.top + skin_height + status_text.start_y + 8, + MENU_ALIGN_BOT_RIGHT, WB1.cur_encoding + 1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866"); + menu_id = ENCODINGS; +} + +void ProcessMenuClick() +{ + int click_id; + if (menu_id) && (click_id = get_menu_click()) { + click_id += menu_id - 1; + menu_id = NULL; + ProcessEvent(click_id); + } } void EventUpdateProgressBar() diff --git a/programs/cmm/browser/build.bat b/programs/cmm/browser/build.bat new file mode 100644 index 0000000000..8bc2935613 --- /dev/null +++ b/programs/cmm/browser/build.bat @@ -0,0 +1,12 @@ +@ECHO OFF + +call "compile_ru.bat" + +if exist WebView ( + "C:\Program Files (x86)\WinImage\winimage.exe" "D:\Kolibri\Desktop\kolibri.img" /H /Q /I WebView + d: + cd "D:\Kolibri\Infrastructure\QEMU" + call "z_kos.bat" +) else ( + pause +) diff --git a/programs/cmm/browser/compile_en.bat b/programs/cmm/browser/compile_en.bat index 20e50b8c5a..87991af5fc 100644 --- a/programs/cmm/browser/compile_en.bat +++ b/programs/cmm/browser/compile_en.bat @@ -6,4 +6,5 @@ @rename WebView.com WebView @del warning.txt @del lang.h-- -@pause \ No newline at end of file + +if not exist WebView ( @pause ) \ No newline at end of file diff --git a/programs/cmm/browser/compile_ru.bat b/programs/cmm/browser/compile_ru.bat index 666163c681..b2dd40c0c8 100644 --- a/programs/cmm/browser/compile_ru.bat +++ b/programs/cmm/browser/compile_ru.bat @@ -6,4 +6,5 @@ @rename WebView.com WebView @del warning.txt @del lang.h-- -@pause \ No newline at end of file + +if not exist WebView ( @pause ) \ No newline at end of file diff --git a/programs/cmm/browser/texts.h b/programs/cmm/browser/texts.h index 897921f760..235b1d91d6 100644 --- a/programs/cmm/browser/texts.h +++ b/programs/cmm/browser/texts.h @@ -1,4 +1,4 @@ -char version[]="WebView 2.4a"; +char version[]="WebView 2.41"; #ifdef LANG_RUS char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; @@ -6,13 +6,13 @@ char homepage[] = FROM "html\\homepage_ru.htm""\0"; char help[] = FROM "html\\help_ru.htm""\0"; char accept_language[]= "Accept-Language: ru\n"; char rmb_menu[] = -"Посмотреть исходник +"Посмотреть исходник|CTRL+U Редактировать исходник"; char main_menu[] = -"Открыть файл -Новое окно -История -Менеджер загрузок +"Открыть файл|CTRL+O +Новое окно|CTRL+N +История|CTRL+H +Менеджер загрузок|CTRL+J Очистить кэш Обновить браузер"; char link_menu[] = @@ -32,13 +32,13 @@ char homepage[] = FROM "html\\homepage_en.htm""\0"; char help[] = FROM "html\\help_en.htm""\0"; char accept_language[]= "Accept-Language: en\n"; char rmb_menu[] = -"View source +"View source|CTRL+U Edit source"; char main_menu[] = -"Open local file -New window -History -Download Manager +"Open local file|CTRL+O +New window|CTRL+N +History|CTRL+H +Download Manager|CTRL+J Clear cache Update browser"; char link_menu[] = diff --git a/programs/cmm/eolite/include/menu.h b/programs/cmm/eolite/include/menu.h index 578f5434d2..626e65da34 100644 --- a/programs/cmm/eolite/include/menu.h +++ b/programs/cmm/eolite/include/menu.h @@ -116,9 +116,9 @@ void EventShowListMenu() bool GetMenuClick() { - dword chick_id; - if (active_menu) && (chick_id = get_menu_click()) { - EventMenuClick(chick_id); + dword click_id; + if (active_menu) && (click_id = get_menu_click()) { + EventMenuClick(click_id); return false; } return true; diff --git a/programs/cmm/eolite/include/settings.h b/programs/cmm/eolite/include/settings.h index c9c5fbc480..5ecb740dfb 100644 --- a/programs/cmm/eolite/include/settings.h +++ b/programs/cmm/eolite/include/settings.h @@ -230,24 +230,7 @@ void SetAppColors() if (col.work == system.color.work) return; old_list_bg_color = col.list_bg; bg_col = system.color.work; - if (GrayScaleImage(#bg_col,1,1)>=65) - { - //use light colors - col.def = true; - col.list_bg = 0xFFFfff; - col.list_gb_text = 0x000000; - col.list_text_hidden = 0xA6A6B7; - col.list_vert_line = 0xDDD7CF; - col.work = system.color.work; - col.graph = system.color.work_graph; - col.lpanel = 0x00699C; - col.selec = col.selec_active = 0x94AECE; - col.selec_text = 0x000000; - system.color.work_dark = MixColors(0, system.color.work, 35); - col.slider_bg_big = 0xCDCFCF; - col.odd_line = 0xF1F1F1; - } - else + if (skin_is_dark()) { //use dark colors col.def = false; @@ -265,6 +248,23 @@ void SetAppColors() col.slider_bg_big = MixColors(0xCED0D0, system.color.work, 35); col.odd_line = MixColors(0xFFFfff, system.color.work, 15); } + else + { + //use light colors + col.def = true; + col.list_bg = 0xFFFfff; + col.list_gb_text = 0x000000; + col.list_text_hidden = 0xA6A6B7; + col.list_vert_line = 0xDDD7CF; + col.work = system.color.work; + col.graph = system.color.work_graph; + col.lpanel = 0x00699C; + col.selec = col.selec_active = 0x94AECE; + col.selec_text = 0x000000; + system.color.work_dark = MixColors(0, system.color.work, 35); + col.slider_bg_big = 0xCDCFCF; + col.odd_line = 0xF1F1F1; + } col.selec_inactive = MixColors(0xBBBbbb, col.list_bg, 65); col.slider_bg_left = MixColors(col.graph, col.slider_bg_big, 10); for (i=0; i<=20; i++) col.work_gradient[20-i] = MixColors(0, system.color.work, i); diff --git a/programs/cmm/iconedit/iconedit.c b/programs/cmm/iconedit/iconedit.c index 8d216aded4..f8d514000c 100644 --- a/programs/cmm/iconedit/iconedit.c +++ b/programs/cmm/iconedit/iconedit.c @@ -159,7 +159,7 @@ void main() system.color.get(); bg_col = system.color.work; - if (GrayScaleImage(#bg_col,1,1)<65) bg_dark=true; else bg_dark=false; + bg_dark = skin_is_dark(); semi_white = MixColors(system.color.work, 0xFFFfff, bg_dark*90 + 96); Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffFFFfff, semi_white); diff --git a/programs/cmm/lib/gui.h b/programs/cmm/lib/gui.h index b4b28ff250..92318cf472 100644 --- a/programs/cmm/lib/gui.h +++ b/programs/cmm/lib/gui.h @@ -299,10 +299,17 @@ PutPixel(x+w+1, y+h, dark); } -:bool is_the_skin_dark() +:bool skin_is_dark() { - dword bg_col = system.color.work; - if (GrayScaleImage(#bg_col,1,1)<65) { + dword gray; + dword color_image = #system.color.work; + + gray = DSBYTE[color_image]*DSBYTE[color_image]; + gray += DSBYTE[color_image+1]*DSBYTE[color_image+1]; + gray += DSBYTE[color_image+2]*DSBYTE[color_image+2]; + gray = sqrt(gray) / 3; + + if (gray < 65) { return true; } else { return false; diff --git a/programs/cmm/lib/gui/menu.h b/programs/cmm/lib/gui/menu.h index 5f74100912..35ced1ea9c 100644 --- a/programs/cmm/lib/gui/menu.h +++ b/programs/cmm/lib/gui/menu.h @@ -79,29 +79,34 @@ KillProcess(menu_process_id); } +#define MENU_ALIGN_TOP_LEFT 0 +#define MENU_ALIGN_TOP_RIGHT 1 +#define MENU_ALIGN_BOT_LEFT 2 +#define MENU_ALIGN_BOT_RIGHT 3 :dword shared_mem = NULL; :char shared_name[] = "LMENU"; :void open_lmenu(dword _x, _y, _position, _selected, _text) { if (!shared_mem) { - shared_mem = memopen(#shared_name, 20, SHM_CREATE); - if (EDX) shared_mem = memopen(#shared_name, 20, SHM_WRITE); + shared_mem = memopen(#shared_name, 16, SHM_CREATE + SHM_WRITE); + if (EDX) shared_mem = memopen(#shared_name, 16, SHM_WRITE); } + ESDWORD[shared_mem ] = _selected; ESDWORD[shared_mem + 4] = _x; ESDWORD[shared_mem + 8] = _y; ESDWORD[shared_mem + 12] = _position; - ESDWORD[shared_mem + 16] = _selected; - RunProgram("/sys/develop/menu", _text); + menu_process_id = RunProgram("/sys/develop/menu", _text); } :dword get_menu_click() { - //dword res = ESDWORD[shared_mem]; - char res[2]; - ReadFile(0, 2, #res, "/tmp0/1/menu.tmp"); - //ESDWORD[shared_mem] = 0; - return res[0]; + if (menu_process_id) && (GetProcessSlot(menu_process_id)) { + return NULL; + } else { + menu_process_id = NULL; + return ESDWORD[shared_mem]; + } } #endif \ No newline at end of file diff --git a/programs/cmm/lib/patterns/toolbar_button.h b/programs/cmm/lib/patterns/toolbar_button.h index fcc3eb867e..5fa9edf65b 100644 --- a/programs/cmm/lib/patterns/toolbar_button.h +++ b/programs/cmm/lib/patterns/toolbar_button.h @@ -3,15 +3,13 @@ void DrawTopPanelButton(dword _button_id, _x, _y, signed int _icon_n) { #define TSZE 25 static libimg_image top_icons; - static dword semi_white=0, bg_col, bg_col_light, bg_col_dark, bg_dark; + static dword semi_white=0, bg_col_light, bg_col_dark; if (!semi_white) { - bg_col = system.color.work; - if (GrayScaleImage(#bg_col,1,1)<65) bg_dark=true; else bg_dark=false; Libimg_LoadImage(#top_icons, "/sys/icons16.png"); - semi_white = MixColors(system.color.work, 0xFFFfff, bg_dark*90 + 96); + semi_white = MixColors(system.color.work, 0xFFFfff, skin_is_dark()*90 + 96); bg_col_dark = MixColors(system.color.work, system.color.work_graph, 90); - bg_col_light = MixColors(semi_white, 0xFFFfff, bg_dark*90 + 10); + bg_col_light = MixColors(semi_white, 0xFFFfff, skin_is_dark()*90 + 10); Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffFFFfff, semi_white); Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffCACBD6, MixColors(semi_white, 0, 220)); diff --git a/programs/cmm/menu/menu.c b/programs/cmm/menu/menu.c index 6e7f824f7e..fe1468846c 100644 --- a/programs/cmm/menu/menu.c +++ b/programs/cmm/menu/menu.c @@ -12,40 +12,39 @@ llist menu1; collection names; collection hotkeys; -int win_x, win_y; +int selected, win_x, win_y; int max_name_len; int max_hotkey_len; -int selected = 0; - -/* -dword cur_param = #param; -int GetNextParam() -{ - int result; - dword next_param = strchr(cur_param, ' '); - ESBYTE[next_param] = '\0'; - result = atoi(cur_param); - cur_param = next_param+1; - return result; -} -*/ - void GetWindowPosition() { - int position, rez; - shared_mem = memopen(#shared_name, 20, SHM_READ); + int position; + shared_mem = memopen(#shared_name, 16, SHM_OPEN + SHM_WRITE); + selected = ESDWORD[shared_mem ]; win_x = ESDWORD[shared_mem + 4]; win_y = ESDWORD[shared_mem + 8]; position = ESDWORD[shared_mem + 12]; - selected = ESDWORD[shared_mem + 16]; - if (position==2) win_x -= menu1.w; - if (position==3) { + if (position == MENU_ALIGN_TOP_RIGHT) win_x -= menu1.w; + if (position == MENU_ALIGN_BOT_LEFT) win_y -= menu1.h; + if (position == MENU_ALIGN_BOT_RIGHT) { win_x -= menu1.w; win_y -= menu1.h; } - if (position==4) win_y -= menu1.h; +} + +void GetMenuWidths() +{ + int i; + for (i=0; i=65) + if (skin_is_dark()) { - //light colors - swc.list_bg = 0xF3F3F3; - swc.text = 0x000000; - swc.dark = 0xDCDCDC; - swc.light = 0xFCFCFC; - } else { //dark colors swc.list_bg = system.color.work; swc.text = system.color.work_text; swc.dark = system.color.work_dark; swc.light = system.color.work_light; + } else { + //light colors + swc.list_bg = 0xF3F3F3; + swc.text = 0x000000; + swc.dark = 0xDCDCDC; + swc.light = 0xFCFCFC; } if (swc.list_bg != old_list_bg_color)