From edc6f75e77eff2b121a2b7db6ded96d075619f4f Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Wed, 5 Oct 2016 13:12:39 +0000 Subject: [PATCH] CLIPVIEW v1.0: upload a new app Clipboard Viewer git-svn-id: svn://kolibrios.org@6567 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/clipview/Tupfile.lua | 6 + programs/cmm/clipview/clipboard_container.txt | 30 +++ programs/cmm/clipview/clipview.c | 236 ++++++++++++++++++ programs/cmm/clipview/compile_en.bat | 9 + programs/cmm/lib/gui.h | 16 ++ 5 files changed, 297 insertions(+) create mode 100644 programs/cmm/clipview/Tupfile.lua create mode 100644 programs/cmm/clipview/clipboard_container.txt create mode 100644 programs/cmm/clipview/clipview.c create mode 100644 programs/cmm/clipview/compile_en.bat diff --git a/programs/cmm/clipview/Tupfile.lua b/programs/cmm/clipview/Tupfile.lua new file mode 100644 index 0000000000..c2b064856b --- /dev/null +++ b/programs/cmm/clipview/Tupfile.lua @@ -0,0 +1,6 @@ +if tup.getconfig("NO_CMM") ~= "" then return end +if tup.getconfig("LANG") == "ru" +then C_LANG = "LANG_RUS" +else C_LANG = "LANG_ENG" -- this includes default case without config +end +tup.rule("clipview.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "clipview.com") diff --git a/programs/cmm/clipview/clipboard_container.txt b/programs/cmm/clipview/clipboard_container.txt new file mode 100644 index 0000000000..4dd56eeb9e --- /dev/null +++ b/programs/cmm/clipview/clipboard_container.txt @@ -0,0 +1,30 @@ +Содержимое контейнера буфера обмена + +1. Первый dword содержит общую длину данных в контейнере + +2. Второй dword указывает тип данныx: + 0 = Текст + 1 = Изображение + 2 = RAW + 4 и выше зарезервировано + +2.1 Текст + Данные в третьем dword содержат тип кодировки: + 0 = UTF + 1 = 0866 + 2 = 1251 + 3 и выше зарезервировано + +2.2 Изображение + Третий dword - размер по X + Четвертый dword - размер по Y + Пятый dword - глубина цвета в битах (8, 16, 24, 32, 48, 64) + Шестой dword - Указатель на палитру (смещение от начала файла). + Если палитры нет то значение 0 + Седьмой dword - Размер области палитры, максимальное значение 256*4=1024байт. + Если палитры нет то значение 0 + Восьмой dword - Указатель на данные пикселей для R, G, B. + Девятый dword - Размер области данных для пикселей. + +2.3 RAW + Может содержать любые данные, т.к. содержимое на усмотрение программиста diff --git a/programs/cmm/clipview/clipview.c b/programs/cmm/clipview/clipview.c new file mode 100644 index 0000000000..091e91a1a7 --- /dev/null +++ b/programs/cmm/clipview/clipview.c @@ -0,0 +1,236 @@ +#ifndef AUTOBUILD + ?include "lang.h--" +#endif + +#define MEMSIZE 0xDFE800 +#include "..\lib\mem.h" +#include "..\lib\strings.h" +#include "..\lib\list_box.h" +#include "..\lib\clipboard.h" +#include "..\lib\gui.h" +#include "..\lib\obj\box_lib.h" + + +//===================================================// +// // +// DATA // +// // +//===================================================// + +?define WINDOW_HEADER "Clipboard viewer v1.0" +?define T_DELETE_LAST_SLOT "Delete last slot" +?define T_DELETE_ALL_SLOTS "Delete all slots" +?define T_RESET_BUFFER_LOCK "Reset the lock buffer" +?define T_COLUMNS_TITLE "# | Data size | Data type | Contents" +?define T_COLUMN_VIEW "View" +?define T_VIEW_OPTIONS "TEXT HEX" +?define T_CLIPBOARD_IS_EMPTY "Clipboard is empty" +?define DEFAULT_SAVE_PATH "/tmp0/1/clipview.tmp" +char *data_type[] = { "Text", "Image", "RAW", "Unknown" }; + +enum { + BT_DELETE_LAST_SLOT = 10, + BT_DELETE_ALL_SLOTS, + BT_UNLOCK +}; + + +#define PANEL_TOP_H 20 +#define PANEL_BOTTOM_H 30 +#define LIST_PADDING 12 + +llist list; + +proc_info Form; + +Clipboard clipboard; + +scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; + + +//===================================================// +// // +// CODE // +// // +//===================================================// + +void main() +{ + int id; + + list.SetFont(8, 14, 0x90); + list.no_selection = true; + SetEventMask(0x27); + load_dll(boxlib, #box_lib_init,0); + loop() + { + WaitEventTimeout(10); + switch(EAX & 0xFF) + { + case evMouse: + if (!CheckActiveProcess(Form.ID)) break; + mouse.get(); + scrollbar_v_mouse (#scroll1); + if (list.first != scroll1.position) + { + list.first = scroll1.position; + Draw_List(); + break; + } + if (mouse.vert) && (list.MouseScroll(mouse.vert)) Draw_List(); + break; + + + case evButton: + id=GetButtonID(); + if (id==1) ExitProcess(); + if (id==BT_DELETE_LAST_SLOT) EventDeleteLastSlot(); + if (id==BT_DELETE_ALL_SLOTS) EventDeleteAllSlots(); + if (id==BT_UNLOCK) EventResetBufferLock(); + if (id>=100) && (id<300) EventOpenAsText(id-100); + if (id>=300) EventOpenAsHex(id-300); + break; + + case evKey: + GetKeys(); + if (list.ProcessKey(key_scancode)) Draw_List(); + break; + + case evReDraw: + system.color.get(); + DefineAndDrawWindow(screen.width-700/2,80,700,454+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0); + GetProcessInfo(#Form, SelfInfo); + IF (Form.status_window>=2) break; + if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } + if (Form.width < 570) { MoveSize(OLD,OLD,570,OLD); break; } + list.SetSizes(LIST_PADDING, LIST_PADDING+PANEL_TOP_H, Form.cwidth-LIST_PADDING-LIST_PADDING-scroll1.size_x, + Form.cheight-PANEL_BOTTOM_H-PANEL_TOP_H-LIST_PADDING-LIST_PADDING, 20); + DrawWindowContent(); + Draw_List(); + break; + + default: + if (clipboard.GetSlotCount() > list.count) Draw_List(); + break; + } + } +} + +void DrawWindowContent() +{ + int button_x = list.x; + DrawBar(0,0, Form.cwidth, PANEL_TOP_H, system.color.work); + DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, system.color.work); + DrawRectangle3D(list.x-2, list.y-2, list.w+3+scroll1.size_x, list.h+3, system.color.work_dark, system.color.work_light); + DrawWideRectangle(list.x-LIST_PADDING, list.y-LIST_PADDING, LIST_PADDING*2+list.w+scroll1.size_x, LIST_PADDING*2+list.h, LIST_PADDING-2, system.color.work); + button_x += DrawStandartCaptButton(button_x, list.y + list.h + 8, BT_DELETE_LAST_SLOT, system.color.work_button, system.color.work_button_text, T_DELETE_LAST_SLOT); + button_x += DrawStandartCaptButton(button_x, list.y + list.h + 8, BT_DELETE_ALL_SLOTS, system.color.work_button, system.color.work_button_text, T_DELETE_ALL_SLOTS); + button_x += DrawStandartCaptButton(button_x, list.y + list.h + 8, BT_UNLOCK, system.color.work_button, system.color.work_button_text, T_RESET_BUFFER_LOCK); + DrawRectangle(list.x-1, list.y-1, list.w+1+scroll1.size_x, list.h+1, system.color.work_graph); + WriteText(list.x+12, list.y - 23, list.font_type, system.color.work_text, T_COLUMNS_TITLE); + WriteText(list.x+list.w-68, list.y - 23, list.font_type, system.color.work_text, T_COLUMN_VIEW); +} + +void DrawScroller() +{ + scroll1.bckg_col = MixColors(system.color.work, 0xBBBbbb, 80); + scroll1.frnt_col = MixColors(system.color.work,0xFFFfff,120); + scroll1.line_col = system.color.work_graph; + + scroll1.max_area = list.count; + scroll1.cur_area = list.visible; + scroll1.position = list.first; + + scroll1.all_redraw=1; + scroll1.start_x = list.x + list.w; + scroll1.start_y = list.y-1; + scroll1.size_y = list.h+2; + + scrollbar_v_draw(#scroll1); +} + + +void Draw_List() +{ + int i, yyy, list_last, slot_data_type_number; + dword text_color = 0x000000; + char line_text[512]; + dword size_kb; + + list.count = clipboard.GetSlotCount(); + list.CheckDoesValuesOkey(); + + + if (list.count > list.visible) list_last = list.visible; else list_last = list.count; + + for (i=0; ilang.h-- + +@C-- clipview.c +@del clipview +@rename clipview.com clipview +@del warning.txt +@del lang.h-- +@pause \ No newline at end of file diff --git a/programs/cmm/lib/gui.h b/programs/cmm/lib/gui.h index 18deb872ad..d64323fa4d 100644 --- a/programs/cmm/lib/gui.h +++ b/programs/cmm/lib/gui.h @@ -51,6 +51,22 @@ WriteText(tx,ty,0x90,color_t,text); } +:int DrawStandartCaptButton(dword x, y, id, color_b, color_t, text) +{ + int padding_v = 5; + int padding_h = 15; + int right_margin = 12; + int tx = x + padding_h; + int ty = y + padding_v; + int h = padding_v + padding_v + 16; //16 font height + int w = strlen(text)*8 + padding_h + padding_h; + + if (id>0) DefineButton(x,y,w,h,id,color_b); + WriteText(tx+1,ty+1,0x90,MixColors(color_b,0,230),text); + WriteText(tx,ty,0x90,color_t,text); + return w + right_margin; +} + :void WriteTextCenter(dword x,y,w,color_t,text) { WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text);