Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7506 → Rev 7658

/programs/cmm/diff/diff_gui.h
1,80 → 1,86
//===================================================//
// //
// LIB //
// //
//===================================================//
 
#include "../lib/gui.h"
#include "../lib/obj/box_lib.h"
#include "../lib/obj/proc_lib.h"
#include "../lib/patterns/simple_open_dialog.h"
 
//===================================================//
// //
// DATA //
// //
//===================================================//
 
//proc_info Form;
#define WIN_W 450
 
char default_dir[] = "/rd/1";
od_filter filter2 = {0,0};
 
char src_box_text[4096];
char dst_box_text[4096];
edit_box src_box = {340,20,35,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(src_box_text)-2,#src_box_text,0, ed_focus};
edit_box dst_box = {340,20,95,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(dst_box_text)-2,#dst_box_text,0, 0b};
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};
 
#define BID_EXIT_PRC 01
#define BID_SRC_OPEN 10
#define BID_DST_OPEN 11
#define BID_COMPARE 12
enum {
BID_EXIT_PRC=1,
BID_SRC_OPEN,
BID_DST_OPEN,
BID_GO
};
 
proc_info Form;
#ifndef COPYING
#define T_FIRST "First file:"
#define T_SECOND "Second file:"
#define T_GO " Compare "
#endif
 
#define READY 0
int state=READY;
 
//===================================================//
// //
// CODE //
// //
//===================================================//
 
void gui()
{
word btn;
char run_param[4096];
load_dll(boxlib, #box_lib_init,0);
load_dll(Proc_lib, #OpenDialog_init,0);
OpenDialog_init stdcall (#o_dialog);
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
 
loop() switch(WaitEvent())
{
case evMouse:
if (READY == state) {
edit_box_mouse stdcall (#src_box);
edit_box_mouse stdcall (#dst_box);
}
break;
 
case evButton:
btn = GetButtonID();
switch (btn)
{
case BID_EXIT_PRC:
ExitProcess();
case BID_SRC_OPEN:
OpenDialog_start stdcall (#o_dialog);
if (o_dialog.status) {
strcpy(#src_box_text, #openfile_path);
EditBox_UpdateText(#src_box, #src_box.flags);
}
btn = @GetButtonID();
if (btn == BID_EXIT_PRC) ExitProcess();
if (btn == BID_SRC_OPEN) EventOpenDialogFirst();
if (btn == BID_DST_OPEN) EventOpenDialogSecond();
if (btn == BID_GO) EventGo();
break;
case BID_DST_OPEN:
OpenDialog_start stdcall (#o_dialog);
if (o_dialog.status) {
strcpy(#dst_box_text, #openfile_path);
EditBox_UpdateText(#dst_box, #dst_box.flags);
}
break;
case BID_COMPARE:
sprintf(#run_param, "\"%s\" \"%s\"", #src_box_text, #dst_box_text);
io.run(I_Path, #run_param);
break;
}
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
if (key_scancode == SCAN_CODE_TAB) {
if ( src_box.flags & ed_focus ) {
src_box.flags -= ed_focus;
dst_box.flags += ed_focus;
} else {
src_box.flags += ed_focus;
dst_box.flags -= ed_focus;
}
edit_box_draw stdcall (#src_box);
edit_box_draw stdcall (#dst_box);
}
if (key_scancode == SCAN_CODE_TAB) EventTabClick();
if (key_scancode == SCAN_CODE_ENTER) EventGo();
if (key_scancode == SCAN_CODE_INS) EventInsert();
EAX = key_editbox;
edit_box_key stdcall (#src_box);
EAX = key_editbox;
90,14 → 96,80
void draw_window()
{
system.color.get();
DefineAndDrawWindow(215, 100, 450, 195 + skin_height, 0x34, system.color.work, #window_title,0);
GetProcessInfo(#Form, SelfInfo);
DefineAndDrawWindow(215, 100, WIN_W+9, 170 + skin_height, 0x34, system.color.work, #window_title,0);
//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);
}
#ifdef COPYING
if (COPYING==state) {
pr.frame_color = system.color.work_graph;
DrawRectangle3D(PR_LEFT-1, PR_TOP-1, PR_W+1, PR_H+1, system.color.work_dark,
system.color.work_light);
DrawProgress();
DrawStandartCaptButton(-19*8+WIN_W/2-15, dst_box.top + 35, B_STOP, " Stop ");
}
#endif
}
 
WriteText(src_box.left-2, src_box.top-21, 0x90, system.color.work_text, "First file:");
WriteText(dst_box.left-2, dst_box.top-21, 0x90, system.color.work_text, "Second file:");
DrawEditBox(#src_box);
DrawEditBox(#dst_box);
DrawStandartCaptButton(src_box.left + src_box.width + 15, src_box.top-3, BID_SRC_OPEN, "...");
DrawStandartCaptButton(dst_box.left + dst_box.width + 15, dst_box.top-3, BID_DST_OPEN, "...");
DrawStandartCaptButton(dst_box.left - 2, dst_box.top + 40, BID_COMPARE, "Compare");
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 //
// //
//===================================================//
 
#ifndef COPYING
void EventGo()
{
char run_param[4096];
sprintf(#run_param, "\"%s\" \"%s\"", #src_path, #dst_path);
RunProgram(I_Path, #run_param);
}
#endif
 
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()
{
#ifdef COPYING
o_dialog.type = 1; //0-file, 1-save, 2-select folder
#endif
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();
}