Subversion Repositories Kolibri OS

Rev

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

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