From e3cfd43e3b29980699e7fa3825bcecec8b4efb3f Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sat, 20 Feb 2016 13:06:19 +0000 Subject: [PATCH] gui.h: add tabs component, use it for kf_font_viewer and appearance; fix font.h crash when '_' is the last git-svn-id: svn://kolibrios.org@6264 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/appearance/appearance.c | 59 ++++--------- programs/cmm/appearance/compile_en.bat | 3 +- programs/cmm/appearance/compile_ru.bat | 3 +- programs/cmm/appearance/icons.png | Bin 521 -> 0 bytes programs/cmm/appearance/icons.raw | 1 - programs/cmm/eolite/include/icons.h | 2 +- .../{compile.bat => compile_en.bat} | 0 programs/cmm/kf_font_viewer/font_viewer.c | 83 +++++++++++++----- programs/cmm/lib/font.h | 4 +- programs/cmm/lib/gui.h | 45 ++++++++++ 10 files changed, 128 insertions(+), 72 deletions(-) delete mode 100644 programs/cmm/appearance/icons.png delete mode 100644 programs/cmm/appearance/icons.raw rename programs/cmm/kf_font_viewer/{compile.bat => compile_en.bat} (100%) diff --git a/programs/cmm/appearance/appearance.c b/programs/cmm/appearance/appearance.c index caa79fa970..f7ae1a8c08 100644 --- a/programs/cmm/appearance/appearance.c +++ b/programs/cmm/appearance/appearance.c @@ -23,25 +23,21 @@ #ifdef LANG_RUS ?define WINDOW_HEADER "ன ଫ" - ?define T_SKINS " ⨫ " - ?define T_WALLPAPERS " " + ?define T_SKINS "⨫ " + ?define T_WALLPAPERS "" #else ?define WINDOW_HEADER "Appearance" - ?define T_SKINS " Skins" - ?define T_WALLPAPERS " Wallpappers" + ?define T_SKINS "Skins" + ?define T_WALLPAPERS "Wallpappers" #endif -unsigned char icons[]= FROM "icons.raw"; - #define PANEL_H 40 #define LIST_PADDING 20 -#define TAB_PADDING 16 -#define TAB_HEIGHT 25 #define SKINS_STANDART_PATH "/kolibrios/res/skins" #define WALP_STANDART_PATH "/kolibrios/res/wallpapers" llist list; -signed int active_tab, active_skin=-1, active_wallpaper=-1; +signed int active_skin=-1, active_wallpaper=-1; enum { SKINS=2, WALLPAPERS }; char folder_path[4096]; @@ -111,7 +107,7 @@ void main() GetKeys(); if (list.ProcessKey(key_scancode)) EventApply(); if (key_scancode==SCAN_CODE_ENTER) EventOpenFile(); - if (key_scancode==SCAN_CODE_TAB) if (active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS); + if (key_scancode==SCAN_CODE_TAB) if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS); if (key_scancode==SCAN_CODE_DEL) EventDeleteFile(); for (id=list.cur_y+1; idlist.visible) list.first=list.cur_y; list.CheckDoesValuesOkey(); if (list.w) DrawWindowContent(); } @@ -283,13 +260,13 @@ void EventDeleteFile() void EventApply() { - if (active_tab==SKINS) + if (tabs.active_tab==SKINS) { cur = list.cur_y; sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur])); SetSystemSkin(#cur_file_path); } - if (active_tab==WALLPAPERS) + if (tabs.active_tab==WALLPAPERS) { cur = list.cur_y; sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur])); @@ -300,8 +277,8 @@ void EventApply() void EventOpenFile() { - if (active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path); - if (active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path); + if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path); + if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path); } stop: diff --git a/programs/cmm/appearance/compile_en.bat b/programs/cmm/appearance/compile_en.bat index 500935dd04..5a34205586 100644 --- a/programs/cmm/appearance/compile_en.bat +++ b/programs/cmm/appearance/compile_en.bat @@ -6,5 +6,4 @@ C-- appearance.c @rename appearance.com appearance @del warning.txt @del lang.h-- -@pause -kpack appearance \ No newline at end of file +@pause \ No newline at end of file diff --git a/programs/cmm/appearance/compile_ru.bat b/programs/cmm/appearance/compile_ru.bat index f4c0adf929..b082f2491b 100644 --- a/programs/cmm/appearance/compile_ru.bat +++ b/programs/cmm/appearance/compile_ru.bat @@ -6,5 +6,4 @@ C-- appearance.c @rename appearance.com appearance @del warning.txt @del lang.h-- -@pause -kpack appearance \ No newline at end of file +@pause \ No newline at end of file diff --git a/programs/cmm/appearance/icons.png b/programs/cmm/appearance/icons.png deleted file mode 100644 index ca3758a98bde83b87a5fd6b8471852d4b56447a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 521 zcmV+k0`~ohP)BFj!q#%ksu->g*tRN zy0nO3iV^WdNI>ww3o$=fVJdw zOXfr}Qw0DRR^`9Uv0i_z0;ht0H7+&bN(us(?_Sc?&;|f0Hry0ho=} z0kYS%t1OYnILiU>weJJ>??V`8Iqu5m?kyOWsG6^Sk~=t(3AqE+urd{6VbhTDJLh4& zxn7gqBkmPs@`6DA7Jqxd74R%)js$$}v|;qii^g#G1pv`clZ}9$&aS36pW0mv>W50M z(!%RB00`E{KB@pQ+y6>{D$VoXSS((6@uU68S}j+QPN(s0@9Zj@p>Tweq3ZiMJjrue zFdK}{9N%(sMjli|nbq}ed3aecS?+D4r0WE2Tds=*Q|2h6><@G_+*ZKwG9w+B1{fpw&Gv%LOq00000 LNkvXXu0mjfSC#Sz diff --git a/programs/cmm/appearance/icons.raw b/programs/cmm/appearance/icons.raw deleted file mode 100644 index f7f39fe6c5..0000000000 --- a/programs/cmm/appearance/icons.raw +++ /dev/null @@ -1 +0,0 @@ -|t|t|t|t|t|t|t|t|t|t|t|t|t|t|t|t|t|t|tܴܴܴܴܴܴܴܴܴܴܴܴ|t|tܴܴܴܴܴܴܴܴ|t|t̔|t|tm;m;|t|tܴܴܴ̔LL̔Lm;m;m;|t|tllLcccccccccccccccc|t|tlLcccccccccccccc|tcc|t|tԔ lsm sm sm sm sm sm sm |tsm |t|tϨPϨPϨPϨPϨPϨPϨPϨPϨPϨP|t|tlllllllllll|t|tԔ Ԕ Ԕ Ԕ Ԕ Ԕ Ԕ Ԕ Ԕ Ԕ Ԕ Ԕ |t|t|t|t|t|t|t|t|t|t|t|t|t|t|t|t|t|t|tx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xpfpfpfpfpfpfpfpfpfx`Xpfpf蕕ѐ蕕ѐpfx`Xpfpfъpfx`Xpfpf蕕ѐpfx`Xpfpfъpfx`XĊpfpfȀȀȀȀȊpfx`Xpfpfpfpfpfpfpfpfpfx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`Xx`X \ No newline at end of file diff --git a/programs/cmm/eolite/include/icons.h b/programs/cmm/eolite/include/icons.h index 70d29bd500..b6fc186802 100644 --- a/programs/cmm/eolite/include/icons.h +++ b/programs/cmm/eolite/include/icons.h @@ -10,7 +10,7 @@ char *ext[]={ "exe", 7, "msi", 7, "sys", 8, "ocx", 8, "drv", 8, "so", 8, "inc", 9, -"chr", 10, "mt", 10, "ttf", 10, "fon", 10, +"chr", 10, "mt", 10, "ttf", 10, "fon", 10, "kf", 10, "asm", 11, "mp3", 12, "wav", 12, "mid", 12, "midi",12, "ogg", 12, "wma", 12, "flac",12, "skn", 13, diff --git a/programs/cmm/kf_font_viewer/compile.bat b/programs/cmm/kf_font_viewer/compile_en.bat similarity index 100% rename from programs/cmm/kf_font_viewer/compile.bat rename to programs/cmm/kf_font_viewer/compile_en.bat diff --git a/programs/cmm/kf_font_viewer/font_viewer.c b/programs/cmm/kf_font_viewer/font_viewer.c index f5529b794f..e8e839d89b 100644 --- a/programs/cmm/kf_font_viewer/font_viewer.c +++ b/programs/cmm/kf_font_viewer/font_viewer.c @@ -4,50 +4,87 @@ #include "../lib/gui.h" #define PANELH 30 +proc_info Form; + +enum { + STRONG_BTN=10, ITALIC_BTN, SMOOTH_BTN, + PHRASE_TAB=20, CHARS_TAB +}; + void main() { - proc_info Form; - int i, y, btn; - char line[256], title[4196]; + int btn; + char title[4196]; if (!param) strcpy(#param, DEFAULT_FONT); label.init(#param); + tabs.active_tab=PHRASE_TAB; strcpy(#title, "Font preview: "); strcat(#title, #param); - loop() + loop() switch(WaitEvent()) { - switch(WaitEvent()) - { case evButton: btn = GetButtonID(); if (btn==1) ExitProcess(); - if (btn==2) label.bold ^=1; - if (btn==3) label.italic ^=1; - if (btn==4) label.smooth ^=1; + if (btn==STRONG_BTN) label.bold ^=1; + if (btn==ITALIC_BTN) label.italic ^=1; + if (btn==SMOOTH_BTN) label.smooth ^=1; + if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn); goto _DRAW_WINDOW_CONTENT; case evReDraw: system.color.get(); - DefineAndDrawWindow(215,100,500,320,0x74,0xFFFFFF,#title); + DefineAndDrawWindow(215,100,500,320+skin_height,0x74,0xFFFFFF,#title); GetProcessInfo(#Form, SelfInfo); if (Form.status_window>2) break; _DRAW_WINDOW_CONTENT: - DrawBar(0, 0, Form.cwidth, PANELH, system.color.work); - CheckBox(10, 8, 2, "Bold", label.bold); - CheckBox(83, 8, 3, "Italic", label.italic); - CheckBox(170, 8, 4, "Smooth", label.smooth); - label.raw_size = free(label.raw); + DrawBar(0, 0, Form.cwidth, PANELH-1, system.color.work); + CheckBox(10, 8, STRONG_BTN, "Bold", label.bold); + CheckBox(83, 8, ITALIC_BTN, "Italic", label.italic); + CheckBox(170,8, SMOOTH_BTN, "Smooth", label.smooth); + tabs.draw(Form.cwidth-150, PANELH, PHRASE_TAB, "Phrase"); + tabs.draw(Form.cwidth-70, PANELH, CHARS_TAB, "Chars"); + DrawBar(0, PANELH-1,Form.cwidth,1,system.color.work_graph); if (!label.font) { DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff); WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); + break; } - else for (i=10, y=5; i<22; i++, y+=label.height;) //not flexible, need to calculate font count and max line length - { - sprintf(#line," /size font %d ᥫ.",i); - label.write_buf(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); - } - if (label.smooth) label.apply_smooth(); - label.show_buf(0, PANELH); - } + if (tabs.active_tab==PHRASE_TAB) DrawPreviewPhrase(); + if (tabs.active_tab==CHARS_TAB) DrawPreviewChars(); } } + +void DrawPreviewPhrase() +{ + dword i, y; + char line[256]; + label.raw_size = free(label.raw); + for (i=10, y=5; i<22; i++, y+=label.height;) //not flexible, need to calculate font count and max line length + { + sprintf(#line," /size font %d ᥫ.",i); + label.write_buf(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); + } + if (label.smooth) label.apply_smooth(); + label.show_buf(0, PANELH); +} + +void DrawPreviewChars() +{ + dword i, x=20, y=0; + char line[2]; + line[1]=NULL; + label.raw_size = free(label.raw); + for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length + { + line[0]=i; + label.write_buf(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line); + x+= label.height+2; + if (x>=Form.cwidth-30) { + x=20; + y+=label.height+2; + } + } + if (label.smooth) label.apply_smooth(); + label.show_buf(0, PANELH); +} diff --git a/programs/cmm/lib/font.h b/programs/cmm/lib/font.h index 5a3cf184dc..99ec672e6b 100644 --- a/programs/cmm/lib/font.h +++ b/programs/cmm/lib/font.h @@ -133,7 +133,7 @@ } size.width += rw; IF(bold) size.width+=size.TMP_WEIGHT; - IF(s=='_') size.width--; + //IF(s=='_') size.width--; //http://board.kolibrios.org/viewtopic.php?f=44&t=973&start=645 IF(size.offset_x<0)size.offset_x = X; } :byte LABEL::symbol(signed x,y; byte s; dword image_raw) @@ -275,7 +275,7 @@ inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; } len = size.offset_x; WHILE(DSBYTE[text1]) { - IF(DSBYTE[text1]=='_') len--; + //IF(DSBYTE[text1]=='_') len--; //http://board.kolibrios.org/viewtopic.php?f=44&t=973&start=645 len+=symbol(len,0,DSBYTE[text1], raw); IF(bold)len+=math.ceil(size.pt/17); text1++; diff --git a/programs/cmm/lib/gui.h b/programs/cmm/lib/gui.h index fd2a4b15aa..4b19c42da9 100644 --- a/programs/cmm/lib/gui.h +++ b/programs/cmm/lib/gui.h @@ -267,4 +267,49 @@ dword incn::inc(dword _addition) return n; } + +/*========================================================= +== +== TABS +== +/========================================================*/ + +#define TAB_PADDING 25 +#define TAB_HEIGHT 25 + +struct _tabs +{ + int active_tab; + void draw(); + int click(); +} tabs; + +void _tabs::draw(dword x,y, but_id, text) +{ + dword col_bg, col_text; + dword w=strlen(text)*8+TAB_PADDING, h=TAB_HEIGHT; + y -= h; + + if (but_id==active_tab) + { + col_bg=system.color.work_button; + col_text=system.color.work_button_text; + } + else + { + col_bg=system.color.work; + col_text=system.color.work_text; + } + DrawCaptButton(x,y, w-1,h+1, but_id, col_bg, col_text, text); +} + +int _tabs::click(int N) +{ + if (N==active_tab) return false; + active_tab = N; + return true; +} + + + #endif \ No newline at end of file