Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
archives.cpp  Aggiunto flag inutile ancora specificato dai vecchi programmi
*.c           Eliminato uso di CUpString
controls.cpp  Corretta resize_rect per tener conto della status bar
currency.cpp  Supporto cambio contro EURO
date.cpp      Migliorato operator=(long) in modo da accettare TODAY
dongle.cpp    Corretta gestione del prawin.ini
expr.cpp      Sostituiti alcuni "" con EMPTY_STRING
form.cpp      Supporto currency
isam.cpp      Aggiunte () per evitare warning di compilazione
os_win*.cpp   Migliorato supporto per minimizzazioe e massimizzazione
prefix.cpp    Aggiunta class TFirm coi dati della ditta
printapp.cpp  Supporto currency
printwin.cpp  Aggiunte () per evitare warning di compilazione
relapp.cpp    Migliorato delete_mode
text.cpp      Sostituiti CHECK inutili con NFCHECK
tree.cpp      Tolti ; errati da statement if
viswin.cpp    Supporto zoom
window.cpp    Aggiunta char2pixel per calcolare bene la dimensione dei caratteri
xvtility.cpp  Corretta resize rect per tener conto della status bar


git-svn-id: svn://10.65.10.50/trunk@7664 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1999-01-19 09:15:17 +00:00
parent e2a275e3ba
commit 4f99172ae0
35 changed files with 854 additions and 549 deletions

View File

@ -400,7 +400,8 @@ bool TArchive::fbuild(
bool TArchive::backup( bool TArchive::backup(
const char* dir, // @parm Directory di cui effettuare il backup const char* dir, // @parm Directory di cui effettuare il backup
char floppy, // @parm Floppy su cui effettuare il backup char floppy, // @parm Floppy su cui effettuare il backup
const char* desc) // @parm Descrizione da assegnare al backup const char* desc, // @parm Descrizione da assegnare al backup
bool)
// @syntax bool backup(const char* dir, char floppy, const char* desc, bool pr_set); // @syntax bool backup(const char* dir, char floppy, const char* desc, bool pr_set);
// @syntax bool backup(long firm, char floppy, const char* desc, bool pr_set); // @syntax bool backup(long firm, char floppy, const char* desc, bool pr_set);
@ -457,7 +458,7 @@ bool TArchive::backup(
return ok; return ok;
} }
bool TArchive::backup(long firm, char floppy, const char* desc) bool TArchive::backup(long firm, char floppy, const char* desc, bool)
{ {
TString_array fl; TString_array fl;
const int num_ditte = build_backup_list(firm, fl); const int num_ditte = build_backup_list(firm, fl);
@ -480,8 +481,8 @@ bool TArchive::backup(long firm, char floppy, const char* desc)
bool TArchive::restore( bool TArchive::restore(
const char* dir, // @parm Directory di cui effettuare il restore const char* dir, // @parm Directory di cui effettuare il restore
char floppy, // @parm Floppy da cui leggere i dati char floppy, // @parm Floppy da cui leggere i dati
bool tmp) // @parm Directory temporanea da utilizzare bool tmp, // @parm Directory temporanea da utilizzare
bool)
// @syntax bool restore(const char* dir, char floppy, bool temp, bool pr_set); // @syntax bool restore(const char* dir, char floppy, bool temp, bool pr_set);
// @syntax bool restore(long firm, char floppy, bool temp, bool pr_set); // @syntax bool restore(long firm, char floppy, bool temp, bool pr_set);
@ -568,7 +569,7 @@ bool TArchive::restore(
return ok; return ok;
} }
bool TArchive::restore(long firm, char floppy, bool temp) bool TArchive::restore(long firm, char floppy, bool temp. bool)
{ {
bool lastdisk = firm >= 0; bool lastdisk = firm >= 0;
bool ok = TRUE; bool ok = TRUE;
@ -1002,22 +1003,22 @@ bool TArchive::unzip(long firm, char floppy, bool temp)
#if XVT_OS == XVT_OS_WIN32 #if XVT_OS == XVT_OS_WIN32
bool TArchive::backup(const char* dir, char floppy, const char* desc) bool TArchive::backup(const char* dir, char floppy, const char* desc, bool)
{ {
return zip(dir, floppy, desc); return zip(dir, floppy, desc);
} }
bool TArchive::backup(long firm, char floppy, const char* desc) bool TArchive::backup(long firm, char floppy, const char* desc, bool)
{ {
return zip(firm, floppy, desc); return zip(firm, floppy, desc);
} }
bool TArchive::restore(const char* dir, char floppy, bool tmp) bool TArchive::restore(const char* dir, char floppy, bool tmp, bool)
{ {
return unzip(dir, floppy, tmp); return unzip(dir, floppy, tmp);
} }
bool TArchive::restore(long firm, char floppy, bool tmp) bool TArchive::restore(long firm, char floppy, bool tmp, bool)
{ {
return unzip(firm, floppy, tmp); return unzip(firm, floppy, tmp);
} }

View File

@ -66,14 +66,14 @@ protected:
public: public:
// @cmember Effettua il backup della directory // @cmember Effettua il backup della directory
bool backup(const char* dir, char floppy, const char* desc); bool backup(const char* dir, char floppy, const char* desc, bool dummy = FALSE);
// @cmember Effettua il backup della ditta // @cmember Effettua il backup della ditta
bool backup(long firm, char floppy, const char* desc); bool backup(long firm, char floppy, const char* desc, bool dummy = FALSE);
// @cmember Effettua il restore della directory // @cmember Effettua il restore della directory
bool restore(const char* dir, char floppy, bool temp); bool restore(const char* dir, char floppy, bool temp, bool dummy = FALSE);
// @cmember Effettua il restore della ditta // @cmember Effettua il restore della ditta
bool restore(long firm, char floppy, bool temp); bool restore(long firm, char floppy, bool temp, bool dummy = FALSE);
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
// @cmember Interrompe le operazioni // @cmember Interrompe le operazioni

View File

@ -169,8 +169,8 @@ extern "C" {
BOOLEAN CGetAut(int ); BOOLEAN CGetAut(int );
char *CGetConf(int ); char *CGetConf(int );
void CMaskP(char *,char *,int , int); void CMaskP(char *,char *,int , int);
char *CUpString(char *); // char *CUpString(char *);
char *CLowString(char *); // char *CLowString(char *);
/* @(!) 2.3.00.21 */ /* @(!) 2.3.00.21 */
char *strfset(char *, char *); char *strfset(char *, char *);
/* @(:) 2.3.00.21 */ /* @(:) 2.3.00.21 */

View File

@ -54,10 +54,6 @@ void COpenDir(lockmode, dirflg)
PathSt name; PathSt name;
if (dirfl[dirflg]++) return; if (dirfl[dirflg]++) return;
#ifndef DOS
if ((excllock(CInsPref(glockname, dirflg), (lockmode == ExclLock)) == -1))
fatal_box("Locked Directory. Error number : %d ", errno);
#endif
strcpy(name, CInsPref(directory, dirflg)) ; strcpy(name, CInsPref(directory, dirflg)) ;
COpen(&fdir[dirflg], name, sizeof(FileDes), 0, lockmode) ; COpen(&fdir[dirflg], name, sizeof(FileDes), 0, lockmode) ;
if (fdir[dirflg].IOR != NoErr) if (fdir[dirflg].IOR != NoErr)

View File

@ -48,9 +48,6 @@
#include <checks.h> #include <checks.h>
#define MAXLEN 137 /* Lunghezza massima chiave */ #define MAXLEN 137 /* Lunghezza massima chiave */
//extern char* CUpString(char *);
#define CUpString(str) _strupr(str)
static CODE4 code_base; static CODE4 code_base;
static DATA4 *dbdata[CB4FILES]; static DATA4 *dbdata[CB4FILES];
@ -544,7 +541,7 @@ HIDDEN void do_key(char *fname, RecDes *r, TAG4INFO *tag_info, int n_keys)
strcpy(tiname,fname); strcpy(tiname,fname);
dot = strchr(tiname, '.'); dot = strchr(tiname, '.');
if (dot) *dot = '\0'; if (dot) *dot = '\0';
CUpString(tiname); _strupr(tiname);
for (i=0; ((i < MaxKeys) && (i < n_keys)); i++) for (i=0; ((i < MaxKeys) && (i < n_keys)); i++)
{ {
tag_info[i].name=(char *)u4alloc(9); tag_info[i].name=(char *)u4alloc(9);
@ -1006,7 +1003,7 @@ int DB_recinfo(const char * filename, FileDes *d, RecDes *r, char* keys)
for (i=0; ((i<num_fields) && (i<MaxFields)); i++) for (i=0; ((i<num_fields) && (i<MaxFields)); i++)
{ {
strcpy(r->Fd[i].Name,field_info[i].name); strcpy(r->Fd[i].Name,field_info[i].name);
CUpString(r->Fd[i].Name); _strupr(r->Fd[i].Name);
r->Fd[i].Len = (unsigned char)field_info[i].len; r->Fd[i].Len = (unsigned char)field_info[i].len;
r->Fd[i].Dec = (unsigned char)field_info[i].dec; r->Fd[i].Dec = (unsigned char)field_info[i].dec;
switch(field_info[i].type) switch(field_info[i].type)
@ -1261,8 +1258,6 @@ int DB_memowrite( const int handle, const char * fieldname, const char * data )
#define MAXLEN 137 /* Lunghezza massima chiave */ #define MAXLEN 137 /* Lunghezza massima chiave */
extern char* CUpString(char *);
static CODE4 code_base; static CODE4 code_base;
static DATA4 *dbdata[CB4FILES]; static DATA4 *dbdata[CB4FILES];
@ -1801,7 +1796,7 @@ HIDDEN void do_key(char *fname, RecDes *r, TAG4INFO *tag_info, int n_keys)
strcpy(tiname,fname); strcpy(tiname,fname);
dot = strchr(tiname, '.'); dot = strchr(tiname, '.');
if (dot) *dot = '\0'; if (dot) *dot = '\0';
CUpString(tiname); _strupr(tiname);
for (i=0; ((i < MaxKeys) && (i < n_keys)); i++) for (i=0; ((i < MaxKeys) && (i < n_keys)); i++)
{ {
tag_info[i].name=(char *)u4alloc(9); tag_info[i].name=(char *)u4alloc(9);
@ -2291,7 +2286,7 @@ int DB_recinfo(const char * filename, FileDes *d, RecDes *r, char* keys)
for (i=0; ((i<num_fields) && (i<MaxFields)); i++) for (i=0; ((i<num_fields) && (i<MaxFields)); i++)
{ {
strcpy(r->Fd[i].Name,field_info[i].name); strcpy(r->Fd[i].Name,field_info[i].name);
CUpString(r->Fd[i].Name); _strupr(r->Fd[i].Name);
r->Fd[i].Len = field_info[i].len; r->Fd[i].Len = field_info[i].len;
r->Fd[i].Dec = field_info[i].dec; r->Fd[i].Dec = field_info[i].dec;
switch(field_info[i].type) switch(field_info[i].type)

View File

@ -10,21 +10,6 @@
#include <statbar.h> #include <statbar.h>
/* COLOR MASK_BACK_COLOR = COLOR_DKCYAN;
COLOR MASK_LIGHT_COLOR = COLOR_CYAN;
COLOR MASK_DARK_COLOR = COLOR_GRAY;
COLOR BTN_BACK_COLOR = COLOR_LTGRAY;
COLOR BTN_LIGHT_COLOR = COLOR_WHITE;
COLOR BTN_DARK_COLOR = COLOR_GRAY;
COLOR TOOL_BACK_COLOR = COLOR_GRAY;
COLOR NORMAL_COLOR = COLOR_BLACK;
COLOR NORMAL_BACK_COLOR = COLOR_LTGRAY;
COLOR DISABLED_COLOR = COLOR_GRAY;
COLOR DISABLED_BACK_COLOR = MASK_BACK_COLOR;
COLOR FOCUS_COLOR = NORMAL_COLOR;
COLOR FOCUS_BACK_COLOR = COLOR_CYAN;
BOOLEAN CAMPI_SCAVATI = FALSE;
BOOLEAN AUTOSELECT = FALSE; */
COLOR MASK_BACK_COLOR = COLOR_LTGRAY; COLOR MASK_BACK_COLOR = COLOR_LTGRAY;
COLOR MASK_LIGHT_COLOR = COLOR_WHITE; COLOR MASK_LIGHT_COLOR = COLOR_WHITE;
COLOR MASK_DARK_COLOR = COLOR_GRAY; COLOR MASK_DARK_COLOR = COLOR_GRAY;
@ -427,7 +412,16 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
max.bottom -= 26; // Non contare la status bar max.bottom -= 26; // Non contare la status bar
if (dy <= 0) if (dy <= 0)
height = max.bottom - top + dy * ROWY; {
if (top < 0)
{
height = -top;
top += max.bottom;
y = 21 - height/ROWY;
}
else
height = max.bottom - top + dy * ROWY;
}
if (dx <= 0) if (dx <= 0)
{ {
@ -1454,7 +1448,7 @@ bool TButton_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
} }
else else
if (xiev->type == XIE_POST_NAVIGATION) if (xiev->type == XIE_POST_NAVIGATION)
ok == notify_key(K_CTRL + K_TAB); ok = notify_key(K_CTRL + K_TAB);
else else
ok = TControl::event_handler(itf, xiev); ok = TControl::event_handler(itf, xiev);
@ -2294,8 +2288,8 @@ TListbox_control::TListbox_control(WINDOW win, short cid,
const char* flags, const char* text, const char* flags, const char* text,
const char* codes, const char* values) const char* codes, const char* values)
{ {
create(win, cid, left, top, width , 1, width, flags, text, TRUE); create(win, cid, left, top, width , 1, width, flags, text, TRUE);
_ddl = new TDropDownList(_obj, codes, values); _ddl = new TDropDownList(_obj, codes, values);
_ddl->select(0, TRUE); _ddl->select(0, TRUE);
} }

View File

@ -1,4 +1,5 @@
#include <currency.h> #include <currency.h>
#include <prefix.h>
#include <recarray.h> #include <recarray.h>
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -9,18 +10,25 @@ class TDowJones : public TFile_cache
{ {
struct TExchangeData : public TObject struct TExchangeData : public TObject
{ {
real _num; real _chg; // Cambio
real _den; int _dec; // Decimali per gli importi normali
int _dec; int _dec_prices; // Decimali per i prezzi unitari
int _dec_prices; bool _is_euro; // E' l'EURO in persona
bool _contro_euro; // Il cambio e' espresso contro EURO
public: public:
const TExchangeData& operator=(const TExchangeData& d) const TExchangeData& operator=(const TExchangeData& d)
{ _num = d._num; _den = d._den; _dec = d._dec; _dec_prices = d._dec_prices; return d; } {
TExchangeData() : _num(1.0), _den(1.0), _dec(0), _dec_prices(0) { } _chg = d._chg; _dec = d._dec; _dec_prices = d._dec_prices;
_is_euro = d._is_euro; _contro_euro = d._contro_euro;
return d;
}
TExchangeData()
: _chg(1.0), _dec(0), _dec_prices(0), _is_euro(FALSE), _contro_euro(FALSE) { }
}; };
TString16 _base_val, _firm_val; TString16 _base_val, _firm_val, _euro_val;
real _euro_chg;
protected: protected:
virtual TObject* rec2obj(const TRectype& rec) const; virtual TObject* rec2obj(const TRectype& rec) const;
@ -32,6 +40,7 @@ protected:
public: public:
const TString& get_base_val(); const TString& get_base_val();
const TString& get_firm_val(); const TString& get_firm_val();
const TString& get_euro_val();
const char* expand_value(const char* val); const char* expand_value(const char* val);
real exchange(const real& num, real exchange(const real& num,
@ -39,6 +48,7 @@ public:
const char* toval, const real& tochg, const char* toval, const real& tochg,
bool price = FALSE); bool price = FALSE);
int get_dec(const char* val, bool prices = FALSE); int get_dec(const char* val, bool prices = FALSE);
const real& get_change(const char* val);
TDowJones() : TFile_cache("%VAL") { } TDowJones() : TFile_cache("%VAL") { }
virtual ~TDowJones() { } virtual ~TDowJones() { }
@ -47,34 +57,29 @@ public:
TObject* TDowJones::rec2obj(const TRectype& rec) const TObject* TDowJones::rec2obj(const TRectype& rec) const
{ {
TExchangeData* data = new TExchangeData; TExchangeData* data = new TExchangeData;
data->_den = rec.get_real("I11");
if (data->_den > ZERO) const TString16 codval = rec.get("CODTAB");
data->_chg = rec.get_real("S4");
if (data->_chg <= ZERO)
{ {
data->_num = rec.get_real("R11"); data->_chg = rec.get_real("R10");
if (data->_num < 1.0) if (data->_chg <= ZERO)
data->_num = 1.0; {
} NFCHECK("Codice valuta errato: '%s'", (const char*)codval);
else data->_chg = 1.0;
{ }
data->_num = rec.get_real("I10");
if (data->_num < 1.0)
data->_num = 1.0;
data->_den = rec.get_real("R10");
data->_num = 1.0;
} }
const bool invalid = rec.get("CODTAB").empty(); if (codval.not_empty())
data->_dec = invalid ? 0 : rec.get_int("I0");
data->_dec_prices = invalid ? data->_dec : rec.get_int("I1");
if (data->_dec_prices < data->_dec)
data->_dec_prices = data->_dec;
if (data->_den <= ZERO)
{ {
NFCHECK("Codice valuta non valido '%s'", (const char*)rec.get("CODTAB")); data->_dec = rec.get_int("I0");
data->_den = 1.0; data->_dec_prices = rec.get_int("I1");
data->_num = 1.0; if (data->_dec_prices < data->_dec)
data->_dec_prices = data->_dec;
data->_is_euro = rec.get_bool("B0");
data->_contro_euro = rec.get_bool("B1");
} }
return data; return data;
} }
@ -82,30 +87,42 @@ void TDowJones::flush()
{ {
_base_val.cut(0); _base_val.cut(0);
_firm_val.cut(0); _firm_val.cut(0);
_euro_val.cut(0);
} }
void TDowJones::test_cache() void TDowJones::test_cache()
{ {
if (_cache.items() == 0) if (_base_val.empty())
{ {
fill(); fill();
FOR_EACH_ASSOC_OBJECT(_cache, hash, key, obj) FOR_EACH_ASSOC_OBJECT(_cache, hash, key, obj) if (*key)
{ {
const TExchangeData* data = (const TExchangeData*)obj; const TExchangeData& data = *(const TExchangeData*)obj;
if (data->_num == 1.0 && data->_den == 1.0) if (_base_val.empty() && data._chg == 1.0)
{ _base_val = key; else
_base_val = key; if (_euro_val.empty() && data._is_euro)
break; _euro_val = key;
}
} }
if (_base_val.empty())
if (_euro_val.empty()) // Si son dimenticati dell'EURO?
{
TExchangeData* euro = new TExchangeData;
euro->_chg = 1936.27; euro->_dec = euro->_dec_prices = 2;
euro->_is_euro = TRUE; euro->_contro_euro = FALSE;
_euro_val = "EUR";
_cache.add(_euro_val, euro);
}
_euro_chg = get_change(_euro_val);
if (_base_val.empty()) // Si son dimenticati delle LIRE?
{ {
TExchangeData* lira = new TExchangeData;
lira->_chg = 1.0; lira->_dec = lira->_dec_prices = 0;
lira->_is_euro = lira->_contro_euro = FALSE;
_base_val = "LIT"; _base_val = "LIT";
_cache.add(_base_val, new TExchangeData); _cache.add(_base_val, lira);
} }
_firm_val = prefix().firm().codice_valuta();
TConfig cfg(CONFIG_DITTA, "cg");
_firm_val = cfg.get("CodVal", NULL, -1, _base_val);
} }
} }
@ -117,6 +134,8 @@ const char* TDowJones::expand_value(const char* val)
{ {
if (stricmp(val, "_FIRM") == 0) if (stricmp(val, "_FIRM") == 0)
val = get_firm_val(); else val = get_firm_val(); else
if (stricmp(val, "_EURO") == 0)
val = get_euro_val(); else
if (stricmp(val, "_BASE") == 0) if (stricmp(val, "_BASE") == 0)
val = ""; val = "";
} }
@ -147,36 +166,43 @@ const TString& TDowJones::get_firm_val()
return _firm_val; return _firm_val;
} }
const TString& TDowJones::get_euro_val()
{
test_cache();
return _euro_val;
}
real TDowJones::exchange(const real& num, // Importo da convertire real TDowJones::exchange(const real& num, // Importo da convertire
const char* fromval, // Dalla valuta const char* frval, // Dalla valuta
const real& fromchg, // Dal cambio const real& frchg, // Dal cambio
const char* toval, // Alla valuta const char* toval, // Alla valuta
const real& tochg, // Al cambio const real& tochg, // Al cambio
bool price) // e' un prezzo ? bool price) // e' un prezzo ?
{ {
real n = num; real n = num;
if (n != ZERO) if (!n.is_zero())
{ {
real fromden = fromchg; const TExchangeData& datafr = get(frval);
real fromnum = 1.0;
real toden = tochg;
real tonum = 1.0;
if (fromden <= ZERO)
{
const TExchangeData& datafrom = get(fromval);
fromden = datafrom._den;
fromnum = datafrom._num;
}
const TExchangeData& datato = get(toval); const TExchangeData& datato = get(toval);
if (toden <= ZERO) const real fr = frchg <= ZERO ? datafr._chg : frchg;
{ const real to = tochg <= ZERO ? datato._chg : tochg;
toden = datato._den; const int mode = (datafr._contro_euro ? 1 : 0)+(datato._contro_euro ? 2 : 0);
tonum = datato._num; switch (mode)
{
case 1:
n = n * _euro_chg / (fr * to); // Modo misto 1
break;
case 2:
n = n * (fr * to) / _euro_chg; // Modo misto 2
break;
case 3:
n = n * to / fr; // Nuovo modo
break;
default:
n = n * fr / to; // Vecchio modo
break;
} }
n *= fromden * tonum; n.round(price ? datato._dec_prices : datato._dec); // Arrotonda
n /= fromnum * toden;
n.round(price ? datato._dec_prices : datato._dec);
} }
return n; return n;
} }
@ -187,6 +213,13 @@ int TDowJones::get_dec(const char* val, bool price)
return price ? data._dec_prices : data._dec; return price ? data._dec_prices : data._dec;
} }
const real& TDowJones::get_change(const char* val)
{
const TExchangeData& data = get(val);
return data._chg;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TCurrency // TCurrency
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -208,7 +241,7 @@ int TCurrency::get_base_dec(bool price)
int TCurrency::get_firm_dec(bool price) int TCurrency::get_firm_dec(bool price)
{ {
return DowJones.get_dec("_FIRM", price); return DowJones.get_dec(get_firm_val(), price);
} }
void TCurrency::force_value(const char* newval, const real& newchange) void TCurrency::force_value(const char* newval, const real& newchange)

View File

@ -189,12 +189,27 @@ TDate::operator const char*() const
return string(); return string();
} }
TDate& TDate::operator =(const char* s) TDate& TDate::operator =(const char* s)
{ {
return *this = TDate(s); return *this = TDate(s);
} }
TDate& TDate::operator =(long val)
{
if (val < 0L)
{
long lt;
val = 0L;
if (time(&lt) != -1)
{
struct tm *timeloc = localtime(&lt);
if (timeloc != NULL)
val = makedata(timeloc->tm_mday, timeloc->tm_mon+1, timeloc->tm_year + 1900);
}
}
_val = val;
return *this;
}
void TDate::print_on(ostream& out) const void TDate::print_on(ostream& out) const
{ {

View File

@ -136,8 +136,7 @@ public:
// @cmember Assegna la data passata come stringa // @cmember Assegna la data passata come stringa
TDate& operator =(const char* s); TDate& operator =(const char* s);
// @cmember Assegna la data passato come valore numerico // @cmember Assegna la data passato come valore numerico
TDate& operator =(long val) TDate& operator =(long val);
{ _val = val; return *this;}
// @cmember Assegna la data passata come oggetto data // @cmember Assegna la data passata come oggetto data
TDate& operator =(const TDate& d) TDate& operator =(const TDate& d)
{ _val = d._val; return *this;} { _val = d._val; return *this;}

View File

@ -4,7 +4,7 @@
#endif #endif
#ifndef LIBDIR #ifndef LIBDIR
#define LIBDIR f:\xvt.403\win_x86\ptk\lib #define LIBDIR f:\xvt.450\win_x86\ptk\lib
#endif #endif
#ifndef RESDIR #ifndef RESDIR

View File

@ -437,7 +437,7 @@ int TDongle::can_try_server() const
if (os_dongle_server_running()) if (os_dongle_server_running())
return 3; return 3;
TConfig ini("prawin.ini", "Server"); TConfig ini(CONFIG_INSTALL, "Server");
const TString& dongle = ini.get("Dongle"); const TString& dongle = ini.get("Dongle");
return dongle.not_empty(); return dongle.not_empty();
} }
@ -468,7 +468,7 @@ bool TDongle::login(bool test_all_keys)
} }
else else
{ {
TConfig ini("prawin.ini", "Main"); TConfig ini(CONFIG_INSTALL, "Main");
hw = (TDongleHardware)ini.get_int("Donglehw"); hw = (TDongleHardware)ini.get_int("Donglehw");
} }
} }
@ -502,7 +502,7 @@ bool TDongle::login(bool test_all_keys)
} }
if (ok) if (ok)
{ {
TConfig ini("prawin.ini", "Main"); TConfig ini(CONFIG_INSTALL, "Main");
ini.set("Donglehw",(int)_hardware); ini.set("Donglehw",(int)_hardware);
} }
} }

View File

@ -91,7 +91,7 @@ const real& TVararray::getnum(int varnum)
if (varnum < 0 || varnum >= items()) if (varnum < 0 || varnum >= items())
{ {
NFCHECK("Invalid variable number : %d", varnum); NFCHECK("Invalid variable number : %d", varnum);
return ""; return ZERO;
} }
return ((TVar*)objptr(varnum))->number(); return ((TVar*)objptr(varnum))->number();
} }
@ -106,7 +106,7 @@ const TString& TVararray::getstring(const char* name)
return var->string(); return var->string();
} }
NFCHECK("Unknown variable : %s", name); NFCHECK("Unknown variable : %s", name);
return ""; return EMPTY_STRING;
} }
@ -115,7 +115,7 @@ const TString& TVararray::getstring(int varnum)
if (varnum < 0 || varnum >= items()) if (varnum < 0 || varnum >= items())
{ {
NFCHECK("Invalid variable number : %d", varnum); NFCHECK("Invalid variable number : %d", varnum);
return ""; return EMPTY_STRING;
} }
TVar* var = (TVar*)objptr(varnum); TVar* var = (TVar*)objptr(varnum);
return var->string(); return var->string();

View File

@ -1,7 +1,8 @@
#include <ctype.h> #include <ctype.h>
#include <stdlib.h>
#include <applicat.h> #include <applicat.h>
#include <defmask.h> #include <currency.h>
#include <form.h> #include <form.h>
#include <msksheet.h> #include <msksheet.h>
#include <os_dep.h> #include <os_dep.h>
@ -12,6 +13,10 @@
#include <expr.h> #include <expr.h>
#include <tabutil.h> #include <tabutil.h>
#ifndef __DEFMASK_H
#include <defmask.h>
#endif
#include "../ba/bafrm.h" #include "../ba/bafrm.h"
// per lo sheet di edit campi // per lo sheet di edit campi
@ -240,7 +245,7 @@ HIDDEN bool fmt_handler(TMask_field& f, KEY k)
TForm_flags::TForm_flags() TForm_flags::TForm_flags()
{ {
automagic = dirty = finkr = finkl = memo = newpage = FALSE; automagic = dirty = finkr = finkl = memo = newpage = price = FALSE;
shown = enabled = TRUE; shown = enabled = TRUE;
} }
@ -265,6 +270,8 @@ bool TForm_flags::update(const char* s)
memo = TRUE; break; memo = TRUE; break;
case 'N': case 'N':
newpage = TRUE; break; newpage = TRUE; break;
case 'U':
price = TRUE; break;
default : default :
error_box("Unknown form item flag '%c'", *s); break; error_box("Unknown form item flag '%c'", *s); break;
} }
@ -285,6 +292,7 @@ void TForm_flags::print_on(ostream& out) const
if (newpage) s << "N"; if (newpage) s << "N";
if (finkl) s << "F"; if (finkl) s << "F";
if (finkr) s << "K"; if (finkr) s << "K";
if (price) s << "U";
if (s.not_empty()) if (s.not_empty())
out << " FLAGS \"" << s << '"' << endl; out << " FLAGS \"" << s << '"' << endl;
@ -412,13 +420,13 @@ void TForm_item::print_body(ostream& out) const
aa.restart(); aa.restart();
THash_object* op; THash_object* op;
TString typ, val, des;
while ((op = aa.get_hashobj()) != NULL) while ((op = aa.get_hashobj()) != NULL)
{ {
TToken_string& t = (TToken_string&)op->obj(); TToken_string& t = (TToken_string&)op->obj();
typ = t.get(0); TString typ(t.get(0));
val = t.get(1); TString val(t.get(1));
des = t.get(2); TString des(t.get(2));
out << " SPECIAL " << typ << " " << op->key() out << " SPECIAL " << typ << " " << op->key()
<< " \"" << val << "\" \"" << des << "\"\n"; << " \"" << val << "\" \"" << des << "\"\n";
} }
@ -651,12 +659,11 @@ void TForm_item::string_at(int x, int y, const char* s)
if (_width > 0 && strlen(s) > (word)_width) // Tronca testo se necessario if (_width > 0 && strlen(s) > (word)_width) // Tronca testo se necessario
{ {
TString tmp(s); strncpy(__tmp_string, s, width());
tmp.cut(_width); __tmp_string[_width] = '\0';
row.put(tmp, x-1); s = __tmp_string;
} }
else row.put(s, x-1); // Stampa testo
row.put(s, x-1); // Stampa testo
} }
} }
@ -759,7 +766,7 @@ bool TForm_item::do_message(int num)
TToken_string& messaggio = message(num); TToken_string& messaggio = message(num);
if (messaggio.empty_items()) return FALSE; if (messaggio.empty_items()) return FALSE;
TToken_string msg(80, ','); TToken_string msg(16, ',');
for (const char* m = messaggio.get(0); m; m = messaggio.get()) for (const char* m = messaggio.get(0); m; m = messaggio.get())
{ {
msg = m; msg = m;
@ -815,7 +822,7 @@ bool TForm_item::update()
{ {
if (_prompt.right(1) == "#") if (_prompt.right(1) == "#")
{ {
TString prompt(_prompt); TString256 prompt(_prompt);
for (int i = prompt.len()-2; i >= 0; i--) for (int i = prompt.len()-2; i >= 0; i--)
if (prompt[i] != '#') break; if (prompt[i] != '#') break;
prompt.cut(i+1); prompt.cut(i+1);
@ -975,19 +982,19 @@ bool TForm_item::edit(TMask& m)
const TString& TForm_item::picture() const const TString& TForm_item::picture() const
{ {
CHECK(0, "Can't get the picture of a generic form item!"); NFCHECK("Can't get the picture of a generic form item!");
return _prompt; return EMPTY_STRING;
} }
void TForm_item::set_picture(const char*) void TForm_item::set_picture(const char*)
{ {
CHECK(0, "Can't set the picture of a generic form item!"); NFCHECK("Can't set the picture of a generic form item!");
} }
TToken_string& TForm_item::memo_info() TToken_string& TForm_item::memo_info()
{ {
CHECK(0, "Can't get a memo of a generic form item!"); NFCHECK("Can't get a memo of a generic form item!");
return TToken_string(); return (TToken_string&)EMPTY_STRING;
} }
short TForm_item::x() short TForm_item::x()
@ -1284,7 +1291,8 @@ bool TForm_subsection::print_body(sec_print_mode showfields)
if (cur->is_first_match(_file_id)) if (cur->is_first_match(_file_id))
{ {
bool again; bool again;
do { do
{
form().match_result(_file_id); form().match_result(_file_id);
ok |= _ssec.update_and_print(showfields,at_newpage); ok |= _ssec.update_and_print(showfields,at_newpage);
_ssec.set_repeat_count(++i); _ssec.set_repeat_count(++i);
@ -1292,8 +1300,8 @@ bool TForm_subsection::print_body(sec_print_mode showfields)
again=form().last_match_result(_file_id); again=form().last_match_result(_file_id);
else else
again= cur->next_match(_file_id); again= cur->next_match(_file_id);
} while (again); } while (again);
ok |=_ssec.repeat_count()>0; // (ovvero, sempre true: se c'e' un first match) ok |= (_ssec.repeat_count()>0); // (ovvero, sempre true: se c'e' un first match)
} }
// _ssec.set_repeat_count(0); // _ssec.set_repeat_count(0);
} }
@ -1596,7 +1604,7 @@ void TForm_string::put_paragraph(const char* s)
#ifdef DBG #ifdef DBG
if (plen>0 && *s) if (plen>0 && *s)
yesno_box("Nei form la stampa di un item su più righe con prompt ora non pone più il prompt isolato sulla prima riga ma allinea a sinistra del prompt "); NFCHECK("Nei form la stampa di un item su più righe con prompt ora non pone più il prompt isolato sulla prima riga ma allinea a sinistra del prompt ");
#endif #endif
for (int i=0; (s = p.get()) != NULL && i < h; i++) for (int i=0; (s = p.get()) != NULL && i < h; i++)
{ {
@ -1720,6 +1728,7 @@ protected:
public: public:
void real2currency(const real& r, TString& str) const;
virtual TObject* dup() const; virtual TObject* dup() const;
void set_decimals(int d) { _height = d; } void set_decimals(int d) { _height = d; }
virtual const char* example() const; virtual const char* example() const;
@ -1760,6 +1769,21 @@ void TForm_number::put_paragraph(const char* s)
string_at(-1, _y, s); // se ha il prompt stampa all'ultima posizione raggiunta string_at(-1, _y, s); // se ha il prompt stampa all'ultima posizione raggiunta
} }
void TForm_number::real2currency(const real& r, TString& str) const
{
TCurrency c(r, "_FIRM");
c.set_price(_flag.price != 0);
const TString& codval = form().get_curr_codval();
if (codval.not_empty())
c.change_value(codval);
const TString& pic = picture();
const bool dotted = pic.empty() || pic.find('.') >= 0;
str = c.string(dotted);
const int w = width();
if (w > pic.len())
str.right_just(w);
}
bool TForm_number::update() bool TForm_number::update()
{ {
if (read()) // valuta il campo if (read()) // valuta il campo
@ -1787,7 +1811,19 @@ bool TForm_number::update()
if (print) if (print)
{ {
TString s(get()); TString s(get());
apply_format(s); const bool mc = form().magic_currency();
if (mc)
{
const real r = s;
const bool b1 = picture() == "." || (picture().len() >= 9 && picture().find(',') < 0);
const bool b2 = width() >= 9 && decimals() == 0;
if (b1 || b2)
real2currency(r, s);
else
apply_format(s);
}
else
apply_format(s);
put_paragraph(s); put_paragraph(s);
} }
} }
@ -1801,7 +1837,7 @@ void TForm_number::apply_format(TString& s) const
{ {
real n(s); real n(s);
TToken_string delim(4, ','); // Stringa con i due delimitatori TToken_string delim(4, ','); // Stringa con i due delimitatori
TString80 pic(picture()); // Picture senza delimitatori TString pic(picture()); // Picture senza delimitatori
int maxlen = -1; int maxlen = -1;
if (pic[0] == '(') // Se ci sono i delimitatori ... if (pic[0] == '(') // Se ci sono i delimitatori ...
@ -1825,7 +1861,7 @@ void TForm_number::apply_format(TString& s) const
} }
} }
s = n.string(pic); // riempi la stringa col valore pitturato s=n.string(pic); // riempi la stringa col valore pitturato
if (maxlen >= 0 && maxlen < s.size()) if (maxlen >= 0 && maxlen < s.size())
s.cut(maxlen); s.cut(maxlen);
@ -1840,35 +1876,133 @@ void TForm_number::apply_format(TString& s) const
if (spc < ld) if (spc < ld)
{ {
TString16 spazi; TString16 spazi;
spazi.spaces(ld - spc); spazi.spaces(ld - spc);
s.insert(spazi,0); s.insert(spazi,0);
spc = ld; spc = ld;
} }
s.overwrite(d,spc - ld); s.overwrite(d,spc - ld);
} }
d = delim.get(); d = delim.get();
if (d.not_empty()) // Se il secondo delimitatore e' valido ... if (d.not_empty()) // Se il secondo delimitatore e' valido ...
s << d; // ... aggiungilo alla fine s << d; // ... aggiungilo alla fine
} }
} }
// else s = n.string();
} }
void TForm_number::set_picture(const char *p) void TForm_number::set_picture(const char *p)
{ {
TForm_string::set_picture(p); TForm_string::set_picture(p);
const int comma = picture().find(','); const int comma = picture().find(',');
if (comma >= 0) if (comma > 0) set_decimals(picture().len() - comma -1);
set_decimals(picture().len() - comma -1);
} }
const char* TForm_number::example() const const char* TForm_number::example() const
{ {
TString80 s("123456789120.00"); TString s("123456789120.00");
apply_format(s); apply_format(s);
return strcpy(__tmp_string, s); return strcpy(__tmp_string, s);
} }
///////////////////////////////////////////////////////////
// TForm_currency
///////////////////////////////////////////////////////////
class TForm_currency : public TForm_number
{
TString16 _driver_id;
TForm_item* _driver;
protected: // TForm_string
virtual const char* class_name() const { return "VALUTA"; }
virtual bool parse_head(TScanner& scanner);
virtual bool parse_item(TScanner& scanner);
virtual bool update();
const char* codval();
public:
virtual TObject* dup() const;
TForm_currency(TPrint_section* section);
virtual ~TForm_currency() {}
};
bool TForm_currency::parse_head(TScanner& scanner)
{
return TForm_item::parse_head(scanner);
}
bool TForm_currency::parse_item(TScanner& scanner)
{
if (scanner.key() == "DR") // DRIVENBY
{
_driver_id = scanner.pop();
return TRUE;
}
return TForm_number::parse_item(scanner);
}
const char* TForm_currency::codval()
{
if (_driver == NULL)
{
if (_driver_id.empty())
return "_FIRM";
_driver = &find_field(_driver_id);
}
return _driver->get();
}
TObject* TForm_currency::dup() const
{
TForm_currency *fn = new TForm_currency(_section);
copy_to_form_item(fn);
fn->_driver_id = _driver_id;
return fn;
}
bool TForm_currency::update()
{
if (read()) // valuta il campo
{
TForm_item::update();
int nm = 0;
if (_message.objptr(1) != NULL)
{
const real oldn(get());
if (oldn.is_zero())
nm =1;
}
do_message(nm);
const real n(get());
TCurrency curr(n, codval(), ZERO, _flag.price != 0);
const TString& codval = form().get_curr_codval();
if (codval.not_empty())
curr.change_value(codval);
const TString& pic = picture();
TString80 str;
if (n.is_zero())
{
if (pic.not_empty() && pic.right(1) != "#")
str = curr.string(TRUE);
}
else
{
const bool dotted = pic.empty() || pic.find('.') >= 0;
str = curr.string(dotted);
}
str.right_just(width() - prompt().len());
put_paragraph(str);
}
return TRUE;
}
TForm_currency::TForm_currency(TPrint_section* section)
: TForm_number(section), _driver(NULL)
{ }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TForm_date // TForm_date
@ -2323,7 +2457,7 @@ HIDDEN bool font_handler(TMask_field& f, KEY key)
{ {
if (key == K_SPACE) if (key == K_SPACE)
{ {
TWait_cursor hourglass; main_app().begin_wait();
const char* family = f.get(); const char* family = f.get();
const int MAXSIZES = 16; const int MAXSIZES = 16;
@ -2354,6 +2488,8 @@ HIDDEN bool font_handler(TMask_field& f, KEY key)
TList_field& lst = (TList_field&)f.mask().field(F_SIZE); TList_field& lst = (TList_field&)f.mask().field(F_SIZE);
lst.replace_items(pn1, pn2); lst.replace_items(pn1, pn2);
lst.set(format("%d",printer().get_char_size())); lst.set(format("%d",printer().get_char_size()));
main_app().end_wait();
} }
return TRUE; return TRUE;
} }
@ -2595,6 +2731,8 @@ TForm_item* TPrint_section::parse_item(const TString& s)
return new TForm_string(this); return new TForm_string(this);
if (s == "NU") if (s == "NU")
return new TForm_number(this); return new TForm_number(this);
if (s == "VA")
return new TForm_currency(this);
if (s == "DA") if (s == "DA")
return new TForm_date(this); return new TForm_date(this);
if (s == "LI") if (s == "LI")
@ -2652,7 +2790,7 @@ bool TPrint_section::parse_body(TScanner& scanner)
bool TPrint_section::parse(TScanner& scanner) bool TPrint_section::parse(TScanner& scanner)
{ {
if (parse_head(scanner)); if (parse_head(scanner))
return parse_body(scanner); return parse_body(scanner);
return FALSE; return FALSE;
} }
@ -3387,22 +3525,24 @@ TForm_item& TPrint_section::find_field(short id) const
{ {
TForm_item * f = find_field_everywhere(id,this); TForm_item * f = find_field_everywhere(id,this);
if (f) return *f; if (f) return *f;
yesnofatal_box("Can't find item with id %d", id); NFCHECK("Can't find item with id %d", id);
return field(0); return field(0);
} }
// Ricerca i campi verso l'alto: // Ricerca i campi verso l'alto:
// prima la sezione attuale, poi le sezioni sopra // prima la sezione attuale, poi le sezioni sopra
TForm_item *TPrint_section::find_field_everywhere(short id,const TPrint_section *starting_section) const TForm_item* TPrint_section::find_field_everywhere(short id,const TPrint_section *starting_section) const
{ {
TForm_item * f ; TForm_item * f ;
for(word i = 0; i < fields(); i++) for(word i = 0; i < fields(); i++)
{ {
f = &field(i); f = &field(i);
if (f->id() == id) return f; if (f->id() == id)
return f;
} }
// look into the section above ("father" ) // look into the section above ("father" )
if (section_above() && section_above()!=starting_section) { if (section_above() && section_above() != starting_section)
{
f=section_above()->find_field_everywhere(id,this); f=section_above()->find_field_everywhere(id,this);
if (f) if (f)
return f; return f;
@ -3411,11 +3551,12 @@ TForm_item *TPrint_section::find_field_everywhere(short id,const TPrint_section
for (int j = 0; j < subsections(); j++) for (int j = 0; j < subsections(); j++)
{ {
const TPrint_section &bs=subsection(j)->printsection(); const TPrint_section &bs=subsection(j)->printsection();
if (&bs!=starting_section) { if (&bs!=starting_section)
f=bs.find_field_everywhere(id,this); {
f = bs.find_field_everywhere(id,this);
if (f) if (f)
return f; return f;
} }
} }
return NULL; return NULL;
} }
@ -3424,7 +3565,7 @@ TForm_item& TPrint_section::find_field(const char *sec_name) const
{ {
TForm_item * f = find_field_everywhere(sec_name,this); TForm_item * f = find_field_everywhere(sec_name,this);
if (f) return *f; if (f) return *f;
yesnofatal_box("Can't find item with id %s", sec_name); NFCHECK("Can't find item with id %s", sec_name);
return field(0); return field(0);
} }
@ -3433,13 +3574,15 @@ TForm_item& TPrint_section::find_field(const char *sec_name) const
TForm_item *TPrint_section::find_field_everywhere(const char *sec_name,const TPrint_section *starting_section) const TForm_item *TPrint_section::find_field_everywhere(const char *sec_name,const TPrint_section *starting_section) const
{ {
// search here // search here
for (int j = 0; j < subsections(); j++) { for (int j = 0; j < subsections(); j++)
{
const char *n=subsection(j)->name(); const char *n=subsection(j)->name();
if (strcmp(n,sec_name)==0) if (strcmp(n,sec_name)==0)
return subsection(j); return subsection(j);
} }
// search down // search down
for (j = 0; j < subsections(); j++) { for (j = 0; j < subsections(); j++)
{
TForm_item *it=subsection(j)->printsection().find_field_everywhere(sec_name,starting_section); TForm_item *it=subsection(j)->printsection().find_field_everywhere(sec_name,starting_section);
if (it) if (it)
return it; return it;
@ -3581,14 +3724,14 @@ bool TForm::parse_sortedjoin(TScanner& scanner)
if (filter.empty() && sortexp.empty()) if (filter.empty() && sortexp.empty())
yesnofatal_box("Sort senza espressioni di ordinamento o filtri"); yesnofatal_box("Sort senza espressioni di ordinamento o filtri");
TRelation * sortrel=new TRelation(atoi(j)); TRelation * sortrel=new TRelation(atoi(j));
while (ok && scanner.popkey() != "JO" ) while (scanner.popkey() != "JO" )
{ {
if (scanner.key() == "US") // USING keyword if (scanner.key() == "US") // USING keyword
{ {
TString16 subj(scanner.pop()); // File or table TString16 subj(scanner.pop()); // File or table
parse_join_param(scanner,sortrel,subj,atoi(j)); parse_join_param(scanner,sortrel,subj,atoi(j));
} else } else
yesnofatal_box("Token non riconosciuto in SORT:%s",scanner.key()); NFCHECK("Token non riconosciuto in SORT:%s",scanner.key());
} }
int to = 0; int to = 0;
@ -3734,6 +3877,9 @@ bool TForm::parse_general(TScanner &scanner)
if (scanner.key() == "PA") // Numero di pagine fisso if (scanner.key() == "PA") // Numero di pagine fisso
_npages=scanner.integer(); _npages=scanner.integer();
if (scanner.key() == "VA") // Valuta/Divisa impiegata
_curr_codval=scanner.string();
extended_parse_general(scanner); // Parse non-standard parameters extended_parse_general(scanner); // Parse non-standard parameters
} }
} else scanner.push(); } else scanner.push();
@ -3859,10 +4005,10 @@ bool TForm::reread(
if (key == "SE" || key == "") // ..if section or end of file... if (key == "SE" || key == "") // ..if section or end of file...
break; break;
} }
const char secr = scanner.popkey()[0]; // Section name (GRAPH, HEAD, BODY, FOOT) const char secr = scanner.popkey()[0]; // Section name (GRAPH, HEAD, BODY, FOOT)
if (secr=='\0') break; if (secr=='\0') break;
const pagetype pr = char2page(scanner.popkey()[0]); // Section type (odd, even, first, last) const pagetype pr = char2page(scanner.popkey()[0]); // Section type (odd, even, first, last)
if (secr == sec && pr == p) ok = TRUE; // L'ha trovata... if (secr==sec && pr==p) ok = TRUE; // L'ha trovata...
} }
// ...riesegue la parse della sezione leggendo dal file sorgente // ...riesegue la parse della sezione leggendo dal file sorgente
if(ok && s->parse(scanner)) if(ok && s->parse(scanner))
@ -4257,24 +4403,19 @@ void TForm::arrange_form()
// CHR(15), allora prima del posizionamento scrivo il chr(15) sulla stampante! // CHR(15), allora prima del posizionamento scrivo il chr(15) sulla stampante!
{ {
TPrinter& pr = printer();
if (!os_open_spool_row(pr.printername()))
{
error_box("Impossibile aprire il device %s.", (const char*)pr.printername());
return;
}
int i, x; int i, x;
TString str_pos; TString str_pos;
TMask m("ba2100c"); TMask m("ba2100c");
// _ipy viene assunto uguale per entrambi i posizionamneti // _ipy viene assunto uguale per entrambi i posizionamneti
str_pos = "\017"; // Questo e' 15 in ottale... str_pos = "\017"; // Questo e' 15 in ottale...
for (i=1; i < _ipy; i++) str_pos << "\n"; for (i=1; i < _ipy; i++) str_pos << "\n";
os_open_spool_row(printer().printername());
os_spool_row(str_pos); os_spool_row(str_pos);
os_close_spool_row();
str_pos = ""; //Azzera la stringa di posizionamento str_pos = ""; //Azzera la stringa di posizionamento
for (i=1; i < _ipx; i++) str_pos << " "; //Aggiunge gli spazi necessari... for (i=1; i < _ipx; i++) str_pos << " "; //Aggiunge gli spazi necessari...
if (_ipx > 0) if (_ipx > 0)
@ -4287,12 +4428,18 @@ void TForm::arrange_form()
// TString bspc; bspc.fill('\b',str_pos.len()); // Questi servono per tornare indietro... // TString bspc; bspc.fill('\b',str_pos.len()); // Questi servono per tornare indietro...
do do
{ {
os_open_spool_row(printer().printername());
os_spool_row(str_pos); os_spool_row(str_pos);
os_close_spool_row();
} while (m.run() == K_ESC); // cicla sulla stampa posizionamento... } while (m.run() == K_ESC); // cicla sulla stampa posizionamento...
/* const int h = height(odd_page);
os_close_spool_row(); str_pos.cut(0);
for (i=0; i < h; i++) str_pos << "\n";
pr.set_offset(-(_ipy-1), printer().get_column_offset()); lpt = fopen(device,"w");
if (lpt == NULL) fatal_box("Non rieso ad aprire il device %s.",device);
fprintf(lpt, "%s", (const char*) str_pos); // Salta tante righe quanto e' lungo il form standard
fclose (lpt); */
printer().set_offset(-(_ipy-1), printer().get_column_offset());
} }
long TForm::records() const long TForm::records() const
@ -4459,8 +4606,6 @@ bool TForm::genera_intestazioni(
case 'r': case 'r':
p.right_just(fi.width()); p.right_just(fi.width());
break; break;
default:
break;
} }
s = new TForm_string(header); s = new TForm_string(header);
s->id() = -1; s->id() = -1;
@ -4587,8 +4732,7 @@ bool TForm::print(
{ {
if (height(t)> (word)pr.formlen()) if (height(t)> (word)pr.formlen())
{ {
TString s; TString s("La lunghezza totale della sezione ");
s = "La lunghezza totale della sezione ";
switch ( t ) switch ( t )
{ {
case odd_page: case odd_page:
@ -4673,7 +4817,7 @@ bool TForm::print(
} }
} }
} }
set_body(page(pr), TRUE); set_body(page(pr), TRUE);
if (cursor()) if (cursor())
{ {
@ -4686,15 +4830,21 @@ bool TForm::print(
i++; i++;
} // fine ciclo di stampa } // fine ciclo di stampa
TPrintrow empty_line; // Perche' static ???
while (fixed_pages() && page(pr) % _npages !=0) while (fixed_pages() && page(pr) % _npages !=0)
{ {
// static TPrintrow empty_line; static TPrintrow empty_line;
pr.formfeed(); pr.formfeed();
pr.print(empty_line); pr.print(empty_line);
} }
if (from >= 0) if (from >= 0)
{
if (!_lastpage)
{
set_last_page(TRUE);
set_footer(0,FALSE);
}
pr.formfeed(); pr.formfeed();
}
if (!was_open) if (!was_open)
pr.close(); pr.close();
@ -5144,7 +5294,7 @@ bool TForm::validate(TForm_item &cf, TToken_string &s)
void TForm::print_on(ostream& out) const void TForm::print_on(ostream& out) const
{ {
TWait_cursor hourglass; main_app().begin_wait();
if (relation()) if (relation())
{ {
@ -5160,6 +5310,8 @@ void TForm::print_on(ostream& out) const
print_section(out, 'F'); print_section(out, 'F');
out << "END" << endl; out << "END" << endl;
main_app().end_wait();
} }
@ -5360,7 +5512,7 @@ void TForm::read(
_editlevel= lev; _editlevel= lev;
_desc= desc; _desc= desc;
TWait_cursor hourglass; main_app().begin_wait();
if (_code.not_empty()) if (_code.not_empty())
{ {
@ -5453,6 +5605,8 @@ void TForm::read(
_fontsize = pr.get_char_size(); _fontsize = pr.get_char_size();
} }
set_fink_mode(TRUE); set_fink_mode(TRUE);
main_app().end_wait();
} }
void TForm::set_compulsory_specials() void TForm::set_compulsory_specials()
@ -5549,7 +5703,7 @@ void TForm::match_result(int file,int val)
info.match_number=((TForm_skip_info &)_skip_info[file]).match_number; info.match_number=((TForm_skip_info &)_skip_info[file]).match_number;
if (val) if (val)
info.match_number++; info.match_number++;
info.match_result= val != 0; info.match_result = val != 0;
_skip_info.add(info,file); _skip_info.add(info,file);
} }
} }

View File

@ -143,10 +143,14 @@ class TForm : public TObject
bool _isbase; bool _isbase;
// @cmember:(INTERNAL) Indica se effettuare il posizionamento manuale dei moduli // @cmember:(INTERNAL) Indica se effettuare il posizionamento manuale dei moduli
bool _arrange; bool _arrange;
// @cmember: (INTERNAL) Trasforma i reali in currency automaticamente
bool _magic_currency;
// @cmember:(INTERNAL) Permessi di Edit // @cmember:(INTERNAL) Permessi di Edit
int _editlevel; int _editlevel;
// @cmember:(INTERNAL) Descrizione del formato // @cmember:(INTERNAL) Descrizione del formato
TString _desc; TString _desc;
// @cmember:(INTERNAL) Descrizione divisa impiegata per stampa prezzi ed importi
TString16 _curr_codval;
// @cmember:(INTERNAL) Array di caratteri di fincatura // @cmember:(INTERNAL) Array di caratteri di fincatura
TString16 _fink; TString16 _fink;
// @cmember:(INTERNAL) Numero iniziale di pagina // @cmember:(INTERNAL) Numero iniziale di pagina
@ -312,6 +316,18 @@ public:
// @cmember Setta la descrizione del formato // @cmember Setta la descrizione del formato
void set_description(const char* s) void set_description(const char* s)
{ _desc = s; } { _desc = s; }
// @cmember Setta la divisa impiegata per la stampa di importi e prezzi
void set_curr_codval(const char* cv = "")
{ _curr_codval = cv; }
// @cmember Ritorna la divisa impiegata per la stampa di importi e prezzi
const TString& get_curr_codval() const
{ return _curr_codval; }
// @cmember Setta il flag di TCurrency automatici
void set_magic_currency(bool mc)
{ _magic_currency = mc; }
// @cmember Ritorna il valore del flag per i TCurrency automatici
const bool magic_currency() const
{ return _magic_currency; }
void enable_message_add(bool on) { _msg_add_enabled = on; } void enable_message_add(bool on) { _msg_add_enabled = on; }
void disable_message_add() { enable_message_add(FALSE); } void disable_message_add() { enable_message_add(FALSE); }
@ -430,6 +446,8 @@ public:
bool memo : 1; bool memo : 1;
// @cmember Indica se va stampato a inizio di pagina nuova // @cmember Indica se va stampato a inizio di pagina nuova
bool newpage : 1; bool newpage : 1;
// @cmember Indica (in caso di TForm_currency) se si tratta di un prezzo unitario
bool price : 1;
// @access Protected Member // @access Protected Member
protected: protected:
@ -456,6 +474,9 @@ public:
// @cmember Setta il flag di campo memo // @cmember Setta il flag di campo memo
void set_newpage (bool b) void set_newpage (bool b)
{ newpage = b; } { newpage = b; }
// @cmember Setta il flag di campo prezzo per TForm_currency
void set_price (bool b)
{ price = b; }
// @cmember Permette di stampare i flags sulla maschera di editing <p m> // @cmember Permette di stampare i flags sulla maschera di editing <p m>
void print_on(TMask& m); void print_on(TMask& m);
// @cmember Legge i flgs dalla maschera <p m> // @cmember Legge i flgs dalla maschera <p m>
@ -602,7 +623,7 @@ public:
// @cmember Ritorna il numero di campi da stampare // @cmember Ritorna il numero di campi da stampare
word fields() const word fields() const
{ return _item.items(); } { return word(_item.items()); }
// @cmember Ritorna il numero di campi stampabili (0 se non e' COLUMNWISE) // @cmember Ritorna il numero di campi stampabili (0 se non e' COLUMNWISE)
word columns() word columns()
{ tab(0); return _nfld; } { tab(0); return _nfld; }
@ -806,7 +827,7 @@ public:
{ return _effective_height; } { return _effective_height; }
// @cmember Imposta l'altezza effettiva del campo // @cmember Imposta l'altezza effettiva del campo
virtual void set_effective_height(int val) virtual void set_effective_height(int val)
{ _effective_height=val; } { _effective_height=short(val); }
// @cmember Formatta la stringa <p s>. Funzione che per default non fa nulla. // @cmember Formatta la stringa <p s>. Funzione che per default non fa nulla.
// Ridefinita solo per TForm_number e TForm_string. // Ridefinita solo per TForm_number e TForm_string.
virtual void apply_format(TString & s) const {} virtual void apply_format(TString & s) const {}
@ -1108,12 +1129,10 @@ protected:
virtual TToken_string& memo_info() { return _memo; } virtual TToken_string& memo_info() { return _memo; }
public: public:
virtual TObject* dup() const; virtual TObject* dup() const;
TFieldref& field(int i) const { return (TFieldref&)_field[i]; }
virtual const int fields() { return _field.items();} virtual const int fields() { return _field.items();}
virtual const TString& picture() const { return _picture; } virtual const TString& picture() const { return _picture; }
virtual void set_picture(const char* p) { _picture = p; } virtual void set_picture(const char* p) { _picture = p; }
virtual void apply_format(TString & s) const; virtual void apply_format(TString & s) const;
@ -1123,6 +1142,8 @@ public:
virtual const char* get() const; virtual const char* get() const;
virtual bool set(const char*); virtual bool set(const char*);
TFieldref& field(int i) const { return (TFieldref&)_field[i]; }
TForm_string(TPrint_section* section); TForm_string(TPrint_section* section);
virtual ~TForm_string() {} virtual ~TForm_string() {}
}; };

View File

@ -258,7 +258,7 @@ void __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout)
const char c = (t == _intzerofld || t == _longzerofld) ? '0' : ' '; const char c = (t == _intzerofld || t == _longzerofld) ? '0' : ' ';
for (i = l - len - 1; i >= 0; i--) for (i = l - len - 1; i >= 0; i--)
{ {
__field_changed |= recout[i] != c; __field_changed |= (recout[i] != c);
recout[i] = c; recout[i] = c;
} }
if (!__field_changed) if (!__field_changed)
@ -3185,7 +3185,8 @@ TRecnotype TRecfield::ptr() const
bool n = r > 127; bool n = r > 127;
if (n) r -= 128; if (n) r -= 128;
while(wp-- > (unsigned char*) _p) r = r << 8 + *wp; while(wp-- > (unsigned char*) _p)
r = (r << 8) + *wp;
return n ? -r : r; return n ? -r : r;
} }

View File

@ -46,5 +46,6 @@
#define NDT_DENEST1 "DENEST1" #define NDT_DENEST1 "DENEST1"
#define NDT_DENEST2 "DENEST2" #define NDT_DENEST2 "DENEST2"
#define NDT_DENEST3 "DENEST3" #define NDT_DENEST3 "DENEST3"
#define NDT_VALUTA "VALUTA"
#endif #endif

View File

@ -462,10 +462,8 @@ int sockbuf::sync()
#define CStringArray TString_array #define CStringArray TString_array
#include "NetSock.h" #include "NetSock.h"
#define STRICT
#include <windows.h> #include <windows.h>
static TLanManager* pSocketManager = NULL; static TLanManager* pSocketManager = NULL;
static skstream* cur_socket = NULL; static skstream* cur_socket = NULL;

View File

@ -38,6 +38,7 @@ void os_wake_up_caller();
void os_iconize_window(WINDOW win); void os_iconize_window(WINDOW win);
void os_maximize_window(WINDOW win); void os_maximize_window(WINDOW win);
void os_restore_window(WINDOW win);
int os_get_printer_names(TToken_string& printers); int os_get_printer_names(TToken_string& printers);
bool os_set_default_printer(const char* name); bool os_set_default_printer(const char* name);

View File

@ -1,6 +1,6 @@
#define XVT_INCL_NATIVE #define XVT_INCL_NATIVE
#define XI_INTERNAL #define XI_INTERNAL
#include <xinclude.h> #include <xi.h>
#include <os_dep.h> #include <os_dep.h>
#include <commdlg.h> #include <commdlg.h>
@ -16,127 +16,11 @@
#include <applicat.h> #include <applicat.h>
#include <colors.h> #include <colors.h>
#include <config.h>
#include <mask.h> #include <mask.h>
extern "C" { WINDOW xvtwi_hwnd_to_window(HWND); } extern "C" { WINDOW xvtwi_hwnd_to_window(HWND); }
// By Matt Pietrek
//########################################################################
// Code that does the real work
//########################################################################
#pragma hdrstop
#include "prochook.h"
//
// Central function that modifies a module table to trick the loader
// into letting a second instance of a multiple data segment program run.
//
HIDDEN int MungeModuleHeader( HINSTANCE hInstance, BOOL fMunge )
{
HMODULE hModuleSel;
LPSTR lpszModName, lpszFileName;
BYTE cbModuleName;
static BOOL fResidentNamesMunged = FALSE;
hModuleSel = SELECTOROF( // Convert the HINSTANCE to an HMODULE
GlobalLock(GetModuleHandle((LPSTR)MAKELP(0,hInstance))));
if ( hModuleSel == 0 ) // Make sure we succeeded.
return 0;
//
// First, we'll take care of the resident names table
//
if ( FALSE == fResidentNamesMunged )
{
// Make pointers to the module name in the resident names table
lpszModName = (LPSTR)MAKELP(hModuleSel,
*(WORD FAR *)MAKELP(hModuleSel, 0x26) );
// Get the module name length, and advance to the actual string
cbModuleName = *lpszModName++; // First byte is a length byte
// Convert the first uppercase letter of the modulename to lowercase
while ( cbModuleName )
{
if ( isupper(*lpszModName) )
{
*lpszModName = tolower(*lpszModName); break;
}
cbModuleName--; lpszModName++;
}
if ( cbModuleName == 0 ) // Make sure we succeeded
return 0;
// Remember that we've done this, so that we don't bother doing
// it in the future.
fResidentNamesMunged = TRUE;
}
//
// Now, we'll turn our attention to the module file name in the OFSTRUCT
//
lpszFileName = (LPSTR)MAKELP(hModuleSel,
*(WORD FAR *)MAKELP(hModuleSel, 0x0A));
// Position to the end of the filename. First byte is a length byte
lpszFileName += *lpszFileName - 1;
// If we're munging, added 0x30 to the last character value, otherwise
// subtract 0x30. 0x30 is chosen completely at random.
if ( fMunge )
*lpszFileName += 0x30;
else
*lpszFileName -= 0x30;
return 1;
}
//########################################################################
// This section watches calls to LoadModule and munges the EXE's module
// database as needed.
//########################################################################
HIDDEN NPHOOKCHILD npHookLoadModule = 0;
HIDDEN TFilename szOurFileName;
HIDDEN HINSTANCE HInstance;
HINSTANCE
WINAPI
__export MultInst95LoadModule( LPCSTR lpszModuleName,
LPVOID lpvParameterBlock )
{
HINSTANCE retValue;
// Uppercase the name of the module name that was passed to LoadModule
TFilename szNewFileName(lpszModuleName);
szNewFileName.upper();
// Compare the incoming filename to our EXE's module name. If they
// don't match, we don't need to bother munging the module database
BOOL fSecondInstance = szOurFileName.find(szNewFileName) >= 0;
// Unhook our LoadModule hook so that we can call the real LoadModule
ProcUnhook( npHookLoadModule );
// Munge module database if needed
if ( fSecondInstance )
MungeModuleHeader( HInstance, TRUE );
// Call the original LoadModule code
retValue = LoadModule( lpszModuleName, lpvParameterBlock );
// Unmunge module database if needed
if ( fSecondInstance )
MungeModuleHeader( HInstance, FALSE );
// Reinstall our LoadModule hook so that we see future loads
ProcHook( npHookLoadModule );
return retValue;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Win16 event hook // Win16 event hook
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -206,39 +90,7 @@ HIDDEN BOOLEAN event_hook(HWND hwnd,
bool os_allow_another_instance() bool os_allow_another_instance()
{ {
if ( npHookLoadModule ) return TRUE;
return TRUE;
#ifdef DBG
bool noMunge = getenv("NOMUNGE") != NULL;
if (noMunge)
return FALSE;
#endif
#ifndef ATTR_WIN_USE_CTL3D
Ctl3dRegister(HInstance);
Ctl3dAutoSubclass(HInstance);
#endif
HInstance = (HINSTANCE)xvt_vobj_get_attr(NULL_WIN, ATTR_WIN_INSTANCE);
// Get the EXE's filename into a global string variable and uppercase it
GetModuleFileName( HInstance, szOurFileName.get_buffer(), szOurFileName.size() );
szOurFileName.upper();
// Create a MakeProcInstance thunk so that our callback function
// will always be using the correct DS selector
FARPROC lpfnMPI
= MakeProcInstance( (FARPROC)MultInst95LoadModule, HInstance );
if ( !lpfnMPI )
return FALSE;
// Call PROCHOOK.DLL to hook calls to LoadModule
npHookLoadModule = SetProcAddress( (FARPROC)LoadModule,
lpfnMPI, FALSE );
return npHookLoadModule != NULL;
} }
COLOR os_choose_color(COLOR col, WINDOW win) COLOR os_choose_color(COLOR col, WINDOW win)
@ -301,15 +153,6 @@ COLOR os_choose_color(COLOR col, WINDOW win)
bool os_deny_another_instance() bool os_deny_another_instance()
{ {
if ( !npHookLoadModule )
return FALSE;
SetProcRelease( npHookLoadModule );
npHookLoadModule = 0;
#ifndef ATTR_WIN_USE_CTL3D
Ctl3dUnregister(HInstance);
#endif
return TRUE; return TRUE;
} }
@ -448,9 +291,14 @@ int os_execute(const TFilename& path, bool sync, bool iconizetask, bool showchil
if (sync) if (sync)
{ {
TTemp_window tw(TASK_WIN); bool was_maximized = FALSE;
if (iconizetask) if (iconizetask)
{ {
TTemp_window tw(TASK_WIN);
RCT rct_scr, rct_tsk;
xvt_vobj_get_client_rect(SCREEN_WIN, &rct_scr);
xvt_vobj_get_client_rect(tw.win(), &rct_tsk);
was_maximized = rct_scr.right == rct_tsk.right;
tw.iconize(); tw.iconize();
tw.deactivate(); tw.deactivate();
} }
@ -481,7 +329,11 @@ int os_execute(const TFilename& path, bool sync, bool iconizetask, bool showchil
if (iconizetask) if (iconizetask)
{ {
tw.maximize(); TTemp_window tw(TASK_WIN);
if (was_maximized)
tw.maximize(); // Non e' piu' detto che sia massimizzata!
else
os_restore_window(tw.win());
tw.activate(); tw.activate();
} }
@ -516,7 +368,7 @@ int os_get_printer_names(TToken_string& t)
{ {
if (buf[i] == '\0') if (buf[i] == '\0')
{ {
if (buf[i+1] != '\0') buf[i] = t.separator(); if (buf[i+1] != '\0') buf[i] = '|';
else break; else break;
} }
} }
@ -592,10 +444,10 @@ void os_set_event_hook()
long twin_style = WSF_ICONIZABLE | WSF_CLOSE | WSF_SIZE; long twin_style = WSF_ICONIZABLE | WSF_CLOSE | WSF_SIZE;
const int scx = GetSystemMetrics(SM_CXSCREEN); const int scx = GetSystemMetrics(SM_CXSCREEN);
const int scy = GetSystemMetrics(SM_CYSCREEN);
static RCT rct; static RCT rct;
if (scx <= 640 && os_get_type() >= os_Windows95) if (scx <= 640 && os_get_type() >= os_Windows95)
{ {
const int scy = GetSystemMetrics(SM_CYSCREEN);
const int bcx = GetSystemMetrics(SM_CXFRAME); const int bcx = GetSystemMetrics(SM_CXFRAME);
const int bcy = GetSystemMetrics(SM_CYFRAME); const int bcy = GetSystemMetrics(SM_CYFRAME);
rct.left = -bcx; rct.left = -bcx;
@ -609,11 +461,15 @@ void os_set_event_hook()
TConfig cfg(CONFIG_USER, "Colors"); TConfig cfg(CONFIG_USER, "Colors");
const int res = cfg.get_int("Resolution"); const int res = cfg.get_int("Resolution");
if (res >= 640 && res < scx) if (res >= 640 && res < scx)
{ {
rct.left = 0; const int width = res + 2*GetSystemMetrics(SM_CXFRAME);
rct.top = GetSystemMetrics(SM_CYCAPTION); const int height = (res * 3) / 4 + 2*GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYCAPTION) - 1;
rct.right = res + 2*GetSystemMetrics(SM_CXFRAME); const int deltax = (scx - width) / 2;
rct.bottom = (res * 3) / 4 + 2*GetSystemMetrics(SM_CYFRAME); const int deltay = (scy - height) / 2;
rct.left = deltax;
rct.top = deltay;
rct.right = deltax + width;
rct.bottom = deltay + height;
xvt_vobj_set_attr(NULL_WIN, ATTR_WIN_PM_TWIN_STARTUP_RCT, long(&rct)); xvt_vobj_set_attr(NULL_WIN, ATTR_WIN_PM_TWIN_STARTUP_RCT, long(&rct));
} }
else else
@ -669,7 +525,25 @@ void os_iconize_window(WINDOW win)
void os_maximize_window(WINDOW win) void os_maximize_window(WINDOW win)
{ {
HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW); HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_SHOWMAXIMIZED); HWND twin = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
if (hwnd != twin)
{
HWND pare = GetParent(hwnd);
RECT rct; GetClientRect(pare, &rct);
if (pare == twin)
rct.bottom -= 24;
SetWindowPos(hwnd, pare,
rct.left, rct.top, rct.right, rct.bottom,
SWP_NOZORDER);
}
else
ShowWindow(hwnd, SW_SHOWMAXIMIZED);
}
void os_restore_window(WINDOW win)
{
HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_NORMAL);
} }
bool os_dongle_server_running() bool os_dongle_server_running()

View File

@ -289,9 +289,14 @@ int os_execute(const TFilename& path, bool sync, bool iconizetask, bool showchil
WaitForInputIdle(hProcess, INFINITE); WaitForInputIdle(hProcess, INFINITE);
TTemp_window tw(TASK_WIN); bool was_maximized = FALSE;
if (iconizetask) if (iconizetask)
{ {
TTemp_window tw(TASK_WIN);
RCT rct_scr, rct_tsk;
xvt_vobj_get_client_rect(SCREEN_WIN, &rct_scr);
xvt_vobj_get_client_rect(tw.win(), &rct_tsk);
was_maximized = rct_scr.right == rct_tsk.right;
tw.iconize(); tw.iconize();
tw.deactivate(); tw.deactivate();
} }
@ -310,7 +315,11 @@ int os_execute(const TFilename& path, bool sync, bool iconizetask, bool showchil
if (iconizetask) if (iconizetask)
{ {
tw.maximize(); TTemp_window tw(TASK_WIN);
if (was_maximized)
tw.maximize();
else
os_restore_window(tw.win());
tw.activate(); tw.activate();
do_events(); do_events();
} }
@ -430,10 +439,10 @@ void os_set_event_hook()
long twin_style = WSF_ICONIZABLE | WSF_CLOSE | WSF_SIZE; long twin_style = WSF_ICONIZABLE | WSF_CLOSE | WSF_SIZE;
const int scx = GetSystemMetrics(SM_CXSCREEN); const int scx = GetSystemMetrics(SM_CXSCREEN);
const int scy = GetSystemMetrics(SM_CYSCREEN);
static RCT rct; static RCT rct;
if (scx <= 640 && os_get_type() >= os_Windows95) if (scx <= 640 && os_get_type() >= os_Windows95)
{ {
const int scy = GetSystemMetrics(SM_CYSCREEN);
const int bcx = GetSystemMetrics(SM_CXFRAME); const int bcx = GetSystemMetrics(SM_CXFRAME);
const int bcy = GetSystemMetrics(SM_CYFRAME); const int bcy = GetSystemMetrics(SM_CYFRAME);
rct.left = -bcx; rct.left = -bcx;
@ -448,10 +457,14 @@ void os_set_event_hook()
const int res = cfg.get_int("Resolution"); const int res = cfg.get_int("Resolution");
if (res >= 640 && res < scx) if (res >= 640 && res < scx)
{ {
rct.left = 0; const int width = res + 2*GetSystemMetrics(SM_CXFRAME);
rct.top = GetSystemMetrics(SM_CYCAPTION); const int height = (res * 3) / 4 + 2*GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYCAPTION) - 1;
rct.right = res + 2*GetSystemMetrics(SM_CXFRAME); const int deltax = (scx - width) / 2;
rct.bottom = (res * 3) / 4 + 2*GetSystemMetrics(SM_CYFRAME); const int deltay = (scy - height) / 2;
rct.left = deltax;
rct.top = deltay;
rct.right = deltax + width;
rct.bottom = deltay + height;
xvt_vobj_set_attr(NULL_WIN, ATTR_WIN_PM_TWIN_STARTUP_RCT, long(&rct)); xvt_vobj_set_attr(NULL_WIN, ATTR_WIN_PM_TWIN_STARTUP_RCT, long(&rct));
} }
else else
@ -496,11 +509,29 @@ void os_iconize_window(WINDOW win)
void os_maximize_window(WINDOW win) void os_maximize_window(WINDOW win)
{ {
HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW); HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_SHOWMAXIMIZED); HWND twin = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
if (hwnd != twin)
{
HWND pare = GetParent(hwnd);
RECT rct; GetClientRect(pare, &rct);
if (pare == twin)
rct.bottom -= 24;
SetWindowPos(hwnd, pare,
rct.left, rct.top, rct.right, rct.bottom,
SWP_NOZORDER);
}
else
ShowWindow(hwnd, SW_SHOWMAXIMIZED);
}
void os_restore_window(WINDOW win)
{
HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_NORMAL);
} }
bool os_dongle_server_running() bool os_dongle_server_running()
{ {
ATOM a = GlobalFindAtom("DONGLE_SERVER_ATOM"); ATOM a = GlobalFindAtom("DONGLE_SERVER_ATOM");
return a != 0; return a != 0;
} }

View File

@ -1,6 +1,6 @@
#include <codeb.h> #include <codeb.h>
#include <extcdecl.h> #include <extcdecl.h>
#include <currency.h>
#include <prefix.h> #include <prefix.h>
#include <progind.h> #include <progind.h>
#include <scanner.h> #include <scanner.h>
@ -324,7 +324,7 @@ int TFile_info::close_low()
DB_close(_handle); DB_close(_handle);
_handle = -1; _handle = -1;
_last_key = -1; _last_key = -1;
_exclusive = _locked = FALSE; _exclusive = _locked = FALSE;
} }
else else
{ {
@ -352,6 +352,7 @@ int TFile_info::open(bool exclusive, bool index)
_exclusive = _locked = TRUE; _exclusive = _locked = TRUE;
err = open_low(exclusive, index); err = open_low(exclusive, index);
} }
touch(); // Memorizza ora apertura del file
_ref_count++; _ref_count++;
return err; return err;
} }
@ -647,7 +648,7 @@ TCodeb_handle TFile_manager::get_handle(TIsam_handle name, int key)
if (i.last_key() != key) if (i.last_key() != key)
handle = i.auto_open(key); handle = i.auto_open(key);
} }
i.touch(); // i.touch(); // Memorizza troppo spesso l'accesso
return handle; return handle;
} }
@ -770,13 +771,72 @@ TFile_manager::TFile_manager()
_max_open_files = 32; _max_open_files = 32;
} }
///////////////////////////////////////////////////////////
// TFirm
///////////////////////////////////////////////////////////
bool TFirm::read(long cod)
{
int err = NOERR;
if (cod < 0L)
cod = prefix().get_codditta();
_rec.destroy();
if (cod > 0L)
{
TLocalisamfile ditte(LF_NDITTE);
ditte.put("CODDITTA", cod);
err = ditte.read();
if (err == NOERR)
{
const TRectype& ditta = ditte.curr();
for (int f = ditta.items()-1; f >= 0; f--)
{
const char* name = ditta.fieldname(f);
_rec.add(name, ditta.get(name));
}
}
else
NFCHECK("Can't read firm %ld: error %d", cod, err);
}
return _rec.items() > 0;
}
const TString& TFirm::get(const char* attr) const
{
const TString* str = (const TString*)_rec.objptr(attr);
if (str == NULL)
str = &EMPTY_STRING;
return *str;
}
long TFirm::get_long(const char* attr) const
{ return atol(get(attr)); }
long TFirm::codice() const
{
return get_long(NDT_CODDITTA);
}
const TString& TFirm::codice_valuta() const
{
const TString& codval = get(NDT_VALUTA);
if (codval.empty())
return TCurrency::get_base_val();
return codval;
}
TFirm::TFirm(long code)
{
read(code);
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TPrefix // TPrefix
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
HIDDEN const char* const glockname = "xx"; HIDDEN const char* const glockname = "xx";
TPrefix::TPrefix() : _filelevel(0), _items(0) TPrefix::TPrefix() : _filelevel(0), _items(0), _firm(NULL)
{ {
_prefix = "."; _prefix = ".";
CGetPref(); CGetPref();
@ -792,6 +852,7 @@ TPrefix::TPrefix() : _filelevel(0), _items(0)
TPrefix::~TPrefix() TPrefix::~TPrefix()
{ {
if (_firm) delete _firm;
set(); set();
DB_exit(); DB_exit();
} }
@ -940,7 +1001,11 @@ bool TPrefix::set_codditta(long codditta, bool force)
{ {
TString16 s("com"); TString16 s("com");
if (codditta > 0L) if (codditta > 0L)
s.format("%05lda", codditta); {
s.format("%05lda", codditta);
if (_firm)
_firm->read(codditta);
}
set(s, force); set(s, force);
CPutPref(_prefix); CPutPref(_prefix);
return TRUE; return TRUE;
@ -1026,6 +1091,13 @@ const char* TPrefix::description(int cod) const
return description(n); return description(n);
} }
const TFirm& TPrefix::firm()
{
if (_firm == NULL)
_firm = new TFirm;
return *_firm;
}
// Certified 90% // Certified 90%
// @doc EXTERNAL // @doc EXTERNAL

View File

@ -60,6 +60,31 @@ public:
virtual ~TFile_manager() { } virtual ~TFile_manager() { }
}; };
// @doc EXTERNAL
// @class TFirm | Classe contenente le informazioni sulla ditta correntemente in uso
//
// @base public | TObject
class TFirm : public TObject
{
TAssoc_array _rec;
protected:
const TString& get(const char* attr) const;
long get_long(const char* attr) const;
public:
bool read(long code);
TFirm& operator=(long code) { read(code); return *this; }
long codice() const;
const TString& codice_valuta() const;
virtual bool ok() const { return codice() > 0L; }
TFirm(long code = -1L);
virtual ~TFirm() { }
};
// @doc EXTERNAL // @doc EXTERNAL
@ -81,6 +106,8 @@ class TPrefix : public TObject
int _items; int _items;
TFile_manager _manager; TFile_manager _manager;
TFirm* _firm;
// @access Protected Member // @access Protected Member
protected: protected:
@ -171,6 +198,8 @@ public:
long last_change(TIsam_handle name) const long last_change(TIsam_handle name) const
{ return _manager.last_change(name); } { return _manager.last_change(name); }
const TFirm& firm();
// @cmember Costruttore // @cmember Costruttore
TPrefix(); TPrefix();
// @cmember Distruttore // @cmember Distruttore

View File

@ -430,10 +430,11 @@ const char* FLD (const char *tabname, const char *f, const char *picture)
TString& fill_str (TString & t, char f) TString& fill_str (TString & t, char f)
{ {
for (int kk = t.len () - 1; kk >= 0; kk--) const int len = t.len();
for (int kk = len - 1; kk >= 0; kk--)
if (t[kk] == ' ') t[kk] = f; if (t[kk] == ' ') t[kk] = f;
else break; else break;
for (kk = 0; kk < t.len (); kk++) for (kk = 0; kk < len; kk++)
if (t[kk] == ' ') t[kk] = f; if (t[kk] == ' ') t[kk] = f;
else break; else break;
return t; return t;
@ -837,7 +838,10 @@ void TPrint_application::set_row (
if (_magic_currency) if (_magic_currency)
{ {
if (size >= 9 && dec == 0 && _picture.find(',') < 0) if (size >= 9 && dec == 0 && _picture.find(',') < 0)
{
flags |= VALUTA_FLAG; flags |= VALUTA_FLAG;
flags &= ~PAD_FLAG;
}
else else
flags |= NUMBER_FLAG; flags |= NUMBER_FLAG;
} }
@ -849,6 +853,7 @@ void TPrint_application::set_row (
// fall down // fall down
case 'v': case 'v':
flags |= VALUTA_FLAG; flags |= VALUTA_FLAG;
flags &= ~PAD_FLAG;
break; break;
default: default:
CHECK (0, "TPrint_application::set_row: invalid @ code"); CHECK (0, "TPrint_application::set_row: invalid @ code");
@ -874,7 +879,7 @@ void TPrint_application::set_row (
case '#': case '#':
case '%': case '%':
{ {
char ccc = ch; const char ccc = ch;
// check for pending string // check for pending string
if (strind) if (strind)
{ {
@ -956,7 +961,7 @@ void TPrint_application::set_row (
if (_magic_currency) if (_magic_currency)
{ {
if (_picture == "." || (_picture.len() >= 9 && _picture.find(',') < 0)) if (_picture == "." || (_picture.len() >= 9 && _picture.find(',') < 0))
real2currency(rrr, q); real2currency(q, rrr);
} }
if (q.empty()) if (q.empty())
q = rrr.string(_picture); q = rrr.string(_picture);
@ -975,6 +980,18 @@ void TPrint_application::set_row (
q.fill (' ', q.len()); q.fill (' ', q.len());
} }
break; break;
case 'v': // Currency
{
const TCurrency& cur = *va_arg(params, TCurrency*);
if (cur.get_num().is_zero() && !_print_zero)
q.cut(0);
else
q = cur.string(_picture.find('.') >= 0);
const int width = atoi(formato.mid(1,-1));
if (width > 0)
q.right_just(width);
}
break;
default: default:
break; break;
} }
@ -1154,16 +1171,17 @@ bool TPrint_application::print_tree (link_item * head)
return go; return go;
} }
void TPrint_application::real2currency(const real& r, TString& str) const void TPrint_application::real2currency(TString& s, const real& r, const char* p) const
{ {
TCurrency c(r, "_FIRM"); TCurrency c(r, "_FIRM");
if (_curr_codval.not_empty()) if (_curr_codval.not_empty())
c.change_value(_curr_codval); c.change_value(_curr_codval);
const bool dotted = _picture.empty() || _picture.find('.') >= 0; const TString80 pic = (p && *p) ? p : _picture;
str = c.string(dotted); const bool dotted = pic.empty() || pic.find('.') >= 0;
const int len = _picture.len(); s = c.string(dotted);
const int len = pic.len();
if (len >= 9) if (len >= 9)
str.right_just(len); s.right_just(len);
} }
// @doc INTERNAL // @doc INTERNAL
@ -1346,7 +1364,7 @@ bool TPrint_application::print_one (
else if (ft->_flags & VALUTA_FLAG) else if (ft->_flags & VALUTA_FLAG)
{ {
const real n = f.get(fn); const real n = f.get(fn);
real2currency(n, toprint); real2currency(toprint, n);
} }
} }
// adjust size and set fill char // adjust size and set fill char

View File

@ -309,7 +309,7 @@ public:
int set_bookmark(const char* txt, int father = -1); int set_bookmark(const char* txt, int father = -1);
// @cmember Converte un real nella stringa generata da un currency // @cmember Converte un real nella stringa generata da un currency
void real2currency(const real& r, TString& str) const; void real2currency(TString& s, const real& r, const char* p = NULL) const;
// @cmember Permette di trovare un link ipertestuale // @cmember Permette di trovare un link ipertestuale
int find_link(const char* descr) const; int find_link(const char* descr) const;

View File

@ -12,7 +12,7 @@ HIDDEN int LEN_SPACES(WINDOW win, int x)
} }
if (w == 0L) if (w == 0L)
{ {
TString256 spc; spc.fill('m', 132); TString spc(132, 'm');
w = xvt_dwin_get_text_width(win, spc.get_buffer(), 132); w = xvt_dwin_get_text_width(win, spc.get_buffer(), 132);
} }
const int k = int((w*x) / 132); const int k = int((w*x) / 132);
@ -291,7 +291,7 @@ bool TPrintwin::do_print()
#endif #endif
ok = print_band(page, *rct); ok = print_band(page, *rct);
} }
_aborted |= xvt_print_close_page(_printrcd) == 0; _aborted |= (xvt_print_close_page(_printrcd) == 0);
page++; page++;
} }
return !_aborted; return !_aborted;

View File

@ -50,6 +50,10 @@
#define RDOC_QTAGG5 "QTAGG5" #define RDOC_QTAGG5 "QTAGG5"
#define RDOC_IMPIANTO "IMPIANTO" #define RDOC_IMPIANTO "IMPIANTO"
#define RDOC_LINEA "LINEA" #define RDOC_LINEA "LINEA"
#define RDOC_DACODNUM "DACODNUM"
#define RDOC_DAANNO "DAANNO"
#define RDOC_DAPROVV "DAPROVV"
#define RDOC_DANDOC "DANDOC"
#endif #endif

View File

@ -584,29 +584,45 @@ int TRelation_application::delete_mode()
} }
} }
int tasto;
sht.open(); sht.open();
while ((tasto = sht.run()) == K_ENTER)
KEY tasto;
bool keep_running = TRUE;
while (keep_running)
{ {
TRectype rec_from(cur.file().num()), rec_to(cur.file().num()); tasto = sht.run();
for(int k = 0; k < keys.items(); k++) if (tasto == K_ENTER)
{
TEditable_field& e = (TEditable_field&)keys[k];
const TFieldref* ref = e.field();
if (ref)
{
const TString& fr = e.enabled() ? sht.get(e.dlg()+1000) : e.get();
ref->write(fr, rec_from);
const TString& to = e.enabled() ? sht.get(e.dlg()+2000) : e.get();
if (to.not_empty()) ref->write(to, rec_to);
}
}
cur.curr() = rec_from;
cur.read();
while (cur.file().status() == NOERR && cur.curr() <= rec_to)
{ {
sht.check(cur.pos()); TRectype rec_from(cur.file().num()), rec_to(cur.file().num());
++cur; for(int k = 0; k < keys.items(); k++)
{
TEditable_field& e = (TEditable_field&)keys[k];
const TFieldref* ref = e.field();
if (ref)
{
const TString& fr = e.enabled() ? sht.get(e.dlg()+1000) : e.get();
ref->write(fr, rec_from);
const TString& to = e.enabled() ? sht.get(e.dlg()+2000) : e.get();
if (to.not_empty()) ref->write(to, rec_to);
}
}
cur.curr() = rec_from;
cur.read();
while (cur.file().status() == NOERR && cur.curr() <= rec_to)
{
sht.check(cur.pos());
++cur;
}
}
else
{
keep_running = FALSE;
if (tasto == K_DEL && sht.checked() == 0)
{
error_box("Non e' stato selezionato nessun documento");
sht.select(0);
keep_running = TRUE;
}
} }
} }
sht.close(); sht.close();
@ -614,62 +630,56 @@ int TRelation_application::delete_mode()
if (tasto == K_DEL) if (tasto == K_DEL)
{ {
long deleting = sht.checked(); long deleting = sht.checked();
if (deleting > 0) TString msg;
{ msg = "Confermate l'eliminazione de";
TString msg; if (deleting == 1)
msg = "Confermate l'eliminazione de"; msg << "l documento selezionato?";
if (deleting == 1)
msg << "l documento selezionato?";
else
msg << "i " << deleting << " documenti selezionati?";
bool can_delete = yesno_box(msg);
if (can_delete && deleting > 100)
{
msg.insert("ATTENZIONE: ", 0);
can_delete = yesno_box(msg);
}
if (can_delete)
{
TWait_cursor hourglass;
long skipped = 0; // Record non cancellati perche' protetti
cur.freeze(TRUE); // Congelo il cursore altrimenti si riaggiorna troppo
for (long pos = 0; deleting > 0; pos++)
{
if (sht.checked(pos))
{
cur = pos;
brw->do_output();
bool can_delete = FALSE;
if (find(1))
{
_autodelete = 0x3;
if (modify_mode())
{
can_delete = !protected_record(get_relation()->curr());
if (can_delete)
remove();
query_mode();
}
_autodelete = FALSE;
}
if (!can_delete)
skipped++;
deleting--;
}
}
cur.freeze(FALSE);
if (skipped > 0)
{
if (skipped == 1)
warning_box("Un documento non e' stato cancellato in quanto protetto.");
else
warning_box("%ld documenti non sono stati cancellati in quanto protetti.");
}
}
}
else else
error_box("Non e' stato selezionato nessun documento"); msg << "i " << deleting << " documenti selezionati?";
bool can_delete = yesno_box(msg);
if (can_delete && deleting > 100)
{
msg.insert("ATTENZIONE: ", 0);
can_delete = yesno_box(msg);
}
if (can_delete)
{
TWait_cursor hourglass;
long skipped = 0; // Record non cancellati perche' protetti
cur.freeze(TRUE); // Congelo il cursore altrimenti si riaggiorna troppo
for (long pos = 0; deleting > 0; pos++)
{
if (sht.checked(pos))
{
cur = pos;
brw->do_output();
bool can_delete = FALSE;
if (find(1))
{
_autodelete = 0x3;
if (!protected_record(get_relation()->curr()))
{
if (modify_mode())
can_delete = remove();
}
query_mode();
_autodelete = FALSE;
}
if (!can_delete)
skipped++;
deleting--;
}
}
cur.freeze(FALSE);
if (skipped > 0)
{
if (skipped == 1)
warning_box("Un documento non e' stato cancellato in quanto protetto.");
else
warning_box("%ld documenti non sono stati cancellati in quanto protetti.", skipped);
}
}
} }
} }
else else

View File

@ -31,7 +31,11 @@ typedef unsigned short UINT16;
// @doc EXTERNAL // @doc EXTERNAL
// @type UINT32 | Altro nome di assegnazione per gli unsigned long // @type UINT32 | Altro nome di assegnazione per gli unsigned long
#ifdef WIN32
typedef unsigned int UINT32;
#else
typedef unsigned long UINT32; typedef unsigned long UINT32;
#endif
// @doc EXTERNAL // @doc EXTERNAL
// @type INT8 | Altro nome di assegnazione per i char // @type INT8 | Altro nome di assegnazione per i char
@ -42,7 +46,11 @@ typedef short INT16;
// @doc EXTERNAL // @doc EXTERNAL
// @type INT32 | Altro nome di assegnazione per i long // @type INT32 | Altro nome di assegnazione per i long
#ifdef WIN32
typedef int INT32;
#else
typedef long INT32; typedef long INT32;
#endif
// @doc EXTERNAL // @doc EXTERNAL
// @type bool | Tipo booleano che puo' assumere i valori TRUE (definito come 1) // @type bool | Tipo booleano che puo' assumere i valori TRUE (definito come 1)

View File

@ -60,26 +60,28 @@ style TTextfile::_trans_style (char ch)
void TTextfile::_save_changes() void TTextfile::_save_changes()
{ {
begin_wait(); TWait_cursor hourglass;
// fa i dovuti replace anche sul disco (solo replace di linee esistenti) // fa i dovuti replace anche sul disco (solo replace di linee esistenti)
long line = 0l; long line = 0l;
fclose(_index); fclose(_index);
remove(_indname); remove(_indname);
TString oldfile(_filename); const TString oldfile(_filename);
_filename.temp("txtf"); _filename.temp("txtf");
FILE* newf = fopen(_filename, "a+"); FILE* newf = fopen(_filename, "a+");
if ((_index = fopen(_indname, "w+b")) == NULL || newf == NULL) if ((_index = fopen(_indname, "w+b")) == NULL || newf == NULL)
{ {
yesnofatal_box ("Impossibile aprire files temporanei"); NFCHECK("Impossibile aprire files temporanei");
freeze(); freeze();
return; return;
} }
fseek(_instr, 0l, SEEK_SET); // fseek(_instr, 0l, SEEK_SET);
rewind(_instr);
while (!feof(_instr)) while (!feof(_instr))
{ {
@ -116,8 +118,6 @@ void TTextfile::_save_changes()
rename(_filename, oldfile); rename(_filename, oldfile);
_filename = oldfile; _filename = oldfile;
_instr = fopen(_filename, "a+"); _instr = fopen(_filename, "a+");
end_wait();
} }
void TTextfile::_read_page (long n) void TTextfile::_read_page (long n)
@ -541,7 +541,7 @@ const char *TTextfile::line_formatted(
long TTextfile::get_attribute (int pos) long TTextfile::get_attribute (int pos)
{ {
long stl = 0; long stl = 0;
if (pos < 0) if (pos == -1)
{ {
CHECK (_item > 0, "must execute piece() before style()!"); CHECK (_item > 0, "must execute piece() before style()!");
stl = _styles[_item - 1]; stl = _styles[_item - 1];
@ -686,7 +686,7 @@ bool TTextfile::append (
_lines++; _lines++;
_dirty = TRUE; _dirty = TRUE;
if (_lines < (_page_start + _page_size)) if ((_lines) < (_page_start + _page_size))
{ {
if (_interactive) if (_interactive)
{ {
@ -725,17 +725,18 @@ bool TTextfile::append (
void TTextfile::close () void TTextfile::close ()
{ {
CHECK (_isopen,"Attempt operation on closed file"); if (_isopen)
fclose (_instr); {
fclose (_index); fclose (_instr);
_instr = _index = NULL; fclose (_index);
_isopen = FALSE; _instr = _index = NULL;
_isopen = FALSE;
}
} }
void TTextfile::print () void TTextfile::print ()
{ {
CHECK (_isopen, "Attempt operation on closed file"); NFCHECK("Funzione non ancora implementata");
warning_box ("Funzione non ancora implementata");
// TBI istanzia una printer inibendo la scelta di video // TBI istanzia una printer inibendo la scelta di video
// add all lines (maybe new method: print_txt) // add all lines (maybe new method: print_txt)
// print // print
@ -819,7 +820,7 @@ void TTextfile::write(
void TTextfile::destroy () void TTextfile::destroy ()
{ {
CHECK (_istemp, "destroy() chiamata su testo permanente!"); CHECK(_istemp, "destroy() chiamata su testo permanente!");
if (_page.items () > 0) if (_page.items () > 0)
{ {
if (_index) if (_index)

View File

@ -70,7 +70,7 @@ HIDDEN bool callback_find_brother(TTree& node, void* jolly, word when)
bool TTree::scan_depth_first(NODE_HANDLER nh, void* jolly, word flags) bool TTree::scan_depth_first(NODE_HANDLER nh, void* jolly, word flags)
{ {
if ((flags & 0x7) == 0); if ((flags & 0x7) == 0)
flags |= SCAN_PRE_ORDER; flags |= SCAN_PRE_ORDER;
bool test_myself = TRUE; bool test_myself = TRUE;
@ -115,7 +115,7 @@ bool TTree::scan_depth_first(NODE_HANDLER nh, void* jolly, word flags)
bool TTree::scan_breadth_first(NODE_HANDLER nh, void* jolly, word flags) bool TTree::scan_breadth_first(NODE_HANDLER nh, void* jolly, word flags)
{ {
if ((flags & 0x7) == 0); if ((flags & 0x7) == 0)
flags |= SCAN_PRE_ORDER; flags |= SCAN_PRE_ORDER;
bool test_myself = TRUE; bool test_myself = TRUE;
@ -297,7 +297,7 @@ TImage* TTree::image(bool selected) const
bool TBidirectional_tree::scan_depth_first(NODE_HANDLER nh, void* jolly, word flags) bool TBidirectional_tree::scan_depth_first(NODE_HANDLER nh, void* jolly, word flags)
{ {
if ((flags & 0x7) == 0); if ((flags & 0x7) == 0)
flags |= SCAN_PRE_ORDER; flags |= SCAN_PRE_ORDER;
bool test_myself = TRUE; bool test_myself = TRUE;
@ -339,7 +339,7 @@ bool TBidirectional_tree::scan_depth_first(NODE_HANDLER nh, void* jolly, word fl
bool TBidirectional_tree::scan_breadth_first(NODE_HANDLER nh, void* jolly, word flags) bool TBidirectional_tree::scan_breadth_first(NODE_HANDLER nh, void* jolly, word flags)
{ {
if ((flags & 0x7) == 0); if ((flags & 0x7) == 0)
flags |= SCAN_PRE_ORDER; flags |= SCAN_PRE_ORDER;
bool test_myself = TRUE; bool test_myself = TRUE;

View File

@ -12,7 +12,7 @@
#include <bagn005.h> #include <bagn005.h>
const char* const PRINT_FONT = XVT_FFN_FIXED; const char* const PRINT_FONT = XVT_FFN_FIXED;
const int PRINT_HEIGHT = 10; int PRINT_HEIGHT = 10;
#define BUTTONROW_SIZE (_showbuts ? 4 : 0) #define BUTTONROW_SIZE (_showbuts ? 4 : 0)
#define X_OFFSET (_rulers ? 6 : 1) #define X_OFFSET (_rulers ? 6 : 1)
@ -74,6 +74,7 @@ public:
int TViswin::tabx(int x) const int TViswin::tabx(int x) const
{ {
/*
HIDDEN long w = 0L; HIDDEN long w = 0L;
if (w == 0L) if (w == 0L)
{ {
@ -81,6 +82,8 @@ int TViswin::tabx(int x) const
w = xvt_dwin_get_text_width(win(), (char*)(const char*)t, 256); w = xvt_dwin_get_text_width(win(), (char*)(const char*)t, 256);
} }
return int((w*x) >> 8); return int((w*x) >> 8);
*/
return char2pixel(x);
} }
int TViswin::taby(int y) const int TViswin::taby(int y) const
@ -888,6 +891,7 @@ void TViswin::paint_row (long j)
autoscroll(FALSE); autoscroll(FALSE);
set_font(PRINT_FONT, XVT_FS_NONE, PRINT_HEIGHT); set_font(PRINT_FONT, XVT_FS_NONE, PRINT_HEIGHT);
set_mode(M_COPY); set_mode(M_COPY);
set_opaque_text(TRUE); set_opaque_text(TRUE);
if (_rulers) if (_rulers)
@ -920,6 +924,7 @@ void TViswin::paint_row (long j)
const COLOR bg = trans_color (_txt.get_background()); const COLOR bg = trans_color (_txt.get_background());
const COLOR fg = trans_color (_txt.get_foreground()); const COLOR fg = trans_color (_txt.get_foreground());
set_font(PRINT_FONT, st, PRINT_HEIGHT); set_font(PRINT_FONT, st, PRINT_HEIGHT);
set_color(fg, bg); set_color(fg, bg);
stringat(X_OFFSET+pos, row, cp); stringat(X_OFFSET+pos, row, cp);
@ -928,7 +933,7 @@ void TViswin::paint_row (long j)
if (_scrolling && (pos < _textcolumns)) if (_scrolling && (pos < _textcolumns))
{ {
set_color (COLOR_BLACK, COLOR_WHITE); set_color (COLOR_BLACK, COLOR_WHITE);
TString80 fill; fill.spaces(80); TString256 fill; fill.spaces(256);
stringat(X_OFFSET+pos, row, fill); stringat(X_OFFSET+pos, row, fill);
} }
@ -1000,8 +1005,9 @@ void TViswin::paint_column (
const char *c = (const char *) _txt.line (riga_txt); const char *c = (const char *) _txt.line (riga_txt);
int st = _txt.get_style ((int) j); const int st = _txt.get_style ((int) j);
set_font (PRINT_FONT, st, PRINT_HEIGHT); set_font (PRINT_FONT, st, PRINT_HEIGHT);
COLOR bg = trans_color (_txt.get_background ((int) j)); COLOR bg = trans_color (_txt.get_background ((int) j));
COLOR fg = trans_color (_txt.get_foreground ((int) j)); COLOR fg = trans_color (_txt.get_foreground ((int) j));
set_color (fg, bg); set_color (fg, bg);
@ -1114,6 +1120,7 @@ void TViswin::paint_header ()
set_opaque_text (TRUE); set_opaque_text (TRUE);
set_color (FOREGROUND, BACKGROUND); set_color (FOREGROUND, BACKGROUND);
set_font (PRINT_FONT, XVT_FS_NONE, PRINT_HEIGHT); set_font (PRINT_FONT, XVT_FS_NONE, PRINT_HEIGHT);
TString16 htmpst; TString16 htmpst;
for (int i = 1; i < 26; i++) for (int i = 1; i < 26; i++)
{ {
@ -1124,7 +1131,7 @@ void TViswin::paint_header ()
} }
autoscroll (FALSE); autoscroll (FALSE);
set_color (COLOR_WHITE, BACKGROUND); set_color (COLOR_WHITE, BACKGROUND);
printat (0, 0, "P.%3ld", ((origin().y) / _formlen) + 1l); printat (0, 0, "P.%3ld", (origin().y / _formlen) + 1L);
autoscroll (TRUE); autoscroll (TRUE);
} }
@ -1389,7 +1396,10 @@ void TViswin::handler (WINDOW win, EVENT * ep)
case E_MOUSE_DBL: case E_MOUSE_DBL:
break; break;
case E_MOUSE_DOWN: case E_MOUSE_DOWN:
p = ep->v.mouse.where; autoscroll(FALSE);
p = dev2log(ep->v.mouse.where);
autoscroll(TRUE);
xvt_win_trap_pointer (win); xvt_win_trap_pointer (win);
if (ep->v.mouse.button == 0) // left button: text selection if (ep->v.mouse.button == 0) // left button: text selection
@ -1406,9 +1416,11 @@ void TViswin::handler (WINDOW win, EVENT * ep)
} }
erase_point (); erase_point ();
_sel_start = ep->v.mouse.where; // _sel_start = ep->v.mouse.where;
_sel_start = p;
_sel_start.x += (origin ().x - X_OFFSET); _sel_start.x += (origin ().x - X_OFFSET);
_sel_start.y += (origin ().y - Y_OFFSET); _sel_start.y += (origin ().y - Y_OFFSET);
_sel_end = _sel_start; _sel_end = _sel_start;
_selecting = TRUE; _selecting = TRUE;
} }
@ -1427,7 +1439,9 @@ void TViswin::handler (WINDOW win, EVENT * ep)
// point // point
{ {
p = ep->v.mouse.where; autoscroll(FALSE);
p = dev2log(ep->v.mouse.where);
autoscroll(TRUE);
if (_isopen && _toplevel && (p.x >= 4 && p.x <= X_OFFSET) && if (_isopen && _toplevel && (p.x >= 4 && p.x <= X_OFFSET) &&
(p.y >= (int)rows() - BUTTONROW_SIZE && p.y <= (int)rows() - Y_OFFSET)) (p.y >= (int)rows() - BUTTONROW_SIZE && p.y <= (int)rows() - Y_OFFSET))
@ -1515,7 +1529,10 @@ void TViswin::handler (WINDOW win, EVENT * ep)
*/ */
if (_selecting || _iscross) if (_selecting || _iscross)
{ {
p = ep->v.mouse.where; autoscroll(FALSE);
p = dev2log(ep->v.mouse.where);
autoscroll(TRUE);
if (_selecting) if (_selecting)
_isselection = TRUE;; _isselection = TRUE;;
{ {
@ -1844,7 +1861,7 @@ bool TViswin::on_key (KEY key)
case K_F7: case K_F7:
find(); find();
break; break;
case K_F8: case K_F3:
find_next(); find_next();
break; break;
case CTRL_E: case CTRL_E:
@ -1970,6 +1987,21 @@ bool TViswin::on_key (KEY key)
case K_F6: case K_F6:
_selflag = !_selflag; _selflag = !_selflag;
break; break;
case '+':
if (PRINT_HEIGHT <= 14)
{
PRINT_HEIGHT += 2;
_need_update = TRUE;
force_update();
}
break;
case '-':
if (PRINT_HEIGHT >= 6)
{
PRINT_HEIGHT -= 2;
_need_update = TRUE;
force_update();
}
default: default:
break; break;
} }
@ -2246,12 +2278,16 @@ void TViswin::add_line (const char *l)
return; return;
} }
_txt.append (l); _txt.append (l);
EVENT ev; const long tot = _txt.lines();
ev.type = E_USER; const bool visible = (tot - origin().y) <= _textrows;
ev.v.user.id = (_txt.lines() - origin().y) <= _textrows ? if (visible || (tot & 0xF) == 0)
E_ADDLINE_ONSCREEN : E_ADDLINE; {
xvt_win_dispatch_event (win (), &ev); EVENT ev;
do_events (); ev.type = E_USER;
ev.v.user.id = visible ? E_ADDLINE_ONSCREEN : E_ADDLINE;
xvt_win_dispatch_event (win(), &ev);
do_events ();
}
} }
} }
@ -2486,7 +2522,7 @@ TViswin::TViswin(const char *fname,
_isopen = fname == NULL || *fname <= ' '; _isopen = fname == NULL || *fname <= ' ';
if (_isopen) if (_isopen)
_filename = _txt.name (); _filename = _txt.name();
if (parent == NULL_WIN) if (parent == NULL_WIN)
parent = TASK_WIN; parent = TASK_WIN;
@ -2502,27 +2538,16 @@ TViswin::TViswin(const char *fname,
// Se rulers vale 3 allora leggi dal config il vero valore // Se rulers vale 3 allora leggi dal config il vero valore
if (_rulers != FALSE && _rulers != TRUE) if (_rulers != FALSE && _rulers != TRUE)
_rulers = cnf.get_bool("Righelli", NULL, -1,TRUE); _rulers = cnf.get_bool("Righelli", NULL, -1,TRUE);
}
RCT r;
xvt_vobj_get_client_rect (parent, &r);
int maxlarg = width == 0 ? (r.right / CHARX - 6) : width;
int maxalt = height == 0 ? (r.bottom / CHARY - 6) : height;
if (_toplevel) PRINT_HEIGHT = cnf.get_int("FontSize", NULL, -1, PRINT_HEIGHT);
{
const int larg = 76;
const int alt = 20;
if (_toplevel && larg > maxlarg)
maxlarg = larg;
if (_toplevel && alt > maxalt)
maxalt = alt;
long flags = WSF_HSCROLL | WSF_VSCROLL | WSF_SIZE; long flags = WSF_HSCROLL | WSF_VSCROLL | WSF_SIZE;
create(x, y, maxlarg, maxalt, title, flags, W_DOC, parent, create(x, y, width, height, title, flags,
_toplevel ? VISWIN_BAR : 0); W_DOC, parent, VISWIN_BAR);
if (width <= 0 && height <= 0)
maximize();
} }
height = rows();
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
_modules.add(new TImage(BMP_MODULE1 + i), i); _modules.add(new TImage(BMP_MODULE1 + i), i);
@ -2531,7 +2556,8 @@ TViswin::TViswin(const char *fname,
attach_interface(win(), BACKGROUND); attach_interface(win(), BACKGROUND);
set_opaque_text (TRUE); set_opaque_text (TRUE);
set_font (PRINT_FONT, XVT_FS_NONE, PRINT_HEIGHT); set_font (XVT_FFN_FIXED, XVT_FS_NONE, PRINT_HEIGHT);
// set_font (printer().fontname(), XVT_FS_NONE, PRINT_HEIGHT);
if (_toplevel) if (_toplevel)
{ {
@ -2582,15 +2608,15 @@ TViswin::TViswin(const char *fname,
(_brwfld->is_multiple_link()); (_brwfld->is_multiple_link());
_bg = _toplevel ? &(printer().getbgdesc()) : &_brwfld->get_bg_desc(); _bg = _toplevel ? &(printer().getbgdesc()) : &_brwfld->get_bg_desc();
_formlen = _toplevel ? printer().formlen() : maxalt; _formlen = _toplevel ? printer().formlen() : height;
_linkID = -1; _linkID = -1;
_inside_linkexec = FALSE; _inside_linkexec = FALSE;
for (i = 0; i < _links->items (); i++) for (i = 0; i < _links->items (); i++)
{ {
TToken_string & t = (TToken_string &) (*_links)[i]; TToken_string & t = (TToken_string &) (*_links)[i];
char f = *(t.get (1)); char f = *(t.get(1));
char b = *(t.get (2)); char b = *(t.get(2));
t.restart(); t.restart();
_txt.set_hotspots(f, b); _txt.set_hotspots(f, b);
} }

View File

@ -169,8 +169,6 @@ class TViswin : public TField_window
bool _menu_present; bool _menu_present;
// @cmember:(INTERNAL) Viene istanziato soltanto se e' usata come controllo // @cmember:(INTERNAL) Viene istanziato soltanto se e' usata come controllo
TBrowsefile_field* _brwfld; TBrowsefile_field* _brwfld;
// @cmember: (INTERNAL) Rettangolo finestra madre
RCT _wr;
// @access Protected Member // @access Protected Member
protected: protected:
@ -338,7 +336,7 @@ public:
// bool editbutton=TRUE, int width=0, bool rulers=3, // bool editbutton=TRUE, int width=0, bool rulers=3,
// WINDOW parent=NULL_WIN, TBrowsefile_field*=NULL | Costruttore // WINDOW parent=NULL_WIN, TBrowsefile_field*=NULL | Costruttore
TViswin(const char* fname=NULL, const char* title=NULL, bool editbutton=TRUE, TViswin(const char* fname=NULL, const char* title=NULL, bool editbutton=TRUE,
bool printbutton=TRUE, bool linkbutton=TRUE, int x=-1, int y=-1, int height=0, bool printbutton=TRUE, bool linkbutton=TRUE, int x=1, int y=1, int height=0,
int width=0, byte rulers=3, WINDOW parent=NULL_WIN, TBrowsefile_field* =NULL); int width=0, byte rulers=3, WINDOW parent=NULL_WIN, TBrowsefile_field* =NULL);
// @cmember Distruttore // @cmember Distruttore
virtual ~TViswin (); virtual ~TViswin ();

View File

@ -561,7 +561,7 @@ bool TWindow::_ctools_saved;
TWindow::TWindow() TWindow::TWindow()
: _win(NULL_WIN), _open(FALSE), _modal(FALSE), _active(TRUE), : _win(NULL_WIN), _open(FALSE), _modal(FALSE), _active(TRUE),
_running(FALSE), _pixmap(FALSE), _lastkey(0) _running(FALSE), _pixmap(FALSE), _lastkey(0), _base_char_width(0L)
{} {}
word TWindow::class_id() const word TWindow::class_id() const
@ -618,7 +618,7 @@ TWindow::~TWindow()
{ {
if (_win != NULL_WIN) if (_win != NULL_WIN)
{ {
if (is_valid_window(_win)); if (is_valid_window(_win))
xvt_vobj_destroy(_win); xvt_vobj_destroy(_win);
_win = NULL_WIN; _win = NULL_WIN;
} }
@ -762,8 +762,10 @@ TPoint TWindow::size() const
RCT r; RCT r;
xvt_vobj_get_client_rect(win() ? win() : TASK_WIN, &r); xvt_vobj_get_client_rect(win() ? win() : TASK_WIN, &r);
// return TPoint(r.right / CHARX, r.bottom / CHARY); // return TPoint(r.right / CHARX, r.bottom / CHARY);
PNT p; p.h = r.right; p.v = r.bottom; TPoint pnt;
return dev2log(p); pnt.x = int(128L * r.right / char2pixel(128));
pnt.y = r.bottom / CHARY;
return pnt;
} }
WINDOW TWindow::parent() const WINDOW TWindow::parent() const
@ -992,6 +994,19 @@ void TWindow::set_font(
int dim) // @parm Dimensione del font (default 0) int dim) // @parm Dimensione del font (default 0)
{ {
xvt_set_font(win(), family, style, dim); xvt_set_font(win(), family, style, dim);
_base_char_width = 0L;
}
int TWindow::char2pixel(int len) const
{
if (_base_char_width == 0L)
{
const TString emme(128, 'm');
long& bcw = (long&)_base_char_width;
bcw = xvt_dwin_get_text_width(win(), (char*)(const char*)emme, 128);
}
const int pix = int(len * _base_char_width / 128L);
return pix;
} }
PNT TWindow::log2dev(long x, long y) const PNT TWindow::log2dev(long x, long y) const
@ -1001,7 +1016,8 @@ PNT TWindow::log2dev(long x, long y) const
pnt.v = (int)y; pnt.v = (int)y;
if (!_pixmap) if (!_pixmap)
{ {
pnt.h *= CHARX; // pnt.h *= CHARX;
pnt.h = char2pixel(pnt.h);
pnt.v *= CHARY; pnt.v *= CHARY;
} }
return pnt; return pnt;
@ -1012,7 +1028,8 @@ TPoint TWindow::dev2log(const PNT& p) const
TPoint pnt(p.h, p.v); TPoint pnt(p.h, p.v);
if (!_pixmap) if (!_pixmap)
{ {
pnt.x /= CHARX; // pnt.x /= CHARX;
pnt.x = int(128L * p.h / char2pixel(128));
pnt.y /= CHARY; pnt.y /= CHARY;
} }
return pnt; return pnt;

View File

@ -167,6 +167,8 @@ class TWindow : public TObject
// vengono recuperati) // vengono recuperati)
bool restore_ctools(); bool restore_ctools();
long _base_char_width; // Lunghezza in pixel di una stringa di m
// @access Protected Member // @access Protected Member
protected: protected:
// @cmember Indica che la finestra e' aperta // @cmember Indica che la finestra e' aperta
@ -197,6 +199,8 @@ protected:
virtual void update() virtual void update()
{} {}
int char2pixel(int len) const;
// @access Public Member // @access Public Member
public: public:
// @cmember Costruttore // @cmember Costruttore

View File

@ -56,9 +56,13 @@ RCT& resize_rect(
{ {
if (y >= 0) if (y >= 0)
{ {
const TMask* m = (const TMask*)xvt_vobj_get_data(parent); const TWindow* w = (const TWindow*)xvt_vobj_get_data(parent);
if (parent != m->toolwin()) if (w->is_kind_of(CLASS_MASK))
y++; {
const TMask* m = (const TMask*)w;
if (parent != m->toolwin())
y++;
}
} }
if (x > 0 || (wt != WO_TE && wt != W_PLAIN && x == 0)) if (x > 0 || (wt != WO_TE && wt != W_PLAIN && x == 0))
{ {