Subversion Repositories Kolibri OS

Rev

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

Rev 7771 Rev 7783
Line 12... Line 12...
12
	#include "lang.h--"
12
	#include "lang.h--"
13
#endif
13
#endif
Line 14... Line 14...
14
 
14
 
Line 15... Line -...
15
/* === TRANSLATIONS === */
-
 
16
 
-
 
17
#define T_WTITLE "EasyShot v1.1"
15
/* === TRANSLATIONS === */
18
 
16
 
19
#ifdef LANG_RUS
17
#ifdef LANG_RUS
20
	?define T_TAKE_SCREENSHOT "  ‘¤¥« âì áªà¨­è®â"
18
	?define T_TAKE_SCREENSHOT "‘¤¥« âì áªà¨­è®â"
21
	?define T_SETTINGS " áâனª¨"
-
 
22
	?define T_EDITBOX_FRAME " ãâì á®åà ­¥­¨ï áªà¨­è®â  "
19
	?define T_SETTINGS " áâனª¨"
23
	?define T_CONTINUOUS_SHOOTING "Continuous shooting"
20
	?define T_EDITBOX_FRAME "ãâì á®åà ­¥­¨ï áªà¨­è®â "
24
	?define T_DELAY "‡ ¤¥à¦ª  ¢ ᥪ㭤 å"
-
 
25
	?define T_NO_DIR "' ¯ª  ­¥ áãé¥áâ¢ã¥â!' -E"
21
	?define T_DELAY "‡ ¤¥à¦ª  ¢ ᥪ㭤 å"
26
	?define T_SET_PATH "‡ ¤ âì"
22
	?define T_NO_DIR "' ¯ª  ­¥ áãé¥áâ¢ã¥â!' -E"
27
#else
23
#else
28
	?define T_TAKE_SCREENSHOT "  Take a screenshot"
24
	?define T_TAKE_SCREENSHOT "Take a screenshot"
29
	?define T_SETTINGS "Settings"
-
 
30
	?define T_EDITBOX_FRAME " Save path "
25
	?define T_SETTINGS "Settings"
31
	?define T_CONTINUOUS_SHOOTING "Continuous shooting"
26
	?define T_EDITBOX_FRAME "Save path"
32
	?define T_DELAY "Delay in seconds"
-
 
33
	?define T_NO_DIR "'Directory does not exists!' -E"
27
	?define T_DELAY "Delay in seconds"
Line 34... Line 28...
34
	?define T_SET_PATH "Set"
28
	?define T_NO_DIR "'Directory does not exists!' -E"
Line 35... Line 29...
35
#endif
29
#endif
36
 
-
 
37
/* === DATA === */	
-
 
38
 
-
 
39
proc_info Form;
-
 
Line 40... Line 30...
40
proc_info Settings;
30
 
41
 
31
/* === DATA === */	
42
dword screenshot;
32
 
-
 
33
proc_info Form;
43
int screenshot_length;
34
 
Line 44... Line 35...
44
 
35
enum {
-
 
36
	BTN_MAKE_SCREENSHOT=10,
Line 45... Line 37...
45
enum {
37
	BTN_SETTINGS,
46
	BTN_MAKE_SCREENSHOT=10,
-
 
47
	BTN_SETTINGS
38
	BTN_CHOOSE_SAVING_PATH
Line -... Line 39...
-
 
39
};
48
};
40
 
49
 
41
#define PD 18 //padding
Line 50... Line 42...
50
#define PD 18 //padding
42
#define SETTINGS_Y PD+PD+30+10
51
 
-
 
52
char save_path[4096];
-
 
Line 53... Line 43...
53
char save_path_stable[4096];
43
 
54
char open_dir[4096];
44
char save_path[4096];
55
 
45
char open_dir[4096];
56
edit_box edit_save = {250,25,100,0xffffff,0x94AECE,0xFFFfff,0xffffff,
46
 
57
	0x10000000,sizeof(save_path)-2,#save_path,0, 0b};
47
more_less_box delay = { 1, 0, SETTINGS_Y, T_DELAY };
58
 
48
edit_box edit_save = {260,PD,SETTINGS_Y+50,0xffffff,0x94AECE,0xFFFfff,0xffffff,
59
more_less_box delay = { 1, 0, 64, T_DELAY };
49
	0x10000000,sizeof(save_path)-2,#save_path,0, 0b};
60
checkbox continuous_shooting = { T_CONTINUOUS_SHOOTING, true };
50
 
61
 
51
bool show_settings = false;
62
 
52
 
63
opendialog open_folder_dialog = 
53
opendialog open_folder_dialog = 
64
{
54
{
65
  2, //0-file, 2-save, 3-select folder
55
  2, //0-file, 2-save, 3-select folder
66
  #Settings,
56
  #Form,
67
  #communication_area_name,
57
  #communication_area_name,
Line 80... Line 70...
80
  NULL
70
  NULL
81
};
71
};
Line 82... Line 72...
82
 
72
 
Line 83... Line 73...
83
/* === CODE === */
73
/* === CODE === */
84
 
74
 
85
void main()
-
 
86
{	
-
 
87
	int id;
75
void init_libraries()
88
 
76
{
89
	load_dll(libio,  #libio_init,  1);
77
	load_dll(libio,  #libio_init,  1);
90
	load_dll(libimg, #libimg_init, 1);
78
	load_dll(libimg, #libimg_init, 1);
91
	load_dll(boxlib, #box_lib_init,0);
79
	load_dll(boxlib, #box_lib_init,0);
-
 
80
	load_dll(Proc_lib,  #OpenDialog_init,0);
Line 92... Line 81...
92
	load_dll(Proc_lib,  #OpenDialog_init,0);
81
	OpenDialog_init stdcall (#open_folder_dialog);	
93
	OpenDialog_init stdcall (#open_folder_dialog);
-
 
94
 
-
 
95
	system.color.get();
-
 
96
	Libimg_LoadImage(#skin, "/sys/icons16.png");
-
 
97
	Libimg_ReplaceColor(skin.image, skin.w, skin.h, 0xffFFFfff, system.color.work_button);
-
 
98
	Libimg_ReplaceColor(skin.image, skin.w, skin.h, 0xffCACBD6, MixColors(system.color.work_button, 0, 200));
82
}
99
	screenshot_length = screen.width * screen.height * 3;
-
 
100
	screenshot = malloc(screenshot_length);
-
 
101
 
83
 
Line -... Line 84...
-
 
84
void main()
-
 
85
{	
-
 
86
	int id;
-
 
87
 
-
 
88
	init_libraries();
-
 
89
 
102
	strcpy(#save_path_stable, "/tmp0/1");
90
	strcpy(#save_path, "/tmp0/1");
103
	strcpy(#save_path, #save_path_stable);
91
	EditBox_UpdateText(#edit_save, 0);
-
 
92
 
-
 
93
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
-
 
94
	loop() switch(WaitEvent())
-
 
95
	{
104
	edit_save.size = strlen(#save_path);
96
	case evMouse:
105
 
97
		edit_box_mouse stdcall (#edit_save);
-
 
98
		break;
106
	loop() switch(WaitEvent())
99
 
107
	{
100
	case evButton:
108
	case evButton:
101
		id = GetButtonID();
-
 
102
		switch(id){
-
 
103
			case CLOSE_BTN: ExitProcess();
-
 
104
			case BTN_MAKE_SCREENSHOT: EventTakeScreenshot(); break;
109
		id = GetButtonID();
105
			case BTN_SETTINGS: EventClickSettings(); break;
Line 110... Line 106...
110
		if (id == CLOSE_BTN) ExitProcess();
106
			case BTN_CHOOSE_SAVING_PATH: EventChooseSavePath(); break;
111
		if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot();
107
			default: delay.click(id);
112
		if (id == BTN_SETTINGS) CreateThread(#SettingsWindow,#settings_stak+4092);
108
		}
-
 
109
		break;
-
 
110
 
-
 
111
	case evKey:
113
		break;
112
		GetKeys();
Line 114... Line 113...
114
 
113
		if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot();
115
	case evKey:
-
 
116
		GetKeys();
-
 
117
		if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot();
-
 
118
		break;
114
		if (SCAN_CODE_ESC == key_scancode) ExitProcess();
119
     
115
		EAX = key_editbox;
120
	case evReDraw:
116
		edit_box_key stdcall (#edit_save);	
Line -... Line 117...
-
 
117
		break;
121
		DefineAndDrawWindow(screen.width/4, screen.height-100/3, 270, 
118
     
122
			skin_height + 27+PD+PD, 0x34, system.color.work, T_WTITLE,0);
119
	case evReDraw:
123
		GetProcessInfo(#Form, SelfInfo);
120
		DrawWindow();
124
		DrawMainContent();
-
 
125
	}
-
 
126
}
-
 
Line 127... Line -...
127
 
-
 
128
void DrawMainContent()
121
	}
129
{
-
 
130
	int take_scr_btn_width;
122
}
131
	take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 45);
123
 
132
	DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10);	
124
 
133
}
-
 
Line 134... Line -...
134
 
-
 
135
void EventTakeScreenshot() {
-
 
136
	MinimizeWindow(); 
-
 
137
	pause(delay.value*100);
-
 
138
	CopyScreen(screenshot, 0, 0, screen.width, screen.height);
-
 
139
	ActivateWindow(GetProcessSlot(Form.ID));
-
 
140
	EventSaveImageFile();
125
void DrawWindow()
141
}
126
{
142
 
127
	int i;
143
void EventSaveImageFile()
-
 
144
{
128
 
145
	int i=0;
-
 
146
	char save_file_name[4096];
129
	system.color.get();
147
	do {
130
	DefineAndDrawWindow(screen.width-400, screen.height/3, 270, 
Line 148... Line 131...
148
		i++;
131
		skin_height + 30+PD+PD, 0x34, system.color.work, "EasyShot",0);
149
		//sprintf(, "%s/screen_%i.png", #save_path_stable, i);
132
	GetProcessInfo(#Form, SelfInfo);
150
		strcpy(#save_file_name, #save_path_stable);
-
 
151
		strcat(#save_file_name, "/screen_");
-
 
152
		strcat(#save_file_name, itoa(i));
-
 
153
		strcat(#save_file_name, ".png");
-
 
154
	} while (file_exists(#save_file_name));
-
 
155
	save_image(screenshot, screen.width, screen.height, #save_file_name);
-
 
156
}
-
 
157
 
-
 
158
 
-
 
159
void SettingsWindow()
-
 
160
{
-
 
161
	#define BTN_OD 10
-
 
162
	#define BTN_SET 11
-
 
163
	int id, butw;
-
 
164
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
-
 
165
	loop() switch(WaitEvent())
-
 
166
	{
-
 
167
	case evMouse:
-
 
168
		edit_box_mouse stdcall (#edit_save);
-
 
169
		break;
-
 
170
 
-
 
171
	case evKey:
133
 
172
		GetKeys();
134
	DrawCaptButton(PD, PD, 170, 28, BTN_MAKE_SCREENSHOT, 0x0090B8, 0xFFFfff, T_TAKE_SCREENSHOT);
173
		if (SCAN_CODE_ESC == key_scancode) ExitProcess();
135
	DefineButton(PD+170+20, PD, 35, 28, BTN_SETTINGS, system.color.work_button);
174
		EAX = key_editbox;
136
	for (i=0; i<=2; i++) DrawBar(PD+170+30, i*5+PD+9, 15, 2, system.color.work_button_text);
175
		edit_box_key stdcall (#edit_save);	
-
 
176
		break;
-
 
177
 
137
	delay.draw(PD, SETTINGS_Y);
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);
138
	DrawFileBox(#edit_save, T_EDITBOX_FRAME, BTN_CHOOSE_SAVING_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) {
-
 
Line 190... Line -...
190
			if (save_path[0]) && (dir_exists(#save_path)) {
-
 
191
				strcpy(#save_path_stable, #save_path);
-
 
192
				strrtrim(#save_path_stable);
-
 
193
				if (save_path_stable[strlen(#save_path_stable)-1]=='/')
-
 
Line 194... Line 139...
194
				    save_path_stable[strlen(#save_path_stable)-1]=NULL; //no "/" at the end
139
}
195
			}
140
 
196
			else notify(T_NO_DIR);
-
 
197
 
-
 
198
		}
141
 
199
		delay.click(id);
142
void EventChooseSavePath()
200
		break;
143
{
201
 
-
 
202
	case evReDraw:
-
 
203
		DrawSettingsWindow();
144
	OpenDialog_start stdcall (#open_folder_dialog);
Line -... Line 145...
-
 
145
	if (open_folder_dialog.status) {
204
	}
146
		strcpy(#save_path, open_folder_dialog.opendir_path);
205
}
147
		EditBox_UpdateText(#edit_save, 0);		
206
 
148
	}
-
 
149
}
-
 
150
 
-
 
151
 
-
 
152
void EventClickSettings()
-
 
153
{
-
 
154
	show_settings ^= 1;
-
 
155
	MoveSize(OLD, OLD, show_settings*75 + 270, 
207
void DrawSettingsWindow()
156
		show_settings*110 + skin_height + PD+PD+30);
-
 
157
}
208
{
158
 
-
 
159
 
-
 
160
void EventTakeScreenshot() 
-
 
161
{
-
 
162
	int i=0;
-
 
163
	char save_file_name[4096];
-
 
164
	static dword screenshot;
-
 
165
 
209
	DefineAndDrawWindow(Form.left+100, Form.top-40, 400, 230, 0x34, system.color.work, T_SETTINGS, 0);
166
	if (!screenshot) screenshot = malloc(screen.width * screen.height * 3);
210
	GetProcessInfo(#Settings, SelfInfo);
167
 
Line -... Line 168...
-
 
168
	do {
-
 
169
		i++;
-
 
170
		//sprintf(, "%s/screen_%i.png", #save_path, i);
-
 
171
		strcpy(#save_file_name, #save_path);
-
 
172
		if (save_file_name[strlen(#save_file_name)-1]!='/') chrcat(#save_file_name, '/');
211
	delay.draw(15, 30);
173
		strcat(#save_file_name, "screen_");
Line 212... Line -...
212
	DrawFrame(15, 85, 360, 95, T_EDITBOX_FRAME);
-
 
213
		DrawEditBoxPos(32, 110, #edit_save);
174
		strcat(#save_file_name, itoa(i));