Gestione tasti rapidi.

git-svn-id: svn://10.65.10.50/trunk@52 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-08-23 13:52:36 +00:00
parent 5f96e2e4ea
commit 6d79069eb6
30 changed files with 7556 additions and 7418 deletions

View File

@ -12,7 +12,7 @@ MENUBAR MENU_BAR(1)
MENU MENU_BAR(1) MENU MENU_BAR(1)
SUBMENU MENU_FILE "~File" SUBMENU MENU_FILE "~File"
ITEM BAR_ITEM(1) "~Selezione" ITEM BAR_ITEM(1) "~Test"
/* ba1 -2 */ /* ba1 -2 */

View File

@ -47,7 +47,7 @@ BEGIN
FLAGS "D" FLAGS "D"
END END
SPREADSHEET F_FIELDS 34 7 SPREADSHEET F_FIELDS 44 7
BEGIN BEGIN
PROMPT 15 4 "" PROMPT 15 4 ""
ITEM "Nome@10" ITEM "Nome@10"

View File

@ -21,28 +21,28 @@ public:
bool TTest_application::menu(MENU_TAG) bool TTest_application::menu(MENU_TAG)
{ {
TLocalisamfile tab(LF_TABCOM); TLocalisamfile tab(LF_COMUNI);
const TRecnotype n = tab.items(); const TRecnotype n = tab.items();
time_t start; clock_t start;
TRecnotype r = 1; TRecnotype r = 1;
TString80 msg; TString80 msg;
{ {
TProgind p(n, "Lettura file tabelle comuni", TRUE, TRUE, 32); TProgind p(n, "Lettura file comuni", TRUE, TRUE, 32);
start = time(NULL); start = clock();
for (tab.first(); tab.good(); tab.next(), r++) for (tab.first(); tab.good(); tab.next(), r++)
{ {
if ((r % 50) == 0) if ((r % 100) == 0)
{ {
msg.format("%ld records %ld sec", r, time(NULL) - start); msg.format("%ld records %ld msec", r, clock() - start);
p.setstatus(r); p.setstatus(r);
p.set_text(msg); p.set_text(msg);
if (p.iscancelled()) break;
} }
if (p.iscancelled()) break;
} }
} }
const time_t t = time(NULL) - start; const clock_t t = clock() - start;
msg.format("%ld records in %ld sec\n%lg records per sec", r, t, (double)r/t); msg.format("%ld records in %ld msec\n%lg records per sec", r, t, 1000.0*r/t);
message_box(msg); message_box(msg);
return TRUE; return TRUE;

View File

@ -90,7 +90,7 @@ BEGIN
OUTPUT FLD_GD1_RAGSOC RAGSOC OUTPUT FLD_GD1_RAGSOC RAGSOC
HELP "Inserire la ragione sociale della ditta" HELP "Inserire la ragione sociale della ditta"
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
FLAGS "G" FLAGS "G"
MESSAGE COPY,2@ MESSAGE COPY,2@
END END

View File

@ -1,23 +1,21 @@
#include <xvt.h> #include <xvt.h>
#include <strings.h>
#include <checks.h> #include <checks.h>
#include "ba6.h" #include "ba6.h"
#define usage "Error - usage : %s -0" #define usage "Errore - uso : %s -{0,1}"
int main(int argc,char** argv) int main(int argc,char** argv)
{ {
int rt = 0 ; const int r = (argc > 1) ? atoi(argv[1]) : -1;
TString p = argv[0], s = argv[1] ;
if (argc!=2) fatal_box(usage, (const char*) p) ; switch (r)
else {
if (s == "-0") rt = ba6100(argc,argv) ; case 0:ba6100(argc,argv) ; break;
if (s == "-1") rt = ba6200(argc,argv) ; case 1:ba6200(argc,argv) ; break;
else fatal_box(usage, (const char*) p) ; default:error_box(usage, argv[0]) ; break;
return rt; }
return r < 0;
} }

View File

@ -110,14 +110,14 @@ BEGIN
FLAGS "U" FLAGS "U"
END END
BUTTON DLG_OK 9 0 BUTTON DLG_OK 9 2
BEGIN BEGIN
PROMPT 10 12 "" PROMPT -12 -2 ""
END END
BUTTON DLG_CANCEL 9 0 BUTTON DLG_CANCEL 9 2
BEGIN BEGIN
PROMPT 43 12 "" PROMPT -22 -2 ""
END END
ENDPAGE ENDPAGE

View File

@ -637,7 +637,7 @@ bool TPrimanota_application::num_handler(TMask_field& f, KEY key)
if (key == K_TAB && f.get().not_empty()) if (key == K_TAB && f.get().not_empty())
{ {
if (app().find(1)) if (app().find(1))
dispatch_e_char(f.parent(), K_SHIFT_ENTER); dispatch_e_char(f.parent(), K_AUTO_ENTER);
} }
return TRUE; return TRUE;
} }
@ -659,7 +659,7 @@ bool TPrimanota_application::caus_query_handler(TMask_field& f, KEY key)
{ {
const bool ok = suspended_handler(f, key); // Controlla sospensione const bool ok = suspended_handler(f, key); // Controlla sospensione
if (ok) if (ok)
dispatch_e_char(f.parent(), K_INS); // Entra in modo inserimento f.mask().stop_run(K_INS); // Entra in modo inserimento
} }
} }

View File

@ -3,7 +3,7 @@
#include "cg4.h" #include "cg4.h"
#define usage "Error - usage : %s -{0,2,3,4,5}" const char* const usage = "Errore - uso : %s -{0,2,3,4,5}";
int main(int argc,char** argv) int main(int argc,char** argv)
{ {
@ -24,6 +24,7 @@ int main(int argc,char** argv)
default: default:
error_box(usage, argv[0]); error_box(usage, argv[0]);
} }
return n < 0; return n < 0;
} }

View File

@ -36,12 +36,9 @@ HIDDEN int compare(const TObject** o1, const TObject** o2)
{ {
TRigaiva* r1 = (TRigaiva*)*o1; TRigaiva* r1 = (TRigaiva*)*o1;
TRigaiva* r2 = (TRigaiva*)*o2; TRigaiva* r2 = (TRigaiva*)*o2;
TString campo1; TString16 campo1; campo1.format("%d%4s", r1->_tipodet, (const char*)r1->_codiva);
TString campo2; TString16 campo2; campo2.format("%d%4s", r2->_tipodet, (const char*)r2->_codiva);
return (strcmp(campo1, campo2));
campo1.format("%d%4s", r1->_tipodet, (const char*)r1->_codiva);
campo2.format("%d%4s", r2->_tipodet, (const char*)r2->_codiva);
return (strcmp((const char*)campo1, (const char*)campo2));
} }
/* /*

View File

@ -2,16 +2,16 @@
// cg4400.h // cg4400.h
// //
#include <isam.h> #include <isam.h>
#include <lffiles.h>
#include <printapp.h> #include <printapp.h>
#include <mask.h> #include <mask.h>
#include <strings.h>
#include <tabutil.h> #include <tabutil.h>
#include <utility.h> #include <utility.h>
#include <stdlib.h>
#include <urldefid.h> #include <urldefid.h>
#include <sheet.h> #include <sheet.h>
#include <config.h> #include <config.h>
#include "cglib03.h"
#include <nditte.h> #include <nditte.h>
#include <anagr.h> #include <anagr.h>
#include <comuni.h> #include <comuni.h>
@ -20,13 +20,13 @@
#include <clifo.h> #include <clifo.h>
#include <occas.h> #include <occas.h>
#include <causali.h> #include <causali.h>
#include <cglib03.h>
const int MAXSTR = 128; const int MAXSTR = 128;
static char __tmp[MAXSTR]; static char __tmp[MAXSTR];
//enum STAMPA { bollati=1, unici=2 }; //enum STAMPA { bollati=1, unici=2 };
const int TABREG = (int)TTable::name2log("REG"); const int TABREG = (int)TTable::name2log("REG");
bool filter_func (const TRelation*); bool filter_func (const TRelation*);
bool my_handler (TMask_field&, KEY); bool my_handler (TMask_field&, KEY);
@ -65,8 +65,8 @@ class CG4400_application : public TPrintapp
friend bool mask_verifica (TMask_field&, KEY); friend bool mask_verifica (TMask_field&, KEY);
friend bool mask_annulla (TMask_field&, KEY); friend bool mask_annulla (TMask_field&, KEY);
TCursor * _cur; TCursor * _cur;
TRelation *_rel; TRelation *_rel;
TLocalisamfile *_clifo, *_nditte, *_occas, *_tab, *_tabcom; TLocalisamfile *_clifo, *_nditte, *_occas, *_tab, *_tabcom;
TTable *_tabreg; TTable *_tabreg;
TRigaiva_array _iva_array, _riga_rmi; TRigaiva_array _iva_array, _riga_rmi;
@ -75,43 +75,43 @@ class CG4400_application : public TPrintapp
TArray_sheet *_ditte; TArray_sheet *_ditte;
TBit_array _selected; TBit_array _selected;
TArray _nomiditte; //array descrizioni ditte per sheet TArray _nomiditte; //array descrizioni ditte per sheet
bool _riferim, _mov_empty; bool _riferim, _mov_empty;
char _frequiva; char _frequiva;
TDate _data_da, _data_a, _data_stampa, _dataregp, _datareg; TDate _data_da, _data_a, _data_stampa, _dataregp, _datareg;
long _annoes, _n_ditte; long _annoes, _n_ditte;
int _riepil, _tipo_reg, _fino_a_mese, _tipo_stampa; int _riepil, _tipo_reg, _fino_a_mese, _tipo_stampa;
int _r, _stampa_width; // riga corrente di stampa int _r, _stampa_width; // riga corrente di stampa
real _totale_doc; real _totale_doc;
TString _codreg, _desc_lib, _codatt, _attivita; TString _codreg, _desc_lib, _codatt, _attivita;
TString _codtab, _tipodoc, _descr_doc; TString _codtab, _tipodoc, _descr_doc;
bool _stampa_tutti_i_registri; bool _stampa_tutti_i_registri;
public: public:
const char* desc_attivita (const char * codatt); const char* desc_attivita (const char * codatt);
const char* descr_doc (const char * tipo); const char* descr_doc (const char * tipo);
const char* descr_iva (const char * cod); const char* descr_iva (const char * cod);
const char* ricerca_cf (char tipocf, long codcf); const char* ricerca_cf (char tipocf, long codcf);
const char* ricerca_occ(const char * occ); const char* ricerca_occ(const char * occ);
int setta_riga (int, const TRigaiva&, real&, real&, real&, real&); int setta_riga (int, const TRigaiva&, real&, real&, real&, real&);
int riga_rmoviva(); int riga_rmoviva();
bool set_print(int); bool set_print(int);
bool set_ditte(TMask&); bool set_ditte(TMask&);
bool compila_reg(); bool compila_reg();
bool controlla_liquidazione(); bool controlla_liquidazione();
bool controlla_mov(); bool controlla_mov();
void stampa_registri_IVA(); void stampa_registri_IVA();
void set_page_tot_reg(); void set_page_tot_reg();
void calcola_progressivi(real&, real&, const char*, const int); void calcola_progressivi(real&, real&, const char*, const int);
void user_create(); void user_create();
void user_destroy(); void user_destroy();
bool preprocess_page(int, int); bool preprocess_page(int, int);
int stampa_intestazione_ditta(); int stampa_intestazione_ditta();
bool preprocess_print(int, int); bool preprocess_print(int, int);
print_action postprocess_print(int, int); print_action postprocess_print(int, int);
void preprocess_header(); void preprocess_header();
CG4400_application() : TPrintapp(),_ditte(NULL),_selected(10000), CG4400_application() : TPrintapp(),_ditte(NULL),_selected(10000),
_nomiditte(100) {} _nomiditte(100) {}
virtual ~CG4400_application() {} virtual ~CG4400_application() {}
}; };

View File

@ -4,10 +4,7 @@
#include <tabutil.h> #include <tabutil.h>
#include <printapp.h> #include <printapp.h>
#include <mask.h> #include <mask.h>
#include <date.h>
#include <scanner.h>
#include <utility.h> #include <utility.h>
#include <prefix.h>
#include <config.h> #include <config.h>
#include <urldefid.h> #include <urldefid.h>
@ -18,9 +15,8 @@
#include <causali.h> #include <causali.h>
#include <nditte.h> #include <nditte.h>
#include <cg4.h> #include "cg4500a.h"
#include <cg4500a.h> #include "cg4500b.h"
#include <cg4500b.h>
bool mask_dataini (TMask_field&, KEY); bool mask_dataini (TMask_field&, KEY);
bool mask_newanno (TMask_field&, KEY); bool mask_newanno (TMask_field&, KEY);
@ -29,32 +25,32 @@ bool mask_frequenza (TMask_field&, KEY);
class CG4500_application : public TApplication class CG4500_application : public TApplication
{ {
friend bool mask_dataini (TMask_field&, KEY); friend bool mask_dataini (TMask_field&, KEY);
friend bool mask_newanno (TMask_field&, KEY); friend bool mask_newanno (TMask_field&, KEY);
friend bool mask_annoiva (TMask_field&, KEY); friend bool mask_annoiva (TMask_field&, KEY);
friend bool mask_frequenza (TMask_field&); friend bool mask_frequenza (TMask_field&);
TTable* _esc, * _reg, * _lia, * _lbu; TTable* _esc, * _reg, * _lia, * _lbu;
TLocalisamfile* _nditte; TLocalisamfile* _nditte;
int _anno, _newanno, _annoiva; int _anno, _newanno, _annoiva;
TDate _dataini, _datafin, _datainp, _datafip; TDate _dataini, _datafin, _datainp, _datafip;
TString _annop; TString _annop;
long _ditta; long _ditta;
char _frequenza; char _frequenza;
public: public:
virtual bool create(); virtual bool create();
virtual bool destroy(); virtual bool destroy();
virtual bool menu(MENU_TAG m); virtual bool menu(MENU_TAG m);
void create_files(); void create_files();
void destroy_files(); void destroy_files();
bool set(); bool set();
bool setta(); bool setta();
bool apertura_es(); bool apertura_es();
bool apertura_iva(); bool apertura_iva();
CG4500_application() {} CG4500_application() {}
}; };
TDate InizioEsercizio(int anno) TDate InizioEsercizio(int anno)
@ -68,7 +64,7 @@ TDate InizioEsercizio(int anno)
TabEs.put ("CODTAB", codtab); TabEs.put ("CODTAB", codtab);
TabEs.read(); TabEs.read();
if (TabEs.good()) if (TabEs.good())
inizio_es= TabEs.get_date ("D0"); inizio_es= TabEs.get_date ("D0");
return inizio_es; return inizio_es;
} }
@ -84,7 +80,7 @@ TDate FineEsercizio(int anno)
TabEs.put ("CODTAB", codtab); TabEs.put ("CODTAB", codtab);
TabEs.read(); TabEs.read();
if (TabEs.good()) if (TabEs.good())
fine_es= TabEs.get_date ("D1"); fine_es= TabEs.get_date ("D1");
return fine_es; return fine_es;
} }
@ -94,7 +90,7 @@ bool mask_newanno (TMask_field& f, KEY k)
TTable TabEs ("ESC"); TTable TabEs ("ESC");
TString codtab; TString codtab;
// if ( (k == K_TAB) && f.mask().is_running() ) // if ( (k == K_TAB) && f.mask().is_running() )
if ( (k == K_ENTER) && f.to_check(k) ) if ( (k == K_ENTER) && f.to_check(k) )
{ {
int newanno = f.mask().get_int(F_NUOVOANNO); int newanno = f.mask().get_int(F_NUOVOANNO);
@ -121,16 +117,16 @@ bool mask_newanno (TMask_field& f, KEY k)
bool mask_annoiva (TMask_field& f, KEY k) bool mask_annoiva (TMask_field& f, KEY k)
{ {
if ( (k == K_ENTER) && f.to_check(k) ) if ( (k == K_ENTER) && f.to_check(k) )
//if ( (k == K_TAB) && f.mask().is_running() ) //if ( (k == K_TAB) && f.mask().is_running() )
{ {
int annoiva = f.mask().get_int(F_ANNOIVA); int annoiva = f.mask().get_int(F_ANNOIVA);
TConfig conf(CONFIG_DITTA); TConfig conf(CONFIG_DITTA);
int annoivap = atoi(conf.get("AnLiIv")); int annoivap = atoi(conf.get("AnLiIv"));
if (annoiva != annoivap + 1) if (annoiva != annoivap + 1)
{ {
f.warning_box("Il nuovo anno esercizio IVA deve essere successivo all'anno esercizio IVA precedente"); f.warning_box("Il nuovo anno esercizio IVA deve essere successivo all'anno esercizio IVA precedente");
return FALSE; return FALSE;
} }
} }
return TRUE; return TRUE;
} }
@ -142,12 +138,12 @@ bool mask_dataini (TMask_field& f, KEY k)
TDate data(f.mask().get(F_DATAINI)); TDate data(f.mask().get(F_DATAINI));
TDate fine(f.mask().get(F_DATAFINC)); TDate fine(f.mask().get(F_DATAFINC));
/* /*
if ( data.year() != FineEsercizio(anno).year() + 1 ) if ( data.year() != FineEsercizio(anno).year() + 1 )
{ {
warning_box ("L'anno del nuovo esercizio deve essere successivo a quello della fine dell'esercizio precedente"); warning_box ("L'anno del nuovo esercizio deve essere successivo a quello della fine dell'esercizio precedente");
return FALSE; return FALSE;
} }
*/ */
if ( data <= fine ) if ( data <= fine )
{ {
f.warning_box ("La data di inizio del nuovo esercizio deve essere superiore alla data di fine esercizio precedente"); f.warning_box ("La data di inizio del nuovo esercizio deve essere superiore alla data di fine esercizio precedente");
@ -199,27 +195,27 @@ bool CG4500_application::set()
KEY tasto; KEY tasto;
/* /*
if (TabEs.last() == NOERR) if (TabEs.last() == NOERR)
{ {
int anno = TabEs.get_int ("CODTAB"); int anno = TabEs.get_int ("CODTAB");
TDate inizio = TabEs.get_date("D0"); //data inizio es. in corso TDate inizio = TabEs.get_date("D0"); //data inizio es. in corso
TDate fine = TabEs.get_date("D1"); //data fine es. in corso TDate fine = TabEs.get_date("D1"); //data fine es. in corso
m.show (F_ANNO); m.show (F_ANNO);
m.show (F_DATAINIC); m.show (F_DATAINIC);
m.show (F_DATAFINC); m.show (F_DATAFINC);
m.set(F_ANNO, (long) anno); m.set(F_ANNO, (long) anno);
m.set(F_DATAINIC, inizio.string()); m.set(F_DATAINIC, inizio.string());
m.set(F_DATAFINC, fine.string()); m.set(F_DATAFINC, fine.string());
} }
else else
{ {
m.hide(F_ANNO); m.hide(F_ANNO);
m.hide(F_DATAINIC); m.hide(F_DATAINIC);
m.hide(F_DATAFINC); m.hide(F_DATAFINC);
} }
*/ */
if (TabEs.last() != NOERR) if (TabEs.last() != NOERR)
{ {
@ -270,20 +266,20 @@ bool CG4500_application::setta()
TabLia.zero(); TabLia.zero();
TabLia.put("CODTAB", anno); TabLia.put("CODTAB", anno);
if (TabLia.read() == NOERR) if (TabLia.read() == NOERR)
m.set(F_FREQUENZA, TabLia.get("S7")); m.set(F_FREQUENZA, TabLia.get("S7"));
else else
{ {
TabLia.zero(); TabLia.zero();
TabLia.put("CODTAB", _annop); TabLia.put("CODTAB", _annop);
if (TabLia.read() == NOERR) if (TabLia.read() == NOERR)
m.set(F_FREQUENZA, TabLia.get("S7")); m.set(F_FREQUENZA, TabLia.get("S7"));
else else
{ {
nditte.zero(); nditte.zero();
nditte.put("CODDITTA", MainApp()->get_firm()); nditte.put("CODDITTA", MainApp()->get_firm());
if (nditte.read() == NOERR) if (nditte.read() == NOERR)
m.set(F_FREQUENZA, nditte.get(NDT_FREQVIVA)); m.set(F_FREQUENZA, nditte.get(NDT_FREQVIVA));
} }
} }
m.set(F_ANNOIVA, aivap+1); m.set(F_ANNOIVA, aivap+1);
@ -307,12 +303,12 @@ bool CG4500_application::menu(MENU_TAG m)
{ {
switch (m) switch (m)
{ {
case BAR_ITEM(1): case BAR_ITEM(1):
apertura_es(); apertura_es();
break; break;
case BAR_ITEM(2): case BAR_ITEM(2):
apertura_iva(); apertura_iva();
break; break;
} }
//return TApplication::menu(m); //return TApplication::menu(m);
return TRUE; return TRUE;
@ -328,7 +324,7 @@ bool CG4500_application::apertura_es()
bool ok = FALSE; bool ok = FALSE;
if (!set()) if (!set())
return FALSE; return FALSE;
//viene aggiornata la tabella dei registri. Se esisteva gia' un record relativo al nuovo esercizio, viene cancellato. //viene aggiornata la tabella dei registri. Se esisteva gia' un record relativo al nuovo esercizio, viene cancellato.
//In ogni caso ne viene creato uno nuovo relativo al nuovo esercizio. //In ogni caso ne viene creato uno nuovo relativo al nuovo esercizio.
@ -347,7 +343,7 @@ bool CG4500_application::apertura_es()
int tiporeg = TabReg.get_int("I0"); int tiporeg = TabReg.get_int("I0");
if (tiporeg == 5) if (tiporeg == 5)
TabReg.remove(); TabReg.remove();
} }
TabReg.zero(); TabReg.zero();
@ -361,26 +357,26 @@ bool CG4500_application::apertura_es()
for (; !TabReg.eof(); TabReg.next()) for (; !TabReg.eof(); TabReg.next())
{ {
if (TabReg.curr() != rec) break; if (TabReg.curr() != rec) break;
int tiporeg = TabReg.get_int("I0"); int tiporeg = TabReg.get_int("I0");
TString cod_reg = TabReg.get("CODTAB"); TString cod_reg = TabReg.get("CODTAB");
cod_reg = cod_reg.mid(4,3); cod_reg = cod_reg.mid(4,3);
if (tiporeg == 5) if (tiporeg == 5)
{ {
ok = TRUE; ok = TRUE;
nuovo = TabReg.curr(); nuovo = TabReg.curr();
TString16 cod; TString16 cod;
cod << _newanno << cod_reg; cod << _newanno << cod_reg;
nuovo.put("CODTAB", cod); nuovo.put("CODTAB", cod);
nuovo.put("D2", data); nuovo.put("D2", data);
nuovo.put("D3", data); nuovo.put("D3", data);
nuovo.put("I6", 0L); nuovo.put("I6", 0L);
nuovo.put("R1", real(0.0)); nuovo.put("R1", real(0.0));
nuovo.put("R2", real(0.0)); nuovo.put("R2", real(0.0));
TabReg.write(nuovo); TabReg.write(nuovo);
} }
} }
if (!ok) if (!ok)
{ {
@ -411,7 +407,7 @@ bool CG4500_application::apertura_iva()
bool ok = FALSE; bool ok = FALSE;
if (!setta()) if (!setta())
return FALSE; return FALSE;
//viene aggiornata la tabella del libro unico. Se esisteva gia' un record relativo al nuovo esercizio IVA, viene cancellato. //viene aggiornata la tabella del libro unico. Se esisteva gia' un record relativo al nuovo esercizio IVA, viene cancellato.
//In ogni caso ne viene creato uno nuovo relativo al nuovo esercizio. //In ogni caso ne viene creato uno nuovo relativo al nuovo esercizio.
@ -478,7 +474,7 @@ bool CG4500_application::apertura_iva()
int tiporeg = TabReg.get_int("I0"); int tiporeg = TabReg.get_int("I0");
if ( (tiporeg == 1)||(tiporeg == 2)||(tiporeg == 3) ) if ( (tiporeg == 1)||(tiporeg == 2)||(tiporeg == 3) )
TabReg.remove(); TabReg.remove();
} }
ok = FALSE; ok = FALSE;
@ -531,7 +527,7 @@ bool CG4500_application::apertura_iva()
TabLia.zero(); TabLia.zero();
TabLia.put ("CODTAB", annoiva); TabLia.put ("CODTAB", annoiva);
if (TabLia.read() == NOERR) if (TabLia.read() == NOERR)
TabLia.remove(); TabLia.remove();
ok = FALSE; ok = FALSE;
TabLia.zero(); TabLia.zero();
@ -540,12 +536,12 @@ bool CG4500_application::apertura_iva()
if (TabLia.read() == NOERR) if (TabLia.read() == NOERR)
{ {
ok = TRUE; ok = TRUE;
newrec = TabLia.curr(); newrec = TabLia.curr();
newrec.put("CODTAB", annoiva); newrec.put("CODTAB", annoiva);
newrec.put("S7", _frequenza); newrec.put("S7", _frequenza);
TabLia.write(newrec); TabLia.write(newrec);
} }
if (!ok) if (!ok)
{ {
@ -554,7 +550,7 @@ bool CG4500_application::apertura_iva()
} }
//viene aggiornato l'anno iva sui parametri ditta //viene aggiornato l'anno iva sui parametri ditta
TConfig conf(CONFIG_DITTA); TConfig conf(CONFIG_DITTA);
conf.set("AnLiIv", _annoiva); conf.set("AnLiIv", _annoiva);
//sull'anagrafica ditte viene aggiornata la frequenza versamento //sull'anagrafica ditte viene aggiornata la frequenza versamento

View File

@ -42,9 +42,9 @@ void TTab_conti::do_agg(TConto* tc, int anno_es, const real& importo,
} }
void TTab_conti::aggiorna_conto(const TConto& tcon, const int anno_es, const real& importo, char sezione, bool movap, bool provv, bool somma) void TTab_conti::aggiorna_conto(const TConto& tcon, int anno_es, const real& importo, char sezione, bool movap, bool provv, bool somma)
{ {
TString key; TString80 key;
key << format("%4d", anno_es); key << format("%4d", anno_es);
key << format("%3d", tcon.gruppo()); key << format("%3d", tcon.gruppo());
key << format("%3d", tcon.conto()); key << format("%3d", tcon.conto());
@ -68,7 +68,7 @@ void TTab_conti::aggiorna_conto(int gruppo, int conto, long sottoconto,
int anno_es, const real& importo, char sezione, int anno_es, const real& importo, char sezione,
bool movap, bool provv, bool somma) bool movap, bool provv, bool somma)
{ {
TString key; TString80 key;
key << format("%4d", anno_es); key << format("%4d", anno_es);
key << format("%3d", gruppo); key << format("%3d", gruppo);
key << format("%3d", conto); key << format("%3d", conto);

View File

@ -3,17 +3,17 @@
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
#include <config.h>
#include <extcdecl.h> #include <extcdecl.h>
#include <modaut.h> #include <modaut.h>
#include <mask.h>
#include <prefix.h> #include <prefix.h>
#include <progind.h>
#include <relation.h>
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
#include <config.h>
#include <mask.h>
#include <relation.h>
#include <bagn002.h> #include <bagn002.h>
#include <progind.h>
HIDDEN XVT_CONFIG cfg; HIDDEN XVT_CONFIG cfg;
HIDDEN TApplication* application = NULL; HIDDEN TApplication* application = NULL;
@ -21,8 +21,8 @@ HIDDEN long savefirm = 0;
TApplication* MainApp() TApplication* MainApp()
{ {
CHECK(application, "NULL application!"); CHECK(application, "NULL application!");
return application; return application;
} }
bool xvt_running() { return application != NULL; } bool xvt_running() { return application != NULL; }
@ -30,46 +30,46 @@ bool xvt_running() { return application != NULL; }
HIDDEN long backdrop_eh( WINDOW win, EVENT* ep) HIDDEN long backdrop_eh( WINDOW win, EVENT* ep)
{ {
#if XVTWS == WMWS #if XVTWS == WMWS
clear_window( win, COLOR_BLUE ); clear_window( win, COLOR_BLUE );
#else #else
clear_window( win, COLOR_GRAY ); clear_window( win, COLOR_GRAY );
/* /*
const RCT& rct = ep->v.update.rct; const RCT& rct = ep->v.update.rct;
bool even = FALSE; bool even = FALSE;
for (int y = 0; y < rct.bottom; y += 96) for (int y = 0; y < rct.bottom; y += 96)
{ {
const int sx = even ? 96 : 0; const int sx = even ? 96 : 0;
for (int x = sx; x < rct.right; x += 192) for (int x = sx; x < rct.right; x += 192)
if ( if (
(y+64) > rct.top && y < rct.bottom && (y+64) > rct.top && y < rct.bottom &&
(x+64) > rct.left && x < rct.right (x+64) > rct.left && x < rct.right
) win_draw_icon(win, x, y, ICON_RSRC); ) win_draw_icon(win, x, y, ICON_RSRC);
even = !even; even = !even;
} }
*/ */
#endif #endif
return 0L; return 0L;
} }
HIDDEN void create_backdrop( void ) HIDDEN void create_backdrop( void )
{ {
#if XVTWS == WMWS #if XVTWS == WMWS
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_MENU, COLOR_BLACK, COLOR_WHITE); xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_MENU, COLOR_BLACK, COLOR_WHITE);
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_DIALOG, COLOR_BLUE, COLOR_WHITE); xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_DIALOG, COLOR_BLUE, COLOR_WHITE);
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_WINDOW, COLOR_RED, COLOR_WHITE); xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_WINDOW, COLOR_RED, COLOR_WHITE);
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_CONTROL, COLOR_BLACK, COLOR_WHITE); xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_CONTROL, COLOR_BLACK, COLOR_WHITE);
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_DISABLED, COLOR_GRAY, COLOR_WHITE); xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_DISABLED, COLOR_GRAY, COLOR_WHITE);
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_MNEMONIC, COLOR_RED, COLOR_WHITE); xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_MNEMONIC, COLOR_RED, COLOR_WHITE);
RCT rct; RCT rct;
get_client_rect( SCREEN_WIN, &rct ); get_client_rect( SCREEN_WIN, &rct );
create_window(W_PLAIN, &rct, (char*) "BACKDROP", 0, TASK_WIN, create_window(W_PLAIN, &rct, (char*) "BACKDROP", 0, TASK_WIN,
WSF_NO_MENUBAR | WSF_CH_BACKDROP , EM_UPDATE, WSF_NO_MENUBAR | WSF_CH_BACKDROP , EM_UPDATE,
backdrop_eh, 0L ); backdrop_eh, 0L );
#else #else
xvt_create_statbar(); xvt_create_statbar();
xvt_statbar_set(""); xvt_statbar_set("");
#endif #endif
} }
@ -80,56 +80,56 @@ HIDDEN void create_backdrop( void )
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP"); const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
DWORD waiting_for = 0; DWORD waiting_for = 0;
BOOLEAN event_hook(HWND, WORD msg, WORD, BOOLEAN waiting_event_hook(HWND, WORD msg, WORD,
DWORD lparam, long far* ret) DWORD lparam, long far* ret)
{ {
if (msg == WM_WAKEUP) if (msg == WM_WAKEUP)
{ {
if( lparam == waiting_for || lparam == 0) if( lparam == waiting_for || lparam == 0)
{ {
waiting_for = 0L; waiting_for = 0L;
TTemp_window tw(TASK_WIN); TTemp_window tw(TASK_WIN);
tw.maximize(); tw.maximize();
} }
*ret = 0; *ret = 0;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
HIDDEN DWORD name2id(const char* name) HIDDEN DWORD name2id(const char* name)
{ {
waiting_for = 0L; waiting_for = 0L;
for (int i = 0; i < 5 && name[i] > ' '; i++) for (int i = 0; i < 5 && name[i] > ' '; i++)
{ {
waiting_for <<= 6; waiting_for <<= 6;
waiting_for |= toupper(name[i]) - '0'; waiting_for |= toupper(name[i]) - '0';
} }
return waiting_for; return waiting_for;
} }
void TApplication::wait_for(const char* command) void TApplication::wait_for(const char* command)
{ {
TTemp_window tw(TASK_WIN); TTemp_window tw(TASK_WIN);
tw.iconize(); tw.iconize();
name2id(cmd2name(command)); name2id(cmd2name(command));
set_value(TASK_WIN, ATTR_EVENT_HOOK, (long)event_hook); set_value(TASK_WIN, ATTR_EVENT_HOOK, (long)waiting_event_hook);
while (waiting_for) do_events(); while (waiting_for) do_events();
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// It seems necessary to restore these things // It seems necessary to restore these things
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
customize_controls(TRUE); customize_controls(TRUE);
xvt_statbar_refresh(); xvt_statbar_refresh();
} }
void TApplication::wake_up_caller() const void TApplication::wake_up_caller() const
{ {
name2id(name()); name2id(name());
SendMessage(-1, WM_WAKEUP, 0, waiting_for); SendMessage(-1, WM_WAKEUP, 0, waiting_for);
} }
#endif #endif
@ -138,116 +138,127 @@ void TApplication::wake_up_caller() const
void TApplication::print() void TApplication::print()
{ {
#ifdef DBG #ifdef DBG
error_box("Non saprei bene cosa stampare!"); error_box("Non saprei bene cosa stampare!");
#endif #endif
} }
long TApplication::task_eh(WINDOW win, EVENT *ep) long TApplication::task_eh(WINDOW win, EVENT *ep)
{ {
switch (ep->type) switch (ep->type)
{ {
case E_CREATE: case E_CREATE:
create_backdrop(); create_backdrop();
#if defined(DBG) && XVT_OS == XVT_OS_SCOUNIX #if defined(DBG) && XVT_OS == XVT_OS_SCOUNIX
message_box("attach to process %d ...", getpid()); message_box("Attach to process %d ...", getpid());
#endif #endif
do_events(); do_events();
break; break;
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
case E_UPDATE: case E_UPDATE:
backdrop_eh(win, ep); backdrop_eh(win, ep);
break; break;
#endif #endif
default: default:
break; break;
} }
return application->handler(win, ep); return application->handler(win, ep);
} }
void TApplication::about() const void TApplication::about() const
{ {
#include <prassi.ver> #include <prassi.ver>
message_box("PRASSI Version %g\nLibreria del %s", VERSION, __DATE__); message_box("PRASSI Versione %g\nProgramma %s\nLibreria del %s",
VERSION, (const char*)name(), __DATE__);
} }
long TApplication::handler(WINDOW, EVENT* ep) long TApplication::handler(WINDOW, EVENT* ep)
{ {
switch (ep->type) switch (ep->type)
{ {
case E_CREATE: case E_CREATE:
if (create() == FALSE) if (create() == FALSE)
stop_run(); stop_run();
break; break;
case E_COMMAND: case E_CHAR:
{ {
MENU_TAG mt = ep->v.cmd.tag; #ifdef DBG
switch(mt) KEY k = e_char_to_key(ep);
{ #endif
case M_FILE_QUIT: }
stop_run(); break;
break; case E_COMMAND:
case M_FILE_PG_SETUP: {
printer().set(); MENU_TAG mt = ep->v.cmd.tag;
break; switch(mt)
case M_FILE_PRINT: {
print(); case M_FILE_QUIT:
break; stop_run();
case M_FILE_NEW: break;
set_firm(); case M_FILE_PG_SETUP:
break; printer().set();
case M_FILE_REVERT: break;
config(); case M_FILE_PRINT:
break; print();
case (M_FILE+11) : break;
about(); case M_FILE_NEW:
break; set_firm();
default: break;
if (!menu(mt)) case M_FILE_REVERT:
stop_run(); config();
break; break;
} case (M_FILE+11) :
} about();
break; break;
case E_CLOSE: default:
if (can_close()) if (mt >= BAR_ITEM(1))
stop_run(); {
break; if(!menu(mt))
case E_QUIT: stop_run();
if (ep->v.query) }
{ break;
if (can_close()) }
quit_OK(); }
else break;
error_box("Chiudere la finestra attiva prima di chiudere il programma"); case E_CLOSE:
} if (can_close())
else stop_run(); stop_run();
break; break;
default: case E_QUIT:
break; if (ep->v.query)
} {
return 0L; if (can_close())
quit_OK();
else
error_box("Chiudere la finestra attiva prima di chiudere il programma");
}
else stop_run();
break;
default:
break;
}
return 0L;
} }
void TApplication::stop_run() void TApplication::stop_run()
{ {
if (savefirm) prefhndl->set_codditta(savefirm); if (savefirm) prefhndl->set_codditta(savefirm);
terminate(); terminate();
//#if XVT_OS == XVT_OS_WIN //#if XVT_OS == XVT_OS_WIN
// xvt_escape(XVT_ESC_WIN_TERMINATE); // xvt_escape(XVT_ESC_WIN_TERMINATE);
//#else //#else
xvt_terminate(); xvt_terminate();
//#endif //#endif
} }
TApplication::TApplication() : _printer(NULL) TApplication::TApplication() : _printer(NULL)
{ {
init_global_vars(); init_global_vars();
_bar = TASK_MENUBAR; _bar = TASK_MENUBAR;
} }
@ -257,71 +268,71 @@ TApplication::~TApplication()
TPrinter* TApplication::set_printer(TPrinter* p) TPrinter* TApplication::set_printer(TPrinter* p)
{ {
TPrinter* printer = _printer; TPrinter* printer = _printer;
_printer = p; _printer = p;
return printer; return printer;
} }
TPrinter& TApplication::printer() TPrinter& TApplication::printer()
{ {
if (_printer == NULL) _printer = new TPrinter; if (_printer == NULL) _printer = new TPrinter;
return *_printer; return *_printer;
} }
bool TApplication::create() bool TApplication::create()
{ {
// include_progind(); // TBC da eliminare quando il linker diventa furbo // include_progind(); // TBC da eliminare quando il linker diventa furbo
return TRUE; return TRUE;
} }
bool TApplication::destroy() bool TApplication::destroy()
{ {
return TRUE; return TRUE;
} }
void TApplication::terminate() void TApplication::terminate()
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
wake_up_caller(); // Manda il segnale di risveglio al chiamante wake_up_caller(); // Manda il segnale di risveglio al chiamante
#endif #endif
close_all_dialogs(); close_all_dialogs();
application->destroy(); // Distruzione files e maschere application->destroy(); // Distruzione files e maschere
do_events(); do_events();
if (_printer) // Distruzione dell'eventuale stampante if (_printer) // Distruzione dell'eventuale stampante
{ {
if (printer().isopen()) if (printer().isopen())
printer().close(); printer().close();
delete _printer; delete _printer;
_printer = NULL; _printer = NULL;
} }
free_global_vars(); // Distruzione variabili globali free_global_vars(); // Distruzione variabili globali
customize_controls(FALSE); // Rilascio eventuali DLL customize_controls(FALSE); // Rilascio eventuali DLL
} }
const char* TApplication::get_module_name() const const char* TApplication::get_module_name() const
{ {
TScanner scanner("prassi.aut"); TScanner scanner("prassi.aut");
bool ok = FALSE; bool ok = FALSE;
for (int aut = 0; scanner.line() != ""; aut++) for (int aut = 0; scanner.line() != ""; aut++)
if (strncmp(scanner.token(), _name, 2) == 0) { ok = TRUE; break; } if (strncmp(scanner.token(), _name, 2) == 0) { ok = TRUE; break; }
const char* module = scanner.token().mid(3); const char* module = scanner.token().mid(3);
if (ok) ok = has_module(aut); if (ok) ok = has_module(aut);
if (!ok) if (!ok)
fatal_box("Il modulo '%s' non e' autorizzato", module); fatal_box("Il modulo '%s' non e' autorizzato", module);
return module; return module;
} }
void TApplication::set_title(const char* t) void TApplication::set_title(const char* t)
@ -332,57 +343,57 @@ const char* TApplication::title() const
void TApplication::run(int argc, char* argv[], const char* title) void TApplication::run(int argc, char* argv[], const char* title)
{ {
TFilename base(argv[0]); TFilename base(argv[0]);
base.ext(""); base.lower(); base.ext(""); base.lower();
__argc = argc; __argc = argc;
__argv = (const char**)argv; __argv = (const char**)argv;
int addbar; int addbar;
if (argc > 1) if (argc > 1)
{ {
addbar = atoi(argv[1]+1); addbar = atoi(argv[1]+1);
_name = cmd2name(argv[0], argv[1]); _name = cmd2name(argv[0], argv[1]);
} }
else else
{ {
addbar = 0; addbar = 0;
_name = cmd2name(argv[0]); _name = cmd2name(argv[0]);
} }
TString80 caption; TString80 caption;
caption << "PRASSI S.P.A. - " << get_module_name(); caption << "PRASSI S.P.A. - " << get_module_name();
cfg.base_appl_name = (char*) base.name(); cfg.base_appl_name = (char*) base.name();
cfg.appl_name = (char*) title; cfg.appl_name = (char*) title;
cfg.taskwin_title = (char*)(const char*)caption; cfg.taskwin_title = (char*)(const char*)caption;
cfg.menu_bar_ID = TASK_MENUBAR+addbar; cfg.menu_bar_ID = TASK_MENUBAR+addbar;
cfg.about_box_ID = 0; cfg.about_box_ID = 0;
customize_controls(TRUE); customize_controls(TRUE);
application = this; application = this;
xvt_system(argc, argv, 0L, task_eh, &cfg); xvt_system(argc, argv, 0L, task_eh, &cfg);
} }
void TApplication::check_menu_item(MENU_TAG item) void TApplication::check_menu_item(MENU_TAG item)
{ {
win_menu_check(TASK_WIN, item, TRUE); win_menu_check(TASK_WIN, item, TRUE);
win_update_menu_bar(TASK_WIN); win_update_menu_bar(TASK_WIN);
} }
void TApplication::uncheck_menu_item(MENU_TAG item) void TApplication::uncheck_menu_item(MENU_TAG item)
{ {
win_menu_check(TASK_WIN, item, FALSE); win_menu_check(TASK_WIN, item, FALSE);
win_update_menu_bar(TASK_WIN); win_update_menu_bar(TASK_WIN);
} }
void TApplication::enable_menu_item(MENU_TAG item, bool on) void TApplication::enable_menu_item(MENU_TAG item, bool on)
{ {
win_menu_enable(TASK_WIN, item, on); win_menu_enable(TASK_WIN, item, on);
win_update_menu_bar(TASK_WIN); win_update_menu_bar(TASK_WIN);
} }
@ -393,140 +404,139 @@ void TApplication::dispatch_e_menu(MENU_TAG item)
HWND w = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW); HWND w = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);
PostMessage(w, WM_COMMAND, item, 0L); PostMessage(w, WM_COMMAND, item, 0L);
#else #else
EVENT e; EVENT e;
e.type = E_COMMAND; e.type = E_COMMAND;
e.v.cmd.tag = item; e.v.cmd.tag = item;
e.v.cmd.shift = e.v.cmd.control = 0; e.v.cmd.shift = e.v.cmd.control = 0;
dispatch_event(TASK_WIN, &e); dispatch_event(TASK_WIN, &e);
#endif #endif
} }
bool TApplication::has_module(int module) const bool TApplication::has_module(int module) const
{ {
return (bool)CGetAut(module); return (bool)CGetAut(module);
} }
long TApplication::get_firm() const long TApplication::get_firm() const
{ {
return prefhndl->get_codditta(); return prefhndl->get_codditta();
} }
const char* TApplication::get_firm_dir() const const char* TApplication::get_firm_dir() const
{ {
// return prefhndl->name(); return format("%s%s", __ptprf, prefhndl->name());
return format("%s%s", __ptprf, prefhndl->name());
} }
bool TApplication::set_firm(long newfirm) bool TApplication::set_firm(long newfirm)
{ {
disable_menu_item(M_FILE_NEW); disable_menu_item(M_FILE_NEW);
const long oldfirm = get_firm(); const long oldfirm = get_firm();
if (newfirm < 1) if (newfirm < 1)
{ {
TMask mask("bagn002"); TMask mask("bagn002");
mask.send_key(K_CTRL+K_SHIFT+(extended_firm() ? 's' : 'h'), -2); mask.send_key(K_CTRL+K_SHIFT+(extended_firm() ? 's' : 'h'), -2);
const KEY k = mask.run(); const KEY k = mask.run();
enable_menu_item(M_FILE_NEW); enable_menu_item(M_FILE_NEW);
if (k == K_ENTER) if (k == K_ENTER)
{ {
newfirm = atol(mask.get(F_CODDITTA)); newfirm = atol(mask.get(F_CODDITTA));
const int tipodir = atoi(mask.get(F_TIPO)); const int tipodir = atoi(mask.get(F_TIPO));
if (tipodir > 0) if (tipodir > 0)
{ {
if (savefirm == 0) savefirm = oldfirm; if (savefirm == 0) savefirm = oldfirm;
prefhndl->set(tipodir == 1 ? "com" : ""); prefhndl->set(tipodir == 1 ? "com" : "");
return TRUE; return TRUE;
} }
} }
} }
if (newfirm == oldfirm || newfirm < 1) if (newfirm == oldfirm || newfirm < 1)
return FALSE; return FALSE;
if (prefhndl->test(newfirm)) if (prefhndl->test(newfirm))
{ {
prefhndl->set_codditta(newfirm); prefhndl->set_codditta(newfirm);
savefirm = 0; savefirm = 0;
} }
return TRUE; return TRUE;
} }
bool TApplication::config() bool TApplication::config()
// gestisce le voci di configurazione // gestisce le voci di configurazione
// le si passa il file in cui cercare il proprio // le si passa il file in cui cercare il proprio
// paragrafo (comunque relativo alla ditta) // paragrafo (comunque relativo alla ditta)
// se non c'e', viene creato copiando il default // se non c'e', viene creato copiando il default
// la variabile EdMask di quel paragrafo specifica // la variabile EdMask di quel paragrafo specifica
// la maschera da usare // la maschera da usare
{ {
TConfig cnf(CONFIG_DITTA); TConfig cnf(CONFIG_DITTA);
bool ok = FALSE; bool ok = FALSE;
TString80 maskname(cnf.get("EdMask")); TString80 maskname(cnf.get("EdMask"));
if (!maskname.empty()) if (!maskname.empty())
{
TMask m(maskname);
// carica campi
for (int i = 0; i < m.fields(); i++)
{ {
TMask m(maskname); TMask_field& f = m.fld(i);
const TFieldref* fref = f.field();
// carica campi if (fref != NULL)
for (int i = 0; i < m.fields(); i++) {
{ const char* fname = fref->name();
TMask_field& f = m.fld(i); if (fname != NULL)
const TFieldref* fref = f.field(); {
if (fref != NULL) TString& oldvl = cnf.get(fname);
{ if (!oldvl.empty())
const char* fname = fref->name(); f.set(oldvl);
if (fname != NULL) }
{ }
TString& oldvl = cnf.get(fname);
if (!oldvl.empty())
f.set(oldvl);
}
}
}
// run mask
disable_menu_item(M_FILE_NEW);
disable_menu_item(M_FILE_REVERT);
if (m.run() == K_ENTER)
{
// aggiusta campi
for (i = 0; i < m.fields(); i++)
{
TMask_field& f = m.fld(i);
if (f.dirty())
{
const TFieldref* fref = f.field();
if (fref != NULL)
{
const char* fname = fref->name();
const char* value = f.get();
const char* oldvl = cnf.get(fname);
if (change_config(fname,oldvl,value))
cnf.set(fname, value, NULL, TRUE);
}
}
}
ok = TRUE;
}
else ok = FALSE;
enable_menu_item(M_FILE_NEW);
enable_menu_item(M_FILE_REVERT);
return ok;
} }
// run mask
disable_menu_item(M_FILE_NEW);
disable_menu_item(M_FILE_REVERT);
if (m.run() == K_ENTER)
{
// aggiusta campi
for (i = 0; i < m.fields(); i++)
{
TMask_field& f = m.fld(i);
if (f.dirty())
{
const TFieldref* fref = f.field();
if (fref != NULL)
{
const char* fname = fref->name();
const char* value = f.get();
const char* oldvl = cnf.get(fname);
if (change_config(fname,oldvl,value))
cnf.set(fname, value, NULL, TRUE);
}
}
}
ok = TRUE;
}
else ok = FALSE;
enable_menu_item(M_FILE_NEW);
enable_menu_item(M_FILE_REVERT);
return ok;
}
return warning_box("Nessun parametro da configurare"); return warning_box("Nessun parametro da configurare");
} }
bool TApplication::change_config(const char* var, const char* oldv, bool TApplication::change_config(const char* var, const char* oldv,
const char* newv) const char* newv)
{ return TRUE; } { return TRUE; }

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,6 @@ MENU MENU_ALT_EDIT
ITEM M_EDIT_SEARCH "C~erca" DISABLED ITEM M_EDIT_SEARCH "C~erca" DISABLED
ACCEL MENU_FILE "f" ALT ACCEL MENU_FILE "f" ALT
ACCEL MENU_EDIT "g" ALT
#if XVTWS == WINWS #if XVTWS == WINWS
#scan <xil.h> #scan <xil.h>

View File

@ -23,12 +23,12 @@
class TFile : public TObject class TFile : public TObject
{ {
// @DPRIV // @DPRIV
SecDef* _file; SecDef* _file;
int _len; int _len;
int _base; int _base;
public: public:
// @FPUB // @FPUB
void open(const char* name, TFilelock lockmode = _manulock); void open(const char* name, TFilelock lockmode = _manulock);
bool verify(const char* name); bool verify(const char* name);
void create(const char* name, TRecnotype nrecord = 10); void create(const char* name, TRecnotype nrecord = 10);
@ -54,12 +54,12 @@ public:
class TDir : public TObject class TDir : public TObject
{ {
// @DPRIV // @DPRIV
FileDes* _dir; FileDes* _dir;
int _num; int _num;
public: public:
// @FPUB // @FPUB
void get(int nfile, TReclock lock = _nolock, TDirtype dirtype = _nordir, TDirop op = _nordirop); void get(int nfile, TReclock lock = _nolock, TDirtype dirtype = _nordir, TDirop op = _nordirop);
void put(int nfile, TDirtype dirtype = _nordir, TDirop op = _nordirop); void put(int nfile, TDirtype dirtype = _nordir, TDirop op = _nordirop);
void zero(); void zero();
@ -91,14 +91,14 @@ public:
class TTrec : public TSortable class TTrec : public TSortable
{ {
// @DPRIV // @DPRIV
RecDes* _rec; RecDes* _rec;
int _num; int _num;
protected: protected:
int compare(const TSortable& a) const; int compare(const TSortable& a) const;
public: public:
// @FPUB // @FPUB
void get(int nfile, TDirtype dirtype = _nordir); void get(int nfile, TDirtype dirtype = _nordir);
void put(int nfile, TDirtype dirtype = _nordir); void put(int nfile, TDirtype dirtype = _nordir);
void zero(); void zero();
@ -114,13 +114,15 @@ public:
void set_keys(int nkeys) { _rec->NKeys = nkeys;} void set_keys(int nkeys) { _rec->NKeys = nkeys;}
const char* fielddef(int fld) const; // ritorna una token string const char* fielddef(int fld) const; // ritorna una token string
const char* keydef(int key) const; const char* keydef(int key) const;
int len() const { return _rec->Fd[fields() - 1].RecOff +
_rec->Fd[fields() - 1].Len; }
#ifndef FOXPRO
void update_keydef(int key, const char* desc); //desc e' una token string void update_keydef(int key, const char* desc); //desc e' una token string
void update_fielddef(int nfld, const char* desc); //desc e' una token string void update_fielddef(int nfld, const char* desc); //desc e' una token string
int len() const { return _rec->Fd[fields() - 1].RecOff +
_rec->Fd[fields() - 1].Len; }
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
virtual void read_from(istream& in); virtual void read_from(istream& in);
#endif
TTrec(); TTrec();
virtual ~TTrec(); virtual ~TTrec();

View File

@ -13,13 +13,14 @@
#define K_SPACE 32 #define K_SPACE 32
#define K_SHIFT 1000 #define K_SHIFT 1000
#define K_CTRL 10000 #define K_CTRL 10000
#define K_SHIFT_ENTER K_ENTER+K_SHIFT #define K_CTRL_ENTER K_CTRL+K_ENTER
#define K_SHIFT_TAB K_TAB+K_SHIFT #define K_AUTO_ENTER K_SHIFT+K_ENTER
#define K_QUIT 10334
#define K_SAVE 10082
#define K_SHIFT_TAB K_SHIFT+K_TAB
#define K_SHIFT_F2 K_SHIFT+K_F2 #define K_SHIFT_F2 K_SHIFT+K_F2
#define K_SHIFT_F3 K_SHIFT+K_F3 #define K_SHIFT_F3 K_SHIFT+K_F3
#define K_NO 'N' #define K_NO 'N'
#define K_SAVE 'S'
#define K_QUIT 'Q'
#define K_YES 'Y' #define K_YES 'Y'
/* @END */ /* @END */

View File

@ -97,30 +97,46 @@ void TMask::handler(WINDOW win, EVENT* ep)
case E_CONTROL: case E_CONTROL:
switch(ep->v.ctl.id) switch(ep->v.ctl.id)
{ {
case DLG_OK :on_key(K_SHIFT_ENTER); break; case DLG_OK :
case DLG_BAR : on_key(K_AUTO_ENTER); break;
case DLG_CANCEL :on_key(K_ESC); break; case DLG_BAR :
case DLG_PGDN :on_key(K_NEXT); break; case DLG_CANCEL :
case DLG_PGUP :on_key(K_PREV); break; on_key(K_ESC); break;
case DLG_FIRSTREC:stop_run(K_HOME); break; /*
case DLG_PREVREC :stop_run(K_PREV); break; case DLG_PGDN :
case DLG_NEXTREC :stop_run(K_NEXT); break; on_key(K_NEXT); break;
case DLG_FINDREC :stop_run(K_F9); break; case DLG_PGUP :
case DLG_LASTREC :stop_run(K_END); break; on_key(K_PREV); break;
case DLG_NEWREC :stop_run(K_INS); break; case DLG_FIRSTREC:
case DLG_DELREC :stop_run(K_DEL); break; stop_run(K_HOME); break;
case DLG_SAVEREC :stop_run(K_SAVE); break; case DLG_PREVREC :
case DLG_QUIT :stop_run(K_QUIT); break; stop_run(K_PREV); break;
case DLG_F9: case DLG_NEXTREC :
{ stop_run(K_NEXT); break;
TMask_field* f = (TMask_field*)get_app_data(ep->v.ctl.ci.win); case DLG_FINDREC :
f->on_key(K_F9); stop_run(K_F9); break;
} case DLG_LASTREC :
break; stop_run(K_END); break;
default: case DLG_NEWREC :
control_handler(ep); stop_run(K_INS); break;
break; case DLG_DELREC :
} stop_run(K_DEL); break;
case DLG_SAVEREC :
stop_run(K_SAVE); break;
case DLG_QUIT :
stop_run(K_QUIT); break;
*/
case DLG_F9:
{
// Attiva ricerca sul campo associato al bottone
TMask_field* f = (TMask_field*)get_app_data(ep->v.ctl.ci.win);
f->on_key(K_F9);
}
break;
default:
control_handler(ep);
break;
}
break; break;
default: default:
break; break;
@ -130,15 +146,16 @@ void TMask::handler(WINDOW win, EVENT* ep)
void TMask::init_mask(int mode) void TMask::init_mask(int mode)
{ {
_sheets = _pages = 0; _sheets = _pages = 0; // Azzera numero pagine e sheets
_enabled = 0xffff; _enabled = 0xffff; // Abilita tutte le pagine
_focus = _first_focus = 0; _focus = _first_focus = 0; // Nessuna ha il focus
_page = -1; _page = -1; // Nessuan pagina corrente
_handler = NULL; _mode = mode; _handler = NULL; // Nessun handler utente
_exchange = 1.0; _mode = mode; // Inizializza modo
_exchange = 1.0; // Il cambio per la valuta e' la lira
for (int i = 0; i <= MAX_PAGES; i++) for (int i = 0; i <= MAX_PAGES; i++)
_pagewin[i] = NULL_WIN; _pagewin[i] = NULL_WIN; // Azzera le finestre delle varie pagine
} }
@ -584,13 +601,42 @@ void TMask::move_focus_field(int d)
bool TMask::stop_run(KEY key) bool TMask::stop_run(KEY key)
{ {
if (key == K_SHIFT_ENTER) key = K_ENTER; if (key == K_CTRL_ENTER) key = K_ENTER;
if (key != K_AUTO_ENTER)
{
const int last = fields();
bool found = FALSE;
for (int i = 0; i < last; i++)
{
const TMask_field& f = fld(i);
if (f.class_id() != CLASS_BUTTON_FIELD) continue;
const TButton_field& b = (const TButton_field&)f;
if (b.exit_key() == key)
{
if (b.active())
{
found = TRUE;
break;
}
}
}
if (!found)
{
#ifdef DBG
return error_box("Non e' attivo il bottone associato a %d", key);
#else
beep();
return FALSE;
#endif
}
} else key = K_ENTER;
if (key != K_ESC && key != K_QUIT && key != K_DEL) if (key != K_ESC && key != K_QUIT && key != K_DEL)
{ {
const bool ok = check_fields(); const bool ok = check_fields();
if (!ok) return FALSE; if (!ok) return FALSE;
if (is_running()) // Gestisce meglio le maschere chiuse if (is_running()) // Gestisce correttamenete le maschere chiuse
get_mask_fields(); get_mask_fields();
} }
@ -607,11 +653,10 @@ bool TMask::on_key(KEY key)
switch(key) switch(key)
{ {
case K_SHIFT_ENTER: case K_AUTO_ENTER:
case K_CTRL_ENTER:
case K_QUIT: case K_QUIT:
case K_ESC: case K_ESC:
case K_INS:
case K_DEL:
stop_run(key); stop_run(key);
break; break;
case K_UP: case K_UP:
@ -639,17 +684,33 @@ bool TMask::on_key(KEY key)
#ifdef DBG #ifdef DBG
case K_F11: case K_F11:
message_box("Siete fortunati utenti del campo %d della maschera '%s'\n" message_box("Siete fortunati utenti del campo %d della maschera '%s'\n"
"caricata nell'incredibile tempo di %ld cicli\n" "caricata nell'incredibile tempo di %ld millisecondi\n"
"ed inizializzata mostruosamente in %ld cicli\n" "ed inizializzata mostruosamente in %ld millisecondi\n"
"Grazie per la comprensione", "Grazie per la comprensione",
fld(_focus).dlg(), (const char*)source_file(), clock1, clock2); fld(_focus).dlg(), (const char*)source_file(), clock1, clock2);
break; break;
#endif #endif
default: default:
if (key >= K_CTRL+K_F1 && key <= K_CTRL+K_F12) if (key > K_CTRL)
{ {
const int page = key - (K_CTRL+K_F1); key -= K_CTRL;
next_page(1000+page); if (key >= K_F1 && key <= K_F10)
next_page(1000 + key - K_F1);
else
{
const int last = fields();
for (int i = 0; i < last; i++)
{
TMask_field& f = fld(i);
if (f.class_id() != CLASS_BUTTON_FIELD || !f.active()) continue;
TButton_field& b = (TButton_field&)f;
if (b.virtual_key() == key && fld(_focus).on_key(K_TAB) == TRUE)
{
f.on_key(K_SPACE);
break;
}
}
}
} }
else return fld(_focus).on_key(key); else return fld(_focus).on_key(key);
} }

View File

@ -17,8 +17,8 @@
// @T // @T
typedef bool (*MASK_HANDLER)(TMask& mask, KEY key); typedef bool (*MASK_HANDLER)(TMask& mask, KEY key);
enum TMaskmode { NO_MODE, MODE_INS , MODE_MOD , MODE_DEL , enum TMaskmode { NO_MODE, MODE_INS , MODE_MOD , MODE_DEL ,
MODE_VIS , MODE_QUERY, MODE_QUERYINS, MODE_VIS , MODE_QUERY, MODE_QUERYINS,
MODE_SEARCH }; MODE_SEARCH };
// @END // @END
// @C // @C
@ -27,161 +27,161 @@ enum TMaskmode { NO_MODE, MODE_INS , MODE_MOD , MODE_DEL ,
class TMask : public TWindow class TMask : public TWindow
{ {
// @DPRIV // @DPRIV
enum { MAX_PAGES = 12 }; // Massimo numero di pagine nella maschera enum { MAX_PAGES = 12 }; // Massimo numero di pagine nella maschera
WINDOW _pagewin[MAX_PAGES+1]; // Windows of the pages WINDOW _pagewin[MAX_PAGES+1]; // Windows of the pages
int _pages; // Number of pages of the mask int _pages; // Number of pages of the mask
int _page; // Current page int _page; // Current page
word _enabled; // Are pages enabled (bit field) word _enabled; // Are pages enabled (bit field)
int _mode; // Mode of the mask int _mode; // Mode of the mask
TArray _field; // Fields in the mask TArray _field; // Fields in the mask
int _first_focus; // First control to have focus int _first_focus; // First control to have focus
int _focus; // Control with focus int _focus; // Control with focus
int _sheets; // Number of sheets int _sheets; // Number of sheets
MASK_HANDLER _handler; // User defined key handler MASK_HANDLER _handler; // User defined key handler
TFilename _source_file; // Source file of the mask TFilename _source_file; // Source file of the mask
TFilename _workfile; // Name of savefile TFilename _workfile; // Name of savefile
long _lastpos; // last read offset on savefile long _lastpos; // last read offset on savefile
real _exchange; // Current value exhange real _exchange; // Current value exhange
protected: protected:
// Ritorna la finestra della pagina corrente (Usare con attenzione) // Ritorna la finestra della pagina corrente (Usare con attenzione)
WINDOW win() const { return _page == -1 ? NULL_WIN : _pagewin[_page]; } WINDOW win() const { return _page == -1 ? NULL_WIN : _pagewin[_page]; }
WINDOW toolwin() const { return _pagewin[MAX_PAGES]; } WINDOW toolwin() const { return _pagewin[MAX_PAGES]; }
int find_field_win(WINDOW win) const; // number of field with window win int find_field_win(WINDOW win) const; // number of field with window win
void set_mask_fields() const; // update screen void set_mask_fields() const; // update screen
void load_checks() const; // load checks related fields void load_checks() const; // load checks related fields
virtual void start_run(); // called when the mask starts to run virtual void start_run(); // called when the mask starts to run
virtual TMask_field* parse_field(TScanner& scanner); virtual TMask_field* parse_field(TScanner& scanner);
void init_mask(int mode); void init_mask(int mode);
WINDOW read_page(TScanner& scanner, bool toolbar = FALSE); WINDOW read_page(TScanner& scanner, bool toolbar = FALSE);
void read_mask(const char* name, int mode, int num); void read_mask(const char* name, int mode, int num);
void add_buttons(); void add_buttons();
int find_parent_page(const TMask_field&) const; int find_parent_page(const TMask_field&) const;
int find_first_field(WINDOW w, int dir) const; int find_first_field(WINDOW w, int dir) const;
int find_active_field(int first, int dir) const; int find_active_field(int first, int dir) const;
bool check_current_page(); // Check all the fields on the current page bool check_current_page(); // Check all the fields on the current page
void next_page(int p); // Show next/previous page void next_page(int p); // Show next/previous page
int curr_page() const { return _page; } // Current page number int curr_page() const { return _page; } // Current page number
void control_handler(EVENT* ep); void control_handler(EVENT* ep);
void handler(WINDOW win, EVENT* ep); void handler(WINDOW win, EVENT* ep);
public: public:
// @FPUB // @FPUB
// crea leggendo descrizione da file .msk // crea leggendo descrizione da file .msk
TMask(const char* name, int mode = NO_MODE, int num = 0); TMask(const char* name, int mode = NO_MODE, int num = 0);
// crea mask vuota con parametri dati // crea mask vuota con parametri dati
TMask(const char* title, int pages, int cols, int rows, int xpos = -1, TMask(const char* title, int pages, int cols, int rows, int xpos = -1,
int ypos = -1, int mode = NO_MODE); int ypos = -1, int mode = NO_MODE);
virtual ~TMask(); virtual ~TMask();
const TFilename& source_file() const { return _source_file; } const TFilename& source_file() const { return _source_file; }
// aggiunta campi a runtime // aggiunta campi a runtime
void add_static (short id, int page, const char* prompt, int x, int y, void add_static (short id, int page, const char* prompt, int x, int y,
const char* flags = ""); const char* flags = "");
void add_string (short id, int page, const char* prompt, int x, int y, void add_string (short id, int page, const char* prompt, int x, int y,
int dim, const char* flags = "", int width = 0); int dim, const char* flags = "", int width = 0);
void add_number (short id, int page, const char* prompt, int x, int y, void add_number (short id, int page, const char* prompt, int x, int y,
int dim, const char* flags = "", int ndec = 0); int dim, const char* flags = "", int ndec = 0);
void add_date (short id, int page, const char* prompt, int x, int y, void add_date (short id, int page, const char* prompt, int x, int y,
const char* flags = ""); const char* flags = "");
void add_button (short id, int page, const char* prompt, int x, int y, void add_button (short id, int page, const char* prompt, int x, int y,
int dx = 9, int dy = 1, const char* flags = ""); int dx = 9, int dy = 1, const char* flags = "");
void add_radio(short id, int page, const char* prompt, int x, int y, void add_radio(short id, int page, const char* prompt, int x, int y,
int dx, const char* codes, const char* items, const char* flags = ""); int dx, const char* codes, const char* items, const char* flags = "");
int fields() const { return _field.items(); } int fields() const { return _field.items(); }
int sheets() const { return _sheets; } int sheets() const { return _sheets; }
void set_mode(int m) { _mode = m; } void set_mode(int m) { _mode = m; }
int mode() const { return _mode; } int mode() const { return _mode; }
void set_exchange(const real& e); void set_exchange(const real& e);
const real& exchange() const { return _exchange; } const real& exchange() const { return _exchange; }
bool check_fields(); bool check_fields();
void get_mask_fields(); // read screen contents void get_mask_fields(); // read screen contents
virtual bool stop_run(KEY key); // called to close the mask virtual bool stop_run(KEY key); // called to close the mask
virtual void open(); virtual void open();
virtual void close(); virtual void close();
virtual void enable(bool on) const; virtual void enable(bool on) const;
int id2pos(short id) const; int id2pos(short id) const;
TMask_field& fld(int i) const { return (TMask_field&)_field[i]; } // Ritorna il campo i-esimo della maschera TMask_field& fld(int i) const { return (TMask_field&)_field[i]; } // Ritorna il campo i-esimo della maschera
TMask_field& field(short id) const; // field with given id TMask_field& field(short id) const; // field with given id
void set(short fld_id, const char* str, bool hit=FALSE); void set(short fld_id, const char* str, bool hit=FALSE);
void set(short fld_id, long num, bool hit=FALSE); void set(short fld_id, long num, bool hit=FALSE);
const TString& get(short fld_id) const; const TString& get(short fld_id) const;
long get_long(short fld_id) const; long get_long(short fld_id) const;
int get_int(short fld_id) const { return (int)get_long(fld_id); } int get_int(short fld_id) const { return (int)get_long(fld_id); }
bool get_bool(short fld_id) const; bool get_bool(short fld_id) const;
int first_focus(short id); int first_focus(short id);
void set_focus(); void set_focus();
void move_focus_field(int num); void move_focus_field(int num);
void set_focus_win(WINDOW win, bool force); void set_focus_win(WINDOW win, bool force);
int focus_field() const { return _focus;} int focus_field() const { return _focus;}
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
void enable(short fld_id, bool on = TRUE); // Abilita un campo void enable(short fld_id, bool on = TRUE); // Abilita un campo
void disable(short fld_id) { enable(fld_id, FALSE); } void disable(short fld_id) { enable(fld_id, FALSE); }
void enable_default(short fld_id = -1); void enable_default(short fld_id = -1);
void enable_page(int p, bool on = TRUE); void enable_page(int p, bool on = TRUE);
void disable_page(int p) { enable_page(p, FALSE); } void disable_page(int p) { enable_page(p, FALSE); }
bool page_enabled(int p) const; bool page_enabled(int p) const;
byte num_keys() const; byte num_keys() const;
void enable_key(byte key, bool on = TRUE); void enable_key(byte key, bool on = TRUE);
void disable_key(byte key) { enable_key(key, FALSE); } void disable_key(byte key) { enable_key(key, FALSE); }
short get_key_field(byte key, bool first) const; short get_key_field(byte key, bool first) const;
bool key_valid(int key) const; bool key_valid(int key) const;
void show(short fld_id = -1, bool on = TRUE); void show(short fld_id = -1, bool on = TRUE);
void hide(short fld_id = -1) { show(fld_id, FALSE); } void hide(short fld_id = -1) { show(fld_id, FALSE); }
void show_default(short fld_id = -1); void show_default(short fld_id = -1);
void reset(short fld_id = -1); void reset(short fld_id = -1);
void undo(short fld_id = -1); void undo(short fld_id = -1);
void autoload(const TRelation* = NULL); void autoload(const TRelation* = NULL);
void autosave(TRelation* = NULL) const; void autosave(TRelation* = NULL) const;
void send_key(KEY key, short id) const; void send_key(KEY key, short id) const;
void set_handler(short fld_id, CONTROL_HANDLER handler); void set_handler(short fld_id, CONTROL_HANDLER handler);
void set_handler(MASK_HANDLER handler); void set_handler(MASK_HANDLER handler);
void set_workfile(const char* workfile) { _workfile = workfile; _lastpos = 0L;} void set_workfile(const char* workfile) { _workfile = workfile; _lastpos = 0L;}
bool save(bool append = FALSE) const; bool save(bool append = FALSE) const;
bool load(bool reset = FALSE); bool load(bool reset = FALSE);
short dirty() const; // Ritorna il primo campo dirty short dirty() const; // Ritorna il primo campo dirty
bool no_mode() const { return _mode == NO_MODE; } bool no_mode() const { return _mode == NO_MODE; }
bool query_mode() const { return _mode == MODE_QUERY || _mode == MODE_QUERYINS; } bool query_mode() const { return _mode == MODE_QUERY || _mode == MODE_QUERYINS; }
bool edit_mode() const { return _mode == MODE_MOD || _mode == MODE_VIS || _mode == MODE_DEL; } bool edit_mode() const { return _mode == MODE_MOD || _mode == MODE_VIS || _mode == MODE_DEL; }
bool insert_mode() const { return _mode == MODE_QUERYINS || _mode == MODE_INS; } bool insert_mode() const { return _mode == MODE_QUERYINS || _mode == MODE_INS; }
virtual const char* get_caption() const; virtual const char* get_caption() const;
virtual void set_caption(const char* c); virtual void set_caption(const char* c);
}; };
#endif // __MASK_H #endif // __MASK_H

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.2 1994-08-17 14:05:45 guy Exp $ // $Id: maskfld.cpp,v 1.3 1994-08-23 13:52:21 guy Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -1823,7 +1823,7 @@ bool TEdit_field::on_key(KEY key)
{ {
for (int fld = m.get_key_field(i, TRUE); fld != -1; fld = m.get_key_field(i, FALSE)) for (int fld = m.get_key_field(i, TRUE); fld != -1; fld = m.get_key_field(i, FALSE))
m.field(fld).set_dirty(FALSE); m.field(fld).set_dirty(FALSE);
dispatch_e_char(get_parent(win()), K_SHIFT_ENTER); dispatch_e_char(get_parent(win()), K_AUTO_ENTER);
break; break;
} }
} }
@ -2053,29 +2053,49 @@ void TButton_field::create(WINDOW parent)
{ {
long flags = CTL_FLAG_CENTER_JUST; long flags = CTL_FLAG_CENTER_JUST;
if (_prompt.empty()) switch (dlg()) switch (dlg())
{ {
case DLG_OK: case DLG_OK:
_prompt = "Conferma"; if (_prompt.empty())
_prompt = "Conferma";
_virtual_key = _exit_key = K_ENTER;
flags |= CTL_FLAG_DEFAULT; flags |= CTL_FLAG_DEFAULT;
break; break;
case DLG_CANCEL: case DLG_CANCEL:
_prompt = "Annulla"; if (_prompt.empty())
_prompt = "Annulla";
_virtual_key = _exit_key = K_ESC;
break; break;
case DLG_PGUP:
_prompt = "Pag <<"; break;
case DLG_PGDN:
_prompt = "Pag >>"; break;
case DLG_SAVEREC:
_prompt = "Registra"; break;
case DLG_QUIT: case DLG_QUIT:
_prompt = "Fine"; break; if (_prompt.empty())
_prompt = "Fine";
_virtual_key = K_F4;
_exit_key = K_QUIT;
break;
default: default:
{
_exit_key = 0;
TToken_string* message = (TToken_string*)_message.objptr(0);
if (message != NULL)
{
TToken_string msg(message->get(0), ',');
const TFixed_string m(msg.get(0));
if (m == "EXIT")
_exit_key = msg.get_int();
else
if (msg.get_int() == 0) _exit_key = atoi(m);
}
const int n = _prompt.find('~');
_virtual_key = (n >= 0) ? toupper(_prompt[n+1]) : _exit_key;
}
break; break;
} }
#if XWTWS == WMWS #if XWTWS == WMWS
_prompt.center_just(_width); _prompt.center_just(_width);
#endif #endif
wincreate(WC_PUSHBUTTON, _width + 2, _size, _prompt, parent, flags); wincreate(WC_PUSHBUTTON, _width + 2, _size, _prompt, parent, flags);
} }

View File

@ -1,4 +1,4 @@
/* $Id: maskfld.h,v 1.1.1.1 1994-08-12 10:51:57 alex Exp $ */ /* $Id: maskfld.h,v 1.2 1994-08-23 13:52:23 guy Exp $ */
#ifndef __MASKFLD_H #ifndef __MASKFLD_H
#define __MASKFLD_H #define __MASKFLD_H
@ -17,8 +17,8 @@
class TMask_field; class TMask_field;
class TRelation; // __RELATION_H class TRelation; // __RELATION_H
class TCursor; class TCursor;
class TFieldref; class TFieldref;
// @T // @T
typedef bool (*CONTROL_HANDLER)(TMask_field& field, KEY key); typedef bool (*CONTROL_HANDLER)(TMask_field& field, KEY key);
@ -33,167 +33,167 @@ enum CheckTime { RUNNING_CHECK, STARTING_CHECK, FINAL_CHECK };
class TMask_field : public TObject class TMask_field : public TObject
{ {
// @DPRIV // @DPRIV
friend class TMask; friend class TMask;
TMask* _mask; // The mask the control belongs to TMask* _mask; // The mask the control belongs to
TString _help; // Help message TString _help; // Help message
TFieldref* _field; // Corresponding field on the file TFieldref* _field; // Corresponding field on the file
TBit_array _keys; // The keys the field belongs to TBit_array _keys; // The keys the field belongs to
TBit_array _groups; // The groups the field belongs to TBit_array _groups; // The groups the field belongs to
protected: protected:
// @DPROT // @DPROT
static int _x, _y; // Coordinate of the control static int _x, _y; // Coordinate of the control
static int _width; // Size of the control static int _width; // Size of the control
static TFixed_string _prompt;// Prompt of the field static TFixed_string _prompt;// Prompt of the field
CONTROL_HANDLER _handler; CONTROL_HANDLER _handler;
int _size; // Max length of the string int _size; // Max length of the string
WINDOW _win; // Window of the control (not its parent!) WINDOW _win; // Window of the control (not its parent!)
WINDOW _promptwin; // Prompt of the control WINDOW _promptwin; // Prompt of the control
short _dlg; // Identifier of the control short _dlg; // Identifier of the control
int _validate_func; // Number of validation function int _validate_func; // Number of validation function
TArray _validate_parms; // Parameters for validation function TArray _validate_parms; // Parameters for validation function
TArray _message; // Messages to send on modify TArray _message; // Messages to send on modify
struct TField_Flags struct TField_Flags
{ {
bool automagic : 1; bool automagic : 1;
bool dirty : 1; // Modified during run ? bool dirty : 1; // Modified during run ?
bool enabled : 1; // Is editable bool enabled : 1; // Is editable
bool enable_default : 1; bool enable_default : 1;
bool firm : 1; // Is the current firm ? bool firm : 1; // Is the current firm ?
bool focusdirty : 1; // Modified during focus ? bool focusdirty : 1; // Modified during focus ?
bool ghost : 1; bool ghost : 1;
bool persistent : 1; bool persistent : 1;
bool rightjust : 1; bool rightjust : 1;
bool roman : 1; // Is a Roman number ? bool roman : 1; // Is a Roman number ?
bool showed : 1; // Is visible bool showed : 1; // Is visible
bool show_default : 1; bool show_default : 1;
bool uppercase : 1; bool uppercase : 1;
bool exchange : 1; // Value exchange bool exchange : 1; // Value exchange
bool zerofilled : 1; bool zerofilled : 1;
TField_Flags(); TField_Flags();
char update(const char*); char update(const char*);
} _flags; } _flags;
void construct(TScanner& scanner, WINDOW parent); void construct(TScanner& scanner, WINDOW parent);
void construct(short id, const char* prompt, int x, int y, int len, void construct(short id, const char* prompt, int x, int y, int len,
WINDOW parent, const char* flags = "", int width = 0); WINDOW parent, const char* flags = "", int width = 0);
virtual WINDOW win() const { return _win; } virtual WINDOW win() const { return _win; }
WINDOW wincreate(WIN_TYPE ct, short dx, short dy, WINDOW wincreate(WIN_TYPE ct, short dx, short dy,
const char* title, WINDOW parent, long flags); const char* title, WINDOW parent, long flags);
int create_prompt(WINDOW parent, int width = 0, int heigth = 1); int create_prompt(WINDOW parent, int width = 0, int heigth = 1);
long default_flags() const; long default_flags() const;
virtual void parse_head(TScanner& scanner); virtual void parse_head(TScanner& scanner);
virtual bool parse_item(TScanner& scanner); virtual bool parse_item(TScanner& scanner);
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
virtual void destroy(); virtual void destroy();
virtual const char* get_window_data() const; virtual const char* get_window_data() const;
virtual void set_window_data(const char* data); virtual void set_window_data(const char* data);
virtual void set_field_data(const char* data); virtual void set_field_data(const char* data);
virtual const char* get_field_data() const; virtual const char* get_field_data() const;
bool do_message(int n); bool do_message(int n);
public: public:
// @FPUB // @FPUB
short atodlg(const char* s) const; short atodlg(const char* s) const;
WINDOW parent() const; WINDOW parent() const;
short dlg() const { return _dlg; } short dlg() const { return _dlg; }
virtual bool ok() const; virtual bool ok() const;
bool dirty() const { return _flags.dirty; } bool dirty() const { return _flags.dirty; }
bool focusdirty() const { return _flags.focusdirty; } bool focusdirty() const { return _flags.focusdirty; }
void set_focusdirty(bool d = TRUE) { _flags.focusdirty = d; } void set_focusdirty(bool d = TRUE) { _flags.focusdirty = d; }
void set_dirty(bool d = TRUE) { _flags.dirty = d; set_focusdirty(d); } void set_dirty(bool d = TRUE) { _flags.dirty = d; set_focusdirty(d); }
virtual const char* class_name() const; virtual const char* class_name() const;
virtual word class_id() const; virtual word class_id() const;
int size() const { return _size; } int size() const { return _size; }
bool roman() const { return _flags.roman; } bool roman() const { return _flags.roman; }
bool automagic() const { return _flags.automagic; } bool automagic() const { return _flags.automagic; }
bool ghost() const { return _flags.ghost; } bool ghost() const { return _flags.ghost; }
virtual bool has_check() const { return FALSE;} virtual bool has_check() const { return FALSE;}
virtual bool has_query() const { return FALSE;} virtual bool has_query() const { return FALSE;}
virtual bool has_message() const { return _message.items() > 0; } virtual bool has_message() const { return _message.items() > 0; }
virtual CheckType check_type() const { return CHECK_NONE; } virtual CheckType check_type() const { return CHECK_NONE; }
bool required() const { return check_type() == CHECK_REQUIRED; } bool required() const { return check_type() == CHECK_REQUIRED; }
virtual bool check(CheckTime = RUNNING_CHECK) { return TRUE;} virtual bool check(CheckTime = RUNNING_CHECK) { return TRUE;}
virtual void reset(); virtual void reset();
virtual void enable(bool on = TRUE); virtual void enable(bool on = TRUE);
void disable() { enable(FALSE); } void disable() { enable(FALSE); }
bool enabled() const { return _flags.enabled; } bool enabled() const { return _flags.enabled; }
void enable_default(); void enable_default();
virtual void show(bool on = TRUE); virtual void show(bool on = TRUE);
void hide() { show(FALSE); } void hide() { show(FALSE); }
bool showed() const { return _flags.showed; } bool showed() const { return _flags.showed; }
void show_default(); void show_default();
bool active() const; // Is visible and enabled? bool active() const; // Is visible and enabled?
void set_handler(CONTROL_HANDLER handler) { _handler = handler; } void set_handler(CONTROL_HANDLER handler) { _handler = handler; }
bool is_edit() const; bool is_edit() const;
bool to_check(KEY k, bool checkrun = FALSE) const; bool to_check(KEY k, bool checkrun = FALSE) const;
virtual bool on_hit(); virtual bool on_hit();
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
void set(const char* s); void set(const char* s);
TString& get() const; TString& get() const;
virtual const char* picture_data(const char* data, bool video); virtual const char* picture_data(const char* data, bool video);
bool autoload(const TRelation* r = NULL); bool autoload(const TRelation* r = NULL);
bool autosave(TRelation* r = NULL) const; bool autosave(TRelation* r = NULL) const;
void undo(); void undo();
const char* prompt() const; const char* prompt() const;
void set_prompt(const char* p); void set_prompt(const char* p);
bool in_key(byte key) const { return _keys[key]; } bool in_key(byte key) const { return _keys[key]; }
void set_key(byte key) { _keys.set(long(key)); _keys.set(0L);} void set_key(byte key) { _keys.set(long(key)); _keys.set(0L);}
word last_key() const; word last_key() const;
bool in_group(byte group) const { return _groups[group]; } bool in_group(byte group) const { return _groups[group]; }
void set_group(byte group) { _groups.set(long(group)); _groups.set(0L);} void set_group(byte group) { _groups.set(long(group)); _groups.set(0L);}
const TFieldref* field() const { return _field; } const TFieldref* field() const { return _field; }
void set_focus() const; void set_focus() const;
// set focus, message-box, set focus // set focus, message-box, set focus
bool message_box(const char* fmt, ...) const; bool message_box(const char* fmt, ...) const;
bool warning_box(const char* fmt, ...) const; bool warning_box(const char* fmt, ...) const;
bool error_box(const char* fmt, ...) const; bool error_box(const char* fmt, ...) const;
bool yesno_box(const char* fmt, ...) const; bool yesno_box(const char* fmt, ...) const;
KEY yesnocancel_box(const char* fmt, ...) const; KEY yesnocancel_box(const char* fmt, ...) const;
TMask& mask() const { return *_mask; } TMask& mask() const { return *_mask; }
TMask_field(TMask* mask); TMask_field(TMask* mask);
virtual ~TMask_field(); virtual ~TMask_field();
}; };
@ -208,57 +208,57 @@ class TEdit_field : public TMask_field
friend class TList_sheet; friend class TList_sheet;
protected: protected:
// @DPROT // @DPROT
TString _str; TString _str;
TString _picture; TString _picture;
TString _warning; TString _warning;
CheckType _check; // Accettabilita' di valori nulli CheckType _check; // Accettabilita' di valori nulli
bool _forced; bool _forced;
bool _check_enabled; // Abilitato bool _check_enabled; // Abilitato
TBrowse* _browse; TBrowse* _browse;
TList_sheet* _sheet; TList_sheet* _sheet;
WINDOW _buttonwin; WINDOW _buttonwin;
const TBrowse* get_browse(TScanner& scanner) const; const TBrowse* get_browse(TScanner& scanner) const;
virtual word class_id() const; virtual word class_id() const;
virtual void parse_head(TScanner& scanner); virtual void parse_head(TScanner& scanner);
virtual bool parse_item(TScanner& scanner); virtual bool parse_item(TScanner& scanner);
virtual void show(bool on); virtual void show(bool on);
virtual void enable(bool on); virtual void enable(bool on);
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
virtual void destroy(); virtual void destroy();
bool validate(KEY k); bool validate(KEY k);
virtual void set_window_data(const char* data); virtual void set_window_data(const char* data);
virtual void set_field_data(const char* data); virtual void set_field_data(const char* data);
virtual const char* get_field_data() const; virtual const char* get_field_data() const;
public: public:
// @FPUB // @FPUB
virtual bool on_hit(); virtual bool on_hit();
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
virtual bool has_check() const; virtual bool has_check() const;
virtual bool has_query() const { return _browse || _sheet;} virtual bool has_query() const { return _browse || _sheet;}
virtual const char* picture_data(const char* data, bool video); virtual const char* picture_data(const char* data, bool video);
virtual CheckType check_type() const { return _check; } virtual CheckType check_type() const { return _check; }
void check_type(CheckType c) { _check = c; } void check_type(CheckType c) { _check = c; }
bool forced() const { return _forced;} bool forced() const { return _forced;}
virtual bool check(CheckTime = RUNNING_CHECK); virtual bool check(CheckTime = RUNNING_CHECK);
TBrowse* browse() const { return _browse;} TBrowse* browse() const { return _browse;}
void enable_check(bool on = TRUE) ; void enable_check(bool on = TRUE) ;
bool check_enabled() const { return _check_enabled;} bool check_enabled() const { return _check_enabled;}
const char* format(const char* data); const char* format(const char* data);
const char* picture() const { return _picture; } const char* picture() const { return _picture; }
TEdit_field(TMask* mask); TEdit_field(TMask* mask);
virtual ~TEdit_field(); virtual ~TEdit_field();
}; };
@ -268,56 +268,56 @@ public:
class TBrowse class TBrowse
{ {
TEdit_field* _fld; // The field owning the sheet TEdit_field* _fld; // The field owning the sheet
TRelation* _relation; // Main relation TRelation* _relation; // Main relation
TCursor* _cursor; // Cursor on the relation TCursor* _cursor; // Cursor on the relation
TString _insert; TString _insert;
TString _filter; TString _filter;
long _rec; long _rec;
bool _secondary; bool _secondary;
bool _checked; bool _checked;
TToken_string _head, _items; TToken_string _head, _items;
TToken_string _inp_id, _inp_fn; TToken_string _inp_id, _inp_fn;
TToken_string _out_id, _out_fn; TToken_string _out_id, _out_fn;
protected: protected:
void do_output(CheckTime = RUNNING_CHECK); void do_output(CheckTime = RUNNING_CHECK);
void do_clear(); void do_clear();
bool do_insert(); bool do_insert();
TMask_field& field(short n) const; TMask_field& field(short n) const;
TToken_string& create_siblings(TToken_string& siblings); TToken_string& create_siblings(TToken_string& siblings);
public: public:
int do_input(bool filter = FALSE); // Serve ai TCursor_sheet int do_input(bool filter = FALSE); // Serve ai TCursor_sheet
TBrowse(TEdit_field* f, TRelation* r, int key = 1, const char* filter = ""); TBrowse(TEdit_field* f, TRelation* r, int key = 1, const char* filter = "");
TBrowse(TEdit_field* f, TCursor* c); TBrowse(TEdit_field* f, TCursor* c);
~TBrowse(); ~TBrowse();
void parse_join(TScanner& scanner); void parse_join(TScanner& scanner);
void parse_input(TScanner& scanner); void parse_input(TScanner& scanner);
void parse_display(TScanner& scanner); void parse_display(TScanner& scanner);
void parse_output(TScanner& scanner); void parse_output(TScanner& scanner);
void parse_insert(TScanner& scanner); void parse_insert(TScanner& scanner);
bool parse_copy(const TString& what, const TBrowse* b); bool parse_copy(const TString& what, const TBrowse* b);
void set_insert(const char* s) { _insert = s;} void set_insert(const char* s) { _insert = s;}
const TString& get_insert() const { return _insert;} const TString& get_insert() const { return _insert;}
const TString& get_filter() const { return _filter;} const TString& get_filter() const { return _filter;}
TEdit_field& field() {return *_fld;} TEdit_field& field() {return *_fld;}
bool check(CheckTime = RUNNING_CHECK); bool check(CheckTime = RUNNING_CHECK);
bool empty_check(); bool empty_check();
const TToken_string& head() const { return _head;} const TToken_string& head() const { return _head;}
const TToken_string& items() const { return _items;} const TToken_string& items() const { return _items;}
TCursor* cursor() const { return _cursor;} TCursor* cursor() const { return _cursor;}
bool checked() const { return _checked;} bool checked() const { return _checked;}
bool secondary() const { return _secondary;} bool secondary() const { return _secondary;}
KEY run(); KEY run();
}; };
@ -330,23 +330,23 @@ class TReal_field : public TEdit_field
int _decimals; int _decimals;
protected: protected:
// @FPROT // @FPROT
virtual word class_id() const; virtual word class_id() const;
virtual const char* get_window_data() const; virtual const char* get_window_data() const;
virtual void set_window_data(const char* data); virtual void set_window_data(const char* data);
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
virtual void parse_head(TScanner& scanner); virtual void parse_head(TScanner& scanner);
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
public: public:
// @FPUB // @FPUB
void set_decimals(int d); // Set precision & picture void set_decimals(int d); // Set precision & picture
int decimals() const { return _decimals; } // Get precision int decimals() const { return _decimals; } // Get precision
void exchange(const real& o, const real& n); // Change value / o * n void exchange(const real& o, const real& n); // Change value / o * n
TReal_field(TMask* mask); TReal_field(TMask* mask);
}; };
@ -357,15 +357,15 @@ public:
class TDate_field : public TEdit_field class TDate_field : public TEdit_field
{ {
protected: protected:
// @FPROT // @FPROT
virtual word class_id() const; virtual word class_id() const;
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
public: public:
// @FPUB // @FPUB
void parse_head(TScanner& scanner); void parse_head(TScanner& scanner);
TDate_field(TMask* mask); TDate_field(TMask* mask);
}; };
@ -376,24 +376,24 @@ public:
class TBoolean_field : public TMask_field class TBoolean_field : public TMask_field
{ {
protected: protected:
// @DPROT // @DPROT
bool _on; bool _on;
virtual word class_id() const; virtual word class_id() const;
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
virtual const char* get_window_data() const; virtual const char* get_window_data() const;
virtual void set_window_data(const char* data); virtual void set_window_data(const char* data);
virtual void set_field_data(const char* data = NULL); virtual void set_field_data(const char* data = NULL);
virtual const char* get_field_data() const; virtual const char* get_field_data() const;
virtual bool parse_item(TScanner& scanner); virtual bool parse_item(TScanner& scanner);
virtual void enable(bool on); virtual void enable(bool on);
virtual bool on_hit(); virtual bool on_hit();
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
public: public:
// @FPUB // @FPUB
TBoolean_field(TMask* mask); TBoolean_field(TMask* mask);
}; };
@ -403,43 +403,43 @@ public:
class TList_field : public TMask_field class TList_field : public TMask_field
{ {
// @FPRIV // @FPRIV
void add_list(); void add_list();
protected: protected:
// @FPROT // @FPROT
TToken_string _values; TToken_string _values;
TToken_string _codes; TToken_string _codes;
TString _str; TString _str;
virtual word class_id() const; virtual word class_id() const;
virtual void set_window_data(const char* data); virtual void set_window_data(const char* data);
virtual const char* get_window_data() const; virtual const char* get_window_data() const;
virtual void set_field_data(const char* data = NULL); virtual void set_field_data(const char* data = NULL);
virtual const char* get_field_data() const; virtual const char* get_field_data() const;
// virtual const char* picture_data(const char* data, bool video); // virtual const char* picture_data(const char* data, bool video);
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
virtual void current(int n); virtual void current(int n);
virtual int current() const; virtual int current() const;
int str2curr(const char* data); int str2curr(const char* data);
virtual bool on_hit(); virtual bool on_hit();
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
virtual void read_item(TScanner& scanner); virtual void read_item(TScanner& scanner);
virtual void parse_head(TScanner& scanner); virtual void parse_head(TScanner& scanner);
virtual bool parse_item(TScanner& scanner); virtual bool parse_item(TScanner& scanner);
public: public:
// @FPUB // @FPUB
TList_field(TMask* mask); TList_field(TMask* mask);
virtual void replace_items(const char* codes, const char* values); virtual void replace_items(const char* codes, const char* values);
virtual void add_item(const char* code_value); virtual void add_item(const char* code_value);
virtual void delete_item(const char* code); virtual void delete_item(const char* code);
int items() const; int items() const;
}; };
@ -451,29 +451,29 @@ class TRadio_field : public TList_field
{ {
enum { MAX_RADIO = 8 }; enum { MAX_RADIO = 8 };
// @FPRIV // @FPRIV
int _nitems; int _nitems;
int _active_item; int _active_item;
WINDOW _radio_ctl_win[MAX_RADIO]; WINDOW _radio_ctl_win[MAX_RADIO];
protected: protected:
// @FPROT // @FPROT
virtual word class_id() const; virtual word class_id() const;
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
virtual void destroy(); virtual void destroy();
virtual void enable(bool on); virtual void enable(bool on);
virtual void show(bool on); virtual void show(bool on);
virtual void current(int n); virtual void current(int n);
virtual int current() const; virtual int current() const;
WINDOW win() const { return _radio_ctl_win[_active_item]; } WINDOW win() const { return _radio_ctl_win[_active_item]; }
public: public:
// @FPUB // @FPUB
TRadio_field(TMask* mask); TRadio_field(TMask* mask);
void check_radiobutton(WINDOW checked); void check_radiobutton(WINDOW checked);
bool move_focus(int d); bool move_focus(int d);
}; };
@ -484,20 +484,24 @@ public:
class TButton_field : public TMask_field class TButton_field : public TMask_field
{ {
protected: KEY _virtual_key, _exit_key;
// @FPROT
virtual word class_id() const;
virtual void create(WINDOW parent);
void parse_head(TScanner& scanner); protected:
bool parse_item(TScanner& scanner); // @FPROT
virtual void enable(bool); virtual word class_id() const;
virtual void show(bool); virtual void create(WINDOW parent);
virtual bool on_key(KEY key);
void parse_head(TScanner& scanner);
bool parse_item(TScanner& scanner);
virtual void enable(bool);
virtual void show(bool);
virtual bool on_key(KEY key);
public: public:
// @FPUB // @FPUB
TButton_field(TMask* mask); TButton_field(TMask* mask);
KEY virtual_key() const { return _virtual_key; }
KEY exit_key() const { return _exit_key; }
}; };
@ -508,12 +512,12 @@ public:
class TGroup_field : public TMask_field class TGroup_field : public TMask_field
{ {
protected: protected:
// @DPROT // @DPROT
virtual void parse_head(TScanner& scanner); virtual void parse_head(TScanner& scanner);
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
public: public:
// @FPUB // @FPUB
TGroup_field(TMask* mask); TGroup_field(TMask* mask);
}; };

View File

@ -609,6 +609,14 @@ break;
} }
set_focus_cell(cur_row, cur_col); set_focus_cell(cur_row, cur_col);
check_enabled = TRUE; // Enable checks check_enabled = TRUE; // Enable checks
}
break;
case K_PREV:
case K_NEXT:
{
XI_OBJ* itf = xi_get_itf(win());
const bool ok = (bool)xi_move_focus(itf);
if (ok) dispatch_e_char(parent(), k);
} }
break; break;
/* /*

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.2 1994-08-17 14:08:21 guy Exp $ // $Id: relapp.cpp,v 1.3 1994-08-23 13:52:26 guy Exp $
#include <mailbox.h> #include <mailbox.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
@ -676,7 +676,7 @@ bool TRelation_application::main_loop()
KEY k; KEY k;
// Provoca l'autopremimento per il messaggio di LINK // Provoca l'autopremimento per il messaggio di LINK
if (_lnflag) _mask->send_key(K_SHIFT_ENTER, 0); if (_lnflag) _mask->send_key(K_CTRL_ENTER, 0);
do do
{ {

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,36 @@
BUTTON DLG_SAVEREC 8 2 BUTTON DLG_SAVEREC 8 2
BEGIN BEGIN
PROMPT -16 -1 "" PROMPT -16 -1 "~Registra"
MESSAGE EXIT,K_SAVE
END END
BUTTON DLG_NEWREC 8 2 BUTTON DLG_NEWREC 8 2
BEGIN BEGIN
PROMPT -26 -1 "Nuovo" PROMPT -26 -1 "~Nuovo"
MESSAGE EXIT,K_INS
END END
BUTTON DLG_DELREC 8 2 BUTTON DLG_DELREC 8 2
BEGIN BEGIN
PROMPT -36 -1 "Elimina" PROMPT -36 -1 "~Elimina"
MESSAGE EXIT,K_DEL
END END
BUTTON DLG_FINDREC 8 2 BUTTON DLG_FINDREC 8 2
BEGIN BEGIN
PROMPT -46 -1 "Ricerca" PROMPT -46 -1 "Ricerca"
MESSAGE EXIT,K_F9
END END
BUTTON DLG_CANCEL 8 2 BUTTON DLG_CANCEL 8 2
BEGIN BEGIN
PROMPT -56 -1 "" PROMPT -56 -1 ""
MESSAGE EXIT,K_ESC
END END
BUTTON DLG_QUIT 8 2 BUTTON DLG_QUIT 8 2
BEGIN BEGIN
PROMPT -66 -1 "" PROMPT -66 -1 ""
MESSAGE EXIT,K_QUIT
END END

View File

@ -15,7 +15,7 @@ HIDDEN const TArray* _parms;
HIDDEN int get_val_param_num() { return _parms->items();} HIDDEN int get_val_param_num() { return _parms->items();}
HIDDEN const char* get_val_param(int i) HIDDEN const char* get_val_param(int i)
{ return i < _parms->items() ? (const char*)((const TString&) (*_parms)[i]):"" ;} { return i < _parms->items() ? (const char*)((const TString&) (*_parms)[i]):"" ;}
HIDDEN bool _expr_val(TEdit_field& f, KEY) HIDDEN bool _expr_val(TEdit_field& f, KEY)
@ -35,12 +35,12 @@ HIDDEN bool _expr_val(TEdit_field& f, KEY)
const int fldid = atoi(s); const int fldid = atoi(s);
if (type == _numexpr) if (type == _numexpr)
{ {
const real r(fldid == 0 ? f.get() : f.mask().get(fldid)); const real r(fldid == 0 ? f.get() : f.mask().get(fldid));
e.setvar(i, r); e.setvar(i, r);
} }
else else
{ {
const char* v = fldid == 0 ? f.get() : f.mask().get(fldid); const char* v = fldid == 0 ? f.get() : f.mask().get(fldid);
e.setvar(i, v); e.setvar(i, v);
} }
} }
@ -52,15 +52,15 @@ HIDDEN bool _emptycopy_val(TEdit_field& f, KEY)
{ {
if (f.get().empty()) if (f.get().empty())
{ {
const short id = atoi(get_val_param(0)); const short id = atoi(get_val_param(0));
const TFixed_string val(f.mask().get(id)); const TFixed_string val(f.mask().get(id));
if (val.not_empty()) if (val.not_empty())
{ {
f.set(val); f.set(val);
f.on_hit(); f.on_hit();
} }
} }
return TRUE; return TRUE;
} }
@ -106,20 +106,20 @@ HIDDEN bool _pi_val(TEdit_field& f, KEY)
if (pi.empty()) return TRUE; if (pi.empty()) return TRUE;
if (pi.len() != 11) if (pi.len() != 11)
{ {
f.error_box("Lunghezza partita IVA diversa da 11"); f.error_box("Lunghezza partita IVA diversa da 11");
return FALSE; return FALSE;
} }
bool ok = pi_check (stato, pi); bool ok = pi_check (stato, pi);
if (!ok) if (!ok)
{ {
if(f.dirty()) if(f.dirty())
{ {
ok = f.yesno_box("Partita IVA errata, la accetto ugualmente?"); ok = f.yesno_box("Partita IVA errata, la accetto ugualmente?");
if (ok) f.set_dirty(FALSE); if (ok) f.set_dirty(FALSE);
} }
else ok = TRUE; // Era gia' errata e la ho accettata else ok = TRUE; // Era gia' errata e la ho accettata
} }
return ok; return ok;
} }
@ -185,7 +185,7 @@ bool cf_check (const char * stato, const char * codcf)
{ {
TFixed_string cf (codcf); TFixed_string cf (codcf);
if (cf.empty()) if (cf.empty())
return TRUE; return TRUE;
const bool ok = (cf.len() == 11) ? pi_check(stato, cf) : __cf_check(cf); const bool ok = (cf.len() == 11) ? pi_check(stato, cf) : __cf_check(cf);
return ok; return ok;
} }
@ -193,7 +193,7 @@ bool cf_check (const char * stato, const char * codcf)
HIDDEN bool _cf_val(TEdit_field& f, KEY key) HIDDEN bool _cf_val(TEdit_field& f, KEY key)
{ {
if (f.mask().query_mode()) return TRUE; if (f.mask().query_mode()) return TRUE;
const TFixed_string cf(f.get()); const TFixed_string cf(f.get());
if (cf.empty()) return TRUE; if (cf.empty()) return TRUE;
@ -203,12 +203,12 @@ HIDDEN bool _cf_val(TEdit_field& f, KEY key)
bool ok = __cf_check(cf); bool ok = __cf_check(cf);
if (!ok) if (!ok)
{ {
if(f.dirty()) if(f.dirty())
{ {
ok = f.yesno_box("Codice fiscale errato: lo accetto ugualmente?"); ok = f.yesno_box("Codice fiscale errato: lo accetto ugualmente?");
if (ok) f.set_dirty(FALSE); if (ok) f.set_dirty(FALSE);
} }
else ok = TRUE; // Era gia' errato al caricamento quindi lo accetto else ok = TRUE; // Era gia' errato al caricamento quindi lo accetto
} }
return ok; return ok;
} }
@ -218,7 +218,7 @@ HIDDEN bool _xt_pi_val(TEdit_field& f, KEY key)
{ {
TMask& m = f.mask(); TMask& m = f.mask();
if (m.query_mode()) return TRUE; if (m.query_mode()) return TRUE;
TString value(f.get()); TString value(f.get());
if (value.empty()) return f.error_box("Partita IVA obbligatoria"); if (value.empty()) return f.error_box("Partita IVA obbligatoria");
@ -234,32 +234,32 @@ HIDDEN bool _xt_pi_val(TEdit_field& f, KEY key)
for (int i = 1 ; i < 3; i++) for (int i = 1 ; i < 3; i++)
{ {
const int comune = atoi(get_val_param(i)); const int comune = atoi(get_val_param(i));
if (comune) if (comune)
{ {
const TString com(m.get(comune)); // Comune residenza fiscale e residenza const TString com(m.get(comune)); // Comune residenza fiscale e residenza
if (com.not_empty()) if (com.not_empty())
{ {
c.zero(); c.zero();
c.put("COM", com); c.put("COM", com);
if (c.read() == NOERR) if (c.read() == NOERR)
{ {
const int s1 = c.get_int("UFFIVA1"); const int s1 = c.get_int("UFFIVA1");
const int s2 = c.get_int("UFFIVA2"); const int s2 = c.get_int("UFFIVA2");
const int s3 = c.get_int("UFFIVA3"); const int s3 = c.get_int("UFFIVA3");
if (pi != s1 && pi != s2 && pi != s3) if (pi != s1 && pi != s2 && pi != s3)
{ {
const char* ui = format("%03d", s1); const char* ui = format("%03d", s1);
if (f.yesno_box("Ufficio IVA della partita IVA non congruente: correggere in %s?", ui)) if (f.yesno_box("Ufficio IVA della partita IVA non congruente: correggere in %s?", ui))
{ {
value.overwrite(ui, 7); value.overwrite(ui, 7);
f.set(value); f.set(value);
} }
} }
break; break;
} }
} }
} }
} }
return TRUE; return TRUE;
} }
@ -268,17 +268,17 @@ HIDDEN bool _xt_pi_val(TEdit_field& f, KEY key)
HIDDEN bool _xtz_pi_val(TEdit_field& f, KEY key) HIDDEN bool _xtz_pi_val(TEdit_field& f, KEY key)
{ {
if (f.mask().query_mode()) return TRUE; if (f.mask().query_mode()) return TRUE;
TString pi(f.get()); TString pi(f.get());
if (pi.empty()) return TRUE; if (pi.empty()) return TRUE;
return _xt_pi_val(f, key); return _xt_pi_val(f, key);
} }
HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key) HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
{ {
if (f.mask().query_mode()) return TRUE; if (f.mask().query_mode()) return TRUE;
const TString cf(f.get()); const TString cf(f.get());
if (cf.empty()) return f.error_box("Codice fiscale obbligatorio"); if (cf.empty()) return f.error_box("Codice fiscale obbligatorio");
@ -287,9 +287,9 @@ HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
if (cf.len() == 11) if (cf.len() == 11)
{ {
if (!_xt_pi_val(f, key)) return FALSE; if (!_xt_pi_val(f, key)) return FALSE;
TString stato(f.mask().get(atoi(get_val_param(0)))); TString stato(f.mask().get(atoi(get_val_param(0))));
if ((stato.not_empty()) && (stato != "IT")) return TRUE; if ((stato.not_empty()) && (stato != "IT")) return TRUE;
} }
bool passed = __cf_check(cf); bool passed = __cf_check(cf);
@ -316,12 +316,12 @@ HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
if ((p = wm.find(cf[14])) != -1) cf[14] = '0' + p; if ((p = wm.find(cf[14])) != -1) cf[14] = '0' + p;
int gn = atoi(cf.mid(9,2)); int gn = atoi(cf.mid(9,2));
if ((sesso == 'F' && gn <= 40) || (sesso == 'M' && gn >= 40)) if ((sesso == 'F' && gn <= 40) || (sesso == 'M' && gn >= 40))
{ {
passed = fld_sex.yesno_box("Sesso non congruente al codice fiscale: correzione automatica?"); passed = fld_sex.yesno_box("Sesso non congruente al codice fiscale: correzione automatica?");
if (passed) fld_sex.set(sesso == 'M' ? "F" : "M"); if (passed) fld_sex.set(sesso == 'M' ? "F" : "M");
else return TRUE; else return TRUE;
} }
if (gn > 40) gn -= 40; if (gn > 40) gn -= 40;
@ -331,38 +331,38 @@ HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
{ {
const TDate d(data); const TDate d(data);
int err = 0; int err = 0;
if ((d.year() % 100) != atoi(cf.mid(6, 2))) if ((d.year() % 100) != atoi(cf.mid(6, 2)))
err = 1; err = 1;
if (wm[d.month() - 1] != cf[8]) if (wm[d.month() - 1] != cf[8])
err = 2; err = 2;
if (d.day() != gn) if (d.day() != gn)
err = 3; err = 3;
if (err != 0) if (err != 0)
{ {
const char* const what = err==1 ? "Anno" : (err==2 ? "Mese" : "Giorno"); const char* const what = err==1 ? "Anno" : (err==2 ? "Mese" : "Giorno");
passed = fld_dat.yesno_box("%s di nascita non congruente al codice fiscale: correzione automatica?", what); passed = fld_dat.yesno_box("%s di nascita non congruente al codice fiscale: correzione automatica?", what);
if (passed) data = ""; if (passed) data = "";
else return TRUE; else return TRUE;
} }
} }
if (data.empty()) if (data.empty())
{ {
const int mn = wm.find(cf[8]) + 1; const int mn = wm.find(cf[8]) + 1;
if (mn > 0) if (mn > 0)
{ {
const TDate d(gn, mn, 1900 + atoi(cf.mid(6, 2))); const TDate d(gn, mn, 1900 + atoi(cf.mid(6, 2)));
fld_dat.set(d.string()); fld_dat.set(d.string());
} }
} }
// Controllo del comune di nascita // Controllo del comune di nascita
const char* const codcom = cf.mid(11, 4); const char* const codcom = cf.mid(11, 4);
if (com.not_empty() && com != codcom) if (com.not_empty() && com != codcom)
{ {
passed = fld_com.yesno_box("Comune non congruente al codice fiscale: correzione automatica?"); passed = fld_com.yesno_box("Comune non congruente al codice fiscale: correzione automatica?");
if (passed) com = ""; if (passed) com = "";
else return TRUE; else return TRUE;
} }
if (com.empty()) if (com.empty())
{ {
@ -377,9 +377,9 @@ HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
HIDDEN bool _xtz_cf_val(TEdit_field& f, KEY key) HIDDEN bool _xtz_cf_val(TEdit_field& f, KEY key)
{ {
if (f.mask().query_mode()) return TRUE; if (f.mask().query_mode()) return TRUE;
const char* cf = f.get(); const char* cf = f.get();
return (*cf == '\0') ? TRUE : _xt_cf_val(f, key); return (*cf == '\0') ? TRUE : _xt_cf_val(f, key);
} }
@ -416,77 +416,77 @@ HIDDEN bool _date_cmp(TEdit_field& f, KEY)
HIDDEN bool _fixlen_val(TEdit_field& f, KEY) HIDDEN bool _fixlen_val(TEdit_field& f, KEY)
{ {
const TFixed_string s(f.get()); const TFixed_string s(f.get());
if (s.empty()) return TRUE; if (s.empty()) return TRUE;
const int length = atoi(get_val_param(0)); const int length = atoi(get_val_param(0));
const bool ok = s.len() == length; const bool ok = s.len() == length;
if (!ok) f.error_box("Lunghezza errata: deve essere %d", length); if (!ok) f.error_box("Lunghezza errata: deve essere %d", length);
return ok; return ok;
} }
HIDDEN bool _mtcheck_val(TEdit_field& f, KEY) HIDDEN bool _mtcheck_val(TEdit_field& f, KEY)
{ {
const int month = atoi(f.get()); const int month = atoi(f.get());
if (month < 1 || month > 13) return FALSE; if (month < 1 || month > 13) return FALSE;
TLocalisamfile d(LF_NDITTE); TLocalisamfile d(LF_NDITTE);
d.zero(); d.zero();
d.put(NDT_CODDITTA, MainApp()->get_firm()); d.put(NDT_CODDITTA, MainApp()->get_firm());
d.read(); d.read();
if (d.bad()) return TRUE; if (d.bad()) return TRUE;
if (d.get_char(NDT_FREQVIVA) == 'M') return TRUE; if (d.get_char(NDT_FREQVIVA) == 'M') return TRUE;
return month == 13 || (month % 3) == 0; return month == 13 || (month % 3) == 0;
} }
HIDDEN bool _reqif_val(TEdit_field& f, KEY) HIDDEN bool _reqif_val(TEdit_field& f, KEY)
{ {
if (f.get().not_empty()) return TRUE; if (f.get().not_empty()) return TRUE;
const int nparms = get_val_param_num(); const int nparms = get_val_param_num();
for (int i = 0 ; i < nparms; i++) for (int i = 0 ; i < nparms; i++)
{ {
const char* s = get_val_param(i); const char* s = get_val_param(i);
if (*s == '\0') break; if (*s == '\0') break;
if (f.mask().get(atoi(s)).not_empty()) return FALSE; if (f.mask().get(atoi(s)).not_empty()) return FALSE;
} }
return TRUE; return TRUE;
} }
HIDDEN bool _autoexit_val(TEdit_field& f, KEY key) HIDDEN bool _autoexit_val(TEdit_field& f, KEY key)
{ {
const int nparms = get_val_param_num(); const int nparms = get_val_param_num();
bool one_not_empty = FALSE; bool one_not_empty = FALSE;
for (int i = nparms; i-- > 0;) for (int i = nparms; i-- > 0;)
{ {
const short id = f.atodlg(get_val_param(i)); const short id = f.atodlg(get_val_param(i));
const TMask_field& c = f.mask().field(id); const TMask_field& c = f.mask().field(id);
const bool empty = c.get().empty(); const bool empty = c.get().empty();
if (empty) if (empty)
{ {
if (c.check_type() != CHECK_NONE || one_not_empty) if (c.check_type() != CHECK_NONE || one_not_empty)
return key == K_TAB; return key == K_TAB;
} }
else else
one_not_empty = TRUE; one_not_empty = TRUE;
} }
bool ok = TRUE; bool ok = TRUE;
if (key == K_TAB) if (key == K_TAB)
f.mask().send_key(K_SHIFT_ENTER, 0); f.mask().send_key(K_AUTO_ENTER, 0);
else else
ok = one_not_empty; ok = one_not_empty;
return ok; return ok;
} }
HIDDEN bool _numcalc_val(TEdit_field& f, KEY k) HIDDEN bool _numcalc_val(TEdit_field& f, KEY k)
{ {
if (k != K_TAB) return TRUE; if (k != K_TAB) return TRUE;
TExpression e(get_val_param(0), _numexpr); TExpression e(get_val_param(0), _numexpr);
for (int i = 0 ; i < e.numvar(); i++) for (int i = 0 ; i < e.numvar(); i++)
@ -499,7 +499,7 @@ HIDDEN bool _numcalc_val(TEdit_field& f, KEY k)
} }
s++; s++;
const int fldid = atoi(s); const int fldid = atoi(s);
e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid)); e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid));
} }
TFixed_string s((const char*) e); TFixed_string s((const char*) e);
f.set(s); f.set(s);
@ -509,7 +509,7 @@ HIDDEN bool _numcalc_val(TEdit_field& f, KEY k)
HIDDEN bool _strcalc_val(TEdit_field& f, KEY k) HIDDEN bool _strcalc_val(TEdit_field& f, KEY k)
{ {
if (k != K_TAB) return TRUE; if (k != K_TAB) return TRUE;
TExpression e(get_val_param(0), _strexpr); TExpression e(get_val_param(0), _strexpr);
for (int i = 0 ; i < e.numvar(); i++) for (int i = 0 ; i < e.numvar(); i++)
@ -522,7 +522,7 @@ HIDDEN bool _strcalc_val(TEdit_field& f, KEY k)
} }
s++; s++;
const int fldid = atoi(s); const int fldid = atoi(s);
e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid)); e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid));
} }
TFixed_string s((const char*) e); TFixed_string s((const char*) e);
f.set(s); f.set(s);
@ -533,24 +533,24 @@ HIDDEN bool _strcalc_val(TEdit_field& f, KEY k)
#define MAX_FUNC 16 #define MAX_FUNC 16
HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] = HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
{ {
_expr_val, _expr_val,
_emptycopy_val, _emptycopy_val,
_pi_val, _pi_val,
_cf_val, _cf_val,
_notempty_val, _notempty_val,
_date_cmp, _date_cmp,
_xt_pi_val, _xt_pi_val,
_xt_cf_val, _xt_cf_val,
_xtz_pi_val, _xtz_pi_val,
_xtz_cf_val, _xtz_cf_val,
_fixlen_val, _fixlen_val,
_mtcheck_val, _mtcheck_val,
_reqif_val, _reqif_val,
_autoexit_val, _autoexit_val,
_numcalc_val, _numcalc_val,
_strcalc_val _strcalc_val
}; };
bool validate(int fn, TEdit_field& f, KEY k, const TArray& parms) bool validate(int fn, TEdit_field& f, KEY k, const TArray& parms)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -21,26 +21,26 @@
class TWindow_manager class TWindow_manager
{ {
// @DPRIV // @DPRIV
enum { MAX_WIN = 4 }; // Max number of modal windows enum { MAX_WIN = 4 }; // Max number of modal windows
TWindow* _window[MAX_WIN]; // Stack of active windows TWindow* _window[MAX_WIN]; // Stack of active windows
char _current; // Stack pointer char _current; // Stack pointer
void menu_enable(bool) const; // Abilita o disabilita il menu della task window void menu_enable(bool) const; // Abilita o disabilita il menu della task window
public: public:
// @FPUB // @FPUB
TWindow_manager(); // Costruttore TWindow_manager(); // Costruttore
~TWindow_manager() { destroy(); } ~TWindow_manager() { destroy(); }
void reg(TWindow* m); void reg(TWindow* m);
// Registra la finestra corrente // Registra la finestra corrente
void unreg(const TWindow* m); void unreg(const TWindow* m);
// De-registra la finestra corrente // De-registra la finestra corrente
TWindow* cur_win() const { return (_current < 0) ? NULL : _window[_current]; } // Ritorna il puntatore alla finestra corrente TWindow* cur_win() const { return (_current < 0) ? NULL : _window[_current]; } // Ritorna il puntatore alla finestra corrente
void destroy(); void destroy();
bool can_close() const { return _current < 1; } bool can_close() const { return _current < 1; }
} WinManager; } WinManager;
@ -50,98 +50,98 @@ TWindow_manager::TWindow_manager() : _current(-1)
void TWindow_manager::destroy() void TWindow_manager::destroy()
{ {
while (_current >= 0) while (_current >= 0)
{ {
TWindow* w = cur_win(); TWindow* w = cur_win();
w->stop_run(K_QUIT); w->stop_run(K_QUIT);
w->close_modal(); w->close_modal();
} }
} }
// Dis/abilitazione del menu principale // Dis/abilitazione del menu principale
HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on) HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on)
{ {
while (m->tag) while (m->tag)
{ {
switch(m->tag) switch(m->tag)
{ {
case M_FILE: case M_FILE:
case MENU_FILE: case MENU_FILE:
case MENU_EDIT: case MENU_EDIT:
case MENU_ALT_EDIT: case MENU_ALT_EDIT:
if (m->child) if (m->child)
xvt_menu_enable(m->child, on); xvt_menu_enable(m->child, on);
break; break;
case 65535: // Separator case 65535: // Separator
case M_FILE_NEW: case M_FILE_NEW:
case M_FILE_REVERT: case M_FILE_REVERT:
case M_FILE_QUIT: case M_FILE_QUIT:
case M_FILE_ABOUT: case M_FILE_ABOUT:
case M_FILE_PRINT: case M_FILE_PRINT:
case M_FILE_PG_SETUP: case M_FILE_PG_SETUP:
case (M_FILE+11): case (M_FILE+11):
case M_EDIT_SEARCH: case M_EDIT_SEARCH:
break; // Leave them as they are break; // Leave them as they are
default: default:
win_menu_enable(TASK_WIN, m->tag, on); win_menu_enable(TASK_WIN, m->tag, on);
break; break;
} }
m++; m++;
} }
} }
void TWindow_manager::menu_enable(bool on) const void TWindow_manager::menu_enable(bool on) const
{ {
MENU_ITEM *mi = win_menu_fetch(TASK_WIN); MENU_ITEM *mi = win_menu_fetch(TASK_WIN);
xvt_menu_enable(mi, on); xvt_menu_enable(mi, on);
win_update_menu_bar(TASK_WIN); win_update_menu_bar(TASK_WIN);
menu_free(mi); menu_free(mi);
} }
void TWindow_manager::reg(TWindow* m) void TWindow_manager::reg(TWindow* m)
{ {
_current++; _current++;
CHECK(_current < MAX_WIN, "Too many windows"); CHECK(_current < MAX_WIN, "Too many windows");
switch (_current) switch (_current)
{ {
case 0 : menu_enable(FALSE); break; case 0 : menu_enable(FALSE); break;
case 1 : win_menu_enable(TASK_WIN, M_FILE_QUIT, FALSE); case 1 : win_menu_enable(TASK_WIN, M_FILE_QUIT, FALSE);
default: _window[_current-1]->disable(); break; default: _window[_current-1]->disable(); break;
} }
_window[_current] = m; _window[_current] = m;
} }
void TWindow_manager::unreg(const TWindow* m) void TWindow_manager::unreg(const TWindow* m)
{ {
#ifdef DBG #ifdef DBG
if (m != cur_win()) if (m != cur_win())
{ {
error_box("You can unregister the current window only"); error_box("You can unregister the current window only");
return; return;
} }
#endif #endif
_current--; _current--;
if (_current < 0) if (_current < 0)
menu_enable(TRUE); menu_enable(TRUE);
else else
{ {
if (_current == 0) if (_current == 0)
win_menu_enable(TASK_WIN, M_FILE_QUIT, TRUE); win_menu_enable(TASK_WIN, M_FILE_QUIT, TRUE);
cur_win()->enable(); cur_win()->enable();
} }
} }
void close_all_dialogs() void close_all_dialogs()
{ {
WinManager.destroy(); WinManager.destroy();
} }
bool can_close() bool can_close()
@ -149,6 +149,12 @@ bool can_close()
return WinManager.can_close(); return WinManager.can_close();
} }
WINDOW cur_win()
{
const TWindow* w = WinManager.cur_win();
return w ? w->win() : NULL_WIN;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TWindow // TWindow
@ -159,135 +165,135 @@ bool TWindow::_ctools_saved;
TWindow::TWindow() TWindow::TWindow()
: _win(NULL_WIN), _open(FALSE), _modal(FALSE), : _win(NULL_WIN), _open(FALSE), _modal(FALSE),
_running(FALSE), _lastkey(0) _running(FALSE), _lastkey(0)
{} {}
long TWindow::window_handler(WINDOW win, EVENT* ep) long TWindow::window_handler(WINDOW win, EVENT* ep)
{ {
TWindow* w = (TWindow*)get_app_data(win); TWindow* w = (TWindow*)get_app_data(win);
CHECK(w != NULL, "Invalid window"); CHECK(w != NULL, "Invalid window");
w->handler(win, ep); w->handler(win, ep);
return 0L; return 0L;
} }
WINDOW TWindow::create(short x, short y, short dx, short dy, WINDOW TWindow::create(short x, short y, short dx, short dy,
const char* title, long flags, WIN_TYPE wt, WINDOW parent) const char* title, long flags, WIN_TYPE wt, WINDOW parent)
{ {
flags |= WSF_NO_MENUBAR; flags |= WSF_NO_MENUBAR;
if (parent == NULL_WIN) parent = TASK_WIN; if (parent == NULL_WIN) parent = TASK_WIN;
if (parent == TASK_WIN) flags |= WSF_INVISIBLE; if (parent == TASK_WIN) flags |= WSF_INVISIBLE;
_win = xvt_create_window( _win = xvt_create_window(
wt, wt,
x, y, dx, dy, x, y, dx, dy,
title, parent, title, parent,
flags, flags,
window_handler, window_handler,
PTR_LONG(this) PTR_LONG(this)
); );
CHECK(_win, "Can't create a window"); CHECK(_win, "Can't create a window");
return _win; return _win;
} }
TWindow::~TWindow() TWindow::~TWindow()
{ {
if (_win != NULL_WIN) if (_win != NULL_WIN)
{ {
close_window(_win); close_window(_win);
_win = NULL_WIN; _win = NULL_WIN;
} }
} }
void TWindow::open() void TWindow::open()
{ {
CHECK(win() != NULL_WIN, "Can't open a NULL window"); CHECK(win() != NULL_WIN, "Can't open a NULL window");
show_window(win(), _open = TRUE); show_window(win(), _open = TRUE);
set_front_window(win()); set_front_window(win());
} }
void TWindow::open_modal() void TWindow::open_modal()
{ {
set_modal(TRUE); set_modal(TRUE);
_open = TRUE; _open = TRUE;
open(); open();
WinManager.reg(this); WinManager.reg(this);
} }
void TWindow::close() void TWindow::close()
{ {
CHECK(_win != NULL_WIN, "Can't close a NULL window"); CHECK(_win != NULL_WIN, "Can't close a NULL window");
show_window(_win, _open = FALSE); show_window(_win, _open = FALSE);
} }
void TWindow::close_modal() void TWindow::close_modal()
{ {
WinManager.unreg(this); WinManager.unreg(this);
close(); close();
_open = FALSE; _open = FALSE;
} }
bool TWindow::stop_run(KEY key) bool TWindow::stop_run(KEY key)
{ {
_running = FALSE; _running = FALSE;
_lastkey = key; _lastkey = key;
return TRUE; return TRUE;
} }
KEY TWindow::run() KEY TWindow::run()
{ {
const bool was_open = is_open(); const bool was_open = is_open();
start_run(); start_run();
_running = TRUE; _running = TRUE;
if (!was_open) open_modal(); if (!was_open) open_modal();
else open(); else open();
while (_running) while (_running)
do_events(); do_events();
if (!was_open) close_modal(); if (!was_open) close_modal();
return last_key(); return last_key();
} }
void TWindow::handler(WINDOW win, EVENT* ep) void TWindow::handler(WINDOW win, EVENT* ep)
{ {
switch(ep->type) switch(ep->type)
{ {
case E_CLOSE: case E_CLOSE:
stop_run(K_ESC); stop_run(K_ESC);
break; break;
case E_UPDATE: case E_UPDATE:
{ {
clear_window(win, NORMAL_BACK_COLOR); clear_window(win, NORMAL_BACK_COLOR);
update(); update();
} }
break; break;
case E_CHAR: case E_CHAR:
on_key(e_char_to_key(ep)); on_key(e_char_to_key(ep));
break; break;
case E_DESTROY: case E_DESTROY:
_win = NULL_WIN; _win = NULL_WIN;
break; break;
default: default:
break; break;
} }
} }
@ -300,7 +306,7 @@ TPoint TWindow::size() const
WINDOW TWindow::parent() const WINDOW TWindow::parent() const
{ {
return get_parent(win()); return get_parent(win());
} }
@ -314,46 +320,46 @@ void TWindow::set_focus()
void TWindow::iconize() const void TWindow::iconize() const
{ {
#if XVTWS != WMWS #if XVTWS != WMWS
HWND hwnd = (HWND)get_value(win(), ATTR_NATIVE_WINDOW); HWND hwnd = (HWND)get_value(win(), ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_MINIMIZE); ShowWindow(hwnd, SW_MINIMIZE);
#endif #endif
} }
void TWindow::maximize() const void TWindow::maximize() const
{ {
#if XVTWS != WMWS #if XVTWS != WMWS
HWND hwnd = (HWND)get_value(win(), ATTR_NATIVE_WINDOW); HWND hwnd = (HWND)get_value(win(), ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_SHOWMAXIMIZED); ShowWindow(hwnd, SW_SHOWMAXIMIZED);
#else #else
RCT r; set_rect(&r, 1,1,79,23); RCT r; set_rect(&r, 1,1,79,23);
move_window(win(),&r); move_window(win(),&r);
#endif #endif
} }
void TWindow::enable(bool on) const void TWindow::enable(bool on) const
{ {
enable_window(win(), on); enable_window(win(), on);
} }
void TWindow::set_caption(const char* title) void TWindow::set_caption(const char* title)
{ {
set_title(win(), (char*)title); set_title(win(), (char*)title);
} }
const char* TWindow::get_caption() const const char* TWindow::get_caption() const
{ {
char* title = &__tmp_string[512]; char* title = &__tmp_string[512];
get_title(win(), title, 80); get_title(win(), title, 80);
return title; return title;
} }
void TWindow::force_update() void TWindow::force_update()
{ {
if (win() != NULL_WIN) if (win() != NULL_WIN)
invalidate_rect(win(), NULL); invalidate_rect(win(), NULL);
} }
@ -376,7 +382,7 @@ bool TWindow::restore_ctools()
_ctools_saved = FALSE; _ctools_saved = FALSE;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
@ -389,58 +395,58 @@ void TWindow::set_color(COLOR fore, COLOR back)
void TWindow::set_pen(COLOR color, int width, PAT_STYLE pat, PEN_STYLE style) void TWindow::set_pen(COLOR color, int width, PAT_STYLE pat, PEN_STYLE style)
{ {
CPEN pen; CPEN pen;
pen.width = width; pen.width = width;
pen.pat = pat; pen.pat = pat;
pen.style = style; pen.style = style;
pen.color = color; pen.color = color;
win_set_cpen(win(), &pen); win_set_cpen(win(), &pen);
} }
void TWindow::hide_pen() void TWindow::hide_pen()
{ {
win_set_std_cpen(win(), TL_PEN_HOLLOW); win_set_std_cpen(win(), TL_PEN_HOLLOW);
} }
void TWindow::set_brush(COLOR color, PAT_STYLE pat) void TWindow::set_brush(COLOR color, PAT_STYLE pat)
{ {
CBRUSH brush = { pat, color }; CBRUSH brush = { pat, color };
win_set_cbrush(win(), &brush); win_set_cbrush(win(), &brush);
} }
void TWindow::hide_brush() void TWindow::hide_brush()
{ {
CBRUSH brush = { PAT_HOLLOW, COLOR_WHITE }; CBRUSH brush = { PAT_HOLLOW, COLOR_WHITE };
win_set_cbrush(win(), &brush); win_set_cbrush(win(), &brush);
} }
HIDDEN void swap(short& a, short& b) HIDDEN void swap(short& a, short& b)
{ {
short tmp = a; short tmp = a;
a = b; a = b;
b = tmp; b = tmp;
} }
void TWindow::frame(short left, short top, short right, short bottom, void TWindow::frame(short left, short top, short right, short bottom,
int flag) int flag)
{ {
if (left > right) swap(left, right); if (left > right) swap(left, right);
if (top > bottom) swap(top, bottom); if (top > bottom) swap(top, bottom);
const bool saved = flag && save_ctools(); const bool saved = flag && save_ctools();
if (flag & 1) hide_pen(); if (flag & 1) hide_pen();
if (flag & 2) hide_brush(); if (flag & 2) hide_brush();
if (flag & 4) if (flag & 4)
{ {
set_mode(M_XOR); set_mode(M_XOR);
set_brush(COLOR_BLACK); // Needed for Windows set_brush(COLOR_BLACK); // Needed for Windows
} }
@ -448,12 +454,12 @@ void TWindow::frame(short left, short top, short right, short bottom,
const PNT f = log2dev(left,top); const PNT f = log2dev(left,top);
const PNT t = log2dev(right,bottom); const PNT t = log2dev(right,bottom);
RCT r; RCT r;
r.top = f.v; r.left = f.h; r.top = f.v; r.left = f.h;
r.bottom = t.v; r.right = t.h; r.bottom = t.v; r.right = t.h;
#if XVTWS != WMWS #if XVTWS != WMWS
if (flag & 2) if (flag & 2)
{ {
r.left += CHARX>>1; r.top += CHARY>>1; r.left += CHARX>>1; r.top += CHARY>>1;
r.right-= CHARX>>1; r.bottom -= CHARY>>1; r.right-= CHARX>>1; r.bottom -= CHARY>>1;
} }
@ -484,15 +490,15 @@ void TWindow::invert_bar(short left, short top, short right, short bottom)
void TWindow::set_opaque_text(bool o) void TWindow::set_opaque_text(bool o)
{ {
DRAW_CTOOLS ct; DRAW_CTOOLS ct;
win_get_draw_ctools(win(), &ct); win_get_draw_ctools(win(), &ct);
ct.opaque_text = o; ct.opaque_text = o;
win_set_draw_ctools(win(), &ct); win_set_draw_ctools(win(), &ct);
} }
void TWindow::set_font(int family, int style, int dim) void TWindow::set_font(int family, int style, int dim)
{ {
xvt_set_font(win(), family, style, dim); xvt_set_font(win(), family, style, dim);
} }
PNT TWindow::log2dev(long x, long y) const PNT TWindow::log2dev(long x, long y) const
@ -507,7 +513,7 @@ PNT TWindow::log2dev(long x, long y) const
TPoint TWindow::dev2log(const PNT& p) const TPoint TWindow::dev2log(const PNT& p) const
{ {
TPoint pnt(p.h / CHARX, p.v / CHARY); TPoint pnt(p.h / CHARX, p.v / CHARY);
return pnt; return pnt;
} }
@ -525,7 +531,7 @@ void TWindow::printat(short x, short y, const char* fmt, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
vsprintf(__tmp_string, fmt, argptr); vsprintf(__tmp_string, fmt, argptr);
va_end(argptr); va_end(argptr);
stringat(x, y, __tmp_string); stringat(x, y, __tmp_string);
} }
@ -533,26 +539,26 @@ void TWindow::printat(short x, short y, const char* fmt, ...)
void TWindow::line(short x0, short y0, short x1, short y1) void TWindow::line(short x0, short y0, short x1, short y1)
{ {
PNT f = log2dev(x0,y0); PNT f = log2dev(x0,y0);
PNT t = log2dev(x1,y1); PNT t = log2dev(x1,y1);
if (f.h == 0) f.h = -CHARX; else f.h += CHARX>>1; if (f.h == 0) f.h = -CHARX; else f.h += CHARX>>1;
if (f.v == 0) f.v = -CHARY; else f.v += CHARY>>1; if (f.v == 0) f.v = -CHARY; else f.v += CHARY>>1;
if (t.h == 0) t.h = -CHARX; else t.h += CHARX>>1; if (t.h == 0) t.h = -CHARX; else t.h += CHARX>>1;
if (t.v == 0) t.v = -CHARY; else t.v += CHARY>>1; if (t.v == 0) t.v = -CHARY; else t.v += CHARY>>1;
win_move_to(_win, f); win_move_to(_win, f);
win_draw_line(_win, t); win_draw_line(_win, t);
} }
void TWindow::icon(short x0, short y0, int iconid) void TWindow::icon(short x0, short y0, int iconid)
{ {
#if XVTWS == WMWS #if XVTWS == WMWS
bar(x0, y0, x0+1, y0+1); bar(x0, y0, x0+1, y0+1);
#else #else
PNT f = log2dev(x0,y0); PNT f = log2dev(x0,y0);
if (iconid < 0) iconid = ICON_RSRC; if (iconid < 0) iconid = ICON_RSRC;
win_draw_icon(win(), f.h, f.v, iconid); win_draw_icon(win(), f.h, f.v, iconid);
#endif #endif
} }
@ -567,7 +573,7 @@ TTemp_window::TTemp_window(WINDOW w)
TTemp_window::~TTemp_window() TTemp_window::~TTemp_window()
{ {
set_win(NULL_WIN); // I don't want to be closed! set_win(NULL_WIN); // I don't want to be closed!
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -575,44 +581,44 @@ TTemp_window::~TTemp_window()
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TScroll_window::TScroll_window() TScroll_window::TScroll_window()
: _origin(0, 0), _max(0, 0), _shift(0), _autoscroll(TRUE), : _origin(0, 0), _max(0, 0), _shift(0), _autoscroll(TRUE),
_has_hscroll(TRUE), _has_vscroll(TRUE) _has_hscroll(TRUE), _has_vscroll(TRUE)
{ {
} }
WINDOW TScroll_window::create(short x, short y, short dx, short dy, WINDOW TScroll_window::create(short x, short y, short dx, short dy,
const char* title, long flags, WIN_TYPE wt, WINDOW parent) const char* title, long flags, WIN_TYPE wt, WINDOW parent)
{ {
_has_hscroll = (flags & WSF_HSCROLL) != 0; _has_hscroll = (flags & WSF_HSCROLL) != 0;
_has_vscroll = (flags & WSF_VSCROLL) != 0 ; _has_vscroll = (flags & WSF_VSCROLL) != 0 ;
return TWindow::create(x, y, dx, dy, title, flags, wt, parent); return TWindow::create(x, y, dx, dy, title, flags, wt, parent);
} }
PNT TScroll_window::log2dev(long x, long y) const PNT TScroll_window::log2dev(long x, long y) const
{ {
if (_autoscroll) if (_autoscroll)
{ {
x -= _origin.x; x -= _origin.x;
y -= _origin.y >> _shift; y -= _origin.y >> _shift;
} }
return TWindow::log2dev(x,y); return TWindow::log2dev(x,y);
} }
void TScroll_window::set_scroll_max(long maxx, long maxy) void TScroll_window::set_scroll_max(long maxx, long maxy)
{ {
if (_has_hscroll && maxx >= 0) if (_has_hscroll && maxx >= 0)
{ {
_max.x = maxx; _max.x = maxx;
set_scroll_range(win(), HSCROLL, 0, int(maxx)); set_scroll_range(win(), HSCROLL, 0, int(maxx));
} }
if (_has_vscroll && maxy >= 0) if (_has_vscroll && maxy >= 0)
{ {
_shift = 0; _shift = 0;
while ((maxy >> _shift) > 0x7FFF) _shift++; while ((maxy >> _shift) > 0x7FFF) _shift++;
_max.y = maxy; _max.y = maxy;
set_scroll_range(win(), VSCROLL, 0, int(maxy >> _shift)); set_scroll_range(win(), VSCROLL, 0, int(maxy >> _shift));
} }
} }
void TScroll_window::update_thumb(long x, long y) void TScroll_window::update_thumb(long x, long y)
@ -621,7 +627,7 @@ void TScroll_window::update_thumb(long x, long y)
if (y >= 0 && y <= _max.y) _origin.y = y; if (y >= 0 && y <= _max.y) _origin.y = y;
if (_has_hscroll) if (_has_hscroll)
set_scroll_pos(win(), HSCROLL, int(_origin.x)); set_scroll_pos(win(), HSCROLL, int(_origin.x));
if (_has_vscroll) if (_has_vscroll)
set_scroll_pos(win(), VSCROLL, int(_origin.y >> _shift)); set_scroll_pos(win(), VSCROLL, int(_origin.y >> _shift));
} }
@ -631,51 +637,51 @@ void TScroll_window::handler(WINDOW win, EVENT* ep)
bool up = FALSE; bool up = FALSE;
switch (ep->type) switch (ep->type)
{ {
case E_HSCROLL: case E_HSCROLL:
case E_VSCROLL: case E_VSCROLL:
{
long& pos = (ep->type == E_HSCROLL) ? _origin.x : _origin.y;
long& max = (ep->type == E_HSCROLL) ? _max.x : _max.y;
short pag = (ep->type == E_HSCROLL) ? columns()/2+1 : rows()/2+1;
switch(ep->v.scroll.what)
{ {
long& pos = (ep->type == E_HSCROLL) ? _origin.x : _origin.y; case SC_PAGE_UP:
long& max = (ep->type == E_HSCROLL) ? _max.x : _max.y; pos -= pag;
short pag = (ep->type == E_HSCROLL) ? columns()/2+1 : rows()/2+1; up = TRUE;
switch(ep->v.scroll.what) break;
{ case SC_LINE_UP:
case SC_PAGE_UP: pos--;
pos -= pag; up = TRUE;
up = TRUE; break;
break; case SC_PAGE_DOWN:
case SC_LINE_UP: pos += pag;
pos--; up = TRUE;
up = TRUE; break;
break; case SC_LINE_DOWN:
case SC_PAGE_DOWN: pos++;
pos += pag; up = TRUE;
up = TRUE; break;
break; case SC_THUMB:
case SC_LINE_DOWN: pos = ep->v.scroll.pos;
pos++; up = TRUE;
up = TRUE; break;
break; default:
case SC_THUMB: break;
pos = ep->v.scroll.pos;
up = TRUE;
break;
default:
break;
}
if (pos < 0) pos = 0;
if (pos > max) pos = max;
} }
break; if (pos < 0) pos = 0;
default: if (pos > max) pos = max;
break;
} }
break;
default:
break;
}
if (up) if (up)
{ {
update_thumb(); update_thumb();
force_update(); force_update();
} }
TWindow::handler(win, ep); TWindow::handler(win, ep);
} }
@ -686,37 +692,37 @@ bool TScroll_window::on_key(KEY key)
{ {
case K_LHOME: case K_LHOME:
update_thumb(0,0); update_thumb(0,0);
force_update(); force_update();
break; break;
case K_LEND: case K_LEND:
update_thumb(0,range().y); update_thumb(0,range().y);
force_update(); force_update();
break; break;
case K_TAB: case K_TAB:
update_thumb(origin().x+8); update_thumb(origin().x+8);
force_update(); force_update();
break; break;
case K_BTAB: case K_BTAB:
{ {
long x = origin().x-8; long x = origin().x-8;
if (x < 0) x = 0; if (x < 0) x = 0;
update_thumb(x); update_thumb(x);
force_update(); force_update();
} }
break; break;
case K_UP: case K_UP:
case K_DOWN: case K_DOWN:
case K_PREV: case K_PREV:
case K_NEXT: case K_NEXT:
case K_LEFT: case K_LEFT:
case K_RIGHT: case K_RIGHT:
dispatch_e_scroll(win(), key); dispatch_e_scroll(win(), key);
break; break;
default: default:
break; break;
} }
return TWindow::on_key(key); return TWindow::on_key(key);
} }
void TWindow::clear(COLOR color) void TWindow::clear(COLOR color)

View File

@ -7,6 +7,7 @@
void close_all_dialogs(); void close_all_dialogs();
bool can_close(); bool can_close();
WINDOW cur_win();
// @C // @C
// Classe TPoint // Classe TPoint
@ -18,13 +19,13 @@ bool can_close();
struct TPoint struct TPoint
{ {
// @DPUB // @DPUB
long x, y; long x, y;
// Coordinate // Coordinate
// @FPUB // @FPUB
TPoint(long sx = 0, long sy = 0) : x(sx), y(sy) {} TPoint(long sx = 0, long sy = 0) : x(sx), y(sy) {}
// Costruttore // Costruttore
TPoint(PNT pnt) : x(pnt.h/CHARX), y(pnt.v/CHARY) {} TPoint(PNT pnt) : x(pnt.h/CHARX), y(pnt.v/CHARY) {}
void set(long sx, long sy) { x = sx; y = sy; } void set(long sx, long sy) { x = sx; y = sy; }
void set(PNT pnt) { x = pnt.h/CHARX; y = pnt.v/CHARY; } void set(PNT pnt) { x = pnt.h/CHARX; y = pnt.v/CHARY; }
@ -43,82 +44,82 @@ struct TPoint
class TWindow class TWindow
{ {
friend class TWindow_manager; friend class TWindow_manager;
// @DPRIV // @DPRIV
static DRAW_CTOOLS _ct; // Set di drawing tools (xvttype.h) static DRAW_CTOOLS _ct; // Set di drawing tools (xvttype.h)
static bool _ctools_saved; // E' stata salvata _ct ? static bool _ctools_saved; // E' stata salvata _ct ?
WINDOW _win; // Descrittore finestra WINDOW _win; // Descrittore finestra
KEY _lastkey; // Tasto di uscita KEY _lastkey; // Tasto di uscita
// @FPRIV // @FPRIV
bool save_ctools(); // Compila la struct _ct con i valori correnti bool save_ctools(); // Compila la struct _ct con i valori correnti
bool restore_ctools(); // Ripristina i valori DA _ct bool restore_ctools(); // Ripristina i valori DA _ct
protected: protected:
// @DPROT // @DPROT
bool _open : 1; // Se la finestra e' aperta bool _open : 1; // Se la finestra e' aperta
bool _modal : 1; // Se la finestra e' modale bool _modal : 1; // Se la finestra e' modale
bool _running : 1; // Se la finestra e' in esecuzione bool _running : 1; // Se la finestra e' in esecuzione
// @FPROT // @FPROT
static long window_handler(WINDOW win, EVENT* ep); static long window_handler(WINDOW win, EVENT* ep);
virtual WINDOW create(short x, short y, short dx, short dy, virtual WINDOW create(short x, short y, short dx, short dy,
const char* title = "", long flags = WSF_NONE, const char* title = "", long flags = WSF_NONE,
WIN_TYPE rt = W_DOC, WINDOW parent = NULL_WIN) ; WIN_TYPE rt = W_DOC, WINDOW parent = NULL_WIN) ;
void set_win(WINDOW w) { _win = w; } // Usare con cautela void set_win(WINDOW w) { _win = w; } // Usare con cautela
void set_modal(bool m) { _modal = m; } // Modifica il flag _modal void set_modal(bool m) { _modal = m; } // Modifica il flag _modal
WINDOW parent() const; WINDOW parent() const;
virtual void update() {} // E_UPDATE virtual void update() {} // E_UPDATE
virtual bool on_key(KEY) { return TRUE; } // E_CHAR virtual bool on_key(KEY) { return TRUE; } // E_CHAR
virtual PNT log2dev(long x, long y) const; virtual PNT log2dev(long x, long y) const;
virtual TPoint dev2log(const PNT& p) const; virtual TPoint dev2log(const PNT& p) const;
public: public:
// @FPUB // @FPUB
TWindow(); // Costruttore TWindow(); // Costruttore
virtual ~TWindow(); virtual ~TWindow();
virtual void handler(WINDOW win, EVENT* ep); // Handler finestra virtual void handler(WINDOW win, EVENT* ep); // Handler finestra
virtual void set_focus(); // Mette la finestra in primo piano virtual void set_focus(); // Mette la finestra in primo piano
virtual WINDOW win() const { return _win; } // Ritorna il descrittore della finestra virtual WINDOW win() const { return _win; } // Ritorna il descrittore della finestra
bool is_open() const { return _open; } // Ritorna _open bool is_open() const { return _open; } // Ritorna _open
bool is_modal() const { return _modal; } // Ritorna _modal bool is_modal() const { return _modal; } // Ritorna _modal
bool is_running() const { return _running; } // Ritorna _running bool is_running() const { return _running; } // Ritorna _running
TPoint size() const; // Determina numero di righe e colonne nella finestra TPoint size() const; // Determina numero di righe e colonne nella finestra
short rows() const { return (short)size().y; }// Ritorna numero di righe short rows() const { return (short)size().y; }// Ritorna numero di righe
short columns() const { return (short)size().x; } // Ritorna numero di colonne short columns() const { return (short)size().x; } // Ritorna numero di colonne
virtual void start_run() {} virtual void start_run() {}
virtual bool stop_run(KEY key); virtual bool stop_run(KEY key);
void force_update(); // Forza ridisegno della finestra void force_update(); // Forza ridisegno della finestra
virtual void open(); // Mostra la finestra virtual void open(); // Mostra la finestra
virtual void close(); // Nasconde la finestra virtual void close(); // Nasconde la finestra
void iconize() const; void iconize() const;
void maximize() const; void maximize() const;
virtual void enable(bool = TRUE) const; virtual void enable(bool = TRUE) const;
void disable() const { enable(FALSE); } void disable() const { enable(FALSE); }
void open_modal(); // Mostra la finestra modale void open_modal(); // Mostra la finestra modale
void close_modal(); // Nasconde la finestra modale void close_modal(); // Nasconde la finestra modale
KEY run(); // Esegue la finestra KEY run(); // Esegue la finestra
KEY last_key() const { return _lastkey; } // Ritorna l'ultimo tasto KEY last_key() const { return _lastkey; } // Ritorna l'ultimo tasto
virtual void set_caption(const char* title); virtual void set_caption(const char* title);
virtual const char* get_caption() const; virtual const char* get_caption() const;
// Riempie la finestra con il colore in color // Riempie la finestra con il colore in color
void clear(COLOR color); void clear(COLOR color);
// Setta il draw mode // Setta il draw mode
@ -130,17 +131,17 @@ public:
// Setta opaque_text. Quando e' FALSE il testo viene scritto in modo trasparente // Setta opaque_text. Quando e' FALSE il testo viene scritto in modo trasparente
void set_opaque_text(bool o); void set_opaque_text(bool o);
// Sceglie penna con colore color eccetera // Sceglie penna con colore color eccetera
void set_pen(COLOR color, int width = 1, PAT_STYLE pat = PAT_SOLID, PEN_STYLE st = P_SOLID); void set_pen(COLOR color, int width = 1, PAT_STYLE pat = PAT_SOLID, PEN_STYLE st = P_SOLID);
void hide_pen(); // Nasconde la penna void hide_pen(); // Nasconde la penna
void hide_brush(); // Nasconde il pennello void hide_brush(); // Nasconde il pennello
void set_brush(COLOR color, PAT_STYLE = PAT_SOLID); // Sceglie pennello con colore color void set_brush(COLOR color, PAT_STYLE = PAT_SOLID); // Sceglie pennello con colore color
void set_font(int family = FF_SYSTEM, int style = 0, int dim = 0); // Sceglie il font void set_font(int family = FF_SYSTEM, int style = 0, int dim = 0); // Sceglie il font
// Disegna un rettangolo con la possibilita' di settare la penna e il draw_mode // Disegna un rettangolo con la possibilita' di settare la penna e il draw_mode
void frame(short left, short top, short right, short bottom, int flag); void frame(short left, short top, short right, short bottom, int flag);
// Queste funzioni chiamano tutte frame con diversi flag // Queste funzioni chiamano tutte frame con diversi flag
void rect(short left, short top, short right, short bottom); void rect(short left, short top, short right, short bottom);
void bar(short left, short top, short right, short bottom); void bar(short left, short top, short right, short bottom);
void invert_bar(short left, short top, short right, short bottom); void invert_bar(short left, short top, short right, short bottom);
@ -169,47 +170,47 @@ public:
class TScroll_window : public TWindow class TScroll_window : public TWindow
{ {
// @DPRIV // @DPRIV
TPoint _origin; TPoint _origin;
TPoint _max; TPoint _max;
short _shift; short _shift;
bool _autoscroll : 1; bool _autoscroll : 1;
bool _has_hscroll : 1; bool _has_hscroll : 1;
bool _has_vscroll : 1; bool _has_vscroll : 1;
protected: protected:
// @FPROT // @FPROT
virtual WINDOW create(short x, short y, short dx, short dy, virtual WINDOW create(short x, short y, short dx, short dy,
const char* title = "", long flags = WSF_NONE, const char* title = "", long flags = WSF_NONE,
WIN_TYPE rt = W_DOC, WINDOW parent = NULL_WIN) ; // Crea la finestra WIN_TYPE rt = W_DOC, WINDOW parent = NULL_WIN) ; // Crea la finestra
virtual PNT log2dev(long x, long y) const; virtual PNT log2dev(long x, long y) const;
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
public: public:
// @FPUB // @FPUB
TScroll_window(); TScroll_window();
// Costruttore // Costruttore
virtual void handler(WINDOW win, EVENT* ep); virtual void handler(WINDOW win, EVENT* ep);
void set_scroll_max(long maxx, long maxy); void set_scroll_max(long maxx, long maxy);
// Setta punto di massimo scroll // Setta punto di massimo scroll
void update_thumb(long x = -1, long y = -1); void update_thumb(long x = -1, long y = -1);
// Aggiorna la scrollbar // Aggiorna la scrollbar
void autoscroll(bool on) { _autoscroll = on; } void autoscroll(bool on) { _autoscroll = on; }
// Setta autoscroll // Setta autoscroll
bool autoscrolling() const { return _autoscroll; } bool autoscrolling() const { return _autoscroll; }
const TPoint& origin() const { return _origin; } const TPoint& origin() const { return _origin; }
// Ritorna punto origine // Ritorna punto origine
const TPoint& range() const { return _max; } const TPoint& range() const { return _max; }
// Ritorna punto massimo // Ritorna punto massimo
}; };
#endif // __WINDOW_H #endif // __WINDOW_H

View File

@ -107,11 +107,13 @@ HIDDEN BOOLEAN event_hook(HWND hwnd,
ULONG lparam, ULONG lparam,
long* ret) long* ret)
{ {
if (msg == WM_CTLCOLOR) switch(msg)
{
case WM_CTLCOLOR:
{ {
const word type = HIWORD(lparam); const word type = HIWORD(lparam);
if (type == CTLCOLOR_LISTBOX || type == CTLCOLOR_EDIT || if (type == CTLCOLOR_LISTBOX || type == CTLCOLOR_EDIT ||
type == CTLCOLOR_MSGBOX) type == CTLCOLOR_MSGBOX)
{ {
HWND hwnd = LOWORD(lparam); HWND hwnd = LOWORD(lparam);
@ -137,44 +139,64 @@ HIDDEN BOOLEAN event_hook(HWND hwnd,
*ret = focus ? FocusBrush : NormalBrush; *ret = focus ? FocusBrush : NormalBrush;
return TRUE; return TRUE;
} }
} else }
if (msg == WM_COMMAND) break;
case WM_COMMAND:
{
const word notify = HIWORD(lparam);
if (notify == EN_KILLFOCUS || notify == EN_SETFOCUS)
{
HWND hwnd = LOWORD(lparam); // Ridisegna BENE il campo
InvalidateRect(hwnd, NULL, TRUE);
}
}
break;
case WM_KEYDOWN:
if (wparam == VK_PRIOR || wparam == VK_NEXT ||
wparam == VK_UP || wparam == VK_DOWN )
{
char name[16];
GetClassName(hwnd, name, 5);
if (stricmp(name, "Edit") == 0)
{
KEY key;
switch(wparam)
{ {
word notify = HIWORD(lparam); case VK_PRIOR:
if (notify == EN_KILLFOCUS || notify == EN_SETFOCUS) wparam = K_PREV; break;
{ case VK_NEXT:
HWND hwnd = LOWORD(lparam); key = K_NEXT; break;
InvalidateRect(hwnd, NULL, TRUE); case VK_UP:
} key = K_UP; break;
} else case VK_DOWN:
if (msg == WM_KEYUP) key = K_DOWN; break;
{ default:
if (wparam == VK_PRIOR || wparam == VK_NEXT || key = 0; break;
wparam == VK_UP || wparam == VK_DOWN ) }
{ if (key > 0)
char name[16]; {
GetClassName(hwnd, name, 15); WINDOW w = cur_win();
if (stricmp(name, "Edit") == 0) if (w != NULL_WIN)
{ dispatch_e_char(w, key);
switch(wparam) }
{ }
case VK_PRIOR:wparam = K_PREV; break; }
case VK_NEXT :wparam = K_NEXT; break; break;
case VK_UP :wparam = K_UP; break; case WM_MENUCHAR:
case VK_DOWN :wparam = K_DOWN; break; {
default:wparam = 0; break; WINDOW w = cur_win();
} if (w != NULL_WIN)
if (wparam) {
{ const KEY key = toupper(wparam)+K_CTRL;
WINDOW w = xvtwi_hwnd_to_window(GetParent(hwnd)); dispatch_e_char(w, key);
dispatch_e_char(w, wparam); }
} }
} break;
} default:
} break;
}
return FALSE;
return FALSE;
} }
#endif #endif
@ -671,6 +693,7 @@ int xvt_get_checked_radio(const WINDOW* ctls, int count)
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
HIDDEN WINDOW statbar = NULL_WIN; HIDDEN WINDOW statbar = NULL_WIN;
HIDDEN TString80 stattext;
WINDOW xvt_create_statbar() WINDOW xvt_create_statbar()
{ {
@ -702,17 +725,22 @@ WINDOW xvt_create_statbar()
void xvt_statbar_set(const char* text) void xvt_statbar_set(const char* text)
{ {
TString t(text); t.cut(60);
const TDate oggi(TODAY);
t << '\t' << oggi.string() << " - " << MainApp()->title();
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
statbar_set_title(statbar, (char*)(const char*)t); if (text != NULL)
{
stattext.strncpy(text, 56);
const TDate oggi(TODAY);
stattext << '\t' << oggi.string() << " - " << MainApp()->title();
}
statbar_set_title(statbar, (char*)(const char*)stattext);
#endif #endif
} }
void xvt_statbar_refresh() void xvt_statbar_refresh()
{ {
invalidate_rect(statbar, NULL); #if XVT_OS == XVT_OS_WIN
statbar_set_title(statbar, (char*)(const char*)stattext);
#endif
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -742,7 +770,8 @@ bool xvt_test_menu_tag(MENU_TAG tag)
COLOR trans_color(char c) COLOR trans_color(char c)
{ {
switch (c) { switch (c)
{
case 'n': return COLOR_BLACK; break; case 'n': return COLOR_BLACK; break;
case 'r': return COLOR_RED; break; case 'r': return COLOR_RED; break;
case 'g': return COLOR_GREEN; break; case 'g': return COLOR_GREEN; break;
@ -755,8 +784,9 @@ COLOR trans_color(char c)
case 'd': return COLOR_DKGRAY; break; case 'd': return COLOR_DKGRAY; break;
case 'l': return COLOR_LTGRAY; break; case 'l': return COLOR_LTGRAY; break;
case 'k': return COLOR_GRAY; break; case 'k': return COLOR_GRAY; break;
default: CHECK(0,"trans_color: Undefined color"); return -1; break; default: CHECK(0,"trans_color: Undefined color"); break;
} }
return -1;
} }
PAT_STYLE trans_brush(char p) PAT_STYLE trans_brush(char p)
@ -772,8 +802,9 @@ PAT_STYLE trans_brush(char p)
case '\\': return PAT_BDIAG; break; case '\\': return PAT_BDIAG; break;
case 'X' : return PAT_DIAGCROSS; break; case 'X' : return PAT_DIAGCROSS; break;
case '+' : return PAT_CROSS; break; case '+' : return PAT_CROSS; break;
default: CHECK(0,"trans_brush: Undefined pattern"); return PAT_NONE; break; default : CHECK(0,"trans_brush: Undefined pattern"); break;
} }
return PAT_NONE;
} }
PEN_STYLE trans_pen(char p) PEN_STYLE trans_pen(char p)
@ -783,7 +814,8 @@ PEN_STYLE trans_pen(char p)
case 'n' : return P_SOLID; break; case 'n' : return P_SOLID; break;
case '.' : return P_DOT; break; case '.' : return P_DOT; break;
case '-' : return P_DASH; break; case '-' : return P_DASH; break;
default: CHECK(0,"trans_pen: Undefined pattern"); return P_SOLID; break; default: CHECK(0,"trans_pen: Undefined pattern"); break;
} }
return P_SOLID;
} }