Corretta disable

git-svn-id: svn://10.65.10.50/trunk@766 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1994-12-14 15:47:07 +00:00
parent 37c1f28282
commit f5a342a935

View File

@ -33,16 +33,16 @@
#define __BA2300_CPP #define __BA2300_CPP
#include <ba2300.h> #include <ba2300.h>
FILE* mirror; FILE* mirror;
FILE* mirror2; FILE* mirror2;
FILE* current; FILE* current;
FILE* printerlist; FILE* printerlist;
FILE* codes; FILE* codes;
FILE* names; FILE* names;
FILE* defcodes; FILE* defcodes;
FILE* defnames; FILE* defnames;
int selprinter=1; int selprinter=1;
void build_list_file (FILE* inputfile, TFilename& outputfile) void build_list_file (FILE* inputfile, TFilename& outputfile)
@ -91,7 +91,7 @@ bool seek_default_printer (FILE* inputfile, TString& newprinter, long* position,
} }
return FALSE; return FALSE;
} }
bool seek_printer (FILE* inputfile, TString& printer, long* position, bool justafter) 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; TString junk;
TToken_string j2; TToken_string j2;
long pos; long pos;
int i; int i;
FILE *codes, *names; FILE *codes, *names;
if (is_present(input, printer)) if (is_present(input, printer))
{ {
@ -344,41 +344,41 @@ protected:
public: public:
void fill_mask (TMask& mask, bool inrun=FALSE); void fill_mask (TMask& mask, bool inrun=FALSE);
void fill_print_codes (TMask& mask); void fill_print_codes (TMask& mask);
virtual bool menu (MENU_TAG); virtual bool menu (MENU_TAG);
void set_current_printer (TString newprinter) { _currentprinter=newprinter; } void set_current_printer (TString newprinter) { _currentprinter=newprinter; }
void update_codes_file (TString str, int pos); void update_codes_file (TString str, int pos);
void update_names_file (TString& str, int items); void update_names_file (TString& str, int items);
}; };
bool codes_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 add_on_key (TMask_field& f, KEY key);
bool names_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 prev_on_key (TMask_field& f, KEY key);
bool next_on_key (TMask_field& f, KEY key); bool next_on_key (TMask_field& f, KEY key);
// global application // global application
EPF_Application epf; EPF_Application epf;
// Constructor // Constructor
EPF_Application::EPF_Application (): EPF_Application::EPF_Application ():
_plname(FILE_PRINTERS), _plname(FILE_PRINTERS),
_cdname(FILE_CODES), _cdname(FILE_CODES),
_nmname(FILE_NAMES), _nmname(FILE_NAMES),
_dcdname(FILE_DEF_CODES), _dcdname(FILE_DEF_CODES),
_dnmname(FILE_DEF_NAMES), _dnmname(FILE_DEF_NAMES),
_isnamed(FALSE), _isnamed(FALSE),
_isopened(FALSE), _isopened(FALSE),
_haschanged(FALSE), _haschanged(FALSE),
_currentname("printer.ini") _currentname("printer.ini")
{ {
_mirrorname=tmpnam(NULL); _mirrorname=tmpnam(NULL);
_mir2name=tmpnam(NULL); _mir2name=tmpnam(NULL);
reset_mirror (); reset_mirror ();
set_files_to_default (); set_files_to_default ();
reset_mirror(); reset_mirror();
make_mirror(); make_mirror();
_isopened=TRUE; _isopened=TRUE;
} }
// Destructor // Destructor
EPF_Application::~EPF_Application () EPF_Application::~EPF_Application ()
@ -413,7 +413,7 @@ bool add_on_key (TMask_field& f, KEY key)
junk = addmask.get(MSK_4_CODE); junk = addmask.get(MSK_4_CODE);
epf.update_names_file (junk, items); epf.update_names_file (junk, items);
epf.fill_print_codes (f.mask()); epf.fill_print_codes (f.mask());
} }
return TRUE; return TRUE;
} }
@ -492,9 +492,9 @@ int EPF_Application::accept_current_name(bool mode)
TString typespec(EXTENSION); TString typespec(EXTENSION);
char dirjunk[50]; char dirjunk[50];
// ritorna 0 se il file esiste // ritorna 0 se il file esiste
// 1 se il file non esiste // 1 se il file non esiste
// 2 se l'operazioe e' stata interrotta // 2 se l'operazioe e' stata interrotta
#if XVT_OS == XVT_OS_DOS #if XVT_OS == XVT_OS_DOS
@ -505,18 +505,18 @@ int EPF_Application::accept_current_name(bool mode)
strcpy(filetoopen.type, (char*)typespec); strcpy(filetoopen.type, (char*)typespec);
filetoopen.dir=_workdir; filetoopen.dir=_workdir;
if (mode==OPEN) junk=open_file_dlg(&filetoopen, "Scegli un file di configurazione stampanti"); 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 (junk==FL_BAD || junk==FL_CANCEL) return 2;
if (mode==OPEN) _isnamed=TRUE; if (mode==OPEN) _isnamed=TRUE;
dir_to_str(&(filetoopen.dir), dirjunk, 50); dir_to_str(&(filetoopen.dir), dirjunk, 50);
_currentname.cut(0); _currentname.cut(0);
_currentname << dirjunk << '/' << filetoopen.name; _currentname << dirjunk << '/' << filetoopen.name;
if (mode==OPEN) if ((current =fopen(_currentname, "r"))==NULL) return 1; if (mode==OPEN) if ((current =fopen(_currentname, "r"))==NULL) return 1;
else else
{ {
fclose(current ); fclose(current );
return 0; return 0;
} }
else 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) 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 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); fgets(__tmp_string, 256, codes);
ok = fgets(__tmp_string, 256, codes); ok = fgets(__tmp_string, 256, codes);
if (ok) mask.set(MSK_23_CODES, __tmp_string); if (ok) mask.set(MSK_23_CODES, __tmp_string);
else mask.set(MSK_23_CODES, ""); else mask.set(MSK_23_CODES, "");
fclose(codes); fclose(codes);
} }
@ -843,25 +843,25 @@ void EPF_Application::set_files_to_default ()
codes=fopen(_cdname, "w"); codes=fopen(_cdname, "w");
defcodes=fopen(_dcdname, "r"); defcodes=fopen(_dcdname, "r");
if (defcodes != NULL) if (defcodes != NULL)
{ {
while (fgets(__tmp_string, 256, defcodes)) while (fgets(__tmp_string, 256, defcodes))
fputs(__tmp_string, codes); fputs(__tmp_string, codes);
fclose(defcodes); fclose(defcodes);
} }
fclose(codes); fclose(codes);
names=fopen(_nmname, "w"); names=fopen(_nmname, "w");
defnames=fopen(_dnmname, "r"); defnames=fopen(_dnmname, "r");
if (defnames != NULL) if (defnames != NULL)
{ {
while (fgets(__tmp_string, 256, defnames)) while (fgets(__tmp_string, 256, defnames))
fputs (__tmp_string, names); fputs (__tmp_string, names);
fclose(defnames); fclose(defnames);
} }
fclose(names); fclose(names);
} }
void EPF_Application::update_names_file (TString& str, int items) void EPF_Application::update_names_file (TString& str, int items)
@ -916,129 +916,129 @@ bool EPF_Application::menu(MENU_TAG m)
switch (m) switch (m)
{ {
case NEW_FILE: case NEW_FILE:
if (_haschanged) save_box(); if (_haschanged) save_box();
_isnamed=FALSE; _isnamed=FALSE;
junk=accept_current_name(OPEN); // da modificare in base a XVTILITY junk=accept_current_name(OPEN); // da modificare in base a XVTILITY
if (junk<2) 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(); TMask mask(MSK_2);
_isopened=TRUE;
_currentprinter="** new file **"; 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; } else warning_box ("Nessun file aperto");
case OPEN_FILE: break;
{ case SHOW_PRINTER:
// 0=file aperto esistente {
// 1=file aperto nuovo long pos;
// 2=non aprire nessun file
int open_status=0;
long pos=0;
if (_haschanged) save_box(); if (_isopened && _currentprinter.find("** new file **")==-1)
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); TMask mask(MSK_3);
set_files_to_default (); selprinter=1;
get_dir(&_workdir); seek_first_printer(mirror, _currentprinter, &pos);
build_code_files(mirror, _cdname, _nmname, _currentprinter);
names=fopen(_nmname, "r"); names=fopen(_nmname, "r");
build_list_box (names, mask, MSK_23_NAMES); build_list_box (names, mask, MSK_23_NAMES);
fclose(names); fclose(names);
_haschanged=TRUE; build_list_file(mirror, _plname);
fill_print_codes (mask); fill_print_codes (mask);
mask.set_handler(MSK_23_NAMES, names_on_key); mask.set_handler(MSK_23_NAMES, names_on_key);
mask.set_handler(MSK_2_ADD, add_on_key); mask.set_handler(MSK_3_PREVIOUS, prev_on_key);
mask.set_handler(MSK_23_CODES, codes_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(); mask.run();
if (mask.last_key()==K_ENTER) insert_new_info(mask); } else warning_box ("Nessun file aperto");
} }
break; break;
case MODIFY_PRINTER: case DELETE_PRINTER:
if (_isopened && _currentprinter.find("** new file **")==-1) if (_isopened)
{
_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:
{ {
long pos; _haschanged=TRUE;
build_list_file(mirror, _plname);
if (_isopened && _currentprinter.find("** new file **")==-1) if (select_printer())
{ delete_printer();
TMask mask(MSK_3); } else warning_box ("Nessun file aperto");
break;
selprinter=1; default:
seek_first_printer(mirror, _currentprinter, &pos); break;
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;
} }
return TRUE; return TRUE;