Corretti problemi di triplo click e aggiunda validazione dei nomi dei file

git-svn-id: svn://10.65.10.50/trunk@722 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-12-02 13:30:45 +00:00
parent 4265b6a9ac
commit 0a2e2fd909
20 changed files with 1182 additions and 1115 deletions

View File

@ -1,128 +1,132 @@
#include <bagn001a.h> #include <bagn001a.h>
PAGE "IMPOSTAZIONE STAMPANTE" -1 -1 76 13 PAGE "IMPOSTAZIONE STAMPANTE" -1 -1 76 13
RADIOBUTTON MSK_1_TYPE 70 RADIOBUTTON MSK_1_TYPE 1 70
BEGIN BEGIN
PROMPT 1 1 "Stampa su..." PROMPT 1 1 "Stampa su..."
HELP "Selezionare il tipo dove direzionare la stampa" HELP "Selezionare il tipo dove direzionare la stampa"
ITEM "0|Stampante" ITEM "0|Stampante"
MESSAGE HIDE,MSK_1_FILENAME|RESET,MSK_1_FILENAME|SHOW,MSK_1_PRINTERS MESSAGE HIDE,MSK_1_FILENAME
MESSAGE ENABLE,MSK_1_PRINTERS MESSAGE SHOW,MSK_1_PRINTERS|ENABLE,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_CODES MESSAGE ENABLE,MSK_1_CODES
MESSAGE ENABLE,MSK_1_SIZE MESSAGE ENABLE,MSK_1_SIZE
MESSAGE ENABLE,MSK_1_LINES MESSAGE ENABLE,MSK_1_LINES
MESSAGE ENABLE,DLG_SETPRINT MESSAGE ENABLE,DLG_SETPRINT
ITEM "2|Visualizzazione" ITEM "2|Visualizzazione"
MESSAGE HIDE,MSK_1_FILENAME|RESET,MSK_1_FILENAME MESSAGE HIDE,MSK_1_FILENAME
MESSAGE SHOW,MSK_1_PRINTERS|DISABLE,MSK_1_PRINTERS MESSAGE SHOW,MSK_1_PRINTERS|DISABLE,MSK_1_PRINTERS
MESSAGE DISABLE,MSK_1_CODES MESSAGE DISABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_SIZE MESSAGE DISABLE,MSK_1_SIZE
MESSAGE DISABLE,MSK_1_LINES MESSAGE DISABLE,MSK_1_LINES
MESSAGE DISABLE,DLG_SETPRINT MESSAGE DISABLE,DLG_SETPRINT
ITEM "1|File su disco" ITEM "1|File su disco"
MESSAGE SHOW,MSK_1_FILENAME|HIDE,MSK_1_PRINTERS MESSAGE SHOW,MSK_1_FILENAME
MESSAGE ENABLE,MSK_1_CODES MESSAGE HIDE,MSK_1_PRINTERS
MESSAGE DISABLE,MSK_1_SIZE MESSAGE ENABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_LINES MESSAGE DISABLE,MSK_1_SIZE
MESSAGE DISABLE,DLG_SETPRINT MESSAGE DISABLE,MSK_1_LINES
FLAGS "Z" MESSAGE DISABLE,DLG_SETPRINT
END FLAGS "Z"
END
LIST MSK_1_PRINTERS 50
BEGIN LIST MSK_1_PRINTERS 50
/* viene riempito a run-time con nomi letti da config */ BEGIN
PROMPT 4 5 "Stampante " /* viene riempito a run-time con nomi letti da config */
HELP "Selezionare il tipo di stampante desiderata" PROMPT 4 5 "Stampante "
END HELP "Selezionare il tipo di stampante desiderata"
END
STRING MSK_1_FILENAME 52
BEGIN STRING MSK_1_FILENAME 52
PROMPT 4 5 "Nome file " BEGIN
HELP "Nome del file su cui direzionare la stampa" PROMPT 4 5 "Nome file "
END CHECKTYPE REQUIRED
VALIDATE FILENAME_FUNC
LIST MSK_1_CODES 40 FLAGS "A"
BEGIN HELP "Nome del file in cui memorizzare la stampa"
PROMPT 4 6 "Tipo stampa " WARNING "E' necessario specificare un nome di file"
/* pure */ END
HELP "Modalita' nelle quale si desidera la stampa"
END LIST MSK_1_CODES 40
BEGIN
LIST MSK_1_SIZE 3 PROMPT 4 6 "Tipo stampa "
BEGIN HELP "Modalita' nelle quale si desidera la stampa"
PROMPT 31 6 "Carattere " END
ITEM "7|7"
ITEM "8|8" LIST MSK_1_SIZE 3
ITEM "10|10" BEGIN
ITEM "12|12" PROMPT 31 6 "Carattere "
ITEM "15|15" ITEM "7|7"
ITEM "17|17" ITEM "8|8"
HELP "Dimensioni del carattere di stampa" ITEM "10|10"
END ITEM "12|12"
ITEM "15|15"
LIST MSK_1_LINES 3 ITEM "17|17"
BEGIN HELP "Dimensioni del carattere di stampa"
PROMPT 52 6 "Linee/Inch " END
ITEM "4|4"
ITEM "5|5" LIST MSK_1_LINES 3
ITEM "6|6" BEGIN
ITEM "7|7" PROMPT 52 6 "Linee/Inch "
ITEM "8|8" ITEM "4|4"
ITEM "9|9" ITEM "5|5"
ITEM "10|10" ITEM "6|6"
HELP "Numero di linee per pollice" ITEM "7|7"
END ITEM "8|8"
ITEM "9|9"
LIST MSK_1_FONT 10 ITEM "10|10"
BEGIN HELP "Numero di linee per pollice"
PROMPT 4 6 "Font " END
HELP "Font di stampa su video o stampante"
ITEM "1|Courier" LIST MSK_1_FONT 10
FLAGS "D" BEGIN
END PROMPT 4 6 "Font "
HELP "Font di stampa su video o stampante"
NUMBER MSK_1_NPAGES 3 0 ITEM "1|Courier"
BEGIN FLAGS "D"
PROMPT 54 8 "N.o copie " END
HELP "Numero di copie da fare"
END NUMBER MSK_1_NPAGES 3 0
BEGIN
BOOLEAN MSK_1_ISGRAPHICS PROMPT 54 8 "N.o copie "
BEGIN HELP "Numero di copie da fare"
PROMPT 4 8 "Stampa elementi grafici" END
HELP "Indicare se stampare elementi grafici (linee, box, logo) quando la stampante lo consente"
END BOOLEAN MSK_1_ISGRAPHICS
BEGIN
PROMPT 4 8 "Stampa elementi grafici"
GROUPBOX DLG_NULL 74 4 HELP "Indicare se stampare elementi grafici (linee, box, logo) quando la stampante lo consente"
BEGIN END
PROMPT 1 9 ""
END
GROUPBOX DLG_NULL 74 4
BUTTON DLG_SETPRINT 9 2 BEGIN
BEGIN PROMPT 1 9 ""
PROMPT -14 -2 "~Imposta" END
HELP "Chiama l'Impostazione Stampante di Windows"
MESSAGE EXIT,DLG_SETPRINT BUTTON DLG_SETPRINT 9 2
END BEGIN
PROMPT -14 -2 "~Imposta"
BUTTON DLG_SAVEREC 9 2 HELP "Chiama l'Impostazione Stampante di Windows"
BEGIN MESSAGE EXIT,DLG_SETPRINT
PROMPT -24 -2 "~Registra" END
MESSAGE EXIT,K_INS
END BUTTON DLG_SAVEREC 9 2
BEGIN
BUTTON DLG_OK 9 2 PROMPT -24 -2 "~Registra"
BEGIN MESSAGE EXIT,K_INS
PROMPT -34 -2 "" END
END
BUTTON DLG_OK 9 2
BUTTON DLG_CANCEL 9 2 BEGIN
BEGIN PROMPT -34 -2 ""
PROMPT -44 -2 "" END
END
BUTTON DLG_CANCEL 9 2
ENDPAGE BEGIN
PROMPT -44 -2 ""
ENDMASK END
ENDPAGE
ENDMASK

View File

@ -598,7 +598,7 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
_accel *= CHARX; _accel *= CHARX;
_dx = (width - win_get_text_width(win(), (char*)caption(), -1)) >> 1; _dx = (width - win_get_text_width(win(), (char*)caption(), -1)) >> 1;
_dy = byte((height-CHARY)/2 + BASEY); _dy = byte((height-CHARY)/2 + BASEY - DEPTH);
} }
} }

View File

@ -1,90 +1,92 @@
#ifndef __DEFMASK_H #ifndef __DEFMASK_H
#define __DEFMASK_H #define __DEFMASK_H
/* @M /* @M
Identificativi predefiniti dei controlli di XVT Identificativi predefiniti dei controlli di XVT
*/ */
#define DLG_NULL -1 #define DLG_NULL -1
#define DLG_OK 1 /* TAG del bottone <Conferma> */ #define DLG_OK 1 /* TAG del bottone <Conferma> */
#define DLG_CANCEL 2 /* TAG del bottone <Annulla> */ #define DLG_CANCEL 2 /* TAG del bottone <Annulla> */
#define DLG_PGDN 5 /* TAG del bottone <PgDn> */ #define DLG_PGDN 5 /* TAG del bottone <PgDn> */
#define DLG_PGUP 6 /* TAG del bottone <PgUp> */ #define DLG_PGUP 6 /* TAG del bottone <PgUp> */
#define DLG_PAGE 7 /* TAG del bottone <PgUp/PgDn> */ #define DLG_PAGE 7 /* TAG del bottone <PgUp/PgDn> */
#define DLG_PAGETAGS 8 /* TAG del bottone <Pg n> */ #define DLG_PAGETAGS 8 /* TAG del bottone <Pg n> */
#define DLG_QUIT 9 /* TAG del bottone <Uscita> */ #define DLG_QUIT 9 /* TAG del bottone <Uscita> */
#define DLG_F9 10 /* TAG del bottone <Ricerca> */ #define DLG_F9 10 /* TAG del bottone <Ricerca> */
#define DLG_FIRSTREC 11 /* TAG del bottone <Primo> */ #define DLG_FIRSTREC 11 /* TAG del bottone <Primo> */
#define DLG_PREVREC 12 /* TAG del bottone <Precedente> */ #define DLG_PREVREC 12 /* TAG del bottone <Precedente> */
#define DLG_STOPREC 13 /* TAG del bottone <Stop> */ #define DLG_STOPREC 13 /* TAG del bottone <Stop> */
#define DLG_NEXTREC 14 /* TAG del bottone <Successivo> */ #define DLG_NEXTREC 14 /* TAG del bottone <Successivo> */
#define DLG_LASTREC 15 /* TAG del bottone <Ultimo> */ #define DLG_LASTREC 15 /* TAG del bottone <Ultimo> */
#define DLG_NEWREC 16 /* TAG del bottone <Nuovo> */ #define DLG_NEWREC 16 /* TAG del bottone <Nuovo> */
#define DLG_DELREC 17 /* TAG del bottone <Cancella> */ #define DLG_DELREC 17 /* TAG del bottone <Cancella> */
#define DLG_SAVEREC 18 /* TAG del bottone <Registra> */ #define DLG_SAVEREC 18 /* TAG del bottone <Registra> */
#define DLG_FINDREC 19 /* TAG del bottone <Ricerca> */ #define DLG_FINDREC 19 /* TAG del bottone <Ricerca> */
#define DLG_BAR 20 /* TAG del bottone <Barra> == <Annulla> */ #define DLG_BAR 20 /* TAG del bottone <Barra> == <Annulla> */
#define DLG_SELECT 21 /* TAG del bottone <Selezione> */ #define DLG_SELECT 21 /* TAG del bottone <Selezione> */
#define DLG_EDIT 22 /* TAG del bottone Edit */ #define DLG_EDIT 22 /* TAG del bottone Edit */
#define DLG_LINK 23 /* TAG del bottone Collega (applicazione) */ #define DLG_LINK 23 /* TAG del bottone Collega (applicazione) */
#define DLG_PRINT 24 /* TAG del bottone Stampa */ #define DLG_PRINT 24 /* TAG del bottone Stampa */
#define DLG_SETPRINT 25 /* TAG del bottone Imposta Stampa */ #define DLG_SETPRINT 25 /* TAG del bottone Imposta Stampa */
#define DLG_USER 100 /* TAG del primo controllo definito dall'utente */ #define DLG_USER 100 /* TAG del primo controllo definito dall'utente */
/* @M /* @M
Funzioni di libreria per i validate delle maschere Funzioni di libreria per i validate delle maschere
Nome descrizione Parametri Nome descrizione Parametri
NUM_EXPR espressione numerica espressione NUM_EXPR espressione numerica espressione
STR_EXPR espressione stringa espressione STR_EXPR espressione stringa espressione
NOT_EMPTY_FUNC campo non vuoto NOT_EMPTY_FUNC campo non vuoto
FIXLEN_FUNC lunghezza fissa lunghezza FIXLEN_FUNC lunghezza fissa lunghezza
EMPTYCOPY_FUNC data id del campo da cui copiarsi se vuoto EMPTYCOPY_FUNC data id del campo da cui copiarsi se vuoto
DATE_CMP_FUNC compara due date operatore,id.campo con l'altra DATE_CMP_FUNC compara due date operatore,id.campo con l'altra
data data
PI_FUNC controllo part.IVA ???? PI_FUNC controllo part.IVA ????
XTPI_FUNC controllo esteso XTPI_FUNC controllo esteso
part.IVA ???? part.IVA ????
XTZPI_FUNC controllo esteso XTZPI_FUNC controllo esteso
part.IVA anche vuota ???? part.IVA anche vuota ????
CF_FUNC controllo cod.fisc. ???? CF_FUNC controllo cod.fisc. ????
XTCF_FUNC controllo esteso XTCF_FUNC controllo esteso
cod.fisc. ???? cod.fisc. ????
XTZCF_FUNC controllo esteso XTZCF_FUNC controllo esteso
cod.fisc.anche vuoto ???? cod.fisc.anche vuoto ????
MTCHECK_FUNC mese corretto per MTCHECK_FUNC mese corretto per
ditta mensile o ditta mensile o
trimestrale trimestrale
REQIF_FUNC richiesto se immesso un campo della lista REQIF_FUNC richiesto se immesso un campo della lista
n.ro di campi lista di campi... n.ro di campi lista di campi...
ONEREQ_FUNC almeno uno non vuoto ONEREQ_FUNC almeno uno non vuoto
n.ro campi lista di campi n.ro campi lista di campi
CHECK_FIELD esegue il check su di un altro campo CHECK_FIELD esegue il check su di un altro campo
campo campo
*/ FILENAME_FUNC controlla se la stringa e' un nome di file
*/
#define EXPR_FUNC 0 2
#define EMPTYCOPY_FUNC 1 1 #define EXPR_FUNC 0 2
#define PI_FUNC 2 1 #define EMPTYCOPY_FUNC 1 1
#define CF_FUNC 3 1 #define PI_FUNC 2 1
#define NOT_EMPTY_FUNC 4 0 #define CF_FUNC 3 1
#define DATE_CMP_FUNC 5 2 #define NOT_EMPTY_FUNC 4 0
#define XTPI_FUNC 6 3 #define DATE_CMP_FUNC 5 2
#define XTCF_FUNC 7 4 #define XTPI_FUNC 6 3
#define XTZPI_FUNC 8 3 #define XTCF_FUNC 7 4
#define XTZCF_FUNC 9 4 #define XTZPI_FUNC 8 3
#define FIXLEN_FUNC 10 1 #define XTZCF_FUNC 9 4
#define MTCHECK_FUNC 11 0 #define FIXLEN_FUNC 10 1
#define REQIF_FUNC 12 #define MTCHECK_FUNC 11 0
#define AUTOEXIT_FUNC 13 #define REQIF_FUNC 12
#define NUMCALC_FUNC 14 #define AUTOEXIT_FUNC 13
#define STRCALC_FUNC 15 #define NUMCALC_FUNC 14
#define ONEREQ_FUNC 16 #define STRCALC_FUNC 15
#define CHECK_FIELD 17 1 #define ONEREQ_FUNC 16
#define CHECK_FIELD 17 1
#define VALEXPR VALIDATE EXPR_FUNC #define FILENAME_FUNC 18
#define NUM_EXPR VALEXPR 0
#define STR_EXPR VALEXPR 1 #define VALEXPR VALIDATE EXPR_FUNC
#define NUM_CALC VALIDATE NUMCALC_FUNC 1 #define NUM_EXPR VALEXPR 0
#define STR_CALC VALIDATE STRCALC_FUNC 1 #define STR_EXPR VALEXPR 1
#define THIS_FIELD 0 #define NUM_CALC VALIDATE NUMCALC_FUNC 1
/* @END */ #define STR_CALC VALIDATE STRCALC_FUNC 1
#endif // __DEFMASK_H #define THIS_FIELD 0
/* @END */
#endif // __DEFMASK_H

View File

@ -1,4 +1,4 @@
// $Id: mailbox.cpp,v 1.7 1994-11-10 14:16:39 alex Exp $ // $Id: mailbox.cpp,v 1.8 1994-12-02 13:30:03 guy Exp $
#include <stdlib.h> #include <stdlib.h>
#include <fstream.h> #include <fstream.h>
@ -16,12 +16,13 @@
#define DEF_MSGS_CAPACITY 50 #define DEF_MSGS_CAPACITY 50
#define MAX_TXT_LEN 200 #define MAX_TXT_LEN 200
TMessage::TMessage(const char* to, const char* sub, const char* text, TMessage::TMessage(const char* to, const char* sub,
const char* from) const char* text, const char* from)
{ {
_to = to; _subject = sub; _to = cmd2name(to);
_subject = sub;
_text = text; _text = text;
_from = (from == NULL || *from == '\0' ? main_app().name() : from); _from = (from == NULL || *from == '\0') ? main_app().name() : from;
_flags = 0x00; _number = -1; _flags = 0x00; _number = -1;
} }
@ -146,9 +147,7 @@ void TMailbox::send(TMessage& m)
ofstream fto(to_path, ios::app); ofstream fto(to_path, ios::app);
CHECK(fto.good(),"send: trouble opening mailbox file"); CHECK(fto.good(),"send: trouble opening mailbox file");
fto << m.from() << '\n' fto << m.from() << '\n' << m.subject() << '\n' << m.body() << '\n';
<< m.subject() << '\n'
<< m.body() << '\n';
fto.close(); fto.close();
} }

View File

@ -110,7 +110,7 @@ void TMask::control_handler(EVENT* ep)
} }
void TMask::handler(WINDOW win, EVENT* ep) void TMask::handler(WINDOW win, EVENT* ep)
{ {
switch (ep->type) switch (ep->type)
{ {
case E_UPDATE: case E_UPDATE:
@ -151,7 +151,7 @@ void TMask::handler(WINDOW win, EVENT* ep)
w = f->win(); w = f->win();
if (test_focus_change(w)) if (test_focus_change(w))
f->on_key(K_F9); // Attiva ricerca sul campo associato al bottone f->on_key(K_F9); // Attiva ricerca sul campo associato al bottone
} }
break; break;
default: default:
control_handler(ep); control_handler(ep);
@ -955,10 +955,11 @@ void TMask::reset(short fld_id)
for (int f = 0; f < fields(); f++) for (int f = 0; f < fields(); f++)
{ {
TMask_field& c = fld(f); TMask_field& c = fld(f);
c._flags.dirty = FALSE;
c.reset(); c.reset();
c.set_dirty(FALSE);
} }
} else field(fld_id).reset(); }
else field(fld_id).reset();
} }

View File

@ -1,195 +1,194 @@
#ifndef __MASK_H #ifndef __MASK_H
#define __MASK_H #define __MASK_H
#ifndef __WINDOW_H #ifndef __WINDOW_H
#include <window.h> #include <window.h>
#endif #endif
#ifndef __MASKFLD_H #ifndef __MASKFLD_H
#include <maskfld.h> #include <maskfld.h>
#endif #endif
#ifndef __REAL_H #ifndef __REAL_H
#include <real.h> #include <real.h>
#endif #endif
// @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_VIS , MODE_QUERY, MODE_QUERYINS, MODE_VIS , MODE_QUERY, MODE_QUERYINS };
MODE_SEARCH }; // @END
// @END
// @C
// @C // Classe TMask : public TWindow
// Classe TMask : public TWindow // @END
// @END
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 WINDOW _pagepag[MAX_PAGES]; // Windows of pgup/pgdn
WINDOW _pagepag[MAX_PAGES]; // Windows of pgup/pgdn WINDOW _pagetag[MAX_PAGES]; // Windows of pagetags
WINDOW _pagetag[MAX_PAGES]; // Windows of pagetags
int _pages; // Number of pages of the mask
int _pages; // Number of pages of the mask int _page; // Current page
int _page; // Current page
TBit_array _enabled; // Are pages enabled
TBit_array _enabled; // Are pages enabled 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 bool _sheetmask; // Mask owned by a sheet
bool _sheetmask; // Mask owned by a sheet
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();
void init_mask(); WINDOW read_page(TScanner& scanner, bool toolbar = FALSE);
WINDOW read_page(TScanner& scanner, bool toolbar = FALSE); void read_mask(const char* name, int num, int max);
void read_mask(const char* name, int num, int max); 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
bool test_focus_change(WINDOW w = NULL_WIN);
bool test_focus_change(WINDOW w = NULL_WIN); 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 num = 0, int max = MAX_PAGES);
TMask(const char* name, int num = 0, int max = MAX_PAGES);
// 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 ypos = -1);
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(bool show_value, const real& nuo);
void set_exchange(bool show_value, const real& nuo); 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 bool can_be_closed() const;
virtual bool can_be_closed() const;
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 TEdit_field& efield(short id) const; // edit-field with given id
TEdit_field& efield(short id) const; // edit-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 on_firm_change();
void on_firm_change();
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(byte p, bool on = TRUE);
void enable_page(byte p, bool on = TRUE); void disable_page(byte p) { enable_page(p, FALSE); }
void disable_page(byte p) { enable_page(p, FALSE); } bool page_enabled(byte p) const;
bool page_enabled(byte 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, TMask_field* from = NULL);
void send_key(KEY key, short id, TMask_field* from = NULL); 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 is_sheetmask() const { return _sheetmask; }
bool is_sheetmask() const { return _sheetmask; }
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; }
bool edit_mode() const { return _mode == MODE_MOD; } 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.56 1994-12-02 13:07:39 alex Exp $ // $Id: maskfld.cpp,v 1.57 1994-12-02 13:30:09 guy Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -1348,7 +1348,7 @@ bool TBrowse::do_insert()
#endif #endif
TMailbox mail; TMailbox mail;
TMessage msg(cmd2name(app), MSG_AI, ""); TMessage msg(app, MSG_AI, "");
mail.send(msg); mail.send(msg);
TExternal_app a(app); TExternal_app a(app);
@ -1497,10 +1497,13 @@ switch (k)
default: default:
if (k >= K_CTRL) if (k >= K_CTRL)
{ {
const TMask& m = _fld->mask();
const short id = siblings.get_int((k - K_CTRL) << 1); const short id = siblings.get_int((k - K_CTRL) << 1);
TEdit_field& ef = (TEdit_field&)_fld->mask().field(id); TEdit_field& ef = m.efield(id);
ef.set_focus(); ef.set_focus();
ef.send_key(k = K_F9, 0); k = K_F9;
if (m.is_running())
ef.send_key(k, 0);
} }
break; break;
} }
@ -1552,10 +1555,7 @@ bool TBrowse::check(CheckTime t)
bool TBrowse::empty_check() bool TBrowse::empty_check()
{ {
const TMaskmode mode = (TMaskmode)field().mask().mode(); if ( field().mask().query_mode() || _fld->check_type() == CHECK_NONE ||
const bool no_check = mode == MODE_SEARCH || field().mask().query_mode();
if ( no_check || _fld->check_type() == CHECK_NONE ||
_fld->check_type() == CHECK_NORMAL) _fld->check_type() == CHECK_NORMAL)
return TRUE; return TRUE;
else else
@ -1870,7 +1870,7 @@ void TEdit_field::create(WINDOW parent)
flags |= CTL_FLAG_INVISIBLE; flags |= CTL_FLAG_INVISIBLE;
} }
_buttonwin = xvt_create_control(WC_PUSHBUTTON, _x+_width+delta, _y, _buttonwin = xvt_create_control(WC_PUSHBUTTON, _x+_width+delta, _y,
2, 1, "*", parent, flags, PTR_LONG(this), DLG_F9); 2, 1, "*", parent, flags, PTR_LONG(this), DLG_F9);
} }
} }
@ -2059,13 +2059,16 @@ bool TEdit_field::on_key(KEY key)
break; break;
case K_F9: case K_F9:
if (check_enabled()) if (check_enabled())
{ {
enable_check(FALSE);
if (dirty()) set(get()); if (dirty()) set(get());
KEY k = K_ESC; KEY k = K_ESC;
if (_browse) k = _browse->run(); if (_browse) k = _browse->run();
else if (_sheet) k = _sheet->run(); else
else beep(); if (_sheet) k = _sheet->run();
if (mask().is_running() && k != K_F9) set_focus(); else beep();
if (k != K_F9) set_focus();
enable_check(TRUE);
if (k == K_ENTER) if (k == K_ENTER)
{ {
set_dirty(); set_dirty();

View File

@ -480,21 +480,7 @@ break;
case XIE_BUTTON: case XIE_BUTTON:
if (xiev->v.xi_obj->type == XIT_CELL) if (xiev->v.xi_obj->type == XIT_CELL)
{ {
if (_edit_field) dispatch_e_char(win(), K_F9);
{
const char* val = xi_get_text(xiev->v.xi_obj, NULL, -1);
_edit_field->set(val); // Update current cell
_check_enabled = FALSE; // Disable checks
if (!_row_dirty) notify(_cur_row, K_SPACE);
if (_edit_field->on_key(K_F9)) // Show search sheet
{
mask2str(_cur_row); // Update row
_row_dirty = TRUE;
}
set_front_window(win()); // It seems necessary to make xi_set_focus work properly
xi_set_focus(xiev->v.xi_obj); // Restore focus to cell
_check_enabled = TRUE; // Enable checks
}
} else } else
if (xiev->v.xi_obj->type == XIT_LIST) if (xiev->v.xi_obj->type == XIT_LIST)
insert(-1); insert(-1);
@ -655,32 +641,40 @@ break;
case K_F8: case K_F8:
case K_F9: case K_F9:
case K_F11: case K_F11:
{ if (_check_enabled)
_check_enabled = FALSE; // Disable checks
if (!_row_dirty) notify(_cur_row, K_SPACE);
if (_edit_field->on_key(k))
{ {
mask2str(_cur_row); _check_enabled = FALSE; // Disable checks
_row_dirty = TRUE; if (!_row_dirty) notify(_cur_row, K_SPACE);
} if (_edit_field->on_key(k))
set_focus_cell(_cur_row, _cur_col); {
_check_enabled = TRUE; // Enable checks mask2str(_cur_row);
} _row_dirty = TRUE;
}
else
if (k == K_F9)
{
_edit_field = &_mask.fld(_mask.focus_field());
const short foca = _edit_field->dlg();
const int col = (foca - FIRST_FIELD) % 100 +1;
if (col > 0 && col != _cur_col)
{
_cur_col = col;
dispatch_e_char(win(), K_F9);
}
}
set_focus_cell(_cur_row, _cur_col);
_check_enabled = TRUE; // Enable checks
}
break; break;
case K_PREV: case K_PREV:
case K_NEXT: case K_NEXT:
{ if (xi_move_focus(_itf))
const bool ok = (bool)xi_move_focus(_itf); dispatch_e_char(parent(), k);
if (ok) dispatch_e_char(parent(), k);
}
break; break;
case K_ESC: case K_ESC:
{
xi_set_focus(_itf); xi_set_focus(_itf);
dispatch_e_char(parent(), K_ESC); dispatch_e_char(parent(), K_ESC);
}
break; break;
case K_CTRL+K_PREV: case K_CTRL+K_PREV:
xi_scroll(_list, XI_SCROLL_PGUP); xi_scroll(_list, XI_SCROLL_PGUP);
break; break;
@ -1087,6 +1081,7 @@ TSheet_field::~TSheet_field()
void TSheet_field::reset() void TSheet_field::reset()
{ {
_sheet->destroy(); _sheet->destroy();
_sheet->mask().reset();
} }
// Certified 100% // Certified 100%

View File

@ -1,6 +1,4 @@
#include <stdlib.h> #include <stdlib.h>
#include <xvt.h>
#include <urldefid.h>
#if XVT_OS==XVT_OS_SCOUNIX #if XVT_OS==XVT_OS_SCOUNIX
#include <unistd.h> #include <unistd.h>
@ -10,18 +8,20 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
#include <strstream.h>
#include <xvt.h>
#define STYLE_NUM 4 #define STYLE_NUM 4
#include <applicat.h>
#include <execp.h>
#include <extcdecl.h>
#include <mask.h> #include <mask.h>
#include <urldefid.h>
#include <utility.h> #include <utility.h>
#include <viswin.h> #include <viswin.h>
#include <extcdecl.h>
#include <applicat.h>
#include <printer.h>
#include <execp.h>
#include <bagn001a.h> #include <bagn001a.h>
#include <strstream.h>
struct PrDesc struct PrDesc
{ {
@ -1157,6 +1157,16 @@ void TPrinter::set()
TMask mask ("bagn001a"); TMask mask ("bagn001a");
TToken_string pn1 (50), pn2 (100); TToken_string pn1 (50), pn2 (100);
int i; int i;
if (_printerfile.empty())
{
_printerfile.tempdir();
#if XVT_OS == XVT_OS_SCOUNIX
_printerfile << '/';
#else
_printerfile << '\\';
#endif
}
TFilename defile("printer.def"); TFilename defile("printer.def");
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
@ -1164,6 +1174,8 @@ void TPrinter::set()
#endif #endif
mask.set_workfile(defile); mask.set_workfile(defile);
mask.set(MSK_1_FILENAME, _printerfile);
mask.set(MSK_1_NPAGES, _ncopies);
#if XVT_OS != XVT_OS_WIN #if XVT_OS != XVT_OS_WIN
@ -1196,12 +1208,9 @@ void TPrinter::set()
mask.set (MSK_1_TYPE, "2"); mask.set (MSK_1_TYPE, "2");
else else
mask.set (MSK_1_TYPE, "0"); mask.set (MSK_1_TYPE, "0");
mask.set(MSK_1_PRINTERS, format("%d", _curprn)); mask.set(MSK_1_PRINTERS, format("%d", _curprn));
mask.set(MSK_1_CODES, format("%d", _curcode)); mask.set(MSK_1_CODES, format("%d", _curcode));
mask.set(MSK_1_FILENAME, _printerfile);
mask.set(MSK_1_NPAGES, _ncopies);
KEY k; KEY k;
if ((k = mask.run()) == K_ESC) if ((k = mask.run()) == K_ESC)
@ -1236,7 +1245,6 @@ void TPrinter::set()
} }
break; break;
case 1: // file case 1: // file
_printertype = fileprinter; _printertype = fileprinter;
_printerfile = mask.get (MSK_1_FILENAME); _printerfile = mask.get (MSK_1_FILENAME);
_curcode = atoi (mask.get (MSK_1_CODES)); _curcode = atoi (mask.get (MSK_1_CODES));
@ -1267,8 +1275,6 @@ void TPrinter::set()
mask.set(MSK_1_SIZE, _ch_size); mask.set(MSK_1_SIZE, _ch_size);
mask.set(MSK_1_LINES, _lines_per_inch); mask.set(MSK_1_LINES, _lines_per_inch);
mask.set(MSK_1_NPAGES, _ncopies);
if (_printertype == fileprinter) if (_printertype == fileprinter)
mask.set (MSK_1_TYPE, "1"); mask.set (MSK_1_TYPE, "1");
else if (_printertype == screenvis) else if (_printertype == screenvis)
@ -1502,9 +1508,6 @@ genera_dischetti ()
{ {
int r; int r;
warning_box ("Questa procedura richiede %2d dischetti",
_volume);
for (int i = 0; i < _tmp_files.items (); i++) for (int i = 0; i < _tmp_files.items (); i++)
{ {
// Avvisa l'utente di inserire un dischetto // Avvisa l'utente di inserire un dischetto

View File

@ -112,15 +112,13 @@ real & real::operator += (const real & b)
real & real::operator += (double a) real & real::operator += (double a)
{ {
__tmp_real = *this; adddfd (ptr (), ptr (), a);
adddfd (ptr (), __tmp_real.ptr (), a);
return *this; return *this;
} }
real & real::operator -= (const real & b) real & real::operator -= (const real & b)
{ {
__tmp_real = *this; dsub (ptr (), ptr (), b.ptr ());
dsub (ptr (), __tmp_real.ptr (), b.ptr ());
return *this; return *this;
} }
@ -235,7 +233,7 @@ char *real ::literals () const
TFixed_string risultato (__string, 80); TFixed_string risultato (__string, 80);
risultato.cut (0); risultato.cut (0);
TString16 centinaia; TString80 centinaia;
for (int migliaia = 0;; migliaia++) for (int migliaia = 0;; migliaia++)
{ {
@ -436,7 +434,7 @@ real & real ::ceil (int prec)
dint (&integer, ptr ()); // Extract the integer part dint (&integer, ptr ()); // Extract the integer part
if (disgt (ptr (), &integer)) // If positive ... if (disgt (ptr (), &integer)) // If positive ...
addid (ptr (), &integer, 1); // add 1 addid (ptr (), &integer, 1); // ... add 1
else else
dcpy(ptr(), &integer); // If negative dcpy(ptr(), &integer); // If negative

View File

@ -1,163 +1,159 @@
#ifndef __REAL_H #ifndef __REAL_H
#define __REAL_H #define __REAL_H
#ifndef GMDOTH #ifndef GMDOTH
#include <gmsys1.h> #include <gmsys1.h>
#include <gfd.h> #include <gfd.h>
#endif #endif
#ifndef __IOSTREAM_H #ifndef __IOSTREAM_H
#include <iostream.h> #include <iostream.h>
#endif #endif
#ifndef __STDTYPES_H #ifndef __STDTYPES_H
#include <stdtypes.h> #include <stdtypes.h>
#endif #endif
#ifndef __OBJECT_H #ifndef __ARRAY_H
#include <object.h> #include <array.h>
#endif #endif
// @C
#ifndef __ARRAY_H class real : public TObject
#include <array.h> {
#endif // @DPRIV
// @C DEC _dec;
class real : public TObject // @END
{
// @DPRIV protected:
DEC _dec; virtual TObject* dup() const;
// @END char* literals() const;
char* points(int decimals = 0) const;
protected:
virtual TObject* dup() const; public:
char* literals() const;
char* points(int decimals = 0) const; static char* eng2ita(char* s);
static char* ita2eng(const char* s);
public: static bool is_real(const char* n);
static char* eng2ita(char* s); // @FPUB
static char* ita2eng(const char* s); DEC* ptr() const { return (DEC*)&_dec; }
static bool is_real(const char* n); char* string(int len = 0, int dec = UNDEFINED, char pad = ' ') const;
char* stringa(int len = 0, int dec = UNDEFINED, char pad = ' ') const;
// @FPUB char* string(const char* picture) const;
DEC* ptr() const { return (DEC*)&_dec; }
char* string(int len = 0, int dec = UNDEFINED, char pad = ' ') const; int precision() ;
char* stringa(int len = 0, int dec = UNDEFINED, char pad = ' ') const; bool is_zero() const;
char* string(const char* picture) const; int sign() const;
long integer() const; // operator int is too dangerous
int precision() ;
bool is_zero() const; real& round(int prec = 0) ;
int sign() const; real& trunc(int prec = 0) ;
long integer() const; // operator int is too dangerous real& ceil(int prec = 0);
real& operator =(double a);
real& round(int prec = 0) ; real& operator =(const real& b);
real& trunc(int prec = 0) ; real& operator +=(const real& b);
real& ceil(int prec = 0); real& operator +=(double a);
real& operator =(double a); real& operator -=(const real& b);
real& operator =(const real& b); real& operator *=(const real& b);
real& operator +=(const real& b); real& operator /=(const real& b);
real& operator +=(double a); bool operator !() const { return is_zero(); }
real& operator -=(const real& b); real operator -() const;
real& operator *=(const real& b);
real& operator /=(const real& b); real();
bool operator !() const { return is_zero(); } real(const real& b);
real operator -() const; real(double a);
real(const char* s);
real(); virtual ~real() {}
real(const real& b); };
real(double a);
real(const char* s); ///////////////////////////////////////////////////////////
virtual ~real() {} // Math operators
}; ///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////// ostream& operator <<(ostream& out, const real& a) ;
// Math operators istream& operator >>(istream& in, real& a) ;
///////////////////////////////////////////////////////////
real operator +(const real& a, const real& b) ;
ostream& operator <<(ostream& out, const real& a) ; real operator +(double a, const real& b) ;
istream& operator >>(istream& in, real& a) ; real operator +(const real& a, double b) ;
real operator -(const real& a, const real& b) ;
real operator +(const real& a, const real& b) ; real operator -(double a, const real& b) ;
real operator +(double a, const real& b) ; real operator -(const real& a, double b) ;
real operator +(const real& a, double b) ; real operator *(const real& a, const real& b) ;
real operator -(const real& a, const real& b) ; real operator *(double a, const real& b) ;
real operator -(double a, const real& b) ; real operator *(const real& a, double b) ;
real operator -(const real& a, double b) ; real operator /(const real& a, const real& b) ;
real operator *(const real& a, const real& b) ; real operator /(double a, const real& b) ;
real operator *(double a, const real& b) ; real operator /(const real& a, double b) ;
real operator *(const real& a, double b) ;
real operator /(const real& a, const real& b) ; bool operator <(const real& a, const real& b) ;
real operator /(double a, const real& b) ; bool operator <(double a, const real& b) ;
real operator /(const real& a, double b) ; bool operator >(const real& a, const real& b) ;
bool operator >(double a, const real& b) ;
bool operator <(const real& a, const real& b) ; bool operator <=(const real& a, const real& b) ;
bool operator <(double a, const real& b) ; bool operator <=(double a, const real& b) ;
bool operator >(const real& a, const real& b) ; bool operator >=(const real& a, const real& b) ;
bool operator >(double a, const real& b) ; bool operator >=(double a, const real& b) ;
bool operator <=(const real& a, const real& b) ; bool operator ==(const real& a, const real& b) ;
bool operator <=(double a, const real& b) ; bool operator ==(double a, const real& b) ;
bool operator >=(const real& a, const real& b) ; bool operator !=(const real& a, const real& b) ;
bool operator >=(double a, const real& b) ; bool operator !=(double a, const real& b) ;
bool operator ==(const real& a, const real& b) ;
bool operator ==(double a, const real& b) ; inline bool operator <(const real& a, double b) { return operator >(b, a); }
bool operator !=(const real& a, const real& b) ; inline bool operator >(const real& a, double b) { return operator <(b, a); }
bool operator !=(double a, const real& b) ; inline bool operator <=(const real& a, double b) { return operator >=(b, a); }
inline bool operator >=(const real& a, double b) { return operator <=(b, a); }
inline bool operator <(const real& a, double b) { return operator >(b, a); } inline bool operator ==(const real& a, double b) { return operator ==(b, a); }
inline bool operator >(const real& a, double b) { return operator <(b, a); } inline bool operator !=(const real& a, double b) { return operator !=(b, a); }
inline bool operator <=(const real& a, double b) { return operator >=(b, a); }
inline bool operator >=(const real& a, double b) { return operator <=(b, a); } real operator %(const real& a, const long b) ;
inline bool operator ==(const real& a, double b) { return operator ==(b, a); } void swap(real& a, real& b) ;
inline bool operator !=(const real& a, double b) { return operator !=(b, a); } real fnc_min(const real& a, const real& b) ;
real fnc_max(const real& a, const real& b) ;
real operator %(const real& a, const long b) ; real sqrt(const real& a) ;
void swap(real& a, real& b) ; real sqr(const real& a) ;
real fnc_min(const real& a, const real& b) ; real exp10(const real& a) ;
real fnc_max(const real& a, const real& b) ; real pow(const real& a, const real& b) ;
real sqrt(const real& a) ; real exp(const real& a) ;
real sqr(const real& a) ; real log10(const real& a) ;
real exp10(const real& a) ; real log(const real& a) ;
real pow(const real& a, const real& b) ; real sin(const real& a) ;
real exp(const real& a) ; real cos(const real& a) ;
real log10(const real& a) ; real tan(const real& a) ;
real log(const real& a) ; real abs(const real& a) ;
real sin(const real& a) ; extern const real ZERO;
real cos(const real& a) ;
real tan(const real& a) ; class TDistrib : public TObject
real abs(const real& a) ; {
extern const real ZERO; real _tot;
real _prog;
class TDistrib : public TObject bool _ready;
{ TArray _slices;
real _tot; int _current;
real _prog; int _decs;
bool _ready;
TArray _slices; public:
int _current;
int _decs; void add(real slice);
real get();
public:
// se zap e' vero scancella tutte le percentuali immesse
void add(real slice); // altrimenti cambia solo il totale
real get(); void init(const real& r, bool zap = FALSE);
void operator =(const real& r) { init(r); }
// se zap e' vero scancella tutte le percentuali immesse const real& last_slice() const
// altrimenti cambia solo il totale {
void init(const real& r, bool zap = FALSE); CHECK(_current,"TDistrib: slices not set");
void operator =(const real& r) { init(r); } return (const real&)_slices[_current-1];
const real& last_slice() const }
{
CHECK(_current,"TDistrib: slices not set"); TDistrib(const real& r, int round = UNDEFINED) :
return (const real&)_slices[_current-1]; _prog(0.0), _tot(r), _ready(FALSE),
} _current(0), _decs(round), _slices(4)
{}
TDistrib(const real& r, int round = UNDEFINED) : virtual ~TDistrib() {}
_prog(0.0), _tot(r), _ready(FALSE), };
_current(0), _decs(round), _slices(4)
{}
virtual ~TDistrib() {}
}; #endif // __REAL_H
#endif // __REAL_H

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.35 1994-11-30 09:04:01 guy Exp $ // $Id: relapp.cpp,v 1.36 1994-12-02 13:30:27 guy Exp $
#include <mailbox.h> #include <mailbox.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
@ -644,10 +644,11 @@ bool TRelation_application::save(bool check_dirty)
get_relation()->restore_status(); get_relation()->restore_status();
err = rewrite(*_mask); err = rewrite(*_mask);
} }
switch(err) switch(err)
{ {
case NOERR: case NOERR:
_recins = get_relation()->lfile().recno();
break; break;
case _isreinsert: case _isreinsert:
warning_box("Esiste gia' un documento con la stessa chiave"); warning_box("Esiste gia' un documento con la stessa chiave");
@ -717,9 +718,9 @@ bool TRelation_application::remove()
bool TRelation_application::main_loop() bool TRelation_application::main_loop()
{ {
long recins = -1; _recins = -1;
query_mode(); query_mode();
_mask->open_modal(); _mask->open_modal();
@ -753,13 +754,8 @@ bool TRelation_application::main_loop()
k = K_QUIT; k = K_QUIT;
break; break;
case K_QUIT: case K_QUIT:
if (save(TRUE)) if (!save(TRUE))
{ k = K_ENTER;
if (_mask->edit_mode() &&
(_autoins_caller.not_empty() || _lnflag))
recins = file().recno();
}
else k = K_ENTER;
break; break;
case K_ENTER: case K_ENTER:
if (find(0)) modify_mode(); if (find(0)) modify_mode();
@ -768,9 +764,8 @@ bool TRelation_application::main_loop()
case K_SAVE: case K_SAVE:
if (save(FALSE)) if (save(FALSE))
{ {
if (_autoins_caller.not_empty() || _lnflag) if (_autoins_caller.not_empty())
{ {
recins = file().recno();
k = K_QUIT; k = K_QUIT;
} }
else else
@ -835,9 +830,9 @@ bool TRelation_application::main_loop()
_mask->set_mode(NO_MODE); _mask->set_mode(NO_MODE);
if (recins > 0 && _autoins_caller.not_empty()) if (autoins_caller().not_empty() && _recins >= 0)
{ {
TMessage msg(_autoins_caller, _lnflag ? MSG_LN : MSG_AI, format("%ld", recins)); TMessage msg(autoins_caller(), _lnflag ? MSG_LN : MSG_AI, format("%ld", _recins));
msg.send(); msg.send();
} }
@ -901,16 +896,15 @@ bool TRelation_application::filter()
_lnflag = TRUE; _lnflag = TRUE;
const char* v = body.get(); const char* v = body.get();
TString80 s;
const int max = _mask->fields(); for (int i = 0; v != NULL && i < _mask->fields(); i++)
for (int i = 0; i < max && v != NULL; i++)
{ {
TMask_field& f = _mask->fld(i); TMask_field& f = _mask->fld(i);
if (f.active() && f.dlg() > 0 && f.in_key(key)) if (f.active() && f.dlg() > 0 && f.in_key(key))
{ {
const TString s(v); s = v;
_fixed.add(format("%d=%s", f.dlg(), (const char*) s)); _fixed.add(format("%d=%s", f.dlg(), (const char*)s));
v = body.get(); v = body.get();
} }
} }

View File

@ -1,112 +1,114 @@
#ifndef __RELAPP_H #ifndef __RELAPP_H
#define __RELAPP_H #define __RELAPP_H
#ifndef __APPLICAT_H #ifndef __APPLICAT_H
#include <applicat.h> #include <applicat.h>
#endif #endif
#ifndef __RELATION_H #ifndef __RELATION_H
#include <relation.h> #include <relation.h>
#endif #endif
#ifndef __MASK_H #ifndef __MASK_H
#include <mask.h> #include <mask.h>
#endif #endif
class TKey_array; class TKey_array;
class TRelation_application : public TApplication class TRelation_application : public TApplication
{ {
TMask * _mask; TMask * _mask;
TKey_array* _maskeys; TKey_array* _maskeys;
TRecnotype _first, _last; TRecnotype _first, _last;
int _search_id; int _search_id;
TString _autoins_caller; TString16 _autoins_caller;
bool _lnflag; long _recins;
TToken_string _fixed;
bool _lnflag;
virtual bool create(); TToken_string _fixed;
virtual bool destroy();
virtual bool create();
bool filter(); virtual bool destroy();
bool test_key(byte k, bool err);
bool save(bool check_dirty); bool filter();
void enable_query(); bool test_key(byte k, bool err);
void set_toolbar(bool all); bool save(bool check_dirty);
void enable_query();
int set_mode(int mode); // Seleziona il nuovo modo e ritorna il vecchio void set_toolbar(bool all);
void set_limits(byte what = 0x3);
void query_insert_mode() { query_mode(TRUE); } int set_mode(int mode); // Seleziona il nuovo modo e ritorna il vecchio
void insert_mode(); // Entra in modo inserimento void set_limits(byte what = 0x3);
virtual bool main_loop(); // Ciclo principale void query_insert_mode() { query_mode(TRUE); }
bool relation_remove(); // Cancella il record corrente void insert_mode(); // Entra in modo inserimento
TMask_field* get_search_field() const; virtual bool main_loop(); // Ciclo principale
bool relation_remove(); // Cancella il record corrente
bool autonum(TMask* m, bool rec); TMask_field* get_search_field() const;
bool has_filtered_cursor() const { return filtered() || force_cursor_usage();}
bool autonum(TMask* m, bool rec);
protected: bool has_filtered_cursor() const { return filtered() || force_cursor_usage();}
TLocalisamfile& file() const { return get_relation()->lfile(); } // File principale della relazione
TRecnotype first() const { return _first;} protected:
TRecnotype last() const { return _first;} TLocalisamfile& file() const { return get_relation()->lfile(); } // File principale della relazione
TMask& curr_mask() const { return *_mask; } TRecnotype first() const { return _first;}
const TString& autoins_caller() const { return _autoins_caller;} TRecnotype last() const { return _first;}
virtual bool menu(MENU_TAG m); TMask& curr_mask() const { return *_mask; }
const TString& autoins_caller() const { return _autoins_caller;}
virtual bool user_create() pure; // Inizializzazione dati utente virtual bool menu(MENU_TAG m);
virtual bool user_destroy() pure; // Distruzione dati utente
virtual bool user_create() pure; // Inizializzazione dati utente
void set_fixed(); // Fissa i campi non modificabili virtual bool user_destroy() pure; // Distruzione dati utente
bool search_mode(); // Attiva la maschera di ricerca
void query_mode(bool pre_ins = FALSE); // Entra in modo ricerca void set_fixed(); // Fissa i campi non modificabili
bool modify_mode(); // Entra in modo modifica bool search_mode(); // Attiva la maschera di ricerca
void setkey(); void query_mode(bool pre_ins = FALSE); // Entra in modo ricerca
bool lnflag() const { return _lnflag;} bool modify_mode(); // Entra in modo modifica
// La richiesta della maschera da utilizzare per ogni fase di lavoro (ricerca, inserimento, void setkey();
// modifica avviene sempre in due tempi: changing_mask e get_mask. Cio' serve per gestire bool lnflag() const { return _lnflag;}
// Correttamente le applicazioni con mashere multiple. La prima funzione serve a sapere se // La richiesta della maschera da utilizzare per ogni fase di lavoro (ricerca, inserimento,
// la futura get_mask ritornera' una maschera diversa dalla corrente. // modifica avviene sempre in due tempi: changing_mask e get_mask. Cio' serve per gestire
virtual bool changing_mask(int mode) pure; // Correttamente le applicazioni con mashere multiple. La prima funzione serve a sapere se
virtual TMask* get_mask(int mode) pure; // Richiede la maschera da usare // la futura get_mask ritornera' una maschera diversa dalla corrente.
virtual bool changing_mask(int mode) pure;
virtual TRelation* get_relation() const pure; // Relazione da modificare virtual TMask* get_mask(int mode) pure; // Richiede la maschera da usare
virtual int read(TMask& m); // Legge dalla relazione i valori nella maschera
virtual int write(const TMask& m); // Scrive sulla relazione i valori dalla maschera virtual TRelation* get_relation() const pure; // Relazione da modificare
virtual int rewrite(const TMask& m); // Riscrive sulla relazione i valori dalla maschera virtual int read(TMask& m); // Legge dalla relazione i valori nella maschera
virtual bool remove(); // Cancella il record corrente virtual int write(const TMask& m); // Scrive sulla relazione i valori dalla maschera
virtual int rewrite(const TMask& m); // Riscrive sulla relazione i valori dalla maschera
// Richiede una stringa nella forma CAMPO1|VALORE1|CAMPO2|VALORE2|...|CAMPOn|VALOREn virtual bool remove(); // Cancella il record corrente
// contenente le coppie NUMERO_CAMPO_MASCHERA - VALORE_DA_ASSEGNARE che descrivono il
// prossimo codice libero da utilizzare per la autonumerazione. // Richiede una stringa nella forma CAMPO1|VALORE1|CAMPO2|VALORE2|...|CAMPOn|VALOREn
// Nel caso di banale numerazione progressiva potrebbe essere implementata come // contenente le coppie NUMERO_CAMPO_MASCHERA - VALORE_DA_ASSEGNARE che descrivono il
// return format("%d|%s", F_NUM, get_relation()->items()); // prossimo codice libero da utilizzare per la autonumerazione.
virtual const char* get_next_key() { return ""; } // Nel caso di banale numerazione progressiva potrebbe essere implementata come
// return format("%d|%s", F_NUM, get_relation()->items());
// Richiede se il record corrente e' protetto (non cancellabile) virtual const char* get_next_key() { return ""; }
virtual bool protected_record(TRectype&) { return FALSE; }
// Richiede se il record corrente e' protetto (non cancellabile)
virtual void init_query_mode(TMask&) { } // Inizializza la maschera per il modo ricerca virtual bool protected_record(TRectype&) { return FALSE; }
virtual void init_query_insert_mode(TMask& m) { init_query_mode(m); }
virtual void init_insert_mode(TMask&) { } // Inizializza la maschera per il modo inserimento virtual void init_query_mode(TMask&) { } // Inizializza la maschera per il modo ricerca
virtual void init_modify_mode(TMask&) { } // Inizializza la maschera per il modo modifica virtual void init_query_insert_mode(TMask& m) { init_query_mode(m); }
virtual void init_insert_mode(TMask&) { } // Inizializza la maschera per il modo inserimento
virtual bool force_cursor_usage() const { return FALSE;} virtual void init_modify_mode(TMask&) { } // Inizializza la maschera per il modo modifica
virtual void write_enable(const bool on = TRUE) { get_relation()->write_enable(-1, on); }
void write_disable() { write_enable(FALSE); } virtual bool force_cursor_usage() const { return FALSE;}
virtual void write_enable(const bool on = TRUE) { get_relation()->write_enable(-1, on); }
virtual bool save_and_new() const; void write_disable() { write_enable(FALSE); }
void set_search_field(short id) { _search_id = id;} // Impone il campo da utilizzare col bottone Ricerca virtual bool save_and_new() const;
public: void set_search_field(short id) { _search_id = id;} // Impone il campo da utilizzare col bottone Ricerca
TRelation_application();
virtual ~TRelation_application(); public:
bool filtered() const { return _fixed.not_empty(); } TRelation_application();
bool find(byte key = 0); virtual ~TRelation_application();
void set_link(TMask & m, const char * keyexpr); bool filtered() const { return _fixed.not_empty(); }
}; bool find(byte key = 0);
void set_link(TMask & m, const char * keyexpr);
#endif };
#endif

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.24 1994-11-18 17:01:26 guy Exp $ // $Id: relation.cpp,v 1.25 1994-12-02 13:30:30 guy Exp $
// relation.cpp // relation.cpp
// fv 12/8/93 // fv 12/8/93
// relation class for isam files // relation class for isam files
@ -98,13 +98,13 @@ TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key,
s = r.left(eq); // Parte a sinistra dell' = s = r.left(eq); // Parte a sinistra dell' =
#ifdef DBG #ifdef DBG
TString80 n(s); const char* n = s;
const int p = n.find('['); const int p = s.find('[');
if (p > 0) n.cut(p); if (p > 0) n = s.left(p);
if (rel->file(_num).curr().exist(n) == FALSE) if (rel->file(_num).curr().exist(n) == FALSE)
{ {
error_box("'%s' non e' un campo del file %d", yesnofatal_box("Errore di JOIN: '%s' non e' un campo del file %d",
(const char*)n, rel->file(_num).num()); n, rel->file(_num).num());
continue; continue;
} }
#endif #endif
@ -115,9 +115,10 @@ TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key,
eq++; eq++;
} }
const TString80 xx(s); // const TString80 xx(s);
_fields.add(new TFieldref(xx,0)); // _fields.add(new TFieldref(xx,0));
_fields.add(new TFieldref(s,0));
_exprs.add(new TExpression(r.mid(eq+1), _strexpr)); _exprs.add(new TExpression(r.mid(eq+1), _strexpr));
} }
} }
@ -1103,10 +1104,10 @@ int name2log(const char* name)
if (name && *name) if (name && *name)
{ {
if (isdigit(*name)) if (isdigit(*name) || *name == '-')
{ {
log = atoi(name); log = atoi(name);
if (strchr(name, '@')) log = -log; if (strchr(name, '@')) log = -log;
} }
else else
{ {

View File

@ -2,7 +2,6 @@
#include <applicat.h> #include <applicat.h>
#include <colors.h> #include <colors.h>
#include <relation.h> #include <relation.h>
#include <printer.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
@ -35,7 +34,12 @@ TSheet::TSheet(short x, short y, short dx, short dy,
_checkable = _size[0] = 1; _checkable = _size[0] = 1;
else else
_size[_columns] = l > 0 ? l : item.len(); _size[_columns] = l > 0 ? l : item.len();
} else _size[_columns] = item.len(); }
else
{
_size[_columns] = item.len();
_type[_columns] = '\0';
}
item.trim(); item.trim();
new_head.add(item); new_head.add(item);
@ -309,15 +313,27 @@ bool TSheet::on_key(KEY key)
if (_checkable && _check_enabled && items() > 0) if (_checkable && _check_enabled && items() > 0)
{ {
bool ok = TRUE; bool force = FALSE;
switch(key) switch(key)
{ {
case K_SPACE: _checked.not(selected()); break; case K_SPACE:
case K_F2 : uncheck(-1); break; _checked.not(selected());
case K_F3 : check(-1); break; set_opaque_text(TRUE);
default : ok = FALSE; break; update_row(selected());
} set_opaque_text(FALSE);
if (ok) force_update(); break;
case K_F2:
uncheck(-1);
force = TRUE;
break;
case K_F3:
check(-1);
force = TRUE;
break;
default:
break;
}
if (force) force_update();
} }
return TScroll_window::on_key(key); return TScroll_window::on_key(key);
} }

View File

@ -585,6 +585,48 @@ const char* TFilename::path() const
return spark; return spark;
} }
bool TFilename::ok() const
{
const int l = len();
int len = 0; // lunghezza ultima sottostringa
bool ext = FALSE; // trovata estensione
for (int c = 0; c < l; c++)
{
switch(_str[c])
{
#if XVT_OS != XVT_OS_SCOUNIX
case ':':
if (c != 1 || !isalpha(_str[0])) return FALSE; // Nome disco errato
len = 0;
break;
case '\\':
#endif
case '/':
if (ext) return FALSE; // Slash dopo estensione
if (len > 8) return FALSE; // Nome troppo lungo
if (!isalnum(_str[++c])) return FALSE;
len = 1;
break;
case '.':
if (len == 0 || ext) return FALSE; // Nome nullo o Doppia estensione
ext = TRUE;
len = 0;
c++;
default:
if (isalnum(_str[c])) len++;
else return FALSE;
break;
}
}
if (ext && len > 3)
return FALSE;
return len > 0 && len < 9;
}
// Certified 70% // Certified 70%
const TFilename& TFilename::tempdir() const TFilename& TFilename::tempdir()
{ {

View File

@ -1,285 +1,289 @@
#ifndef __STRINGS_H #ifndef __STRINGS_H
#define __STRINGS_H #define __STRINGS_H
#ifndef __STRING_H #ifndef __STRING_H
#include <string.h> #include <string.h>
#endif #endif
#ifndef __OBJECT_H #ifndef __OBJECT_H
#include <object.h> #include <object.h>
#endif #endif
// @C // @C
// Classe TString : public TObject // Classe TString : public TObject
// @END // @END
class TString : public TObject class TString : public TObject
{ {
protected: protected:
// @DPROT // @DPROT
char* _str; // Puntatore alla stringa char* _str; // Puntatore alla stringa
int _size; // Lunghezza int _size; // Lunghezza
// @END // @END
// @FPROT // @FPROT
int make_room(int size); // Cerca spazio per altri size caratteri int make_room(int size); // Cerca spazio per altri size caratteri
TString& set(const char*); // Inizializza con la stringa puntata da char* di lunghezza size TString& set(const char*); // Inizializza con la stringa puntata da char* di lunghezza size
TString(char* str, int size) : _str(str), _size(size) {} TString(char* str, int size) : _str(str), _size(size) {}
public: public:
// @FPUB // @FPUB
virtual void resize(int size, bool cpy); // Ri/alloca la stringa virtual void resize(int size, bool cpy); // Ri/alloca la stringa
TString(); TString();
TString(int size); // Default constructor for a string of given size TString(int size); // Default constructor for a string of given size
TString(const char* s); // Costruttore a partire da una stringa s TString(const char* s); // Costruttore a partire da una stringa s
TString(const TString& s); // Costruttore da un oggetto TString s TString(const TString& s); // Costruttore da un oggetto TString s
virtual ~TString(); // Deallocates the string virtual ~TString(); // Deallocates the string
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @DES Methods derived from TObject // @DES Methods derived from TObject
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @FPUB // @FPUB
virtual const char* class_name() const; // Ritorna il nome della classe virtual const char* class_name() const; // Ritorna il nome della classe
virtual word class_id() const; // Ritorna l'identificatore della classe virtual word class_id() const; // Ritorna l'identificatore della classe
virtual bool ok() const { return _str != NULL; } virtual bool ok() const { return _str != NULL; }
virtual TObject* dup() const; virtual TObject* dup() const;
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);
virtual word hash() const; // Return hash value virtual word hash() const; // Return hash value
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @DES Query methods // @DES Query methods
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @FPUB // @FPUB
operator const char*() const { return (const char*)_str; } // *(TString) -> _str operator const char*() const { return (const char*)_str; } // *(TString) -> _str
char& operator[](int i) // TString[i] -> _str[i] char& operator[](int i) // TString[i] -> _str[i]
{ {
CHECKD(i >= 0 && i <= _size, "Bad string subscript: ", i); CHECKD(i >= 0 && i <= _size, "Bad string subscript: ", i);
return _str[i]; return _str[i];
} }
char operator[](int i) const // TString[i] -> _str[i] char operator[](int i) const // TString[i] -> _str[i]
{ {
CHECKD(i >= 0 && i <= _size, "Bad string subscript: ", i); CHECKD(i >= 0 && i <= _size, "Bad string subscript: ", i);
return _str[i]; return _str[i];
} }
int size() const { return _size; } int size() const { return _size; }
int len() const { return strlen(_str); } int len() const { return strlen(_str); }
bool empty() const { return *_str == '\0'; } bool empty() const { return *_str == '\0'; }
bool not_empty() const { return *_str != '\0'; } bool not_empty() const { return *_str != '\0'; }
int find(char, int from = 0) const; // Ritorna la posizione del carattere char nell'oggetto TString int find(char, int from = 0) const; // Ritorna la posizione del carattere char nell'oggetto TString
int find(const char* s, int from = 0) const; // Ritorna la posizione della stringa s nell'oggetto TString int find(const char* s, int from = 0) const; // Ritorna la posizione della stringa s nell'oggetto TString
const TString& left(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da sinistra const TString& left(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da sinistra
const TString& mid(int from, int count = -1) const; // Ritorna l'oggetto TString composto dai count caratteri a partire da from const TString& mid(int from, int count = -1) const; // Ritorna l'oggetto TString composto dai count caratteri a partire da from
const TString& sub(int from, int to = -1) const; // Ritorna la stringa da FROM a TO (escluso) const TString& sub(int from, int to = -1) const; // Ritorna la stringa da FROM a TO (escluso)
const TString& right(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da destra const TString& right(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da destra
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @DES Modifying methods // @DES Modifying methods
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @FPUB // @FPUB
TString& fill(char c, int n = -1); // Riempie con n caratteri c
TString& spaces(int n = -1) { return fill(' ', n); } TString& fill(char c, int n = -1); // Riempie con n caratteri c
TString& overwrite(const char* s, int pos = 0); // Sovrascrive la stringa s dalla posizione pos TString& spaces(int n = -1) { return fill(' ', n); }
TString& insert(const char* s, int pos = 0); // Inserisce la stringa s dalla posizione pos TString& overwrite(const char* s, int pos = 0); // Sovrascrive la stringa s dalla posizione pos
TString& insert(const char* s, int pos = 0); // Inserisce la stringa s dalla posizione pos
TString& strip(const char* k); // Elimina tutti i caratteri contenuti in k
TString& strip_spaces(); // Elimina tutti gli spazi non contenuti tra apici singoli o doppi TString& strip(const char* k); // Elimina tutti i caratteri contenuti in k
TString& ltrim(int n = 0); // Elimina gli spazi da sinistra se n=0 altrimenti elimina i primi n caratteri (da sinistra). TString& strip_spaces(); // Elimina tutti gli spazi non contenuti tra apici singoli o doppi
TString& rtrim(int n = 0); // Elimina gli spazi da destra se n=0 altrimenti elimina i primi n caratteri (da destra). TString& ltrim(int n = 0); // Elimina gli spazi da sinistra se n=0 altrimenti elimina i primi n caratteri (da sinistra).
TString& trim(); // ltrim e rtrim TString& rtrim(int n = 0); // Elimina gli spazi da destra se n=0 altrimenti elimina i primi n caratteri (da destra).
TString& trim(); // ltrim e rtrim
TString& right_just(int n = -1, char c = ' '); // Giustifica a destra
TString& center_just(int n = -1, char c = ' '); // Centra TString& right_just(int n = -1, char c = ' '); // Giustifica a destra
TString& left_just(int n = -1, char c = ' '); // Giustifica a sinistra TString& center_just(int n = -1, char c = ' '); // Centra
TString& left_just(int n = -1, char c = ' '); // Giustifica a sinistra
TString& picture(const char* pic, const char* s);
virtual TString& format(const char* fmt, ...); TString& picture(const char* pic, const char* s);
virtual TString& format(const char* fmt, ...);
TString& cut(int n); // Inserisce un '\0' alla posizione n-esima.
TString& cut(int n); // Inserisce un '\0' alla posizione n-esima.
TString& upper(); // Mette la stringa in maiuscolo
TString& lower(); // Mette la stringa in minuscolo TString& upper(); // Mette la stringa in maiuscolo
TString& lower(); // Mette la stringa in minuscolo
///////////////////////////////////////////////////////////
// @DES Standard operators ///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////// // @DES Standard operators
///////////////////////////////////////////////////////////
// @FPUB
const TString& operator =(const TString& s) { return set(s._str); } // @FPUB
const TString& operator =(const char* s) { return set(s); }
const TString& operator =(const TString& s) { return set(s._str); }
TString& operator <<(const char*); const TString& operator =(const char* s) { return set(s); }
TString& operator <<(char);
TString& operator <<(int); TString& operator <<(const char*);
TString& operator <<(long); TString& operator <<(char);
TString& operator <<(double); TString& operator <<(int);
TString& operator <<(const TObject& obj); TString& operator <<(long);
TString& operator <<(const TString& str); // For efficiency only TString& operator <<(double);
TString& operator <<(const TObject& obj);
bool operator ==(const char* s) const { return strcmp(_str, s) == 0; } TString& operator <<(const TString& str); // For efficiency only
bool operator ==(char* s) const { return strcmp(_str, s) == 0; }
bool operator ==(const TString& s) const { return strcmp(_str, s._str) == 0; } bool operator ==(const char* s) const { return strcmp(_str, s) == 0; }
bool operator !=(const char* s) const { return strcmp(_str, s) != 0; } bool operator ==(char* s) const { return strcmp(_str, s) == 0; }
bool operator !=(char* s) const { return strcmp(_str, s) != 0; } bool operator ==(const TString& s) const { return strcmp(_str, s._str) == 0; }
bool operator !=(const TString& s) const { return strcmp(_str, s._str) != 0; } bool operator !=(const char* s) const { return strcmp(_str, s) != 0; }
bool operator <(const char* s) const { return strcmp(_str, s) < 0; } bool operator !=(char* s) const { return strcmp(_str, s) != 0; }
bool operator >(const char* s) const { return strcmp(_str, s) > 0; } bool operator !=(const TString& s) const { return strcmp(_str, s._str) != 0; }
bool operator >=(const char* s) const { return strcmp(_str, s) >= 0; } bool operator <(const char* s) const { return strcmp(_str, s) < 0; }
bool operator <=(const char* s) const { return strcmp(_str, s) <= 0; } bool operator >(const char* s) const { return strcmp(_str, s) > 0; }
bool match(const char* s) const; bool operator >=(const char* s) const { return strcmp(_str, s) >= 0; }
bool compare(const char* s, int max = -1, bool ignorecase = FALSE) const; bool operator <=(const char* s) const { return strcmp(_str, s) <= 0; }
}; bool match(const char* s) const;
bool compare(const char* s, int max = -1, bool ignorecase = FALSE) const;
// @C };
// Classe TFixed_string : public TString
// @END // @C
// Classe TFixed_string : public TString
class TFixed_string : public TString // @END
{
protected: class TFixed_string : public TString
virtual void resize(int size, bool cpy); // Causa un errore fatale! {
protected:
public: virtual void resize(int size, bool cpy); // Causa un errore fatale!
TFixed_string(const char* str, int size = -1);
virtual ~TFixed_string(); public:
TFixed_string(const char* str, int size = -1);
virtual TString& format(const char* fmt, ...); virtual ~TFixed_string();
const TString& operator =(const TString& s) { return set((const char*)s); } virtual TString& format(const char* fmt, ...);
const TString& operator=(const char* str) { return set(str); }
void strncpy(const char* s, int n); const TString& operator =(const TString& s) { return set((const char*)s); }
}; const TString& operator=(const char* str) { return set(str); }
void strncpy(const char* s, int n);
class TString16 : public TFixed_string };
{
char _str16[17]; class TString16 : public TFixed_string
{
public: char _str16[17];
TString16(const char* str = "") : TFixed_string(_str16, 17) { set(str); }
TString16(const TString& s) : TFixed_string(_str16, 17) { set(s); } public:
const TString& operator =(const TString& s) { return set((const char*)s); } TString16(const char* str = "") : TFixed_string(_str16, 17) { set(str); }
const TString& operator =(const char* str) { return set(str); } TString16(const TString& s) : TFixed_string(_str16, 17) { set(s); }
}; const TString& operator =(const TString& s) { return set((const char*)s); }
const TString& operator =(const char* str) { return set(str); }
class TString80 : public TFixed_string };
{
char _str80[81]; class TString80 : public TFixed_string
{
public: char _str80[81];
TString80(const char* str = "") : TFixed_string(_str80, 81) { set(str); }
TString80(const TString& s) : TFixed_string(_str80, 81) { set(s); } public:
const TString& operator =(const char* str) { return set(str); } TString80(const char* str = "") : TFixed_string(_str80, 81) { set(str); }
const TString& operator =(const TString& s) { return set((const char*)s); } TString80(const TString& s) : TFixed_string(_str80, 81) { set(s); }
}; const TString& operator =(const char* str) { return set(str); }
const TString& operator =(const TString& s) { return set((const char*)s); }
class TString256 : public TFixed_string };
{
char _str256[257]; class TString256 : public TFixed_string
{
public: char _str256[257];
TString256(const char* str = "") : TFixed_string(_str256, 257) { set(str); }
TString256(const TString& s) : TFixed_string(_str256, 257) { set(s); } public:
const TString& operator =(const char* str) { return set(str); } TString256(const char* str = "") : TFixed_string(_str256, 257) { set(str); }
const TString& operator =(const TString& s) { return set((const char*)s); } TString256(const TString& s) : TFixed_string(_str256, 257) { set(s); }
}; const TString& operator =(const char* str) { return set(str); }
const TString& operator =(const TString& s) { return set((const char*)s); }
};
// @C
// Classe TFilename : public TString80 (256 su Windows'95)
// @END // @C
// Classe TFilename : public TString80 (256 su Windows'95)
class TFilename : public TString80 // @END
{
public: class TFilename : public TString80
// @FPUB {
public:
TFilename(const char* n = "") : TString80(n) {} // @FPUB
TFilename(const TString& n) : TString80(n) {}
TFilename(const char* n = "") : TString80(n) {}
const TString& operator =(const char* s) { return set(s); } TFilename(const TString& n) : TString80(n) {}
const TString& operator =(const TString& s) { return set((const char*)s); }
// assegnazione tra TFile e stringa // assegnazione tra TFile e stringa
const TString& operator =(const char* s) { return set(s); }
const char* ext() const; // Ritorna l'estensione const TString& operator =(const TString& s) { return set((const char*)s); }
void ext(const char*); // Imposta come estensione la stringa puntata da char*
virtual bool ok() const; // Controlla il formato del nome del file
const char* name() const; // Ritorna il nome del file
const char* path() const; // Ritorna il nome del direttorio const char* ext() const; // Ritorna l'estensione
const TFilename& temp(const char* prefix = NULL); // Genera il nome di un file temporaneo void ext(const char*); // Imposta come estensione la stringa puntata da char*
const TFilename& tempdir(); // Genera il nome della directory temporanea
}; const char* name() const; // Ritorna il nome del file
const char* path() const; // Ritorna il nome del direttorio
// @C const TFilename& temp(const char* prefix = NULL); // Genera il nome di un file temporaneo
// Classe TToken_string : public TString const TFilename& tempdir(); // Genera il nome della directory temporanea
// @END };
class TToken_string : public TString // @C
{ // Classe TToken_string : public TString
// @DPRIV // @END
char _separator; // Carattere separatore
int _last; // Puntatore all'ultimo class TToken_string : public TString
{
protected: // @DPRIV
// @FPROT char _separator; // Carattere separatore
int _last; // Puntatore all'ultimo
virtual TObject* dup() const; // Crea un duplicato della token string
bool set_item(const char* v, int n); protected:
// @FPROT
public:
// @FPUB virtual TObject* dup() const; // Crea un duplicato della token string
TToken_string(const char* = "", char separator = '|'); bool set_item(const char* v, int n);
TToken_string(int n, char separator = '|');
TToken_string(const TToken_string& s); public:
// @FPUB
void separator(char s) { _separator = s; } // Setta il separatore a s TToken_string(const char* = "", char separator = '|');
TToken_string(int n, char separator = '|');
void restart() { _last = empty() ? -1 : 0; } // Rimette all'inizio il puntatore TToken_string(const TToken_string& s);
const TString& operator =(const char* s) { set(s);restart();return *this; }
const TString& operator =(const TString& s) { set(s);restart();return *this; } void separator(char s) { _separator = s; } // Setta il separatore a s
void add(const char* s, int n = -1); // Aggiunge una stringa void restart() { _last = empty() ? -1 : 0; } // Rimette all'inizio il puntatore
void add(char c, int pos = -1); // Aggiunge un char const TString& operator =(const char* s) { set(s);restart();return *this; }
void add(long n, int pos = -1); // Aggiunge un intero const TString& operator =(const TString& s) { set(s);restart();return *this; }
void add(int n, int pos = -1); // Aggiunge un intero
void destroy(int pos); // Toglie la stringa pos void add(const char* s, int n = -1); // Aggiunge una stringa
const char* get(); // Ritorna il prossimo token void add(char c, int pos = -1); // Aggiunge un char
const char* get(int n); // Ritorna un token (-1 = prossimo; -2 = ultimo; n = ennesimo) void add(long n, int pos = -1); // Aggiunge un intero
char get_char(int n = -1); // Ritorna un carattere void add(int n, int pos = -1); // Aggiunge un intero
int get_int(int n = -1); // Ritorna un intero void destroy(int pos); // Toglie la stringa pos
long get_long(int n = -1); // Ritorna un intero esteso const char* get(); // Ritorna il prossimo token
int get_pos(const char* s); // Ritorna la posizione dell'item s const char* get(int n); // Ritorna un token (-1 = prossimo; -2 = ultimo; n = ennesimo)
int items() const; // Ritorna il numero di token presenti char get_char(int n = -1); // Ritorna un carattere
bool empty_items() const; // Controlla se tutti i token sono nulli int get_int(int n = -1); // Ritorna un intero
}; long get_long(int n = -1); // Ritorna un intero esteso
int get_pos(const char* s); // Ritorna la posizione dell'item s
/////////////////////////////////////////////////////////// int items() const; // Ritorna il numero di token presenti
// @DES Paragraph bool empty_items() const; // Controlla se tutti i token sono nulli
/////////////////////////////////////////////////////////// };
class TParagraph_string : public TToken_string ///////////////////////////////////////////////////////////
{ // @DES Paragraph
int _width; ///////////////////////////////////////////////////////////
bool _fixed;
class TParagraph_string : public TToken_string
protected: {
void tokenize(); int _width;
bool _fixed;
public:
TParagraph_string(const char* s, int width); protected:
const TString& operator =(const char* s); void tokenize();
void set_width(int width) { _width = width; }
}; public:
TParagraph_string(const char* s, int width);
#endif const TString& operator =(const char* s);
void set_width(int width) { _width = width; }
};
#endif

View File

@ -436,7 +436,7 @@ HIDDEN bool _fixlen_val(TEdit_field& f, KEY)
} }
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;
@ -549,12 +549,11 @@ HIDDEN bool _onereq_val(TEdit_field& f, KEY k)
const TMask& m = f.mask(); const TMask& m = f.mask();
if (m.mode() == MODE_QUERY) return TRUE; if (m.mode() == MODE_QUERY) return TRUE;
const int nparms = get_val_param_num(); const int nparms = get_val_param_num();
TString s;
for (int i = 0; i < nparms ; i++) for (int i = 0; i < nparms ; i++)
{ {
s = m.get(atoi(get_val_param(i))); const char* s = m.get(atoi(get_val_param(i)));
if (s.not_empty()) return TRUE; if (*s) return TRUE;
} }
return FALSE; return FALSE;
} }
@ -572,7 +571,13 @@ HIDDEN bool _chkfld_val(TEdit_field& f, KEY k)
return TRUE; return TRUE;
} }
#define MAX_FUNC 18 HIDDEN bool _filename_val(TEdit_field& f, KEY)
{
const TFilename fn(f.get());
return fn.ok();
}
#define MAX_FUNC 19
HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] = HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
{ {
@ -593,7 +598,8 @@ HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
_numcalc_val, _numcalc_val,
_strcalc_val, _strcalc_val,
_onereq_val, _onereq_val,
_chkfld_val _chkfld_val,
_filename_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)

View File

@ -8,8 +8,6 @@
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
#include <viswin.h> #include <viswin.h>
#include <xvtility.h>
#include <colors.h>
#ifndef __PRINTER_H #ifndef __PRINTER_H
typedef void (*LINKHANDLER) (int, const char *); typedef void (*LINKHANDLER) (int, const char *);
@ -1784,24 +1782,26 @@ default:
bool TViswin::call_editor () bool TViswin::call_editor ()
{ {
TConfig cnf (CONFIG_GENERAL, "Link"); TConfig cnf (CONFIG_GENERAL, "Link");
TString editor (cnf.get ("txt")); const TFilename editor (cnf.get ("txt"));
bool ok = FALSE; bool ok = FALSE;
if (!editor.empty ()) if (!editor.empty ())
{ {
TString newfilename; TFilename newfilename; newfilename.tempdir();
FILE_SPEC fs;
static FILE_SPEC fs; str_to_dir((char*)(const char*)newfilename, &fs.dir);
get_default_dir(&fs.dir);
strcpy (fs.type, "txt"); strcpy (fs.type, "txt");
strcpy (fs.name, "");
save_dir (); save_dir ();
if (save_file_dlg (&fs, "Salva il file con il nome:") == FL_OK) if (save_file_dlg (&fs, "Salva il file con il nome:") == FL_OK)
{ {
restore_dir (); restore_dir ();
char path[256]; char path[256];
dir_to_str (&fs.dir, path, sizeof (path)); dir_to_str (&fs.dir, path, sizeof (path));
newfilename << path << '/' << fs.name; newfilename = path;
newfilename << '/' << fs.name;
TPoint p1, p2; TPoint p1, p2;
if (_isselection) if (_isselection)
@ -1819,8 +1819,7 @@ bool TViswin::call_editor ()
ok = TRUE; ok = TRUE;
} }
} }
else restore_dir ();
restore_dir ();
} }
else else
warning_box ("Nessun editor specificato nei parametri studio"); warning_box ("Nessun editor specificato nei parametri studio");

View File

@ -342,7 +342,7 @@ void beep()
class TEvent_manager class TEvent_manager
{ {
enum { MAX = 16 }; enum { MAX = 2 };
WINDOW _w[MAX]; WINDOW _w[MAX];
EVENT _e[MAX]; EVENT _e[MAX];
int _begin, _end; int _begin, _end;
@ -360,8 +360,11 @@ void TEvent_manager::push(WINDOW w, const EVENT& e)
CHECK(w, "You shouldn't send events to NULL_WIN!"); CHECK(w, "You shouldn't send events to NULL_WIN!");
_w[_end] = w; _w[_end] = w;
_e[_end] = e; _e[_end] = e;
_end = (++_end) % MAX; const int next = (_end+1) % MAX;
CHECKD(_end != _begin, "Too many events queued: max. ", MAX); if (next == _begin)
error_box("Hey %s, clicca piu' piano!", (const char*)main_app().user());
else
_end = next;
} }
void TEvent_manager::pop() void TEvent_manager::pop()