Subversion Repositories Kolibri OS

Rev

Rev 7244 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7244 Rev 7245
Line 4... Line 4...
4
#include "../lib/mem.h" 
4
#include "../lib/mem.h" 
5
#include "../lib/gui.h" 
5
#include "../lib/gui.h" 
Line 6... Line 6...
6
 
6
 
7
#include "../lib/obj/libimg.h"
7
#include "../lib/obj/libimg.h"
-
 
8
#include "../lib/obj/box_lib.h"
Line 8... Line 9...
8
#include "../lib/obj/box_lib.h"
9
#include "../lib/obj/proc_lib.h"
9
 
10
 
10
#ifndef AUTOBUILD
11
#ifndef AUTOBUILD
Line 11... Line 12...
11
	#include "lang.h--"
12
	#include "lang.h--"
Line 12... Line 13...
12
#endif
13
#endif
Line 13... Line 14...
13
 
14
 
14
/* === TRANSLATIONS === */
15
/* === TRANSLATIONS === */
-
 
16
 
-
 
17
#define T_WTITLE "EasyShot v1.0"
-
 
18
 
-
 
19
#ifdef LANG_RUS
-
 
20
	?define T_TAKE_SCREENSHOT "  ‘¤¥« âì áªà¨­è®â"
-
 
21
	?define T_SETTINGS " áâனª¨"
15
 
22
	?define T_EDITBOX_FRAME " ãâì á®åà ­¥­¨ï áªà¨­è®â  "
16
#define T_WTITLE "EasyShot v0.76"
23
	?define T_DELAY "‡ ¤¥à¦ª  ¢ ᥪ㭤 å"
-
 
24
	?define T_MINIMIZE "‘¢¥àâãâì ®ª­® ¯à¨ á­¨¬ª¥"
-
 
25
	?define T_NO_DIR "' ¯ª  ­¥ áãé¥áâ¢ã¥â!' -E"
-
 
26
	?define T_SET_PATH "‡ ¤ âì"
-
 
27
#else
-
 
28
	?define T_TAKE_SCREENSHOT "  Take a screenshot"
-
 
29
	?define T_SETTINGS "Settings"
17
 
30
	?define T_EDITBOX_FRAME " Save path "
Line 18... Line 31...
18
#ifdef LANG_RUS
31
	?define T_DELAY "Delay in seconds"
Line 19... Line 32...
19
	?define T_TAKE_SCREENSHOT "  ‘¤¥« âì áªà¨­è®â"
32
	?define T_MINIMIZE "Minimize window"
Line 33... Line 46...
33
	BTN_SETTINGS
46
	BTN_SETTINGS
34
};
47
};
Line 35... Line 48...
35
 
48
 
Line -... Line 49...
-
 
49
#define PD 18 //padding
-
 
50
 
-
 
51
char save_path[4096];
Line 36... Line -...
36
#define PD 18 //padding
-
 
37
 
52
char save_path_stable[4096];
38
 
53
char open_dir[4096];
39
char save_path[4096] = "/tmp0/1";
54
 
Line 40... Line 55...
40
dword mouse_dd1;
55
dword mouse_dd1;
41
edit_box edit_box_path = {270,10,70,0xffffff,0x94AECE,0xFFFfff,0xffffff,
56
edit_box edit_save = {250,25,100,0xffffff,0x94AECE,0xFFFfff,0xffffff,
Line -... Line 57...
-
 
57
	0x10000000,sizeof(save_path),#save_path,#mouse_dd1, 0b};
-
 
58
 
-
 
59
more_less_box delay = { 1, 0, 64, T_DELAY };
-
 
60
checkbox minimize = { T_MINIMIZE, true };
-
 
61
 
-
 
62
proc_info Settings;
-
 
63
 
-
 
64
opendialog open_folder_dialog = 
-
 
65
{
-
 
66
  2, //0-file, 2-save, 3-select folder
-
 
67
  #Settings,
-
 
68
  #communication_area_name,
-
 
69
  0,
-
 
70
  0, //dword opendir_path,
-
 
71
  #open_dir, //dword dir_default_path,
-
 
72
  #open_dialog_path,
-
 
73
  #DrawSettingsWindow,
-
 
74
  0,
-
 
75
  #open_dir, //dword openfile_path,
-
 
76
  0, //dword filename_area,
-
 
77
  0, //dword filter_area,
Line 42... Line 78...
42
	0x10000000,sizeof(save_path),#save_path,#mouse_dd1, 0b};
78
  420,
Line 43... Line 79...
43
 
79
  NULL,
44
more_less_box delay = { 1, 0, 64, "Delay in seconds" };
80
  320,
45
checkbox minimise = { "Minimize window", true };
81
  NULL
Line 46... Line 82...
46
 
82
};
47
 
83
 
48
/* === CODE === */
84
/* === CODE === */
-
 
85
 
-
 
86
void main()
Line -... Line 87...
-
 
87
{	
49
 
88
	char id;
-
 
89
 
-
 
90
	load_dll(libio,  #libio_init,  1);
50
void main()
91
	load_dll(libimg, #libimg_init, 1);
51
{	
92
	load_dll(boxlib, #box_lib_init,0);
Line -... Line 93...
-
 
93
	load_dll(Proc_lib,  #OpenDialog_init,0);
-
 
94
	OpenDialog_init stdcall (#open_folder_dialog);
-
 
95
 
-
 
96
	system.color.get();
52
	char id;
97
	Libimg_LoadImage(#skin, "/sys/icons16.png");
53
 
98
	Libimg_ReplaceColor(skin.image, skin.w, skin.h, 0xffFFFfff, system.color.work_button);
54
	load_dll(libio,  #libio_init,  1);
99
	Libimg_ReplaceColor(skin.image, skin.w, skin.h, 0xffCACBD6, MixColors(system.color.work_button, 0, 200));
55
	load_dll(libimg, #libimg_init, 1);
100
	screenshot_length = screen.width * screen.height * 3;
56
	load_dll(boxlib, #box_lib_init,0);
101
	screenshot = malloc(screenshot_length);
Line 89... Line 134...
89
	take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 44);
134
	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);	
135
	DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10);	
91
}
136
}
Line 92... Line 137...
92
 
137
 
93
void EventTakeScreenshot() {
138
void EventTakeScreenshot() {
94
	if (minimise.checked) MinimizeWindow(); 
139
	if (minimize.checked) MinimizeWindow(); 
95
	pause(delay.value*100);
140
	pause(delay.value*100);
96
	CopyScreen(screenshot, 0, 0, screen.width, screen.height);
141
	CopyScreen(screenshot, 0, 0, screen.width, screen.height);
97
	ActivateWindow(GetProcessSlot(Form.ID));
142
	ActivateWindow(GetProcessSlot(Form.ID));
98
	if (!minimise.checked) DrawMainContent();
143
	if (!minimize.checked) DrawMainContent();
99
	EventSaveImageFile();
144
	EventSaveImageFile();
Line 100... Line 145...
100
}
145
}
101
 
146
 
102
void EventSaveImageFile()
147
void EventSaveImageFile()
103
{
148
{
104
	int i=0;
149
	int i=0;
105
	char save_file_name[4096];
150
	char save_file_name[4096];
106
	do {
151
	do {
107
		i++;
152
		i++;
108
		sprintf(#save_file_name, "%s/screen_%i.png", #save_path, i);
153
		sprintf(#save_file_name, "%s/screen_%i.png", #save_path_stable, i);
109
	} while (file_exists(#save_file_name));
154
	} while (file_exists(#save_file_name));
Line 110... Line 155...
110
	save_image(screenshot, screen.width, screen.height, #save_file_name);
155
	save_image(screenshot, screen.width, screen.height, #save_file_name);
111
}
156
}
-
 
157
 
-
 
158
 
112
 
159
void SettingsWindow()
113
 
160
{
114
void SettingsWindow()
161
	#define BTN_OD 10
115
{
162
	#define BTN_SET 11
116
	int id;
163
	int id, butw;
117
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);	
164
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
118
	loop() switch(WaitEvent())
165
	loop() switch(WaitEvent())
Line 119... Line 166...
119
	{
166
	{
120
	case evMouse:
167
	case evMouse:
121
		//edit_box_mouse stdcall (#address_box);
168
		edit_box_mouse stdcall (#edit_save);
-
 
169
		break;
-
 
170
 
122
		break;
171
	case evKey:
Line 123... Line 172...
123
 
172
		GetKeys();
124
	case evKey:
173
		if (SCAN_CODE_ESC == key_scancode) ExitProcess();
125
		GetKeys();
174
		EAX= key_ascii << 8;
-
 
175
		edit_box_key stdcall (#edit_save);	
-
 
176
		break;
-
 
177
 
-
 
178
	case evButton:
-
 
179
		id = GetButtonID();
-
 
180
		if (CLOSE_BTN == id) ExitProcess();
-
 
181
		if (BTN_OD == id) {
-
 
182
			OpenDialog_start stdcall (#open_folder_dialog);
-
 
183
			if (open_folder_dialog.status) {
-
 
184
				strcpy(#save_path, open_folder_dialog.opendir_path);
-
 
185
				edit_save.size = edit_save.pos = edit_save.shift 
-
 
186
					= edit_save.shift_old = strlen(#save_path);
-
 
187
			}
-
 
188
		}
-
 
189
		if (BTN_SET == id) {
-
 
190
			if (save_path[0]) && (dir_exists(#save_path)) {
-
 
191
				strcpy(#save_path_stable, #save_path);
-
 
192
				strrtrim(#save_path_stable);
126
		if (SCAN_CODE_ESC == key_scancode) ExitProcess();
193
				if (save_path_stable[strlen(#save_path_stable)-1]=='/')
127
		break;
194
				    save_path_stable[strlen(#save_path_stable)-1]=NULL; //no "/" at the end
128
 
195
			}
Line 129... Line 196...
129
	case evButton:
196
			else notify(T_NO_DIR);
130
		id = GetButtonID();
-
 
131
		if (CLOSE_BTN == id) ExitProcess();
-
 
132
		delay.click(id);
197
 
133
		minimise.click(id);
198
		}
134
		break;
-
 
135
 
199
		delay.click(id);
-
 
200
		minimize.click(id);
-
 
201
		break;
-
 
202
 
-
 
203
	case evReDraw:
-
 
204
		DrawSettingsWindow();
-
 
205
	}
-
 
206
}
-
 
207
 
-
 
208
void DrawSettingsWindow()
-
 
209
{
-
 
210
	DefineAndDrawWindow(Form.left+100, Form.top-40, 400, 230, 0x34, system.color.work, T_SETTINGS, 0);
136
	case evReDraw:
211
	GetProcessInfo(#Settings, SelfInfo);
Line 137... Line 212...
137
		DefineAndDrawWindow(Form.left+100, Form.top-40, 330, 170, 0x34, system.color.work, "Settings",0);
212
	minimize.draw(15, 15);
138
		_DRAW_CONTENT:
213
	delay.draw(15, 45);
139
		minimise.draw(15, 10);
214
	DrawFrame(15, 85, 360, 95, T_EDITBOX_FRAME);
140
		delay.draw(15, 40);
-
 
141
		//DrawEditBox(#edit_box_path);
-
 
142
	}
215
		DrawEditBoxPos(32, 110, #edit_save);
143
}
216
		DrawStandartCaptButton(edit_save.left + edit_save.width + 15, edit_save.top-3, BTN_OD, "...");
144
 
-
 
145
int DrawIconButton(dword x, y, id, text, icon)
217
		DrawStandartCaptButton(edit_save.left, edit_save.top+32, BTN_SET, T_SET_PATH);	
146
{
218
}
Line 147... Line 219...
147
	int btwidth;
219