Subversion Repositories Kolibri OS

Rev

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

Rev 7243 Rev 7244
Line 11... Line 11...
11
	#include "lang.h--"
11
	#include "lang.h--"
12
#endif
12
#endif
Line 13... Line 13...
13
 
13
 
Line 14... Line 14...
14
/* === TRANSLATIONS === */
14
/* === TRANSLATIONS === */
Line 15... Line 15...
15
 
15
 
16
#define T_WTITLE "EasyShot v0.75"
16
#define T_WTITLE "EasyShot v0.76"
17
 
17
 
18
#ifdef LANG_RUS
18
#ifdef LANG_RUS
Line 33... Line 33...
33
	BTN_SETTINGS
33
	BTN_SETTINGS
34
};
34
};
Line 35... Line 35...
35
 
35
 
Line -... Line 36...
-
 
36
#define PD 18 //padding
36
#define PD 18 //padding
37
 
37
 
38
 
38
struct _settings {
39
char save_path[4096] = "/tmp0/1";
39
	bool minimise;
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};
40
	int delay;
43
 
-
 
44
more_less_box delay = { 1, 0, 64, "Delay in seconds" };
Line 41... Line 45...
41
	char save_path[4096];
45
checkbox minimise = { "Minimize window", true };
Line 42... Line 46...
42
} settings = { true, 1, "/tmp0/1" };
46
 
43
 
47
 
Line 50... Line 54...
50
	load_dll(libio,  #libio_init,  1);
54
	load_dll(libio,  #libio_init,  1);
51
	load_dll(libimg, #libimg_init, 1);
55
	load_dll(libimg, #libimg_init, 1);
52
	load_dll(boxlib, #box_lib_init,0);
56
	load_dll(boxlib, #box_lib_init,0);
Line 53... Line 57...
53
 
57
 
54
	Libimg_LoadImage(#skin, "/sys/icons16.png");
-
 
55
 
58
	Libimg_LoadImage(#skin, "/sys/icons16.png");
56
	screenshot_length = screen.width * screen.height * 3;
-
 
57
 
59
	screenshot_length = screen.width * screen.height * 3;
Line 58... Line 60...
58
	screenshot  = malloc(screenshot_length);
60
	screenshot = malloc(screenshot_length);
59
 
61
 
60
	loop() switch(WaitEvent())
62
	loop() switch(WaitEvent())
61
	{
63
	{
62
	case evButton:
64
	case evButton:
63
		id = GetButtonID();
65
		id = GetButtonID();
64
		if (id == CLOSE_BTN) ExitProcess();
66
		if (id == CLOSE_BTN) ExitProcess();
65
		if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot();
67
		if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot();
Line 66... Line 68...
66
		if (id == BTN_SETTINGS) EventShowSettings();
68
		if (id == BTN_SETTINGS) CreateThread(#SettingsWindow,#settings_stak+4092);
67
		break;
69
		break;
68
 
70
 
Line 87... Line 89...
87
	take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 44);
89
	take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 44);
88
	DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10);	
90
	DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10);	
89
}
91
}
Line 90... Line 92...
90
 
92
 
91
void EventTakeScreenshot() {
93
void EventTakeScreenshot() {
92
	if (settings.minimise) MinimizeWindow(); 
94
	if (minimise.checked) MinimizeWindow(); 
93
	pause(settings.delay*100);
95
	pause(delay.value*100);
94
	CopyScreen(screenshot, 0, 0, screen.width, screen.height);
96
	CopyScreen(screenshot, 0, 0, screen.width, screen.height);
95
	ActivateWindow(GetProcessSlot(Form.ID));
97
	ActivateWindow(GetProcessSlot(Form.ID));
96
	if (!settings.minimise) DrawMainContent();
98
	if (!minimise.checked) DrawMainContent();
97
	EventSaveImageFile();
99
	EventSaveImageFile();
Line 98... Line 100...
98
}
100
}
99
 
101
 
100
void EventSaveImageFile()
102
void EventSaveImageFile()
101
{
103
{
102
	int i=0;
104
	int i=0;
103
	char save_file_name[4096];
105
	char save_file_name[4096];
104
	do {
106
	do {
105
		i++;
107
		i++;
106
		sprintf(#save_file_name, "%s/screen_%i.png", #settings.save_path, i);
108
		sprintf(#save_file_name, "%s/screen_%i.png", #save_path, i);
107
	} while (file_exists(#save_file_name));
109
	} while (file_exists(#save_file_name));
Line 108... Line -...
108
	save_image(screenshot, screen.width, screen.height, #save_file_name);
-
 
109
}
-
 
110
 
-
 
111
void EventShowSettings()
-
 
112
{
-
 
113
	CreateThread(#SettingsWindow,#settings_stak+4092);	
-
 
114
}
-
 
115
 
-
 
116
char path_tmp[4096];
-
 
117
dword mouse_dd1;
-
 
Line 118... Line 110...
118
edit_box edit_box_path = {270,10,70,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(path_tmp),#path_tmp,#mouse_dd1, 0b};
110
	save_image(screenshot, screen.width, screen.height, #save_file_name);
119
 
111
}
120
more_less_box delay = { 1, 0, 64, "Delay in seconds" };
112
 
121
 
113
 
Line 134... Line 126...
134
		if (SCAN_CODE_ESC == key_scancode) ExitProcess();
126
		if (SCAN_CODE_ESC == key_scancode) ExitProcess();
135
		break;
127
		break;
Line 136... Line 128...
136
 
128
 
137
	case evButton:
129
	case evButton:
138
		id = GetButtonID();
-
 
139
		delay.click(id);
130
		id = GetButtonID();
-
 
131
		if (CLOSE_BTN == id) ExitProcess();
140
		if (CLOSE_BTN == id) ExitProcess();
132
		delay.click(id);
141
		if (12 == id) { settings.minimise ^= 1; goto _DRAW_CONTENT; }
133
		minimise.click(id);
Line 142... Line 134...
142
		break;
134
		break;
143
 
135
 
144
	case evReDraw:
136
	case evReDraw:
145
		DefineAndDrawWindow(Form.left+100, Form.top-40, 330, 170, 0x34, system.color.work, "Settings",0);
137
		DefineAndDrawWindow(Form.left+100, Form.top-40, 330, 170, 0x34, system.color.work, "Settings",0);
146
		_DRAW_CONTENT:
138
		_DRAW_CONTENT:
147
		CheckBox(15, 10, 12, "Minimize window", settings.minimise);
139
		minimise.draw(15, 10);
148
		delay.draw(15, 40);
140
		delay.draw(15, 40);
149
		//DrawEditBox(#edit_box_path);
141
		//DrawEditBox(#edit_box_path);
Line 150... Line -...
150
	}
-
 
151
}
-
 
152
 
-
 
153
inline byte calc_rgb(dword B, item_h)
-
 
154
{
-
 
155
	return calc(ESBYTE[B+3] + ESBYTE[B] + ESBYTE[B-3]
-
 
156
		+ ESBYTE[B-item_h] + ESBYTE[B+item_h] / 5);
142
	}
157
}
143
}
158
 
144
 
159
int DrawIconButton(dword x, y, id, text, icon)
145
int DrawIconButton(dword x, y, id, text, icon)
160
{
146
{