Subversion Repositories Kolibri OS

Rev

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

Rev 7229 Rev 7235
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.7"
16
#define T_WTITLE "EasyShot v0.75"
17
 
-
 
18
#ifdef LANG_RUS
-
 
19
	?define T_TAKE_SCREENSHOT "  ‘¤¥« âì áªà¨­è®â"
17
 
20
	?define T_SAVE "  ‘®åà ­¨âì"
18
#ifdef LANG_RUS
21
	?define T_PREVIEW "à¥¤¯à®á¬®âà"
-
 
22
#else
-
 
23
	?define T_TAKE_SCREENSHOT "  Take a screenshot"
19
	?define T_TAKE_SCREENSHOT "  ‘¤¥« âì áªà¨­è®â"
Line 24... Line 20...
24
	?define T_SAVE "  Save"
20
#else
Line 25... Line 21...
25
	?define T_PREVIEW "Preview"
21
	?define T_TAKE_SCREENSHOT "  Take a screenshot"
Line 26... Line 22...
26
#endif
22
#endif
27
 
-
 
Line 28... Line 23...
28
/* === DATA === */
23
 
29
 
-
 
Line 30... Line 24...
30
proc_info Form;
24
/* === DATA === */	
31
 
25
 
32
dword screenshot,
-
 
33
      preview;
26
proc_info Form;
34
 
27
 
Line 35... Line 28...
35
int screenshot_length,
28
dword screenshot;
36
    preview_length;
-
 
37
 
-
 
38
enum {
-
 
Line 39... Line 29...
39
	BTN_MAKE_SCREENSHOT=10,
29
 
40
	BTN_SAVE,
30
int screenshot_length;
41
	BTN_SETTINGS
31
 
42
};
32
enum {
Line 63... Line 53...
63
	load_dll(boxlib, #box_lib_init,0);
53
	load_dll(boxlib, #box_lib_init,0);
Line 64... Line 54...
64
 
54
 
Line 65... Line 55...
65
	Libimg_LoadImage(#skin, "/sys/icons16.png");
55
	Libimg_LoadImage(#skin, "/sys/icons16.png");
66
 
-
 
67
	screenshot_length = screen.width * screen.height * 3;
-
 
Line 68... Line 56...
68
	pw.set_size(PD, TOOLBAR_H+PD, screen.width/2, screen.height/2);
56
 
69
	preview_length = screenshot_length / 2;	
-
 
Line 70... Line 57...
70
 
57
	screenshot_length = screen.width * screen.height * 3;
71
	screenshot  = malloc(screenshot_length);
58
 
72
	preview = malloc(screenshot_length/2);
59
	screenshot  = malloc(screenshot_length);
73
 
60
 
74
	loop() switch(WaitEvent())
61
	loop() switch(WaitEvent())
75
	{
62
	{
76
	case evButton:
-
 
77
		id = GetButtonID();
63
	case evButton:
78
		if (id == CLOSE_BTN) ExitProcess();
64
		id = GetButtonID();
Line 79... Line 65...
79
		if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot();
65
		if (id == CLOSE_BTN) ExitProcess();
80
		if (id == BTN_SAVE) EventSaveImageFile();
66
		if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot();
81
		if (id == BTN_SETTINGS) EventShowSettings();
-
 
82
		break;
67
		if (id == BTN_SETTINGS) EventShowSettings();
83
 
68
		break;
Line 84... Line 69...
84
	case evKey:
69
 
-
 
70
	case evKey:
85
		GetKeys();
71
		GetKeys();
86
		if (SCAN_CODE_KEY_S == key_scancode) EventSaveImageFile();
72
		if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot();
87
		if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot();
73
		break;
88
		break;
74
     
89
     
-
 
90
	case evReDraw:
75
	case evReDraw:
91
		DefineAndDrawWindow(screen.width/4, screen.height/4, pw.w + 9 +PD+PD, 
76
		system.color.get();
92
			pw.h + skin_height + TOOLBAR_H + 4 +PD+PD, 0x74, 0, T_WTITLE,0);
77
		DefineAndDrawWindow(screen.width/4, screen.height-100/3, 270, 
Line 93... Line 78...
93
		GetProcessInfo(#Form, SelfInfo);
78
			skin_height + 27+PD+PD, 0x34, system.color.work, T_WTITLE,0);
94
		if (Form.status_window>2) break;
79
		GetProcessInfo(#Form, SelfInfo);
95
		system.color.get();
80
		if (Form.status_window>2) break;
96
		DrawMainContent();
-
 
97
	}
-
 
98
}
-
 
99
 
81
		DrawMainContent();
100
void DrawMainContent()
-
 
101
{
-
 
102
	int take_scr_btn_width;
-
 
103
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H, system.color.work);
-
 
104
	DrawWideRectangle(0, TOOLBAR_H, pw.w+PD+PD, pw.h+PD+PD, PD-1, system.color.work);
-
 
105
	DrawRectangle(pw.x-1, pw.y-1, pw.w+1, pw.h+1, system.color.work_graph);
-
 
106
	take_scr_btn_width = DrawIconButton(pw.x, pw.y-42, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 44);
-
 
107
	if (ESDWORD[preview]==0) {
-
 
108
		DrawBar(pw.x, pw.y, pw.w, pw.h, 0xEEEeee);
82
	}
109
		WriteText(Form.cwidth-calc(strlen(T_PREVIEW)*8)/2, pw.h/2+pw.y, 0x90, 0x777777, T_PREVIEW);
83
}
Line 110... Line 84...
110
	}
84
 
111
	else {
85
void DrawMainContent()
112
		_PutImage(pw.x, pw.y, pw.w, pw.h, preview);
86
{
113
		DrawIconButton(take_scr_btn_width + pw.x, pw.y-42, BTN_SAVE, T_SAVE, 5);
87
	int take_scr_btn_width;
114
	}
-
 
115
	DrawIconButton(Form.cwidth-40-PD, pw.y-42, BTN_SETTINGS, " ", 10);	
88
	take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 44);
116
}
89
	DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10);	
-
 
90
}
117
 
91
 
Line 118... Line 92...
118
void EventTakeScreenshot() {
92
void EventTakeScreenshot() {
119
	if (settings.minimise) MinimizeWindow(); 
93
	if (settings.minimise) MinimizeWindow(); 
120
	pause(settings.delay*100);
94
	pause(settings.delay*100);
Line 182... Line 156...
182
{
156
{
183
	return calc(ESBYTE[B+3] + ESBYTE[B] + ESBYTE[B-3]
157
	return calc(ESBYTE[B+3] + ESBYTE[B] + ESBYTE[B-3]
184
		+ ESBYTE[B-item_h] + ESBYTE[B+item_h] / 5);
158
		+ ESBYTE[B-item_h] + ESBYTE[B+item_h] / 5);
185
}
159
}
Line 186... Line -...
186
 
-
 
187
void ZoomImageTo50percent() {
-
 
188
	dword point_x = 0;
-
 
189
	dword item_h = screen.width * 3;
-
 
190
	dword small = preview;
-
 
191
	dword big = screenshot;
-
 
192
 
-
 
193
	while( (small <= preview + preview_length) && (big <= screenshot + screenshot_length ) ) {
-
 
194
		
-
 
195
		if (big <= screenshot + item_h) || (big >= screenshot + screenshot_length - item_h)
-
 
196
		{
-
 
197
			ESBYTE[small]   = ESBYTE[big];
-
 
198
			ESBYTE[small+1] = ESBYTE[big+1];
-
 
199
			ESBYTE[small+2] = ESBYTE[big+2];
-
 
200
		}
-
 
201
		else
-
 
202
		{
-
 
203
			ESBYTE[small]   = calc_rgb(big, item_h);
-
 
204
			ESBYTE[small+1] = calc_rgb(big+1, item_h);
-
 
205
			ESBYTE[small+2] = calc_rgb(big+2, item_h);
-
 
206
		}
-
 
207
	
-
 
208
		small+=3;
-
 
209
		big+=6;
-
 
210
 
-
 
211
		point_x+=2;
-
 
212
		if (point_x >= screen.width) 
-
 
213
		{
-
 
214
			big += item_h;
-
 
215
			point_x = 0;
-
 
216
		}
-
 
217
	}
-
 
218
}
-
 
219
 
160
 
220
int DrawIconButton(dword x, y, id, text, icon)
161
int DrawIconButton(dword x, y, id, text, icon)
221
{
162
{
222
	int btwidth;
163
	int btwidth;
223
	system.color.work_button = 0xFFFfff;
164
	system.color.work_button = 0xFFFfff;