Corretta disable
git-svn-id: svn://10.65.10.50/trunk@766 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
37c1f28282
commit
f5a342a935
346
ba/ba2300.cpp
346
ba/ba2300.cpp
@ -33,16 +33,16 @@
|
||||
#define __BA2300_CPP
|
||||
#include <ba2300.h>
|
||||
|
||||
FILE* mirror;
|
||||
FILE* mirror2;
|
||||
FILE* current;
|
||||
FILE* printerlist;
|
||||
FILE* codes;
|
||||
FILE* names;
|
||||
FILE* defcodes;
|
||||
FILE* defnames;
|
||||
FILE* mirror;
|
||||
FILE* mirror2;
|
||||
FILE* current;
|
||||
FILE* printerlist;
|
||||
FILE* codes;
|
||||
FILE* names;
|
||||
FILE* defcodes;
|
||||
FILE* defnames;
|
||||
|
||||
int selprinter=1;
|
||||
int selprinter=1;
|
||||
|
||||
|
||||
void build_list_file (FILE* inputfile, TFilename& outputfile)
|
||||
@ -91,7 +91,7 @@ bool seek_default_printer (FILE* inputfile, TString& newprinter, long* position,
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool seek_printer (FILE* inputfile, TString& printer, long* position, bool justafter)
|
||||
{
|
||||
@ -195,9 +195,9 @@ bool build_code_files (FILE* input, TFilename& outcdfile, TFilename& outnmfile,
|
||||
{
|
||||
TString junk;
|
||||
TToken_string j2;
|
||||
long pos;
|
||||
long pos;
|
||||
int i;
|
||||
FILE *codes, *names;
|
||||
FILE *codes, *names;
|
||||
|
||||
if (is_present(input, printer))
|
||||
{
|
||||
@ -344,41 +344,41 @@ protected:
|
||||
public:
|
||||
void fill_mask (TMask& mask, bool inrun=FALSE);
|
||||
void fill_print_codes (TMask& mask);
|
||||
virtual bool menu (MENU_TAG);
|
||||
void set_current_printer (TString newprinter) { _currentprinter=newprinter; }
|
||||
virtual bool menu (MENU_TAG);
|
||||
void set_current_printer (TString newprinter) { _currentprinter=newprinter; }
|
||||
void update_codes_file (TString str, int pos);
|
||||
void update_names_file (TString& str, int items);
|
||||
};
|
||||
|
||||
bool codes_on_key (TMask_field& f, KEY key);
|
||||
bool add_on_key (TMask_field& f, KEY key);
|
||||
bool names_on_key (TMask_field& f, KEY key);
|
||||
bool prev_on_key (TMask_field& f, KEY key);
|
||||
bool next_on_key (TMask_field& f, KEY key);
|
||||
bool codes_on_key (TMask_field& f, KEY key);
|
||||
bool add_on_key (TMask_field& f, KEY key);
|
||||
bool names_on_key (TMask_field& f, KEY key);
|
||||
bool prev_on_key (TMask_field& f, KEY key);
|
||||
bool next_on_key (TMask_field& f, KEY key);
|
||||
|
||||
// global application
|
||||
EPF_Application epf;
|
||||
|
||||
// Constructor
|
||||
EPF_Application::EPF_Application ():
|
||||
_plname(FILE_PRINTERS),
|
||||
_cdname(FILE_CODES),
|
||||
_nmname(FILE_NAMES),
|
||||
_dcdname(FILE_DEF_CODES),
|
||||
_dnmname(FILE_DEF_NAMES),
|
||||
_isnamed(FALSE),
|
||||
_isopened(FALSE),
|
||||
_haschanged(FALSE),
|
||||
_currentname("printer.ini")
|
||||
{
|
||||
_mirrorname=tmpnam(NULL);
|
||||
_mir2name=tmpnam(NULL);
|
||||
reset_mirror ();
|
||||
set_files_to_default ();
|
||||
reset_mirror();
|
||||
make_mirror();
|
||||
_isopened=TRUE;
|
||||
}
|
||||
_plname(FILE_PRINTERS),
|
||||
_cdname(FILE_CODES),
|
||||
_nmname(FILE_NAMES),
|
||||
_dcdname(FILE_DEF_CODES),
|
||||
_dnmname(FILE_DEF_NAMES),
|
||||
_isnamed(FALSE),
|
||||
_isopened(FALSE),
|
||||
_haschanged(FALSE),
|
||||
_currentname("printer.ini")
|
||||
{
|
||||
_mirrorname=tmpnam(NULL);
|
||||
_mir2name=tmpnam(NULL);
|
||||
reset_mirror ();
|
||||
set_files_to_default ();
|
||||
reset_mirror();
|
||||
make_mirror();
|
||||
_isopened=TRUE;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
EPF_Application::~EPF_Application ()
|
||||
@ -413,7 +413,7 @@ bool add_on_key (TMask_field& f, KEY key)
|
||||
junk = addmask.get(MSK_4_CODE);
|
||||
epf.update_names_file (junk, items);
|
||||
epf.fill_print_codes (f.mask());
|
||||
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -492,9 +492,9 @@ int EPF_Application::accept_current_name(bool mode)
|
||||
TString typespec(EXTENSION);
|
||||
char dirjunk[50];
|
||||
|
||||
// ritorna 0 se il file esiste
|
||||
// 1 se il file non esiste
|
||||
// 2 se l'operazioe e' stata interrotta
|
||||
// ritorna 0 se il file esiste
|
||||
// 1 se il file non esiste
|
||||
// 2 se l'operazioe e' stata interrotta
|
||||
|
||||
|
||||
#if XVT_OS == XVT_OS_DOS
|
||||
@ -505,18 +505,18 @@ int EPF_Application::accept_current_name(bool mode)
|
||||
strcpy(filetoopen.type, (char*)typespec);
|
||||
filetoopen.dir=_workdir;
|
||||
if (mode==OPEN) junk=open_file_dlg(&filetoopen, "Scegli un file di configurazione stampanti");
|
||||
else junk=save_file_dlg(&filetoopen, "Digita il nome del nuovo file");
|
||||
else junk=save_file_dlg(&filetoopen, "Digita il nome del nuovo file");
|
||||
if (junk==FL_BAD || junk==FL_CANCEL) return 2;
|
||||
if (mode==OPEN) _isnamed=TRUE;
|
||||
dir_to_str(&(filetoopen.dir), dirjunk, 50);
|
||||
_currentname.cut(0);
|
||||
_currentname << dirjunk << '/' << filetoopen.name;
|
||||
if (mode==OPEN) if ((current =fopen(_currentname, "r"))==NULL) return 1;
|
||||
else
|
||||
{
|
||||
fclose(current );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(current );
|
||||
return 0;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
@ -703,7 +703,7 @@ bool EPF_Application::select_printer ()
|
||||
|
||||
void EPF_Application::set_field (TMask& mask, int fldid, char* str, bool inrun)
|
||||
{
|
||||
mask.set(fldid, str);
|
||||
mask.set(fldid, str);
|
||||
}
|
||||
|
||||
void EPF_Application::fill_mask (TMask& mask, bool inrun) // a ba2300
|
||||
@ -772,7 +772,7 @@ void EPF_Application::fill_print_codes (TMask& mask)
|
||||
fgets(__tmp_string, 256, codes);
|
||||
ok = fgets(__tmp_string, 256, codes);
|
||||
if (ok) mask.set(MSK_23_CODES, __tmp_string);
|
||||
else mask.set(MSK_23_CODES, "");
|
||||
else mask.set(MSK_23_CODES, "");
|
||||
|
||||
fclose(codes);
|
||||
}
|
||||
@ -843,25 +843,25 @@ void EPF_Application::set_files_to_default ()
|
||||
codes=fopen(_cdname, "w");
|
||||
defcodes=fopen(_dcdname, "r");
|
||||
|
||||
if (defcodes != NULL)
|
||||
{
|
||||
while (fgets(__tmp_string, 256, defcodes))
|
||||
fputs(__tmp_string, codes);
|
||||
if (defcodes != NULL)
|
||||
{
|
||||
while (fgets(__tmp_string, 256, defcodes))
|
||||
fputs(__tmp_string, codes);
|
||||
|
||||
fclose(defcodes);
|
||||
}
|
||||
fclose(defcodes);
|
||||
}
|
||||
fclose(codes);
|
||||
|
||||
names=fopen(_nmname, "w");
|
||||
defnames=fopen(_dnmname, "r");
|
||||
if (defnames != NULL)
|
||||
{
|
||||
while (fgets(__tmp_string, 256, defnames))
|
||||
fputs (__tmp_string, names);
|
||||
if (defnames != NULL)
|
||||
{
|
||||
while (fgets(__tmp_string, 256, defnames))
|
||||
fputs (__tmp_string, names);
|
||||
|
||||
fclose(defnames);
|
||||
}
|
||||
fclose(names);
|
||||
fclose(defnames);
|
||||
}
|
||||
fclose(names);
|
||||
}
|
||||
|
||||
void EPF_Application::update_names_file (TString& str, int items)
|
||||
@ -916,129 +916,129 @@ bool EPF_Application::menu(MENU_TAG m)
|
||||
|
||||
switch (m)
|
||||
{
|
||||
case NEW_FILE:
|
||||
if (_haschanged) save_box();
|
||||
_isnamed=FALSE;
|
||||
junk=accept_current_name(OPEN); // da modificare in base a XVTILITY
|
||||
if (junk<2)
|
||||
case NEW_FILE:
|
||||
if (_haschanged) save_box();
|
||||
_isnamed=FALSE;
|
||||
junk=accept_current_name(OPEN); // da modificare in base a XVTILITY
|
||||
if (junk<2)
|
||||
{
|
||||
reset_mirror();
|
||||
_isopened=TRUE;
|
||||
_currentprinter="** new file **";
|
||||
}
|
||||
break;
|
||||
case OPEN_FILE:
|
||||
{
|
||||
// 0=file aperto esistente
|
||||
// 1=file aperto nuovo
|
||||
// 2=non aprire nessun file
|
||||
int open_status=0;
|
||||
long pos=0;
|
||||
|
||||
if (_haschanged) save_box();
|
||||
open_status=accept_current_name(OPEN); // in base a XVTILITY
|
||||
if (open_status==1) open_status=(create_box()?1:2);
|
||||
if (open_status<2) reset_mirror();
|
||||
if (open_status==0) make_mirror();
|
||||
if (open_status<2) _isopened=TRUE;
|
||||
current=fopen(_currentname, "r");
|
||||
seek_default_printer(current, _currentprinter, &pos);
|
||||
fclose(current);
|
||||
}
|
||||
break;
|
||||
case SAVE_FILE:
|
||||
if (_haschanged) save_file();
|
||||
_haschanged=FALSE;
|
||||
break;
|
||||
case SAVE_FILE_AS:
|
||||
save_file(TRUE);
|
||||
_haschanged=FALSE;
|
||||
break;
|
||||
case QUIT_EPF:
|
||||
if (_haschanged) save_box();
|
||||
xvt_terminate();
|
||||
break;
|
||||
case INSERT_PRINTER:
|
||||
{
|
||||
TMask mask(MSK_2);
|
||||
|
||||
set_files_to_default ();
|
||||
get_dir(&_workdir);
|
||||
names=fopen(_nmname, "r");
|
||||
build_list_box (names, mask, MSK_23_NAMES);
|
||||
fclose(names);
|
||||
_haschanged=TRUE;
|
||||
fill_print_codes (mask);
|
||||
mask.set_handler(MSK_23_NAMES, names_on_key);
|
||||
mask.set_handler(MSK_2_ADD, add_on_key);
|
||||
mask.set_handler(MSK_23_CODES, codes_on_key);
|
||||
mask.run();
|
||||
if (mask.last_key()==K_ENTER) insert_new_info(mask);
|
||||
}
|
||||
break;
|
||||
case MODIFY_PRINTER:
|
||||
if (_isopened && _currentprinter.find("** new file **")==-1)
|
||||
{
|
||||
_haschanged=TRUE;
|
||||
build_list_file(mirror, _plname);
|
||||
if (select_printer())
|
||||
{
|
||||
reset_mirror();
|
||||
_isopened=TRUE;
|
||||
_currentprinter="** new file **";
|
||||
TMask mask(MSK_2);
|
||||
|
||||
build_code_files(mirror, _cdname, _nmname, _currentprinter);
|
||||
names=fopen(_nmname, "r");
|
||||
build_list_box (names, mask, MSK_23_NAMES);
|
||||
fclose(names);
|
||||
fill_print_codes (mask);
|
||||
fill_mask(mask);
|
||||
mask.set_handler (MSK_23_NAMES, names_on_key);
|
||||
mask.set_handler (MSK_2_ADD, add_on_key);
|
||||
mask.set_handler (MSK_23_CODES, codes_on_key);
|
||||
mask.run();
|
||||
if (mask.last_key()==K_ENTER) update_mirror(mask);
|
||||
}
|
||||
break;
|
||||
case OPEN_FILE:
|
||||
{
|
||||
// 0=file aperto esistente
|
||||
// 1=file aperto nuovo
|
||||
// 2=non aprire nessun file
|
||||
int open_status=0;
|
||||
long pos=0;
|
||||
} else warning_box ("Nessun file aperto");
|
||||
break;
|
||||
case SHOW_PRINTER:
|
||||
{
|
||||
long pos;
|
||||
|
||||
if (_haschanged) save_box();
|
||||
open_status=accept_current_name(OPEN); // in base a XVTILITY
|
||||
if (open_status==1) open_status=(create_box()?1:2);
|
||||
if (open_status<2) reset_mirror();
|
||||
if (open_status==0) make_mirror();
|
||||
if (open_status<2) _isopened=TRUE;
|
||||
current=fopen(_currentname, "r");
|
||||
seek_default_printer(current, _currentprinter, &pos);
|
||||
fclose(current);
|
||||
}
|
||||
break;
|
||||
case SAVE_FILE:
|
||||
if (_haschanged) save_file();
|
||||
_haschanged=FALSE;
|
||||
break;
|
||||
case SAVE_FILE_AS:
|
||||
save_file(TRUE);
|
||||
_haschanged=FALSE;
|
||||
break;
|
||||
case QUIT_EPF:
|
||||
if (_haschanged) save_box();
|
||||
xvt_terminate();
|
||||
break;
|
||||
case INSERT_PRINTER:
|
||||
if (_isopened && _currentprinter.find("** new file **")==-1)
|
||||
{
|
||||
TMask mask(MSK_2);
|
||||
TMask mask(MSK_3);
|
||||
|
||||
set_files_to_default ();
|
||||
get_dir(&_workdir);
|
||||
selprinter=1;
|
||||
seek_first_printer(mirror, _currentprinter, &pos);
|
||||
build_code_files(mirror, _cdname, _nmname, _currentprinter);
|
||||
names=fopen(_nmname, "r");
|
||||
build_list_box (names, mask, MSK_23_NAMES);
|
||||
fclose(names);
|
||||
_haschanged=TRUE;
|
||||
build_list_file(mirror, _plname);
|
||||
fill_print_codes (mask);
|
||||
mask.set_handler(MSK_23_NAMES, names_on_key);
|
||||
mask.set_handler(MSK_2_ADD, add_on_key);
|
||||
mask.set_handler(MSK_23_CODES, codes_on_key);
|
||||
mask.set_handler(MSK_3_PREVIOUS, prev_on_key);
|
||||
mask.set_handler(MSK_3_NEXT, next_on_key);
|
||||
fill_mask(mask, TRUE);
|
||||
mask.deactivate();
|
||||
mask.enable(MSK_23_NAMES);
|
||||
mask.enable(MSK_3_PREVIOUS);
|
||||
mask.enable(MSK_3_NEXT);
|
||||
|
||||
mask.run();
|
||||
if (mask.last_key()==K_ENTER) insert_new_info(mask);
|
||||
}
|
||||
break;
|
||||
case MODIFY_PRINTER:
|
||||
if (_isopened && _currentprinter.find("** new file **")==-1)
|
||||
{
|
||||
_haschanged=TRUE;
|
||||
build_list_file(mirror, _plname);
|
||||
if (select_printer())
|
||||
{
|
||||
TMask mask(MSK_2);
|
||||
|
||||
build_code_files(mirror, _cdname, _nmname, _currentprinter);
|
||||
names=fopen(_nmname, "r");
|
||||
build_list_box (names, mask, MSK_23_NAMES);
|
||||
fclose(names);
|
||||
fill_print_codes (mask);
|
||||
fill_mask(mask);
|
||||
mask.set_handler (MSK_23_NAMES, names_on_key);
|
||||
mask.set_handler (MSK_2_ADD, add_on_key);
|
||||
mask.set_handler (MSK_23_CODES, codes_on_key);
|
||||
mask.run();
|
||||
if (mask.last_key()==K_ENTER) update_mirror(mask);
|
||||
}
|
||||
} else warning_box ("Nessun file aperto");
|
||||
break;
|
||||
case SHOW_PRINTER:
|
||||
} else warning_box ("Nessun file aperto");
|
||||
}
|
||||
break;
|
||||
case DELETE_PRINTER:
|
||||
if (_isopened)
|
||||
{
|
||||
long pos;
|
||||
|
||||
if (_isopened && _currentprinter.find("** new file **")==-1)
|
||||
{
|
||||
TMask mask(MSK_3);
|
||||
|
||||
selprinter=1;
|
||||
seek_first_printer(mirror, _currentprinter, &pos);
|
||||
build_code_files(mirror, _cdname, _nmname, _currentprinter);
|
||||
names=fopen(_nmname, "r");
|
||||
build_list_box (names, mask, MSK_23_NAMES);
|
||||
fclose(names);
|
||||
build_list_file(mirror, _plname);
|
||||
fill_print_codes (mask);
|
||||
mask.set_handler(MSK_23_NAMES, names_on_key);
|
||||
mask.set_handler(MSK_3_PREVIOUS, prev_on_key);
|
||||
mask.set_handler(MSK_3_NEXT, next_on_key);
|
||||
fill_mask(mask, TRUE);
|
||||
mask.disable();
|
||||
mask.enable(MSK_23_NAMES);
|
||||
mask.enable(MSK_3_PREVIOUS);
|
||||
mask.enable(MSK_3_NEXT);
|
||||
|
||||
mask.run();
|
||||
} else warning_box ("Nessun file aperto");
|
||||
}
|
||||
break;
|
||||
case DELETE_PRINTER:
|
||||
if (_isopened)
|
||||
{
|
||||
_haschanged=TRUE;
|
||||
build_list_file(mirror, _plname);
|
||||
if (select_printer())
|
||||
delete_printer();
|
||||
} else warning_box ("Nessun file aperto");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
_haschanged=TRUE;
|
||||
build_list_file(mirror, _plname);
|
||||
if (select_printer())
|
||||
delete_printer();
|
||||
} else warning_box ("Nessun file aperto");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user