From 85f85fa6d020550a2e0e9fd5aeaf4ce8c40bba7b Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Wed, 25 Mar 2015 11:46:22 +0000 Subject: [PATCH] Appearance and Pixie fixes, upload TTF Viewer v0.1 git-svn-id: svn://kolibrios.org@5548 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/appearance/appearance.c | 12 +- programs/cmm/appearance/compile_en.bat | 4 +- programs/cmm/appearance/compile_ru.bat | 4 +- programs/cmm/example/compile.bat | 7 +- programs/cmm/installer/installer.c | 8 +- programs/cmm/lib/kolibri.h | 7 ++ programs/cmm/lib/patterns/restart_process.h | 19 +++ programs/cmm/panels_cfg/panels_cfg.c | 22 ++-- programs/cmm/pixie/get_files_list.h | 11 +- programs/cmm/pixie/pixie.c | 14 ++- programs/cmm/ttf_viewer/compile_en.bat | 11 ++ programs/cmm/ttf_viewer/compile_ru.bat | 11 ++ programs/cmm/ttf_viewer/simple_open_dialog.h | 14 +++ programs/cmm/ttf_viewer/ttf_viewer.c | 115 +++++++++++++++++++ 14 files changed, 225 insertions(+), 34 deletions(-) create mode 100644 programs/cmm/lib/patterns/restart_process.h create mode 100644 programs/cmm/ttf_viewer/compile_en.bat create mode 100644 programs/cmm/ttf_viewer/compile_ru.bat create mode 100644 programs/cmm/ttf_viewer/simple_open_dialog.h create mode 100644 programs/cmm/ttf_viewer/ttf_viewer.c diff --git a/programs/cmm/appearance/appearance.c b/programs/cmm/appearance/appearance.c index dd449e8501..640f587045 100644 --- a/programs/cmm/appearance/appearance.c +++ b/programs/cmm/appearance/appearance.c @@ -79,10 +79,12 @@ void Draw_List() { int i; int yyy; + int list_last; list[SKINS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20); list[WALLPAPERS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20); - - for (i=0; i list[active].visible) list_last = list[active].visible; else list_last = list[active].count; + + for (i=0; isc.work) { DrawBar(0, yyy, list[active].w, list[active].line_h, sc.work_button); - WriteText(12,yyy+list[active].text_y,0x80,sc.work_button_text, #temp_filename); + if (ilang.h-- C-- appearance.c -@del appearance.kex -@rename appearance.com appearance.kex +@del appearance +@rename appearance.com appearance @del warning.txt @del lang.h-- @pause \ No newline at end of file diff --git a/programs/cmm/appearance/compile_ru.bat b/programs/cmm/appearance/compile_ru.bat index 1bde76ee57..b082f2491b 100644 --- a/programs/cmm/appearance/compile_ru.bat +++ b/programs/cmm/appearance/compile_ru.bat @@ -2,8 +2,8 @@ @echo #define LANG_RUS 1 >lang.h-- C-- appearance.c -@del appearance.kex -@rename appearance.com appearance.kex +@del appearance +@rename appearance.com appearance @del warning.txt @del lang.h-- @pause \ No newline at end of file diff --git a/programs/cmm/example/compile.bat b/programs/cmm/example/compile.bat index 02bd21c04f..fb404a7356 100644 --- a/programs/cmm/example/compile.bat +++ b/programs/cmm/example/compile.bat @@ -1,5 +1,10 @@ C-- example.c @del example @rename example.com example -@pause +kpack example @del warning.txt +@pause +@rem ====== Automatically add binnary to kolibri.img and then run QEMU ===== +@rem"C:\Program Files (x86)\WinImage\WINIMAGE.exe" D:\Kolibri\work\QEMU\kolibri.img /I /H/Q C:\Users\Leency\Dropbox\CMM\example\example +@rem @cd /d C:\Work\QEMU +@rem C:\Work\QEMU\kolibri_qumu.bat \ No newline at end of file diff --git a/programs/cmm/installer/installer.c b/programs/cmm/installer/installer.c index 90cde5c19d..45dad7eaf0 100644 --- a/programs/cmm/installer/installer.c +++ b/programs/cmm/installer/installer.c @@ -5,6 +5,8 @@ #include "..\lib\mem.h" #include "..\lib\copyf.h" +#include "..\lib\patterns\restart_process.h" + #include "add_appl_dir.c"; ?define T_END "\'Установка KolibriN успешно завершена.\' -O" @@ -15,13 +17,15 @@ void main() mem_Init(); SetAddApplDir("kolibrios", abspath("kolibrios")+1); RunProgram("/sys/media/kiv", "\\S__/kolibrios/res/Wallpapers/In the wind there is longing.png"); - notify(T_END); copyf(abspath("tmp"), "/tmp0/1"); copyf(abspath("sys"), "/sys"); + RestartProcessByName("@icon", MULTIPLE); + RestartProcessByName("@taskbar", SINGLE); + RestartProcessByName("@docky", SINGLE); + notify(T_END); ExitProcess(); } - void copyf_Draw_Progress(dword filename) { return; } diff --git a/programs/cmm/lib/kolibri.h b/programs/cmm/lib/kolibri.h index 449ba1c7df..97be2925d7 100644 --- a/programs/cmm/lib/kolibri.h +++ b/programs/cmm/lib/kolibri.h @@ -588,4 +588,11 @@ inline fastcall void DeleteButton( EDX) EAX = 8; EDX += BT_DEL; $int 0x40; +} + +inline fastcall dword GetStartTime() +{ + $mov eax,26 + $mov ebx,9 + $int 0x40 } \ No newline at end of file diff --git a/programs/cmm/lib/patterns/restart_process.h b/programs/cmm/lib/patterns/restart_process.h new file mode 100644 index 0000000000..60385825b8 --- /dev/null +++ b/programs/cmm/lib/patterns/restart_process.h @@ -0,0 +1,19 @@ +enum { + MULTIPLE, + SINGLE +}; + +void RestartProcessByName(dword proc_name, byte multiple) { + int i; + proc_info Process; + for (i=0; i<1000; i++;) + { + GetProcessInfo(#Process, i); + if (strcmpi(#Process.name, proc_name)==0) + { + KillProcess(Process.ID); + if (multiple==SINGLE) break; + } + } + RunProgram(proc_name, ""); +} \ No newline at end of file diff --git a/programs/cmm/panels_cfg/panels_cfg.c b/programs/cmm/panels_cfg/panels_cfg.c index b1a6bdf10d..c006f09508 100644 --- a/programs/cmm/panels_cfg/panels_cfg.c +++ b/programs/cmm/panels_cfg/panels_cfg.c @@ -15,6 +15,7 @@ #include "..\lib\obj\box_lib.h" #include "..\lib\patterns\libimg_load_skin.h" +#include "..\lib\patterns\restart_process.h" #ifdef LANG_RUS ?define WINDOW_TITLE "Настройки панели задач и Дока" @@ -246,20 +247,17 @@ void SaveCfg(byte panel_type) void RestartProcess(byte panel_type) { - int i; - dword proc_name; - proc_info Process; - if (panel_type == TASKBAR) proc_name = "@taskbar"; - if (panel_type == DOCKY) proc_name = "@docky"; - for (i=0; i<1000; i++;) + dword proc_name1; + if (panel_type == TASKBAR) { - GetProcessInfo(#Process, i); - if (strcmpi(#Process.name, proc_name)==0) { KillProcess(Process.ID); break; } + RestartProcessByName("@taskbar", SINGLE); + pause(50); + } + else + { + RestartProcessByName("@docky", SINGLE); + pause(120); } - RunProgram(proc_name, ""); - - if (panel_type == TASKBAR) pause(50); - if (panel_type == DOCKY) pause(120); GetProcessInfo(#Form, SelfInfo); ActivateWindow(GetProcessSlot(Form.ID)); } diff --git a/programs/cmm/pixie/get_files_list.h b/programs/cmm/pixie/get_files_list.h index 011688dcd8..e3d5fa9776 100644 --- a/programs/cmm/pixie/get_files_list.h +++ b/programs/cmm/pixie/get_files_list.h @@ -1,6 +1,3 @@ -char temp_filename[4096], - work_folder[4096], - current_filename[256]; int files_mas[2000]; dword buf; @@ -8,10 +5,11 @@ dword buf; void OpenDirectory(dword folder_path) { int cur; + char temp_filename[4096]; dword j, filesnum, end_pointer; list.count = 0; - //free(buf); + if (buf) free(buf); if (GetDir(#buf, #filesnum, folder_path, DIRS_ONLYREAL)==0) if (filesnum==0) { @@ -28,7 +26,6 @@ void OpenDirectory(dword folder_path) list.count++; } SortByName(0, list.count-1); - SetOpenedFileFirst(); } void SortByName(int a, b) @@ -41,10 +38,10 @@ void SortByName(int a, b) SortByName(i, b); } -void SetOpenedFileFirst() +void SetOpenedFileFirst(dword in_name) { int i; - dword opened_filename = #param + strrchr(#param, '/'); + dword opened_filename = in_name + strrchr(in_name, '/'); for (i=0; i skin.h) - notify("'Pixies Player v1.1\nChange sound volume: Left/Right key\nChange skin: F1/F2\nMute: M key' -St\n"); + notify("'Pixies Player v1.11\nChange sound volume: Left/Right key\nChange skin: F1/F2\nMute: M key' -St\n"); break; case evButton: @@ -232,7 +239,7 @@ void main() if (current_playing_file_n < list.count) { current_playing_file_n = list.current; - StartPlayingMp3(); + if (list.KeyDown()) StartPlayingMp3(); } else { @@ -249,6 +256,7 @@ void DrawPlayList() { int i; int yyy; + char temp_filename[4096]; for (i=0; ilang.h-- + +@del ttf_viewer +cls +c-- ttf_viewer.c +@rename ttf_viewer.com ttf_viewer +@kpack ttf_viewer +@del warning.txt +@del lang.h-- +@pause \ No newline at end of file diff --git a/programs/cmm/ttf_viewer/compile_ru.bat b/programs/cmm/ttf_viewer/compile_ru.bat new file mode 100644 index 0000000000..68f71fa9a8 --- /dev/null +++ b/programs/cmm/ttf_viewer/compile_ru.bat @@ -0,0 +1,11 @@ +@del lang.h-- +@echo #define LANG_RUS 1 >lang.h-- + +@del ttf_viewer +cls +c-- ttf_viewer.c +@rename ttf_viewer.com ttf_viewer +@kpack ttf_viewer +@del warning.txt +@del lang.h-- +@pause \ No newline at end of file diff --git a/programs/cmm/ttf_viewer/simple_open_dialog.h b/programs/cmm/ttf_viewer/simple_open_dialog.h new file mode 100644 index 0000000000..2956914beb --- /dev/null +++ b/programs/cmm/ttf_viewer/simple_open_dialog.h @@ -0,0 +1,14 @@ +struct od_filter +{ + dword size; + byte end; +}; + +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]; + +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}; diff --git a/programs/cmm/ttf_viewer/ttf_viewer.c b/programs/cmm/ttf_viewer/ttf_viewer.c new file mode 100644 index 0000000000..5c2e471d6a --- /dev/null +++ b/programs/cmm/ttf_viewer/ttf_viewer.c @@ -0,0 +1,115 @@ +#ifndef AUTOBUILD +#include "lang.h--" +#endif + +#define MEMSIZE 397113 +#include "..\lib\kolibri.h" +#include "..\lib\strings.h" +#include "..\lib\mem.h" +#include "..\lib\file_system.h" +#include "..\lib\dll.h" +#include "..\lib\gui.h" +#include "..\lib\obj\truetype.h" +#include "..\lib\obj\proc_lib.h" + +#include "simple_open_dialog.h" +char default_dir[] = "/rd/1"; +od_filter filter2 = {"TTF",0}; + +dword font_data; +stbtt_fontinfo font_info; +dword font_mem; + +system_colors sc; +proc_info Form; +char test_text[] = "The quick brown fox jumps over the lazy dog"; +char win_title[4096] = "TTF Viewer v0.1 - "; + +#ifdef LANG_RUS + ?define T_INTRO "Это простая программа для просмотра шрифтов формата TTF" + ?define T_INTRO_BUTTON_TEXT "Открыть шрифт" +#else + ?define T_INTRO "This is simple program to view TTF fonts." + ?define T_INTRO_BUTTON_TEXT "Open font" +#endif + + +void main() +{ + int id, key; + + mem_Init(); + if (load_dll2(libtruetype, #truetype, 1) != 0) notify("Error: library doesn't exists - truetype"); + if (load_dll2(Proc_lib, #OpenDialog_init,0)!=0) notify("Error: library doesn't exists - Proc_lib (open_dialog)"); + OpenDialog_init stdcall (#o_dialog); + + if (param[0]) OpenFont(#param); + + loop() + { + switch(WaitEvent()) + { + case evButton: + id=GetButtonID(); + if (id==1) ExitProcess(); + if (id==10) + { + OpenDialog_start stdcall (#o_dialog); + OpenFont(#openfile_path); + } + break; + + case evKey: + key = GetKey(); + break; + + case evReDraw: + draw_window(); + } + } +} + + +void draw_window() +{ + sc.get(); + DefineAndDrawWindow(30, 100, 800, 250+GetSkinHeight(), 0x34, 0xFFFfff, #win_title); + GetProcessInfo(#Form, SelfInfo); + DrawFonts(); +} + + +word DrawFonts() +{ + if (!font_data) + { + WriteTextCenter(0,85,Form.cwidth,0x555555, T_INTRO); + DrawCaptButton(Form.cwidth - 140 / 2, Form.cheight - 30 / 2, 140, 30, 10, sc.work_button, sc.work_button_text, T_INTRO_BUTTON_TEXT); + return; + } + text_out stdcall (#test_text, #font_info, 10, 0x000000, 0xFFFfff, 3, 4); + text_out stdcall (#test_text, #font_info, 12, 0x000000, 0xFFFfff, 3, 18); + text_out stdcall (#test_text, #font_info, 24, 0x000000, 0xFFFfff, 3, 35); + text_out stdcall (#test_text, #font_info, 36, 0x000000, 0xFFFfff, 3, 60); + text_out stdcall (#test_text, #font_info, 48, 0x000000, 0xFFFfff, 3, 110); + text_out stdcall (#test_text, #font_info, 58, 0x000000, 0xFFFfff, 3, 170); +} + + +void OpenFont(dword font_path) +{ + BDVK FontFile_atr; + GetFileInfo(font_path, #FontFile_atr); + font_data = malloc(FontFile_atr.sizelo); + ReadFile(0, FontFile_atr.sizelo, #font_data, font_path); + init_font stdcall (#font_info, #font_data); + if (EAX==0) + { + font_data = 0; + notify("'Can\096t open font: init_font failed' - E"); + } + strcpy(#win_title + 18, font_path); + draw_window(); +} + +stop: