Subversion Repositories Kolibri OS

Rev

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

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