Subversion Repositories Kolibri OS

Rev

Rev 7768 | Rev 7984 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7768 Rev 7806
1
//===================================================//
1
//===================================================//
2
//                                                   //
2
//                                                   //
3
//                       LIB                         //
3
//                       LIB                         //
4
//                                                   //
4
//                                                   //
5
//===================================================//
5
//===================================================//
6
 
6
 
7
#include "../lib/gui.h"
7
#include "../lib/gui.h"
8
#include "../lib/obj/box_lib.h"
8
#include "../lib/obj/box_lib.h"
9
#include "../lib/obj/proc_lib.h"
9
#include "../lib/obj/proc_lib.h"
10
#include "../lib/patterns/simple_open_dialog.h"
10
#include "../lib/patterns/simple_open_dialog.h"
11
 
11
 
12
//===================================================//
12
//===================================================//
13
//                                                   //
13
//                                                   //
14
//                       DATA                        //
14
//                       DATA                        //
15
//                                                   //
15
//                                                   //
16
//===================================================//
16
//===================================================//
17
 
17
 
18
//proc_info Form;
18
//proc_info Form;
19
#define WIN_W 450
19
#define WIN_W 450
20
 
20
 
21
char default_dir[] = "/rd/1";
21
char default_dir[] = "/rd/1";
22
od_filter filter2 = {0,0};
22
od_filter filter2 = {0,0};
23
 
23
 
24
char src_path[4096];
24
char src_path[4096];
25
char dst_path[4096];
25
char dst_path[4096];
26
edit_box src_box = {WIN_W-36-DOT_W,18,30,0xffffff,0x94AECE,0xFFFfff,
26
edit_box src_box = {WIN_W-36-DOT_W,18,30,0xffffff,0x94AECE,0xFFFfff,
27
	0xffffff,0x10000000,sizeof(src_path)-2,#src_path,0, ed_focus};
27
	0xffffff,0x10000000,sizeof(src_path)-2,#src_path,0, ed_focus};
28
edit_box dst_box = {WIN_W-36-DOT_W,18,85,0xffffff,0x94AECE,0xFFFfff,
28
edit_box dst_box = {WIN_W-36-DOT_W,18,85,0xffffff,0x94AECE,0xFFFfff,
29
	0xffffff,0x10000000,sizeof(dst_path)-2,#dst_path,0, 0b};
29
	0xffffff,0x10000000,sizeof(dst_path)-2,#dst_path,0, 0b};
30
 
30
 
31
enum {
31
enum {
32
	BID_EXIT_PRC=1,
32
	BID_EXIT_PRC=1,
33
	BID_SRC_OPEN,
33
	BID_SRC_OPEN,
34
	BID_DST_OPEN,
34
	BID_DST_OPEN,
35
	BID_GO
35
	BID_GO
36
};
36
};
37
 
37
 
38
#ifndef COPYING
38
#ifndef COPYING
39
	#define T_FIRST "First file:"
39
	#define T_FIRST "First file:"
40
	#define T_SECOND "Second file:"
40
	#define T_SECOND "Second file:"
41
	#define T_GO  " Compare "
41
	#define T_GO  " Compare "
42
#endif
42
#endif
43
 
43
 
44
#define READY 0
44
#define READY 0
45
int state=READY;
45
int state=READY;
46
 
46
 
47
//===================================================//
47
//===================================================//
48
//                                                   //
48
//                                                   //
49
//                       CODE                        //
49
//                       CODE                        //
50
//                                                   //
50
//                                                   //
51
//===================================================//
51
//===================================================//
52
 
52
 
53
void gui()
53
void gui()
54
{
54
{
55
	word btn;
55
	word btn;
56
	load_dll(boxlib, #box_lib_init,0);
56
	load_dll(boxlib, #box_lib_init,0);
57
	load_dll(Proc_lib,  #OpenDialog_init,0);
57
	load_dll(Proc_lib,  #OpenDialog_init,0);
58
	OpenDialog_init stdcall (#o_dialog);
58
	OpenDialog_init stdcall (#o_dialog);
59
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
59
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
60
 
60
 
61
	loop() switch(WaitEvent())
61
	loop() switch(WaitEvent())
62
	{
62
	{
63
		case evMouse:
63
		case evMouse:
64
			if (READY == state) {
64
			if (READY == state) {
65
				edit_box_mouse stdcall (#src_box);
65
				edit_box_mouse stdcall (#src_box);
66
				edit_box_mouse stdcall (#dst_box);				
66
				edit_box_mouse stdcall (#dst_box);				
67
			}
67
			}
68
			break;
68
			break;
69
 
69
 
70
		case evButton:
70
		case evButton:
71
			btn = @GetButtonID();
71
			btn = @GetButtonID();
72
			if (btn == BID_EXIT_PRC) ExitProcess();
72
			if (btn == BID_EXIT_PRC) ExitProcess();
73
			if (btn == BID_SRC_OPEN) EventOpenDialogFirst();
73
			if (btn == BID_SRC_OPEN) EventOpenDialogFirst();
74
			if (btn == BID_DST_OPEN) EventOpenDialogSecond();
74
			if (btn == BID_DST_OPEN) EventOpenDialogSecond();
75
			if (btn == BID_GO) EventGo();
75
			if (btn == BID_GO) EventGo();
76
			break;
76
			break;
77
	  
77
	  
78
		case evKey:
78
		case evKey:
79
			GetKeys();
79
			GetKeys();
80
			if (key_scancode == SCAN_CODE_ESC) ExitProcess();
80
			if (key_scancode == SCAN_CODE_ESC) ExitProcess();
81
			if (key_scancode == SCAN_CODE_TAB) EventTabClick();
81
			if (key_scancode == SCAN_CODE_TAB) EventTabClick();
82
			if (key_scancode == SCAN_CODE_ENTER) EventGo();
82
			if (key_scancode == SCAN_CODE_ENTER) EventGo();
83
			if (key_scancode == SCAN_CODE_INS) EventInsert();
83
			if (key_scancode == SCAN_CODE_INS) EventInsert();
84
			EAX = key_editbox;
84
			EAX = key_editbox;
85
			edit_box_key stdcall (#src_box);
85
			edit_box_key stdcall (#src_box);
86
			EAX = key_editbox;
86
			EAX = key_editbox;
87
			edit_box_key stdcall (#dst_box);
87
			edit_box_key stdcall (#dst_box);
88
			break;
88
			break;
89
		 
89
		 
90
		case evReDraw:
90
		case evReDraw:
91
			draw_window();
91
			draw_window();
92
			break;
92
			break;
93
	}
93
	}
94
}
94
}
95
 
95
 
96
void draw_window()
96
void draw_window()
97
{
97
{
98
	system.color.get();
98
	sc.get();
99
	DefineAndDrawWindow(215, 100, WIN_W+9, 170 + skin_height, 0x34, system.color.work, #window_title,0);
99
	DefineAndDrawWindow(215, 100, WIN_W+9, 170 + skin_height, 0x34, sc.work, #window_title,0);
100
	//GetProcessInfo(#Form, SelfInfo);
100
	//GetProcessInfo(#Form, SelfInfo);
101
	if (READY==state) {
101
	if (READY==state) {
102
		DrawFileBox(#src_box, T_FIRST, BID_SRC_OPEN);
102
		DrawFileBox(#src_box, T_FIRST, BID_SRC_OPEN);
103
		DrawFileBox(#dst_box, T_SECOND, BID_DST_OPEN);
103
		DrawFileBox(#dst_box, T_SECOND, BID_DST_OPEN);
104
		DrawStandartCaptButton(dst_box.left - 2, dst_box.top + 40, BID_GO, T_GO);
104
		DrawStandartCaptButton(dst_box.left - 2, dst_box.top + 40, BID_GO, T_GO);
105
	}
105
	}
106
	#ifdef COPYING
106
	#ifdef COPYING
107
	if (COPYING==state) {
107
	if (COPYING==state) {
108
		pr.frame_color = system.color.work_graph;
108
		pr.frame_color = sc.work_graph;
109
		DrawRectangle3D(PR_LEFT-1, PR_TOP-1, PR_W+1, PR_H+1, system.color.work_dark, 
109
		DrawRectangle3D(PR_LEFT-1, PR_TOP-1, PR_W+1, PR_H+1, sc.work_dark, 
110
			system.color.work_light);
110
			sc.work_light);
111
		DrawProgress();
111
		DrawProgress();
112
		DrawStandartCaptButton(-19*8+WIN_W/2-15, dst_box.top + 35, B_STOP, "        Stop       ");
112
		DrawStandartCaptButton(-19*8+WIN_W/2-15, dst_box.top + 35, B_STOP, "        Stop       ");
113
	}
113
	}
114
	#endif
114
	#endif
115
}
115
}
116
 
116
 
117
void UpdateEditBoxes(dword f1, f2)
117
void UpdateEditBoxes(dword f1, f2)
118
{
118
{
119
	EditBox_UpdateText(#src_box, f1);
119
	EditBox_UpdateText(#src_box, f1);
120
	EditBox_UpdateText(#dst_box, f2);
120
	EditBox_UpdateText(#dst_box, f2);
121
	edit_box_draw stdcall (#src_box);
121
	edit_box_draw stdcall (#src_box);
122
	edit_box_draw stdcall (#dst_box);
122
	edit_box_draw stdcall (#dst_box);
123
}
123
}
124
 
124
 
125
//===================================================//
125
//===================================================//
126
//                                                   //
126
//                                                   //
127
//                     EVENTS                        //
127
//                     EVENTS                        //
128
//                                                   //
128
//                                                   //
129
//===================================================//
129
//===================================================//
130
 
130
 
131
#ifndef COPYING
131
#ifndef COPYING
132
void EventGo()
132
void EventGo()
133
{
133
{
134
	char run_param[4096];
134
	char run_param[4096];
135
	wsprintf(#run_param, "\"%s\" \"%s\"", #src_path, #dst_path);
135
	wsprintf(#run_param, "\"%s\" \"%s\"", #src_path, #dst_path);
136
	RunProgram(I_Path, #run_param);
136
	RunProgram(I_Path, #run_param);
137
}
137
}
138
#endif
138
#endif
139
 
139
 
140
void EventTabClick()
140
void EventTabClick()
141
{
141
{
142
	if ( src_box.flags & ed_focus ) {
142
	if ( src_box.flags & ed_focus ) {
143
		UpdateEditBoxes(0, ed_focus);
143
		UpdateEditBoxes(0, ed_focus);
144
	} else {
144
	} else {
145
		UpdateEditBoxes(ed_focus, 0);
145
		UpdateEditBoxes(ed_focus, 0);
146
	} 
146
	} 
147
}
147
}
148
 
148
 
149
void EventOpenDialogFirst()
149
void EventOpenDialogFirst()
150
{
150
{
151
	o_dialog.type = 0; //0-file, 1-save, 2-select folder
151
	o_dialog.type = 0; //0-file, 1-save, 2-select folder
152
	OpenDialog_start stdcall (#o_dialog);
152
	OpenDialog_start stdcall (#o_dialog);
153
	if (o_dialog.status) {
153
	if (o_dialog.status) {
154
		strcpy(#src_path, #openfile_path);
154
		strcpy(#src_path, #openfile_path);
155
		UpdateEditBoxes(ed_focus, 0);
155
		UpdateEditBoxes(ed_focus, 0);
156
	}
156
	}
157
}
157
}
158
 
158
 
159
void EventOpenDialogSecond()
159
void EventOpenDialogSecond()
160
{
160
{
161
	#ifdef COPYING
161
	#ifdef COPYING
162
	o_dialog.type = 1; //0-file, 1-save, 2-select folder
162
	o_dialog.type = 1; //0-file, 1-save, 2-select folder
163
	#endif
163
	#endif
164
	OpenDialog_start stdcall (#o_dialog);
164
	OpenDialog_start stdcall (#o_dialog);
165
	if (o_dialog.status) {
165
	if (o_dialog.status) {
166
		strcpy(#dst_path, #openfile_path);
166
		strcpy(#dst_path, #openfile_path);
167
		UpdateEditBoxes(0, ed_focus);
167
		UpdateEditBoxes(0, ed_focus);
168
	}
168
	}
169
}
169
}
170
 
170
 
171
void EventInsert()
171
void EventInsert()
172
{
172
{
173
	if ( src_box.flags & ed_focus ) EventOpenDialogFirst();
173
	if ( src_box.flags & ed_focus ) EventOpenDialogFirst();
174
	if ( dst_box.flags & ed_focus ) EventOpenDialogSecond();
174
	if ( dst_box.flags & ed_focus ) EventOpenDialogSecond();
175
}
175
}