Rev 7243 | Rev 7245 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7224 | leency | 1 | #define MEMSIZE 1024 * 50 |
5598 | pavelyakov | 2 | #include "../lib/kolibri.h" |
3 | #include "../lib/strings.h" |
||
4 | #include "../lib/mem.h" |
||
5 | #include "../lib/gui.h" |
||
5520 | leency | 6 | |
7220 | leency | 7 | #include "../lib/obj/libimg.h" |
7224 | leency | 8 | #include "../lib/obj/box_lib.h" |
7220 | leency | 9 | |
5520 | leency | 10 | #ifndef AUTOBUILD |
11 | #include "lang.h--" |
||
12 | #endif |
||
13 | |||
7221 | leency | 14 | /* === TRANSLATIONS === */ |
15 | |||
7244 | leency | 16 | #define T_WTITLE "EasyShot v0.76" |
7224 | leency | 17 | |
7221 | leency | 18 | #ifdef LANG_RUS |
7224 | leency | 19 | ?define T_TAKE_SCREENSHOT " Сделать скриншот" |
7221 | leency | 20 | #else |
7224 | leency | 21 | ?define T_TAKE_SCREENSHOT " Take a screenshot" |
7221 | leency | 22 | #endif |
23 | |||
7235 | leency | 24 | /* === DATA === */ |
5520 | leency | 25 | |
26 | proc_info Form; |
||
27 | |||
7235 | leency | 28 | dword screenshot; |
29 | int screenshot_length; |
||
5520 | leency | 30 | |
7220 | leency | 31 | enum { |
32 | BTN_MAKE_SCREENSHOT=10, |
||
7224 | leency | 33 | BTN_SETTINGS |
7220 | leency | 34 | }; |
5520 | leency | 35 | |
7224 | leency | 36 | #define PD 18 //padding |
7220 | leency | 37 | |
7224 | leency | 38 | |
7244 | leency | 39 | char save_path[4096] = "/tmp0/1"; |
40 | dword mouse_dd1; |
||
41 | edit_box edit_box_path = {270,10,70,0xffffff,0x94AECE,0xFFFfff,0xffffff, |
||
42 | 0x10000000,sizeof(save_path),#save_path,#mouse_dd1, 0b}; |
||
43 | |||
44 | more_less_box delay = { 1, 0, 64, "Delay in seconds" }; |
||
45 | checkbox minimise = { "Minimize window", true }; |
||
46 | |||
47 | |||
5520 | leency | 48 | /* === CODE === */ |
49 | |||
50 | void main() |
||
51 | { |
||
52 | char id; |
||
7221 | leency | 53 | |
7224 | leency | 54 | load_dll(libio, #libio_init, 1); |
7221 | leency | 55 | load_dll(libimg, #libimg_init, 1); |
7224 | leency | 56 | load_dll(boxlib, #box_lib_init,0); |
7221 | leency | 57 | |
7224 | leency | 58 | Libimg_LoadImage(#skin, "/sys/icons16.png"); |
7221 | leency | 59 | screenshot_length = screen.width * screen.height * 3; |
7244 | leency | 60 | screenshot = malloc(screenshot_length); |
5520 | leency | 61 | |
7220 | leency | 62 | loop() switch(WaitEvent()) |
5520 | leency | 63 | { |
7220 | leency | 64 | case evButton: |
65 | id = GetButtonID(); |
||
66 | if (id == CLOSE_BTN) ExitProcess(); |
||
67 | if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot(); |
||
7244 | leency | 68 | if (id == BTN_SETTINGS) CreateThread(#SettingsWindow,#settings_stak+4092); |
7220 | leency | 69 | break; |
70 | |||
71 | case evKey: |
||
72 | GetKeys(); |
||
73 | if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot(); |
||
74 | break; |
||
75 | |||
76 | case evReDraw: |
||
7235 | leency | 77 | system.color.get(); |
78 | DefineAndDrawWindow(screen.width/4, screen.height-100/3, 270, |
||
79 | skin_height + 27+PD+PD, 0x34, system.color.work, T_WTITLE,0); |
||
7220 | leency | 80 | GetProcessInfo(#Form, SelfInfo); |
81 | if (Form.status_window>2) break; |
||
7224 | leency | 82 | DrawMainContent(); |
7220 | leency | 83 | } |
5520 | leency | 84 | } |
85 | |||
7224 | leency | 86 | void DrawMainContent() |
87 | { |
||
88 | int take_scr_btn_width; |
||
7235 | leency | 89 | take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 44); |
90 | DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10); |
||
7224 | leency | 91 | } |
92 | |||
7220 | leency | 93 | void EventTakeScreenshot() { |
7244 | leency | 94 | if (minimise.checked) MinimizeWindow(); |
95 | pause(delay.value*100); |
||
7221 | leency | 96 | CopyScreen(screenshot, 0, 0, screen.width, screen.height); |
5520 | leency | 97 | ActivateWindow(GetProcessSlot(Form.ID)); |
7244 | leency | 98 | if (!minimise.checked) DrawMainContent(); |
7235 | leency | 99 | EventSaveImageFile(); |
5520 | leency | 100 | } |
101 | |||
7224 | leency | 102 | void EventSaveImageFile() |
7220 | leency | 103 | { |
7221 | leency | 104 | int i=0; |
105 | char save_file_name[4096]; |
||
106 | do { |
||
107 | i++; |
||
7244 | leency | 108 | sprintf(#save_file_name, "%s/screen_%i.png", #save_path, i); |
7221 | leency | 109 | } while (file_exists(#save_file_name)); |
7224 | leency | 110 | save_image(screenshot, screen.width, screen.height, #save_file_name); |
7220 | leency | 111 | } |
112 | |||
113 | |||
7224 | leency | 114 | void SettingsWindow() |
115 | { |
||
116 | int id; |
||
117 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
||
118 | loop() switch(WaitEvent()) |
||
119 | { |
||
120 | case evMouse: |
||
121 | //edit_box_mouse stdcall (#address_box); |
||
122 | break; |
||
7220 | leency | 123 | |
7224 | leency | 124 | case evKey: |
125 | GetKeys(); |
||
126 | if (SCAN_CODE_ESC == key_scancode) ExitProcess(); |
||
127 | break; |
||
7220 | leency | 128 | |
7224 | leency | 129 | case evButton: |
130 | id = GetButtonID(); |
||
7244 | leency | 131 | if (CLOSE_BTN == id) ExitProcess(); |
7243 | leency | 132 | delay.click(id); |
7244 | leency | 133 | minimise.click(id); |
7224 | leency | 134 | break; |
135 | |||
136 | case evReDraw: |
||
137 | DefineAndDrawWindow(Form.left+100, Form.top-40, 330, 170, 0x34, system.color.work, "Settings",0); |
||
138 | _DRAW_CONTENT: |
||
7244 | leency | 139 | minimise.draw(15, 10); |
7243 | leency | 140 | delay.draw(15, 40); |
7224 | leency | 141 | //DrawEditBox(#edit_box_path); |
7220 | leency | 142 | } |
143 | } |
||
144 | |||
7224 | leency | 145 | int DrawIconButton(dword x, y, id, text, icon) |
146 | { |
||
147 | int btwidth; |
||
148 | system.color.work_button = 0xFFFfff; |
||
149 | system.color.work_button_text = 0; |
||
150 | btwidth = DrawStandartCaptButton(x, y, id, text); |
||
151 | img_draw stdcall(skin.image, x+12, y+5, 16, 16, 0, icon*16); |
||
152 | system.color.get(); |
||
153 | return btwidth; |
||
154 | } |
||
5520 | leency | 155 | |
7224 | leency | 156 | stop: |
7221 | leency | 157 | |
7224 | leency | 158 | char settings_stak[4096]; |