2019-05-16 13:48:21 +03:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// LIB //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
2016-11-21 00:48:03 +03:00
|
|
|
#include "../lib/gui.h"
|
|
|
|
#include "../lib/obj/box_lib.h"
|
|
|
|
#include "../lib/obj/proc_lib.h"
|
|
|
|
#include "../lib/patterns/simple_open_dialog.h"
|
|
|
|
|
2019-05-16 13:48:21 +03:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// DATA //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
//proc_info Form;
|
|
|
|
#define WIN_W 450
|
|
|
|
|
2016-11-21 00:48:03 +03:00
|
|
|
char default_dir[] = "/rd/1";
|
|
|
|
od_filter filter2 = {0,0};
|
|
|
|
|
2019-05-16 13:48:21 +03:00
|
|
|
char src_path[4096];
|
|
|
|
char dst_path[4096];
|
|
|
|
edit_box src_box = {WIN_W-36-DOT_W,18,30,0xffffff,0x94AECE,0xFFFfff,
|
|
|
|
0xffffff,0x10000000,sizeof(src_path)-2,#src_path,0, ed_focus};
|
|
|
|
edit_box dst_box = {WIN_W-36-DOT_W,18,85,0xffffff,0x94AECE,0xFFFfff,
|
|
|
|
0xffffff,0x10000000,sizeof(dst_path)-2,#dst_path,0, 0b};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
BID_EXIT_PRC=1,
|
|
|
|
BID_SRC_OPEN,
|
|
|
|
BID_DST_OPEN,
|
|
|
|
BID_GO
|
|
|
|
};
|
|
|
|
|
2020-05-26 03:17:12 +03:00
|
|
|
#define T_FIRST "First file:"
|
|
|
|
#define T_SECOND "Second file:"
|
|
|
|
#define T_GO " Compare "
|
|
|
|
|
2016-11-21 00:48:03 +03:00
|
|
|
|
2019-05-16 13:48:21 +03:00
|
|
|
#define READY 0
|
|
|
|
int state=READY;
|
2016-11-21 00:48:03 +03:00
|
|
|
|
2019-05-16 13:48:21 +03:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// CODE //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
2016-11-21 00:48:03 +03:00
|
|
|
|
|
|
|
void gui()
|
|
|
|
{
|
2020-05-26 03:17:12 +03:00
|
|
|
#define NO_DLL_INIT
|
2016-11-21 00:48:03 +03:00
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
|
|
|
OpenDialog_init stdcall (#o_dialog);
|
2020-05-26 03:17:12 +03:00
|
|
|
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
2016-11-21 00:48:03 +03:00
|
|
|
|
2020-05-26 03:17:12 +03:00
|
|
|
loop() switch(@WaitEvent())
|
2016-11-21 00:48:03 +03:00
|
|
|
{
|
|
|
|
case evMouse:
|
2019-05-16 13:48:21 +03:00
|
|
|
if (READY == state) {
|
|
|
|
edit_box_mouse stdcall (#src_box);
|
|
|
|
edit_box_mouse stdcall (#dst_box);
|
|
|
|
}
|
2016-11-21 00:48:03 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case evButton:
|
2020-05-26 03:17:12 +03:00
|
|
|
@GetButtonID();
|
|
|
|
if (EAX == BID_EXIT_PRC) ExitProcess();
|
|
|
|
if (EAX == BID_SRC_OPEN) EventOpenDialogFirst();
|
|
|
|
if (EAX == BID_DST_OPEN) EventOpenDialogSecond();
|
|
|
|
if (EAX == BID_GO) EventGo();
|
2016-11-21 00:48:03 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case evKey:
|
2020-05-26 03:17:12 +03:00
|
|
|
@GetKey();
|
2016-11-21 00:48:03 +03:00
|
|
|
edit_box_key stdcall (#src_box);
|
|
|
|
edit_box_key stdcall (#dst_box);
|
2020-05-26 03:17:12 +03:00
|
|
|
EAX >>= 16;
|
|
|
|
if (AL == SCAN_CODE_ESC) ExitProcess();
|
|
|
|
if (AL == SCAN_CODE_TAB) EventTabClick();
|
|
|
|
if (AL == SCAN_CODE_ENTER) EventGo();
|
|
|
|
if (AL == SCAN_CODE_INS) EventInsert();
|
2016-11-21 00:48:03 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case evReDraw:
|
|
|
|
draw_window();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void draw_window()
|
|
|
|
{
|
2020-04-18 02:52:24 +03:00
|
|
|
sc.get();
|
|
|
|
DefineAndDrawWindow(215, 100, WIN_W+9, 170 + skin_height, 0x34, sc.work, #window_title,0);
|
2019-05-16 13:48:21 +03:00
|
|
|
//GetProcessInfo(#Form, SelfInfo);
|
|
|
|
if (READY==state) {
|
|
|
|
DrawFileBox(#src_box, T_FIRST, BID_SRC_OPEN);
|
|
|
|
DrawFileBox(#dst_box, T_SECOND, BID_DST_OPEN);
|
|
|
|
DrawStandartCaptButton(dst_box.left - 2, dst_box.top + 40, BID_GO, T_GO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateEditBoxes(dword f1, f2)
|
|
|
|
{
|
|
|
|
EditBox_UpdateText(#src_box, f1);
|
|
|
|
EditBox_UpdateText(#dst_box, f2);
|
|
|
|
edit_box_draw stdcall (#src_box);
|
|
|
|
edit_box_draw stdcall (#dst_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// EVENTS //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
void EventGo()
|
|
|
|
{
|
|
|
|
char run_param[4096];
|
2020-04-05 22:29:24 +03:00
|
|
|
wsprintf(#run_param, "\"%s\" \"%s\"", #src_path, #dst_path);
|
2019-05-16 13:48:21 +03:00
|
|
|
RunProgram(I_Path, #run_param);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventTabClick()
|
|
|
|
{
|
|
|
|
if ( src_box.flags & ed_focus ) {
|
|
|
|
UpdateEditBoxes(0, ed_focus);
|
|
|
|
} else {
|
|
|
|
UpdateEditBoxes(ed_focus, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventOpenDialogFirst()
|
|
|
|
{
|
|
|
|
o_dialog.type = 0; //0-file, 1-save, 2-select folder
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
|
|
|
if (o_dialog.status) {
|
|
|
|
strcpy(#src_path, #openfile_path);
|
|
|
|
UpdateEditBoxes(ed_focus, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventOpenDialogSecond()
|
|
|
|
{
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
|
|
|
if (o_dialog.status) {
|
|
|
|
strcpy(#dst_path, #openfile_path);
|
|
|
|
UpdateEditBoxes(0, ed_focus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventInsert()
|
|
|
|
{
|
|
|
|
if ( src_box.flags & ed_focus ) EventOpenDialogFirst();
|
|
|
|
if ( dst_box.flags & ed_focus ) EventOpenDialogSecond();
|
2016-11-21 00:48:03 +03:00
|
|
|
}
|