From 7ed0962aa5ac829c421b4807337db8fa1a826d90 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Tue, 3 Oct 2017 14:55:12 +0000 Subject: [PATCH] Calypte 0.35: add scroll, mark current encoding in list git-svn-id: svn://kolibrios.org@7043 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/Calypte/Calypte.c | 91 +++++++++++-------- programs/cmm/Calypte/compile_en.bat | 1 - programs/cmm/TWB/TWB.c | 1 - programs/cmm/lib/collection.h | 8 +- programs/cmm/lib/obj/box_lib.h | 84 ----------------- .../cmm/lib/patterns/simple_open_dialog.h | 30 ++++-- programs/cmm/txtread/gui.h | 1 - programs/cmm/txtread/txtread.c | 1 + 8 files changed, 84 insertions(+), 133 deletions(-) diff --git a/programs/cmm/Calypte/Calypte.c b/programs/cmm/Calypte/Calypte.c index e035bf5654..b7d758aa73 100644 --- a/programs/cmm/Calypte/Calypte.c +++ b/programs/cmm/Calypte/Calypte.c @@ -1,7 +1,7 @@ -//Calypte 0.3 - Leency +//Calypte 0.35 - Leency //Calypte 0.15 - Punk Joker -#define MEMSIZE 1024*80 +#define MEMSIZE 1024*100 #ifndef AUTOBUILD #include "lang.h--" @@ -19,14 +19,17 @@ #include "../lib/gui.h" #include "../lib/list_box.h" #include "../lib/menu.h" +//#include "../lib/collection.h" + #include "../lib/obj/iconv.h" -//#include "../lib/obj/box_lib.h" //TO CHECK: boxlib doesn't work well with opendial +#include "../lib/obj/box_lib.h" +#include "../lib/obj/libio_lib.h" //TO CHECK: why opendial is a peace of shit! #include "../lib/obj/proc_lib.h" -#include "../lib/obj/libio_lib.h" #include "../lib/patterns/simple_open_dialog.h" + char default_dir[] = "/rd/1"; od_filter filter2 = { "TXT",0}; @@ -93,6 +96,7 @@ char win_title[4096] = TITLE; #define BOTPANELH 10 #define WIN_W 750 #define WIN_H 550 +#define SCROLL_SIZE 15 proc_info Form; llist rows; @@ -105,6 +109,11 @@ dword bufpointer; dword bufsize; dword draw_sruct; +scroll_bar scroll_v = { SCROLL_SIZE,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; +scroll_bar scroll_h = { SCROLL_SIZE,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; + +//collection s; + //===================================================// // // // CODE // @@ -113,7 +122,7 @@ dword draw_sruct; void InitDlls() { - //load_dll(boxlib, #box_lib_init, 0); + load_dll(boxlib, #box_lib_init, 0); load_dll(libio, #libio_init, 1); load_dll(iconv_lib, #iconv_open, 0); load_dll(Proc_lib, #OpenDialog_init,0); @@ -143,26 +152,12 @@ void main() case evButton: id=GetButtonID(); if (id==1) ExitProcess(); - if (id==MENU_ID_FILE) menu.show( - Form.left+5 + menu_file_x, - Form.top+skin_height + TOPPANELH, - 140, - #menu_file_list, - MENU_ID_FILE); - - if (id==MENU_ID_ENCODING) menu.show( - Form.left+5 + menu_encoding_x, - Form.top+skin_height + TOPPANELH, - 120, - #menu_encoding_list, - MENU_ID_ENCODING); - - if (id==MENU_ID_REOPEN) menu.show( - Form.left+5 + menu_reopen_x, - Form.top+skin_height + TOPPANELH, - 120, - #menu_reopen_list, - MENU_ID_REOPEN); + if (id==MENU_ID_FILE) + EventShowMenu(menu_file_x, #menu_file_list, MENU_ID_FILE, NULL); + if (id==MENU_ID_ENCODING) + EventShowMenu(menu_encoding_x, #menu_encoding_list, MENU_ID_ENCODING, encoding+1); + if (id==MENU_ID_REOPEN) + EventShowMenu(menu_reopen_x, #menu_reopen_list, MENU_ID_REOPEN, NULL); break; case evKey: @@ -201,14 +196,26 @@ void main() } } -void ReopenFileIn(dword app) +void ReopenFileIn(dword _app) { - RunProgram(app, #param); + RunProgram(_app, #param); +} + +void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected) +{ + menu.selected = _selected; + menu.show( + Form.left+5 + _menu_item_x, + Form.top+skin_height + TOPPANELH, + 140, + _menu_list, + _id); } void EventOpenFile() { OpenDialog_start stdcall (#o_dialog); + if (!o_dialog.status) return; OpenFile(#openfile_path); Prepare(); draw_window(); @@ -216,6 +223,7 @@ void EventOpenFile() void EventCloseFile() { + if (!bufpointer) return; strcpy(#win_title, TITLE); FreeBuf(); draw_window(); @@ -266,17 +274,14 @@ void draw_window() rows.no_selection = true; rows.SetFont(8, 14, 0x90); - rows.SetSizes(0, TOPPANELH, Form.cwidth, Form.cheight - TOPPANELH - BOTPANELH, 20); + rows.SetSizes(0, TOPPANELH, Form.cwidth - SCROLL_SIZE, Form.cheight - TOPPANELH - BOTPANELH, 20); rows.column_max = rows.w / rows.font_w; if (bufpointer) Prepare(); rows.CheckDoesValuesOkey(); } - if (bufpointer) - { - DrawText(); - } - else DrawBar(0, TOPPANELH, Form.cwidth, Form.cheight-BOTPANELH-TOPPANELH, 0xFFFFFF); + DrawRectangle(rows.x+rows.w-1, rows.y, SCROLL_SIZE, rows.h-1, 0xEEEeee); + DrawText(); } void OpenFile(dword _path) @@ -301,6 +306,7 @@ void OpenFile(dword _path) void FreeBuf() { int i; + if (!bufpointer) return; for (i=0; i= 4096*3) return 0; element[count] = in; count++; return 1; } -:dword collection_int::get(dword pos) { +dword collection_int::get(dword pos) { if (pos<0) || (pos>=count) return 0; return element[pos]; } -:void collection_int::drop() { +void collection_int::drop() { element[0] = count = 0; } diff --git a/programs/cmm/lib/obj/box_lib.h b/programs/cmm/lib/obj/box_lib.h index eaeb57cfef..f744af1685 100644 --- a/programs/cmm/lib/obj/box_lib.h +++ b/programs/cmm/lib/obj/box_lib.h @@ -20,11 +20,6 @@ dword edit_box_key = #aEdit_box_key; dword edit_box_mouse = #aEdit_box_mouse; dword version_ed = #aVersion_ed; -dword menu_bar_draw = #aMenu_bar_draw; -dword menu_bar_activate = #aMenu_bar_activate; -dword menu_bar_mouse = #aMenu_bar_mouse; -dword version_menu_bar = #aVersion_menu_bar; - dword scrollbar_v_draw = #aScrollbar_v_draw; dword scrollbar_v_mouse = #aScrollbar_v_mouse; dword scrollbar_h_draw = #aScrollbar_h_draw; @@ -37,10 +32,6 @@ dword PathShow_draw = #aPathShow_draw; dword progressbar_draw = #aProgressbar_draw; dword progressbar_progress = #aProgressbar_progress; -dword check_box_draw = #aCheck_box_draw; -dword check_box_mouse = #aCheck_box_mouse; -dword version_ch = #aVersion_ch; - dword frame_draw = #aFrame_draw; $DD 2 dup 0 @@ -50,11 +41,6 @@ char aEdit_box_key [] = "edit_box_key"; char aEdit_box_mouse[] = "edit_box_mouse"; char aVersion_ed [] = "version_ed"; -char aMenu_bar_draw [] = "menu_bar_draw"; -char aMenu_bar_activate[] = "menu_bar_activate"; -char aMenu_bar_mouse [] = "menu_bar_mouse"; -char aVersion_menu_bar [] = "version_menu_bar"; - char aboxlib_init[] = "lib_init"; char aScrollbar_v_draw [] = "scrollbar_v_draw"; char aScrollbar_v_mouse[] = "scrollbar_v_mouse"; @@ -62,14 +48,6 @@ char aScrollbar_h_draw [] = "scrollbar_h_draw"; char aScrollbar_h_mouse[] = "scrollbar_h_mouse"; char aVersion_scrollbar[] = "version_scrollbar"; -char aCheck_box_draw [] = "check_box_draw2"; -char aCheck_box_mouse [] = "check_box_mouse2"; -char aVersion_ch [] = "version_ch2"; - -char aOption_box_draw [] = "option_box_draw"; -char aOption_box_mouse [] = "option_box_mouse"; -char aVersion_op [] = "version_op" ; - char aPathShow_prepare [] = "PathShow_prepare"; char aPathShow_draw [] = "PathShow_draw"; @@ -101,48 +79,6 @@ PathShow_prepare stdcall(#PathShow); PathShow_draw stdcall(#PathShow); */ -struct menu_data -{ - dword type; - - word size_x; - word start_x; - - word size_y; - word start_y; - dword text_pointer; - dword pos_pointer; - dword text_end; - dword mouse_pos; - dword mouse_keys; - - word size_x1; - word start_x1; - - word size_y1; - word start_y1; - dword bckg_col; - dword frnt_col; - dword menu_col; - dword select; - dword out_select; - dword buf_adress; - dword procinfo; - dword click; - dword cursor; - dword cursor_old; - dword interval; - dword cursor_max; - dword extended_key; - dword menu_sel_col; - dword bckg_text_col; - dword frnt_text_col; - dword mouse_keys_old; - dword font_height; - dword cursor_out; - dword get_mouse_flag; -}; - struct edit_box{ dword width, left, @@ -167,26 +103,6 @@ dword width, ed_char_width; }; -struct checkbox2 -{ - dword - left_s, - top_s, - ch_text_margin, - color, - border_color, - text_color, - text, - flags, - size_of_str; -}; - -//flags for checkbox2 -#define CH_FLAG_EN 10b -#define CH_FLAG_TOP 0x0 -#define CH_FLAG_MIDDLE 100b -#define CH_FLAG_BOTTOM 1000b - struct scroll_bar { word size_x, diff --git a/programs/cmm/lib/patterns/simple_open_dialog.h b/programs/cmm/lib/patterns/simple_open_dialog.h index 1a6a9fc448..7fa5b37cf5 100644 --- a/programs/cmm/lib/patterns/simple_open_dialog.h +++ b/programs/cmm/lib/patterns/simple_open_dialog.h @@ -6,10 +6,28 @@ struct od_filter proc_info pr_inf; char communication_area_name[] = "FFFFFFFF_open_dialog"; -byte plugin_path[4096]; -char open_dialog_path[] = "/rd/1/File managers/opendial"; //opendial -byte openfile_path[2048]; -byte filename_area[4096]; +char opendir_path[4096]; +char open_dialog_path[] = "/rd/1/File managers/opendial"; +char openfile_path[4096]; +char filename_area[256]; -opendialog o_dialog = {0, #pr_inf, #communication_area_name, 0, #plugin_path, #default_dir, #open_dialog_path, - #draw_window, 0, #openfile_path, #filename_area, #filter2, 420, 200, 320, 120}; +opendialog o_dialog = { + 0, + #pr_inf, + #communication_area_name, + 0, + #opendir_path, + #default_dir, + #open_dialog_path, + #draw_window, + 0, + #openfile_path, + #filename_area, + #filter2, + + 420, + 200, + + 320, + 120 +}; diff --git a/programs/cmm/txtread/gui.h b/programs/cmm/txtread/gui.h index 6682fa92da..45fa3320e0 100644 --- a/programs/cmm/txtread/gui.h +++ b/programs/cmm/txtread/gui.h @@ -14,6 +14,5 @@ void DrawScroller() scroll.start_x = list.x + list.w; scroll.start_y = list.y; scroll.size_y = list.h; - scroll.start_x = list.x + list.w; scrollbar_v_draw(#scroll); } \ No newline at end of file diff --git a/programs/cmm/txtread/txtread.c b/programs/cmm/txtread/txtread.c index 69dca7cf4a..3b1c38e8c1 100644 --- a/programs/cmm/txtread/txtread.c +++ b/programs/cmm/txtread/txtread.c @@ -277,6 +277,7 @@ void draw_window() DrawToolbarButton(RUN_EDIT, 135); DrawToolbarButton(SHOW_INFO, Form.cwidth - 34); + if ((Form.cwidth-scroll.size_x-1 == list.w) && (Form.cheight-TOOLBAR_H == list.h) && (list.count)