Viswin interruption working
git-svn-id: svn://10.65.10.50/trunk@15 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
da54026c24
commit
260dd9d29f
@ -10,7 +10,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
|
|
||||||
|
|
||||||
#define BLOCKLEN 512
|
#define BLOCKLEN 512
|
||||||
#define INVFLD 255
|
#define INVFLD 255
|
||||||
|
|
||||||
@ -20,7 +19,8 @@ TFile::TFile(int lenrec, int base)
|
|||||||
|
|
||||||
{
|
{
|
||||||
_file = new SecDef;
|
_file = new SecDef;
|
||||||
if (_file == NULL) fatal_box("Can't allocate record file ");
|
if (_file == NULL)
|
||||||
|
fatal_box ("Can't allocate record file ");
|
||||||
_file->IOR = NOERR;
|
_file->IOR = NOERR;
|
||||||
_len = lenrec;
|
_len = lenrec;
|
||||||
_base = base;
|
_base = base;
|
||||||
@ -29,58 +29,57 @@ TFile::TFile(int lenrec, int base)
|
|||||||
_file->name[0] = '\0';
|
_file->name[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TFile ::~TFile ()
|
TFile ::~TFile ()
|
||||||
|
|
||||||
{
|
{
|
||||||
delete _file;
|
delete _file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TFile ::
|
||||||
void TFile::open(const char* name, TFilelock lockmode)
|
open (const char *name, TFilelock lockmode)
|
||||||
|
|
||||||
{
|
{
|
||||||
COpen (_file, (char *) name, _len, _base, lockmode);
|
COpen (_file, (char *) name, _len, _base, lockmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TFile ::
|
||||||
bool TFile::verify(const char* name)
|
verify (const char *name)
|
||||||
|
|
||||||
{
|
{
|
||||||
CVerify (_file, (char *) name);
|
CVerify (_file, (char *) name);
|
||||||
return _file->IOR == NOERR;
|
return _file->IOR == NOERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TFile ::
|
||||||
void TFile::create(const char* name, TRecnotype nrecord)
|
create (const char *name, TRecnotype nrecord)
|
||||||
|
|
||||||
{
|
{
|
||||||
CCreate (_file, (char *) name, _len, _base, (nrecord * _len) / BLOCKLEN + 1);
|
CCreate (_file, (char *) name, _len, _base, (nrecord * _len) / BLOCKLEN + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TFile ::
|
||||||
void TFile::chsize(const char* name, TRecnotype nrecord)
|
chsize (const char *name, TRecnotype nrecord)
|
||||||
|
|
||||||
{
|
{
|
||||||
CChsize (_file, (char *) name, _len, _base, (nrecord * _len) / BLOCKLEN + 1);
|
CChsize (_file, (char *) name, _len, _base, (nrecord * _len) / BLOCKLEN + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TFile ::
|
||||||
void TFile::close()
|
close ()
|
||||||
|
|
||||||
{
|
{
|
||||||
CClose (_file);
|
CClose (_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TFile ::
|
||||||
void TFile::unlink(const char* name)
|
unlink (const char *name)
|
||||||
|
|
||||||
{
|
{
|
||||||
CDelete (_file, (char *) name);
|
CDelete (_file, (char *) name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TFile ::
|
||||||
void TFile::read(char* record, TRecnotype recnum, TReclock lock)
|
read (char *record, TRecnotype recnum, TReclock lock)
|
||||||
|
|
||||||
{
|
{
|
||||||
_file->LenRec = _len;
|
_file->LenRec = _len;
|
||||||
@ -88,8 +87,8 @@ void TFile::read(char* record, TRecnotype recnum, TReclock lock)
|
|||||||
CRead (_file, record, recnum, lock);
|
CRead (_file, record, recnum, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TFile ::
|
||||||
void TFile::write(char* record, TRecnotype recnum, TReclock lock)
|
write (char *record, TRecnotype recnum, TReclock lock)
|
||||||
|
|
||||||
{
|
{
|
||||||
_file->LenRec = _len;
|
_file->LenRec = _len;
|
||||||
@ -97,15 +96,16 @@ void TFile::write(char* record, TRecnotype recnum, TReclock lock)
|
|||||||
CWrite (_file, record, recnum, lock);
|
CWrite (_file, record, recnum, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TFile ::
|
||||||
int TFile::status() const
|
status ()
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _file->IOR;
|
return _file->IOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TDir ::
|
||||||
TDir::TDir()
|
TDir ()
|
||||||
|
|
||||||
{
|
{
|
||||||
_dir = new FileDes;
|
_dir = new FileDes;
|
||||||
@ -115,81 +115,86 @@ TDir::TDir()
|
|||||||
_num = -1;
|
_num = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TDir ::~TDir ()
|
TDir ::~TDir ()
|
||||||
|
|
||||||
{
|
{
|
||||||
delete _dir;
|
delete _dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *TDir ::
|
||||||
const char* TDir::name() const
|
name ()
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->SysName;
|
return _dir->SysName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *TDir ::des ()
|
||||||
const char* TDir::des() const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->Des;
|
return _dir->Des;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *TDir ::expr ()
|
||||||
const char* TDir::expr() const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->FCalc;
|
return _dir->FCalc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRecnotype & TDir ::
|
||||||
TRecnotype& TDir::eod() const
|
eod ()
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->EOD;
|
return _dir->EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRecnotype & TDir ::
|
||||||
TRecnotype& TDir::eox() const
|
eox ()
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->EOX;
|
return _dir->EOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRecnotype & TDir ::
|
||||||
TRecnotype& TDir::flags() const
|
flags ()
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->Flags;
|
return _dir->Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
word & TDir ::
|
||||||
word& TDir::len()
|
len ()
|
||||||
|
|
||||||
{
|
{
|
||||||
return (word &) _dir->LenR;
|
return (word &) _dir->LenR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TDir ::
|
||||||
int TDir::status(TDirtype dirop) const
|
status (TDirtype dirop)
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return fdir[dirop].IOR;
|
return fdir[dirop].IOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TDir ::set_len (const UINT16 len)
|
void TDir ::set_len (const UINT16 len)
|
||||||
{
|
{
|
||||||
_dir->LenR = len;
|
_dir->LenR = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDir::set_eox(const RecNoType eox)
|
void TDir ::
|
||||||
|
set_eox (const RecNoType eox)
|
||||||
{
|
{
|
||||||
_dir->EOX = eox;
|
_dir->EOX = eox;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDir::set(const char * name, const RecNoType eod, const RecNoType flag, const char * des, const char * calc)
|
void TDir ::
|
||||||
|
set (const char *name, const RecNoType eod, const RecNoType flag, const char *des, const char *calc)
|
||||||
{
|
{
|
||||||
strncpy (_dir->SysName, name, sizeof (_dir->SysName));
|
strncpy (_dir->SysName, name, sizeof (_dir->SysName));
|
||||||
_dir->EOD = eod;
|
_dir->EOD = eod;
|
||||||
@ -198,7 +203,8 @@ void TDir::set(const char * name, const RecNoType eod, const RecNoType flag, con
|
|||||||
strncpy (_dir->FCalc, calc, sizeof (_dir->FCalc));
|
strncpy (_dir->FCalc, calc, sizeof (_dir->FCalc));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDir::get(int nfile, TReclock lock, TDirtype dirtype, TDirop op)
|
void TDir ::
|
||||||
|
get (int nfile, TReclock lock, TDirtype dirtype, TDirop op)
|
||||||
|
|
||||||
{
|
{
|
||||||
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
||||||
@ -210,8 +216,8 @@ void TDir::get(int nfile, TReclock lock, TDirtype dirtype, TDirop op)
|
|||||||
_num = nfile;
|
_num = nfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TDir ::
|
||||||
void TDir::put(int nfile, TDirtype dirtype, TDirop op)
|
put (int nfile, TDirtype dirtype, TDirop op)
|
||||||
|
|
||||||
{
|
{
|
||||||
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
||||||
@ -224,15 +230,16 @@ void TDir::put(int nfile, TDirtype dirtype, TDirop op)
|
|||||||
CPutFile (nfile, _dir, _whichdir);
|
CPutFile (nfile, _dir, _whichdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TDir ::
|
||||||
void TDir::zero()
|
zero ()
|
||||||
|
|
||||||
{
|
{
|
||||||
zerofdes (_dir);
|
zerofdes (_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TDir ::
|
||||||
int TDir::items(TDirtype dirtype) const
|
items (TDirtype dirtype)
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
FileDes f;
|
FileDes f;
|
||||||
@ -242,7 +249,8 @@ int TDir::items(TDirtype dirtype) const
|
|||||||
return (int) f.EOD;
|
return (int) f.EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
TTrec::TTrec()
|
TTrec ::
|
||||||
|
TTrec ()
|
||||||
|
|
||||||
{
|
{
|
||||||
_rec = new RecDes;
|
_rec = new RecDes;
|
||||||
@ -252,15 +260,15 @@ TTrec::TTrec()
|
|||||||
_num = -1;
|
_num = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TTrec ::~TTrec ()
|
TTrec ::~TTrec ()
|
||||||
|
|
||||||
{
|
{
|
||||||
delete _rec;
|
delete _rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TTrec ::
|
||||||
int TTrec::compare(const TSortable& a) const
|
compare (const TSortable & a)
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
const TTrec & r = (const TTrec &) a;
|
const TTrec & r = (const TTrec &) a;
|
||||||
@ -282,7 +290,8 @@ TTrec& TTrec::operator =(const TTrec& b)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrec::get(int nfile, TDirtype dirtype)
|
void TTrec ::
|
||||||
|
get (int nfile, TDirtype dirtype)
|
||||||
|
|
||||||
{
|
{
|
||||||
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
||||||
@ -291,8 +300,8 @@ void TTrec::get(int nfile, TDirtype dirtype)
|
|||||||
_num = nfile;
|
_num = nfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TTrec ::
|
||||||
void TTrec::put(int nfile, TDirtype dirtype)
|
put (int nfile, TDirtype dirtype)
|
||||||
|
|
||||||
{
|
{
|
||||||
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
||||||
@ -302,29 +311,31 @@ void TTrec::put(int nfile, TDirtype dirtype)
|
|||||||
CPutRec (nfile, _rec, _whichdir);
|
CPutRec (nfile, _rec, _whichdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TTrec ::
|
||||||
void TTrec::zero()
|
zero ()
|
||||||
|
|
||||||
{
|
{
|
||||||
zerordes (_rec);
|
zerordes (_rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TTrec ::
|
||||||
int TTrec::status(TDirtype dirop) const
|
status (TDirtype dirop)
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return rdir[dirop].IOR;
|
return rdir[dirop].IOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TTrec ::field (const char *name)
|
||||||
int TTrec::field(const char* name) const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return findfld (_rec, (char *) name);
|
return findfld (_rec, (char *) name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TTrec::fielddef(int fld) const
|
const char *TTrec ::fielddef (int fld)
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
sprintf (_files_tmp_string, "%s|%d|%d|%d", _rec->Fd[fld].Name,
|
sprintf (_files_tmp_string, "%s|%d|%d|%d", _rec->Fd[fld].Name,
|
||||||
@ -333,7 +344,8 @@ const char* TTrec::fielddef(int fld) const
|
|||||||
return _files_tmp_string;
|
return _files_tmp_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TTrec::keydef(int key) const
|
const char *TTrec ::keydef (int key)
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
TFixed_string s (_files_tmp_string, 128);
|
TFixed_string s (_files_tmp_string, 128);
|
||||||
@ -344,19 +356,23 @@ const char* TTrec::keydef(int key) const
|
|||||||
const bool upper = _rec->Ky[key].FieldSeq[j] > MaxFields;
|
const bool upper = _rec->Ky[key].FieldSeq[j] > MaxFields;
|
||||||
const int nfld = _rec->Ky[key].FieldSeq[j] - (upper ? MaxFields : 0);
|
const int nfld = _rec->Ky[key].FieldSeq[j] - (upper ? MaxFields : 0);
|
||||||
|
|
||||||
if (j) s << "+";
|
if (j)
|
||||||
if (upper) s << "UPPER(";
|
s << "+";
|
||||||
|
if (upper)
|
||||||
|
s << "UPPER(";
|
||||||
s << _rec->Fd[nfld].Name;
|
s << _rec->Fd[nfld].Name;
|
||||||
if (_rec->Ky[key].FromCh[j] < INVFLD)
|
if (_rec->Ky[key].FromCh[j] < INVFLD)
|
||||||
s << format ("[%d,%d]", _rec->Ky[key].FromCh[j] + 1,
|
s << format ("[%d,%d]", _rec->Ky[key].FromCh[j] + 1,
|
||||||
_rec->Ky[key].ToCh[j] + 1);
|
_rec->Ky[key].ToCh[j] + 1);
|
||||||
if (upper) s << ")";
|
if (upper)
|
||||||
|
s << ")";
|
||||||
}
|
}
|
||||||
s << (_rec->Ky[key].DupKeys ? "|X" : "| ");
|
s << (_rec->Ky[key].DupKeys ? "|X" : "| ");
|
||||||
return (const char *) s;
|
return (const char *) s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrec::update_fielddef(int nfld, const char* desc)
|
void TTrec ::
|
||||||
|
update_fielddef (int nfld, const char *desc)
|
||||||
|
|
||||||
{
|
{
|
||||||
TToken_string s (desc);
|
TToken_string s (desc);
|
||||||
@ -366,8 +382,8 @@ void TTrec::update_fielddef(int nfld, const char* desc)
|
|||||||
_rec->Fd[nfld].Dec = s.get_int ();
|
_rec->Fd[nfld].Dec = s.get_int ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TTrec ::
|
||||||
void TTrec::update_keydef(int key, const char* desc)
|
update_keydef (int key, const char *desc)
|
||||||
|
|
||||||
{
|
{
|
||||||
TExpression expr ("", _strexpr);
|
TExpression expr ("", _strexpr);
|
||||||
@ -390,7 +406,8 @@ void TTrec::update_keydef(int key, const char* desc)
|
|||||||
const char *s = inst.string ();
|
const char *s = inst.string ();
|
||||||
|
|
||||||
for (int i = 0; i < _rec->NFields; i++)
|
for (int i = 0; i < _rec->NFields; i++)
|
||||||
if (strcmp(_rec->Fd[i].Name, s) == 0) break;
|
if (strcmp (_rec->Fd[i].Name, s) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
_rec->Ky[key].FieldSeq[n] = i;
|
_rec->Ky[key].FieldSeq[n] = i;
|
||||||
_rec->Ky[key].FromCh[n] = INVFLD;
|
_rec->Ky[key].FromCh[n] = INVFLD;
|
||||||
@ -399,15 +416,15 @@ void TTrec::update_keydef(int key, const char* desc)
|
|||||||
sym = inst.getsym ();
|
sym = inst.getsym ();
|
||||||
if (sym == _upper)
|
if (sym == _upper)
|
||||||
_rec->Ky[key].FieldSeq[n] += MaxFields;
|
_rec->Ky[key].FieldSeq[n] += MaxFields;
|
||||||
else
|
else if (sym == _number)
|
||||||
if (sym == _number)
|
|
||||||
{
|
{
|
||||||
_rec->Ky[key].FromCh[n] = inst.number ().integer () - 1;
|
_rec->Ky[key].FromCh[n] = inst.number ().integer () - 1;
|
||||||
inst = c.step ();
|
inst = c.step ();
|
||||||
_rec->Ky[key].ToCh[n] = _rec->Ky[key].FromCh[n] + inst.number ().integer () - 1;
|
_rec->Ky[key].ToCh[n] = _rec->Ky[key].FromCh[n] + inst.number ().integer () - 1;
|
||||||
inst = c.step ();
|
inst = c.step ();
|
||||||
}
|
}
|
||||||
else c.backtrace();
|
else
|
||||||
|
c.backtrace ();
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -415,7 +432,9 @@ void TTrec::update_keydef(int key, const char* desc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrec::print_on(ostream& out) const
|
void TTrec ::
|
||||||
|
print_on (ostream & out)
|
||||||
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
out << num () << '\n';
|
out << num () << '\n';
|
||||||
@ -438,8 +457,8 @@ void TTrec::print_on(ostream& out) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TTrec ::
|
||||||
void TTrec::read_from(istream& in)
|
read_from (istream & in)
|
||||||
|
|
||||||
{
|
{
|
||||||
int ln;
|
int ln;
|
||||||
@ -470,5 +489,3 @@ void TTrec::read_from(istream& in)
|
|||||||
}
|
}
|
||||||
rehash ();
|
rehash ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,9 +18,13 @@ const short FIRST_FIELD = 101;
|
|||||||
|
|
||||||
class TSpreadsheet:public TWindow
|
class TSpreadsheet:public TWindow
|
||||||
{
|
{
|
||||||
enum { ITF_CID = 0, LIST_CID = 1 };
|
enum
|
||||||
|
{
|
||||||
|
ITF_CID = 0, LIST_CID = 1
|
||||||
|
};
|
||||||
|
|
||||||
TArray _str; // Array di TToken_strings
|
TArray _str; // Array di TToken_strings
|
||||||
|
|
||||||
TBit_array _column_disabled;
|
TBit_array _column_disabled;
|
||||||
TArray _disabled; // Array di TBit_array
|
TArray _disabled; // Array di TBit_array
|
||||||
|
|
||||||
@ -57,7 +61,10 @@ public:
|
|||||||
void update (int row);
|
void update (int row);
|
||||||
|
|
||||||
TToken_string & row (int n);
|
TToken_string & row (int n);
|
||||||
TArray& rows_array() const { return (TArray&)_str; }
|
TArray & rows_array () const
|
||||||
|
{
|
||||||
|
return (TArray &) _str;
|
||||||
|
}
|
||||||
int add (TToken_string &);
|
int add (TToken_string &);
|
||||||
int insert (int rec);
|
int insert (int rec);
|
||||||
bool destroy (int rec = -1);
|
bool destroy (int rec = -1);
|
||||||
@ -66,13 +73,30 @@ public:
|
|||||||
void enable_cell (int row, int column, bool on = TRUE);
|
void enable_cell (int row, int column, bool on = TRUE);
|
||||||
bool cell_disabled (int row, int column) const;
|
bool cell_disabled (int row, int column) const;
|
||||||
|
|
||||||
TMask& mask() { return _mask; }
|
TMask & mask ()
|
||||||
int items() const { return _str.items(); }
|
{
|
||||||
int columns() const { return _columns; }
|
return _mask;
|
||||||
bool dirty() const { return _dirty; }
|
}
|
||||||
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
|
int items () const
|
||||||
|
{
|
||||||
|
return _str.items ();
|
||||||
|
}
|
||||||
|
int columns () const
|
||||||
|
{
|
||||||
|
return _columns;
|
||||||
|
}
|
||||||
|
bool dirty () const
|
||||||
|
{
|
||||||
|
return _dirty;
|
||||||
|
}
|
||||||
|
void set_notify (SPREADSHEET_NOTIFY n)
|
||||||
|
{
|
||||||
|
_notify = n;
|
||||||
|
}
|
||||||
|
|
||||||
void set_dirty(bool spork = TRUE) { _dirty = spork; }
|
void set_dirty (bool spork = TRUE)
|
||||||
|
{_dirty = spork;
|
||||||
|
}
|
||||||
|
|
||||||
TSpreadsheet (short x, short y, short dx, short dy, const char *maskname, int maskno,
|
TSpreadsheet (short x, short y, short dx, short dy, const char *maskname, int maskno,
|
||||||
const char *head, WINDOW parent);
|
const char *head, WINDOW parent);
|
||||||
@ -125,7 +149,9 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
|||||||
{
|
{
|
||||||
w = atoi (at + 1);
|
w = atoi (at + 1);
|
||||||
*at = '\0';
|
*at = '\0';
|
||||||
} else w = strlen(h);
|
}
|
||||||
|
else
|
||||||
|
w = strlen (h);
|
||||||
|
|
||||||
width[i] = w + 1;
|
width[i] = w + 1;
|
||||||
|
|
||||||
@ -188,7 +214,8 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
|||||||
long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL;
|
long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL;
|
||||||
if (f->class_id () == CLASS_REAL_FIELD) flags |= XI_ATR_RJUST;
|
if (f->class_id () == CLASS_REAL_FIELD) flags |= XI_ATR_RJUST;
|
||||||
if (f->active ())flags |= XI_ATR_ENABLED;
|
if (f->active ())flags |= XI_ATR_ENABLED;
|
||||||
else _column_disabled.set(i);
|
else
|
||||||
|
_column_disabled.set (i);
|
||||||
|
|
||||||
coldef = xi_add_column_def (listdef, cid,
|
coldef = xi_add_column_def (listdef, cid,
|
||||||
flags, cid, w, width[i], (char *) h);
|
flags, cid, w, width[i], (char *) h);
|
||||||
@ -215,7 +242,6 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
|||||||
_list = xi_get_obj (itf, LIST_CID);
|
_list = xi_get_obj (itf, LIST_CID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Converts a row number in the correspondig record number
|
// Converts a row number in the correspondig record number
|
||||||
int TSpreadsheet ::row2rec (int row)
|
int TSpreadsheet ::row2rec (int row)
|
||||||
{
|
{
|
||||||
@ -233,7 +259,6 @@ int TSpreadsheet::row2rec(int row)
|
|||||||
return (int) rec[row];
|
return (int) rec[row];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Converts a row number in the correspondig record number
|
// Converts a row number in the correspondig record number
|
||||||
int TSpreadsheet ::rec2row (int record)
|
int TSpreadsheet ::rec2row (int record)
|
||||||
{
|
{
|
||||||
@ -286,7 +311,6 @@ void TSpreadsheet::set_focus_cell(int riga, int colonna)
|
|||||||
xi_set_focus (&cell);
|
xi_set_focus (&cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int TSpreadsheet ::insert (int rec)
|
int TSpreadsheet ::insert (int rec)
|
||||||
{
|
{
|
||||||
const bool ok = notify (rec, K_INS);
|
const bool ok = notify (rec, K_INS);
|
||||||
@ -302,7 +326,6 @@ int TSpreadsheet::insert(int rec)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TSpreadsheet ::destroy (int rec)
|
bool TSpreadsheet ::destroy (int rec)
|
||||||
{
|
{
|
||||||
bool ok = TRUE;
|
bool ok = TRUE;
|
||||||
@ -324,7 +347,6 @@ bool TSpreadsheet::destroy(int rec)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSpreadsheet ::update (int row)
|
void TSpreadsheet ::update (int row)
|
||||||
{
|
{
|
||||||
if (row < 0)
|
if (row < 0)
|
||||||
@ -337,7 +359,6 @@ void TSpreadsheet::update(int row)
|
|||||||
update_rec (row);
|
update_rec (row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSpreadsheet ::xiev_handler (XI_OBJ * itf, XI_EVENT * xiev)
|
void TSpreadsheet ::xiev_handler (XI_OBJ * itf, XI_EVENT * xiev)
|
||||||
{
|
{
|
||||||
TSpreadsheet * es = (TSpreadsheet *) xi_get_app_data (itf);
|
TSpreadsheet * es = (TSpreadsheet *) xi_get_app_data (itf);
|
||||||
@ -345,7 +366,6 @@ void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev)
|
|||||||
es->list_handler (xiev);
|
es->list_handler (xiev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 75%
|
// Certified 75%
|
||||||
void TSpreadsheet ::list_handler (XI_EVENT * xiev)
|
void TSpreadsheet ::list_handler (XI_EVENT * xiev)
|
||||||
{
|
{
|
||||||
@ -411,7 +431,9 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
|
|||||||
if (cell_disabled (rec, col))
|
if (cell_disabled (rec, col))
|
||||||
xiev->v.cell_request.back_color = MASK_BACK_COLOR;
|
xiev->v.cell_request.back_color = MASK_BACK_COLOR;
|
||||||
}
|
}
|
||||||
} else src = format("%d", rec+1);
|
}
|
||||||
|
else
|
||||||
|
src = format ("%d", rec + 1);
|
||||||
|
|
||||||
const int len = xiev->v.cell_request.len;
|
const int len = xiev->v.cell_request.len;
|
||||||
char *dst = xiev->v.cell_request.s;
|
char *dst = xiev->v.cell_request.s;
|
||||||
@ -445,7 +467,8 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
|
|||||||
check_enabled = TRUE; // Enable checks
|
check_enabled = TRUE; // Enable checks
|
||||||
xi_set_focus (xiev->v.xi_obj); // Restore focus to cell
|
xi_set_focus (xiev->v.xi_obj); // Restore focus to cell
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
if (xiev->v.xi_obj->type == XIT_LIST)
|
if (xiev->v.xi_obj->type == XIT_LIST)
|
||||||
insert (-1);
|
insert (-1);
|
||||||
break;
|
break;
|
||||||
@ -517,7 +540,8 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
|
|||||||
case XIE_OFF_CELL:
|
case XIE_OFF_CELL:
|
||||||
if (edit_field && check_enabled)
|
if (edit_field && check_enabled)
|
||||||
{
|
{
|
||||||
TMask_field* c = edit_field; // Save field, it could turn out to be NULL on error
|
TMask_field * c = edit_field; // Save field, it could turn out to
|
||||||
|
// be NULL on error
|
||||||
const TString80 old (c->get ()); // Save old value on mask
|
const TString80 old (c->get ()); // Save old value on mask
|
||||||
const TString80 nuo (c->picture_data (xi_get_text (xiev->v.xi_obj, NULL, -1), TRUE));
|
const TString80 nuo (c->picture_data (xi_get_text (xiev->v.xi_obj, NULL, -1), TRUE));
|
||||||
if (old != nuo)
|
if (old != nuo)
|
||||||
@ -674,12 +698,26 @@ public:
|
|||||||
TSpreadsheet (short x, short y, short dx, short dy, const char *maskname, int maskno,
|
TSpreadsheet (short x, short y, short dx, short dy, const char *maskname, int maskno,
|
||||||
const char *head, WINDOW parent);
|
const char *head, WINDOW parent);
|
||||||
|
|
||||||
TArray& rows_array() const { return data(); }
|
TArray & rows_array () const
|
||||||
|
{
|
||||||
|
return data ();
|
||||||
|
}
|
||||||
|
|
||||||
TMask& mask() { return _mask; }
|
TMask & mask ()
|
||||||
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
|
{
|
||||||
void set_dirty(bool spork = TRUE) { _dirty = spork;}
|
return _mask;
|
||||||
bool dirty() const { return _dirty;}
|
}
|
||||||
|
void set_notify (SPREADSHEET_NOTIFY n)
|
||||||
|
{
|
||||||
|
_notify = n;
|
||||||
|
}
|
||||||
|
void set_dirty (bool spork = TRUE)
|
||||||
|
{_dirty = spork;
|
||||||
|
}
|
||||||
|
bool dirty ()const
|
||||||
|
{
|
||||||
|
return _dirty;
|
||||||
|
}
|
||||||
|
|
||||||
void enable_column (int col, bool on);
|
void enable_column (int col, bool on);
|
||||||
void enable_cell (int row, int column, bool on = TRUE);
|
void enable_cell (int row, int column, bool on = TRUE);
|
||||||
@ -691,7 +729,8 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
|||||||
const char *head, WINDOW parent)
|
const char *head, WINDOW parent)
|
||||||
:TArray_sheet (x, y, dx, dy, maskname, head, 0, parent),
|
:TArray_sheet (x, y, dx, dy, maskname, head, 0, parent),
|
||||||
_mask (maskname, NO_MODE, maskno), _notify (NULL)
|
_mask (maskname, NO_MODE, maskno), _notify (NULL)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool TSpreadsheet ::on_key (KEY k)
|
bool TSpreadsheet ::on_key (KEY k)
|
||||||
{
|
{
|
||||||
@ -702,18 +741,24 @@ bool TSpreadsheet::on_key(KEY k)
|
|||||||
mask ().send_key (k, 0);
|
mask ().send_key (k, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case K_ENTER: // Selezione riga per editing
|
case K_ENTER: // Selezione riga per editing
|
||||||
|
|
||||||
if (items () < 1) k = K_INS; // Se vuoto crea riga da editare
|
if (items () < 1) k = K_INS; // Se vuoto crea riga da editare
|
||||||
case K_INS:
|
case K_INS:
|
||||||
case 'A': // Aggiunge dopo
|
case 'A': // Aggiunge dopo
|
||||||
|
|
||||||
case 'I': // Aggiunge prima
|
case 'I': // Aggiunge prima
|
||||||
|
|
||||||
{
|
{
|
||||||
int n = (int)selected ();
|
int n = (int)selected ();
|
||||||
if (k != K_ENTER)
|
if (k != K_ENTER)
|
||||||
{
|
{
|
||||||
if (k == K_INS) n = items(); else // Aggiunge alla fine
|
if (k == K_INS) n = items ();
|
||||||
|
else // Aggiunge alla fine
|
||||||
|
|
||||||
if (k == 'A') n++;
|
if (k == 'A') n++;
|
||||||
|
|
||||||
if (n < 0) n = 0; else
|
if (n < 0) n = 0;
|
||||||
|
else
|
||||||
if (n > items ())n = items (); // Controlla range n
|
if (n > items ())n = items (); // Controlla range n
|
||||||
|
|
||||||
if (notify (n, K_INS) == FALSE) // Chiede l'ok alla applicazione
|
if (notify (n, K_INS) == FALSE) // Chiede l'ok alla applicazione
|
||||||
@ -750,7 +795,6 @@ TMask_field* TSpreadsheet::field(short id) const
|
|||||||
return &_mask.fld (pos);
|
return &_mask.fld (pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSpreadsheet ::mask2str (int riga)
|
void TSpreadsheet ::mask2str (int riga)
|
||||||
{
|
{
|
||||||
TToken_string & r = row (riga);
|
TToken_string & r = row (riga);
|
||||||
@ -766,7 +810,6 @@ void TSpreadsheet::mask2str(int riga)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 50%
|
// Certified 50%
|
||||||
void TSpreadsheet ::enable_cell (int row, int column, bool on)
|
void TSpreadsheet ::enable_cell (int row, int column, bool on)
|
||||||
{
|
{
|
||||||
@ -796,13 +839,11 @@ void TSpreadsheet::enable_cell(int row, int column, bool on)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSpreadsheet ::enable_column (int col, bool on)
|
void TSpreadsheet ::enable_column (int col, bool on)
|
||||||
{
|
{
|
||||||
_column_disabled.set (col, !on);
|
_column_disabled.set (col, !on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 99%
|
// Certified 99%
|
||||||
bool TSpreadsheet ::cell_disabled (int row, int column) const
|
bool TSpreadsheet ::cell_disabled (int row, int column) const
|
||||||
{
|
{
|
||||||
@ -811,7 +852,6 @@ bool TSpreadsheet::cell_disabled(int row, int column) const
|
|||||||
return (*ba)[column];
|
return (*ba)[column];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 75%
|
// Certified 75%
|
||||||
void TSpreadsheet ::str2mask (int riga)
|
void TSpreadsheet ::str2mask (int riga)
|
||||||
{
|
{
|
||||||
@ -853,14 +893,12 @@ void TSpreadsheet::str2mask(int riga)
|
|||||||
_mask.set_caption (format ("Riga %d", riga + 1));
|
_mask.set_caption (format ("Riga %d", riga + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 100%
|
// Certified 100%
|
||||||
bool TSpreadsheet ::notify (int n, KEY k)
|
bool TSpreadsheet ::notify (int n, KEY k)
|
||||||
{
|
{
|
||||||
return _notify ? _notify (n, k) : TRUE;
|
return _notify ? _notify (n, k) : TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 99%
|
// Certified 99%
|
||||||
KEY TSpreadsheet ::edit (int n)
|
KEY TSpreadsheet ::edit (int n)
|
||||||
{
|
{
|
||||||
@ -870,7 +908,8 @@ KEY TSpreadsheet::edit(int n)
|
|||||||
if (k == K_ENTER)
|
if (k == K_ENTER)
|
||||||
{
|
{
|
||||||
mask2str (n);
|
mask2str (n);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
if (k == K_DEL)
|
if (k == K_DEL)
|
||||||
{
|
{
|
||||||
const bool ok = notify (n, K_DEL); // Notifica intenzione di cancellare
|
const bool ok = notify (n, K_DEL); // Notifica intenzione di cancellare
|
||||||
@ -890,7 +929,8 @@ KEY TSpreadsheet::edit(int n)
|
|||||||
// Certified 100%
|
// Certified 100%
|
||||||
TSheet_field ::TSheet_field (TMask * m)
|
TSheet_field ::TSheet_field (TMask * m)
|
||||||
: TMask_field (m), _sheet (NULL)
|
: TMask_field (m), _sheet (NULL)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Certified 100%
|
// Certified 100%
|
||||||
word TSheet_field ::class_id ()const
|
word TSheet_field ::class_id ()const
|
||||||
@ -918,7 +958,6 @@ void TSheet_field::parse_head(TScanner& scanner)
|
|||||||
if (_size == 0) _size = -1;
|
if (_size == 0) _size = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 100%
|
// Certified 100%
|
||||||
bool TSheet_field ::parse_item (TScanner & scanner)
|
bool TSheet_field ::parse_item (TScanner & scanner)
|
||||||
{
|
{
|
||||||
@ -942,14 +981,12 @@ void TSheet_field::create(WINDOW parent)
|
|||||||
show_window (_win, showed ());
|
show_window (_win, showed ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 100%
|
// Certified 100%
|
||||||
TArray & TSheet_field ::rows_array ()const
|
TArray & TSheet_field ::rows_array ()const
|
||||||
{
|
{
|
||||||
return _sheet->rows_array ();
|
return _sheet->rows_array ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 100%
|
// Certified 100%
|
||||||
// Ritorna l'indice della prima riga vuota dello sheet
|
// Ritorna l'indice della prima riga vuota dello sheet
|
||||||
int TSheet_field ::first_empty ()const
|
int TSheet_field ::first_empty ()const
|
||||||
@ -961,7 +998,6 @@ int TSheet_field::first_empty() const
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TToken_string & TSheet_field ::row (int n)
|
TToken_string & TSheet_field ::row (int n)
|
||||||
{
|
{
|
||||||
const int max = _sheet->items ();
|
const int max = _sheet->items ();
|
||||||
@ -973,7 +1009,6 @@ TToken_string& TSheet_field::row(int n)
|
|||||||
return _sheet->row (n);
|
return _sheet->row (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSheet_field ::force_update (int r)
|
void TSheet_field ::force_update (int r)
|
||||||
{
|
{
|
||||||
#if XVTWS == WMWS
|
#if XVTWS == WMWS
|
||||||
@ -983,7 +1018,6 @@ void TSheet_field::force_update(int r)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSheet_field ::set_window_data (const char *)
|
void TSheet_field ::set_window_data (const char *)
|
||||||
{
|
{
|
||||||
_sheet->set_dirty (FALSE);
|
_sheet->set_dirty (FALSE);
|
||||||
@ -995,37 +1029,31 @@ void TSheet_field::set_field_data(const char*)
|
|||||||
set_dirty (_sheet->dirty ());
|
set_dirty (_sheet->dirty ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int TSheet_field ::items ()const
|
int TSheet_field ::items ()const
|
||||||
{
|
{
|
||||||
return (int)_sheet->items ();
|
return (int)_sheet->items ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSheet_field ::set_notify (SPREADSHEET_NOTIFY n)
|
void TSheet_field ::set_notify (SPREADSHEET_NOTIFY n)
|
||||||
{
|
{
|
||||||
_sheet->set_notify (n);
|
_sheet->set_notify (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSheet_field ::enable_column (int column, bool on)
|
void TSheet_field ::enable_column (int column, bool on)
|
||||||
{
|
{
|
||||||
_sheet->enable_column (column, on);
|
_sheet->enable_column (column, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSheet_field ::enable_cell (int row, int column, bool on)
|
void TSheet_field ::enable_cell (int row, int column, bool on)
|
||||||
{
|
{
|
||||||
_sheet->enable_cell (row, column, on);
|
_sheet->enable_cell (row, column, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TMask & TSheet_field ::sheet_mask ()const
|
TMask & TSheet_field ::sheet_mask ()const
|
||||||
{
|
{
|
||||||
return _sheet->mask ();
|
return _sheet->mask ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TSheet_field ::on_key (KEY k)
|
bool TSheet_field ::on_key (KEY k)
|
||||||
{
|
{
|
||||||
if (k == K_TAB)
|
if (k == K_TAB)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// $Id: printapp.cpp,v 1.1.1.1 1994-08-12 10:51:57 alex Exp $
|
// $Id: printapp.cpp,v 1.2 1994-08-17 07:58:45 villa Exp $
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
@ -41,11 +41,18 @@ class _Transfield : public TObject
|
|||||||
TString _from, // "from" value
|
TString _from, // "from" value
|
||||||
_to, // "to" value
|
_to, // "to" value
|
||||||
_fn; // field name
|
_fn; // field name
|
||||||
|
|
||||||
int _lognum; // logical number
|
int _lognum; // logical number
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_Transfield (int l, const char *fn, const char *from, const char *to):
|
_Transfield (int l, const char *fn, const char *from, const char *to):
|
||||||
_from (3), _to (20), _fn (10)
|
_from (3), _to (20), _fn (10)
|
||||||
{ _lognum = l; _from = from; _to = to; _fn = fn; }
|
{
|
||||||
|
_lognum = l;
|
||||||
|
_from = from;
|
||||||
|
_to = to;
|
||||||
|
_fn = fn;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class _Token:public TObject
|
class _Token:public TObject
|
||||||
@ -54,11 +61,25 @@ friend class TPrint_application;
|
|||||||
int _tag;
|
int _tag;
|
||||||
int _row;
|
int _row;
|
||||||
public:
|
public:
|
||||||
int tag() { return _tag; }
|
int tag ()
|
||||||
int row() { return _row; }
|
{
|
||||||
void tag(int t) { _tag = t; }
|
return _tag;
|
||||||
void row(int r) { _row = r; }
|
}
|
||||||
virtual ~_Token() {}
|
int row ()
|
||||||
|
{
|
||||||
|
return _row;
|
||||||
|
}
|
||||||
|
void tag (int t)
|
||||||
|
{
|
||||||
|
_tag = t;
|
||||||
|
}
|
||||||
|
void row (int r)
|
||||||
|
{
|
||||||
|
_row = r;
|
||||||
|
}
|
||||||
|
virtual ~ _Token ()
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class _PrintfTok:public _Token
|
class _PrintfTok:public _Token
|
||||||
@ -68,8 +89,14 @@ friend class TPrint_application;
|
|||||||
TString _val;
|
TString _val;
|
||||||
public:
|
public:
|
||||||
_PrintfTok (int rw, const char *val):_val (0)
|
_PrintfTok (int rw, const char *val):_val (0)
|
||||||
{ tag(0); row(rw); _val = val; }
|
{
|
||||||
virtual ~_PrintfTok() {}
|
tag (0);
|
||||||
|
row (rw);
|
||||||
|
_val = val;
|
||||||
|
}
|
||||||
|
virtual ~ _PrintfTok ()
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class _FieldTok:public _Token
|
class _FieldTok:public _Token
|
||||||
@ -79,16 +106,25 @@ friend class TPrint_application;
|
|||||||
int _size, _dec;
|
int _size, _dec;
|
||||||
char _align;
|
char _align;
|
||||||
TString _fld; // field description
|
TString _fld; // field description
|
||||||
|
|
||||||
word _flags; // all you need to know
|
word _flags; // all you need to know
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_FieldTok (int rw, char *fld, word flags, char align = 'l',
|
_FieldTok (int rw, char *fld, word flags, char align = 'l',
|
||||||
int size = -1, int dec = -1):
|
int size = -1, int dec = -1):
|
||||||
_fld (20)
|
_fld (20)
|
||||||
{
|
{
|
||||||
tag(1); row(rw); _fld = (const char*)fld; _flags = flags;
|
tag (1);
|
||||||
_size = size, _align = align; _dec = dec; delete fld;
|
row (rw);
|
||||||
|
_fld = (const char *) fld;
|
||||||
|
_flags = flags;
|
||||||
|
_size = size, _align = align;
|
||||||
|
_dec = dec;
|
||||||
|
delete fld;
|
||||||
|
}
|
||||||
|
virtual ~ _FieldTok ()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
virtual ~_FieldTok() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class _PrintfRef:public _Token
|
class _PrintfRef:public _Token
|
||||||
@ -102,23 +138,33 @@ friend class TPrint_application;
|
|||||||
public:
|
public:
|
||||||
_PrintfRef (int rw, const char *fmt, char type, void *what):_fmt (1)
|
_PrintfRef (int rw, const char *fmt, char type, void *what):_fmt (1)
|
||||||
{
|
{
|
||||||
tag(2); row(rw); _type = type; _what = what; _fmt = fmt;
|
tag (2);
|
||||||
|
row (rw);
|
||||||
|
_type = type;
|
||||||
|
_what = what;
|
||||||
|
_fmt = fmt;
|
||||||
_fmt[0] = '%';
|
_fmt[0] = '%';
|
||||||
}
|
}
|
||||||
virtual ~_PrintfRef() {}
|
virtual ~ _PrintfRef ()
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void TPrint_application::_reset_tree(link_item* head)
|
void TPrint_application ::
|
||||||
|
_reset_tree (link_item * head)
|
||||||
{
|
{
|
||||||
if (head)
|
if (head)
|
||||||
{
|
{
|
||||||
if (head->_brother) _reset_tree(head->_brother);
|
if (head->_brother)
|
||||||
if (head->_son) _reset_tree(head->_son);
|
_reset_tree (head->_brother);
|
||||||
|
if (head->_son)
|
||||||
|
_reset_tree (head->_son);
|
||||||
delete head;
|
delete head;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
link_item* TPrint_application::_look_print_node(link_item* head, int logicnum)
|
link_item *TPrint_application ::
|
||||||
|
_look_print_node (link_item * head, int logicnum)
|
||||||
{
|
{
|
||||||
// look for <from> node to attach to
|
// look for <from> node to attach to
|
||||||
// since it reflects a relation, it won't have more than
|
// since it reflects a relation, it won't have more than
|
||||||
@ -126,7 +172,8 @@ link_item* TPrint_application::_look_print_node(link_item* head, int logicnum)
|
|||||||
link_item *s;
|
link_item *s;
|
||||||
while (head)
|
while (head)
|
||||||
{
|
{
|
||||||
if (head->_logicnum == logicnum) return head;
|
if (head->_logicnum == logicnum)
|
||||||
|
return head;
|
||||||
else if (head->_son)
|
else if (head->_son)
|
||||||
if ((s = _look_print_node (head->_son, logicnum)) != NULL)
|
if ((s = _look_print_node (head->_son, logicnum)) != NULL)
|
||||||
return s;
|
return s;
|
||||||
@ -135,12 +182,14 @@ link_item* TPrint_application::_look_print_node(link_item* head, int logicnum)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::add_file(const char* tab, int from)
|
void TPrint_application ::
|
||||||
|
add_file (const char *tab, int from)
|
||||||
{
|
{
|
||||||
add_file (TTable ::name2log (tab), from);
|
add_file (TTable ::name2log (tab), from);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::add_file(int file, int from)
|
void TPrint_application ::
|
||||||
|
add_file (int file, int from)
|
||||||
{
|
{
|
||||||
link_item *nw = new link_item (file);
|
link_item *nw = new link_item (file);
|
||||||
if (_pr_tree == NULL)
|
if (_pr_tree == NULL)
|
||||||
@ -159,10 +208,12 @@ void TPrint_application::add_file(int file, int from)
|
|||||||
if (fr->_son)
|
if (fr->_son)
|
||||||
{
|
{
|
||||||
fr = fr->_son;
|
fr = fr->_son;
|
||||||
while (fr->_brother) fr = fr->_brother;
|
while (fr->_brother)
|
||||||
|
fr = fr->_brother;
|
||||||
fr->_brother = nw;
|
fr->_brother = nw;
|
||||||
}
|
}
|
||||||
else fr->_son = nw;
|
else
|
||||||
|
fr->_son = nw;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
@ -170,21 +221,29 @@ void TPrint_application::add_file(int file, int from)
|
|||||||
|
|
||||||
static char tb[120];
|
static char tb[120];
|
||||||
|
|
||||||
int TPrint_application::enable_link (const char* descr, char fg, char bg)
|
int TPrint_application ::
|
||||||
|
enable_link (const char *descr, char fg, char bg)
|
||||||
{
|
{
|
||||||
TToken_string *tt = new TToken_string (30);
|
TToken_string *tt = new TToken_string (30);
|
||||||
char b[2]; b[1] = '\0';
|
char b[2];
|
||||||
tt->add(descr); b[0] = fg; tt->add(b); b[0] = bg; tt->add(b);
|
b[1] = '\0';
|
||||||
|
tt->add (descr);
|
||||||
|
b[0] = fg;
|
||||||
|
tt->add (b);
|
||||||
|
b[0] = bg;
|
||||||
|
tt->add (b);
|
||||||
printer ().links ().add (tt);
|
printer ().links ().add (tt);
|
||||||
return printer ().links ().items () - 1;
|
return printer ().links ().items () - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::disable_link(char fg, char bg)
|
void TPrint_application ::
|
||||||
|
disable_link (char fg, char bg)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < printer ().links ().items (); i++)
|
for (int i = 0; i < printer ().links ().items (); i++)
|
||||||
{
|
{
|
||||||
TToken_string & t = (TToken_string &) printer ().links ()[i];
|
TToken_string & t = (TToken_string &) printer ().links ()[i];
|
||||||
char f = *(t.get(1)); char b = *(t.get(2));
|
char f = *(t.get (1));
|
||||||
|
char b = *(t.get (2));
|
||||||
if (f == fg && b == bg)
|
if (f == fg && b == bg)
|
||||||
{
|
{
|
||||||
printer ().links ().add (NULL, i);
|
printer ().links ().add (NULL, i);
|
||||||
@ -194,19 +253,21 @@ void TPrint_application::disable_link(char fg, char bg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::set_multiple_link(bool on)
|
void TPrint_application ::
|
||||||
|
set_multiple_link (bool on)
|
||||||
{
|
{
|
||||||
printer ().setmultiplelink (on);
|
printer ().setmultiplelink (on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TPrint_application ::
|
||||||
void TPrint_application::_pp_link(int id, const char* text)
|
_pp_link (int id, const char *text)
|
||||||
{
|
{
|
||||||
TPrint_application *prapp = (TPrint_application *) MainApp ();
|
TPrint_application *prapp = (TPrint_application *) MainApp ();
|
||||||
prapp->process_link (id, text);
|
prapp->process_link (id, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::_pp_header(TPrinter&)
|
void TPrint_application ::
|
||||||
|
_pp_header (TPrinter &)
|
||||||
{
|
{
|
||||||
TPrint_application *prapp = (TPrint_application *) MainApp ();
|
TPrint_application *prapp = (TPrint_application *) MainApp ();
|
||||||
|
|
||||||
@ -221,8 +282,8 @@ void TPrint_application::_pp_header(TPrinter&)
|
|||||||
new TPrintrow ((TPrintrow &) (prapp->_header)[i]));
|
new TPrintrow ((TPrintrow &) (prapp->_header)[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TPrint_application ::
|
||||||
void TPrint_application::_pp_footer(TPrinter&)
|
_pp_footer (TPrinter &)
|
||||||
{
|
{
|
||||||
TPrint_application *prapp = (TPrint_application *) MainApp ();
|
TPrint_application *prapp = (TPrint_application *) MainApp ();
|
||||||
|
|
||||||
@ -235,15 +296,14 @@ void TPrint_application::_pp_footer(TPrinter&)
|
|||||||
new TPrintrow ((TPrintrow &) (prapp->_footer)[i]));
|
new TPrintrow ((TPrintrow &) (prapp->_footer)[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TPrint_application ::
|
||||||
void TPrint_application::set_background(const char* bgdesc)
|
set_background (const char *bgdesc)
|
||||||
{
|
{
|
||||||
printer ().setbackground (bgdesc);
|
printer ().setbackground (bgdesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
FLD (int lognum, const char *f, int from, int to)
|
||||||
const char* FLD(int lognum, const char* f, int from, int to)
|
|
||||||
{
|
{
|
||||||
sprintf (tb, "%c|%d|%s|%d|%d", 'n', lognum, f, from, to);
|
sprintf (tb, "%c|%d|%s|%d|%d", 'n', lognum, f, from, to);
|
||||||
char *p = new char[strlen (tb) + 1];
|
char *p = new char[strlen (tb) + 1];
|
||||||
@ -251,7 +311,8 @@ const char* FLD(int lognum, const char* f, int from, int to)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* FLD(int lognum, const char* f, const char* picture)
|
const char *
|
||||||
|
FLD (int lognum, const char *f, const char *picture)
|
||||||
{
|
{
|
||||||
sprintf (tb, "%c|%d|%s|%s", 'p', lognum, f, picture);
|
sprintf (tb, "%c|%d|%s|%s", 'p', lognum, f, picture);
|
||||||
char *p = new char[strlen (tb) + 1];
|
char *p = new char[strlen (tb) + 1];
|
||||||
@ -259,7 +320,8 @@ const char* FLD(int lognum, const char* f, const char* picture)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* FLD(const char* tabname, const char* f, int from, int to)
|
const char *
|
||||||
|
FLD (const char *tabname, const char *f, int from, int to)
|
||||||
{
|
{
|
||||||
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
|
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
|
||||||
int lognum = TTable ::name2log (tabname);
|
int lognum = TTable ::name2log (tabname);
|
||||||
@ -269,8 +331,8 @@ const char* FLD(const char* tabname, const char* f, int from, int to)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
const char* FLD(const char* tabname, const char* f, const char* picture)
|
FLD (const char *tabname, const char *f, const char *picture)
|
||||||
{
|
{
|
||||||
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
|
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
|
||||||
int lognum = TTable ::name2log (tabname);
|
int lognum = TTable ::name2log (tabname);
|
||||||
@ -280,13 +342,22 @@ const char* FLD(const char* tabname, const char* f, const char* picture)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TString & fill_str (TString & t, char f)
|
TString & fill_str (TString & t, char f)
|
||||||
{
|
{
|
||||||
for (int kk = t.len () - 1; kk >= 0; kk--)
|
for (int kk = t.len () - 1; kk >= 0; kk--)
|
||||||
{ if (t[kk] == ' ') t[kk] = f; else break; }
|
{
|
||||||
|
if (t[kk] == ' ')
|
||||||
|
t[kk] = f;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
for (kk = 0; kk < t.len (); kk++)
|
for (kk = 0; kk < t.len (); kk++)
|
||||||
{ if (t[kk] == ' ') t[kk] = f; else break; }
|
{
|
||||||
|
if (t[kk] == ' ')
|
||||||
|
t[kk] = f;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,27 +370,36 @@ TString& fill_str(TString& t, char f)
|
|||||||
// printer().setlinkdescr(descr);
|
// printer().setlinkdescr(descr);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void TPrint_application::select_cursor(int c)
|
void TPrint_application ::
|
||||||
|
select_cursor (int c)
|
||||||
{
|
{
|
||||||
if (c == -1) _cur = NULL;
|
if (c == -1)
|
||||||
else _cur = (TCursor*) &_cursors[c];
|
_cur = NULL;
|
||||||
|
else
|
||||||
|
_cur = (TCursor *) & _cursors[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
TCursor* TPrint_application::get_cursor(int c)
|
TCursor *TPrint_application ::
|
||||||
|
get_cursor (int c)
|
||||||
{
|
{
|
||||||
if (c == -1) return NULL;
|
if (c == -1)
|
||||||
else return (TCursor*) &_cursors[c];
|
return NULL;
|
||||||
|
else
|
||||||
|
return (TCursor *) & _cursors[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
int TPrint_application::add_cursor(TCursor* c)
|
int TPrint_application ::
|
||||||
|
add_cursor (TCursor * c)
|
||||||
{
|
{
|
||||||
if (c == NULL) return -1;
|
if (c == NULL)
|
||||||
|
return -1;
|
||||||
_cursors.add (c);
|
_cursors.add (c);
|
||||||
_cur = c;
|
_cur = c;
|
||||||
return _cursors.items () - 1;
|
return _cursors.items () - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::reset_row(int r)
|
void TPrint_application ::
|
||||||
|
reset_row (int r)
|
||||||
{
|
{
|
||||||
r--;
|
r--;
|
||||||
int tmp = _rows.items ();
|
int tmp = _rows.items ();
|
||||||
@ -337,14 +417,16 @@ void TPrint_application::reset_row(int r)
|
|||||||
_maxrow--;
|
_maxrow--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::reset_print()
|
void TPrint_application ::
|
||||||
|
reset_print ()
|
||||||
{
|
{
|
||||||
_rows.destroy ();
|
_rows.destroy ();
|
||||||
_maxrow = 0;
|
_maxrow = 0;
|
||||||
_print_defined = FALSE;
|
_print_defined = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::set_header(int r, const char* fmt, ...)
|
void TPrint_application ::
|
||||||
|
set_header (int r, const char *fmt,...)
|
||||||
{
|
{
|
||||||
CHECK (r >= 1, "Header rows start at 1");
|
CHECK (r >= 1, "Header rows start at 1");
|
||||||
va_list vl;
|
va_list vl;
|
||||||
@ -361,7 +443,8 @@ void TPrint_application::set_header(int r, const char* fmt, ...)
|
|||||||
pp->put (__tmp_string);
|
pp->put (__tmp_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::set_footer(int r, const char* fmt, ...)
|
void TPrint_application ::
|
||||||
|
set_footer (int r, const char *fmt,...)
|
||||||
{
|
{
|
||||||
CHECK (r >= 1, "Footer rows start at 1");
|
CHECK (r >= 1, "Footer rows start at 1");
|
||||||
va_list vl;
|
va_list vl;
|
||||||
@ -377,27 +460,33 @@ void TPrint_application::set_footer(int r, const char* fmt, ...)
|
|||||||
pp->put (__tmp_string);
|
pp->put (__tmp_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::reset_header()
|
void TPrint_application ::
|
||||||
|
reset_header ()
|
||||||
{
|
{
|
||||||
_header.destroy ();
|
_header.destroy ();
|
||||||
printer ().resetheader ();
|
printer ().resetheader ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::reset_footer()
|
void TPrint_application ::
|
||||||
|
reset_footer ()
|
||||||
{
|
{
|
||||||
_footer.destroy ();
|
_footer.destroy ();
|
||||||
printer ().resetfooter ();
|
printer ().resetfooter ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::fill_page(int from)
|
void TPrint_application ::
|
||||||
|
fill_page (int from)
|
||||||
{
|
{
|
||||||
from--;
|
from--;
|
||||||
for (int i = (from == -1 ? _maxrow : from); i <= printer ().formlen (); i++)
|
for (int i = (from == -1 ? _maxrow : from); i <= printer ().formlen (); i++)
|
||||||
{ reset_row(i); set_row(i,""); }
|
{
|
||||||
|
reset_row (i);
|
||||||
|
set_row (i, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TPrint_application ::
|
||||||
void TPrint_application::set_row(int r, const char* frmt, ...)
|
set_row (int r, const char *frmt,...)
|
||||||
{
|
{
|
||||||
CHECK (r >= 1, "Print rows start at 1");
|
CHECK (r >= 1, "Print rows start at 1");
|
||||||
|
|
||||||
@ -418,7 +507,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
|
|||||||
_print_defined = TRUE;
|
_print_defined = TRUE;
|
||||||
|
|
||||||
_currow = r;
|
_currow = r;
|
||||||
if (_currow > _maxrow) _maxrow = _currow;
|
if (_currow > _maxrow)
|
||||||
|
_maxrow = _currow;
|
||||||
|
|
||||||
va_list params;
|
va_list params;
|
||||||
va_start (params, frmt);
|
va_start (params, frmt);
|
||||||
@ -438,7 +528,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
|
|||||||
ch = *fmt++;
|
ch = *fmt++;
|
||||||
if (isdigit (ch))
|
if (isdigit (ch))
|
||||||
{
|
{
|
||||||
int i = 0; digbuf[i++] = ch;
|
int i = 0;
|
||||||
|
digbuf[i++] = ch;
|
||||||
while (isdigit (ch = *fmt++))
|
while (isdigit (ch = *fmt++))
|
||||||
digbuf[i++] = ch;
|
digbuf[i++] = ch;
|
||||||
digbuf[i] = '\0';
|
digbuf[i] = '\0';
|
||||||
@ -447,7 +538,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
|
|||||||
if (ch == '.')
|
if (ch == '.')
|
||||||
{
|
{
|
||||||
// decimal size follows
|
// decimal size follows
|
||||||
i = 0; digbuf[i++] = ch;
|
i = 0;
|
||||||
|
digbuf[i++] = ch;
|
||||||
while (isdigit (ch = *fmt++))
|
while (isdigit (ch = *fmt++))
|
||||||
digbuf[i] = ch;
|
digbuf[i] = ch;
|
||||||
digbuf[i] = '\0';
|
digbuf[i] = '\0';
|
||||||
@ -573,20 +665,29 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// read format
|
// read format
|
||||||
t << ccc; bool islong = FALSE;
|
t << ccc;
|
||||||
|
bool islong = FALSE;
|
||||||
while (strchr (printf_types, ch) == NULL)
|
while (strchr (printf_types, ch) == NULL)
|
||||||
{
|
{
|
||||||
t << ch;
|
t << ch;
|
||||||
if (ch == 'l') islong = TRUE;
|
if (ch == 'l')
|
||||||
|
islong = TRUE;
|
||||||
ch = *fmt++;
|
ch = *fmt++;
|
||||||
if (ch == '\0')
|
if (ch == '\0')
|
||||||
fatal_box ("sorry, zer's samzing vruong"
|
fatal_box ("sorry, zer's samzing vruong"
|
||||||
" uitz ioar format.");
|
" uitz ioar format.");
|
||||||
}
|
}
|
||||||
if (isupper(ch)) { ch = tolower(ch); fill = ' '; }
|
if (isupper (ch))
|
||||||
if (ch == 't') t << 's';
|
{
|
||||||
else if (ch == 'r') t << 't';
|
ch = tolower (ch);
|
||||||
else t << ch;
|
fill = ' ';
|
||||||
|
}
|
||||||
|
if (ch == 't')
|
||||||
|
t << 's';
|
||||||
|
else if (ch == 'r')
|
||||||
|
t << 't';
|
||||||
|
else
|
||||||
|
t << ch;
|
||||||
if (ccc == '%')
|
if (ccc == '%')
|
||||||
{
|
{
|
||||||
TString q (60);
|
TString q (60);
|
||||||
@ -615,10 +716,12 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
|
|||||||
q.format (t, va_arg (params, char *));
|
q.format (t, va_arg (params, char *));
|
||||||
break;
|
break;
|
||||||
case 't': // TString
|
case 't': // TString
|
||||||
|
|
||||||
q.format (t, (const char *)
|
q.format (t, (const char *)
|
||||||
(TString) * ((va_arg (params, TString *))));
|
(TString) * ((va_arg (params, TString *))));
|
||||||
break;
|
break;
|
||||||
case 'r': // Real
|
case 'r': // Real
|
||||||
|
|
||||||
{
|
{
|
||||||
real *rrr = va_arg (params, real *);
|
real *rrr = va_arg (params, real *);
|
||||||
if (t.len () == 2 && *_picture)
|
if (t.len () == 2 && *_picture)
|
||||||
@ -630,7 +733,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *fff = (char *) ((const char *) t);
|
char *fff = (char *) ((const char *) t);
|
||||||
// dsprintf(__tmp_string, fff, (DEC*)(*rrr));
|
// dsprintf(__tmp_string, fff,
|
||||||
|
// (DEC*)(*rrr));
|
||||||
dsprintf (__tmp_string, fff, rrr->ptr ());
|
dsprintf (__tmp_string, fff, rrr->ptr ());
|
||||||
q = __tmp_string;
|
q = __tmp_string;
|
||||||
}
|
}
|
||||||
@ -641,7 +745,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fill != ' ') q = fill_str(q,fill);
|
if (fill != ' ')
|
||||||
|
q = fill_str (q, fill);
|
||||||
fill = _fillchar;
|
fill = _fillchar;
|
||||||
_rows.add (new _PrintfTok (_currow, q));
|
_rows.add (new _PrintfTok (_currow, q));
|
||||||
}
|
}
|
||||||
@ -652,11 +757,13 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\n': // ignore
|
case '\n': // ignore
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// add to string
|
// add to string
|
||||||
strbuf[strind++] = ch;
|
strbuf[strind++] = ch;
|
||||||
if (!ch) fmt--;
|
if (!ch)
|
||||||
|
fmt--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -670,13 +777,15 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
|
|||||||
va_end (params);
|
va_end (params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::set_translation(int lognum, const char* field,
|
void TPrint_application ::
|
||||||
|
set_translation (int lognum, const char *field,
|
||||||
const char *from, const char *to)
|
const char *from, const char *to)
|
||||||
{
|
{
|
||||||
_transtab.add (new _Transfield (lognum, field, from, to));
|
_transtab.add (new _Transfield (lognum, field, from, to));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::print()
|
void TPrint_application ::
|
||||||
|
print ()
|
||||||
{
|
{
|
||||||
// open printer if needed
|
// open printer if needed
|
||||||
if (!(printer ().isopen ()))
|
if (!(printer ().isopen ()))
|
||||||
@ -687,7 +796,8 @@ void TPrint_application::print()
|
|||||||
// pre and post process do everything
|
// pre and post process do everything
|
||||||
if (_cur == NULL)
|
if (_cur == NULL)
|
||||||
{
|
{
|
||||||
int cnt = 0; bool ok = TRUE;
|
int cnt = 0;
|
||||||
|
bool ok = TRUE;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (preprocess_print (0, cnt))
|
if (preprocess_print (0, cnt))
|
||||||
@ -735,7 +845,8 @@ void TPrint_application::print()
|
|||||||
postclose_print ();
|
postclose_print ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TPrint_application::print_tree(link_item* head)
|
bool TPrint_application ::
|
||||||
|
print_tree (link_item * head)
|
||||||
{
|
{
|
||||||
bool go = TRUE;
|
bool go = TRUE;
|
||||||
while (head)
|
while (head)
|
||||||
@ -774,22 +885,24 @@ bool TPrint_application::print_tree(link_item* head)
|
|||||||
while (go && postprocess_print (head->_logicnum, head->_cnt++)
|
while (go && postprocess_print (head->_logicnum, head->_cnt++)
|
||||||
== REPEAT_PAGE);
|
== REPEAT_PAGE);
|
||||||
}
|
}
|
||||||
if (!go) break;
|
if (!go)
|
||||||
|
break;
|
||||||
go = TRUE;
|
go = TRUE;
|
||||||
head = head->_brother;
|
head = head->_brother;
|
||||||
}
|
}
|
||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TPrint_application ::
|
||||||
bool TPrint_application::print_one(int file)
|
print_one (int file)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (_prind && _prind->iscancelled())
|
if ((_prind && _prind->iscancelled ()) || printer ().frozen ())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!_print_defined) return TRUE;
|
if (!_print_defined)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
if (_prind && file == _pr_tree->_logicnum)
|
if (_prind && file == _pr_tree->_logicnum)
|
||||||
_prind->addstatus (1);
|
_prind->addstatus (1);
|
||||||
@ -808,7 +921,9 @@ bool TPrint_application::print_one(int file)
|
|||||||
for (int j = 0; j < _rows.items (); j++)
|
for (int j = 0; j < _rows.items (); j++)
|
||||||
{
|
{
|
||||||
_Token *t = (_Token *) & (_rows[j]);
|
_Token *t = (_Token *) & (_rows[j]);
|
||||||
if (!t) continue; // should not happen
|
if (!t)
|
||||||
|
continue; // should not happen
|
||||||
|
|
||||||
if (t->row () == i)
|
if (t->row () == i)
|
||||||
{
|
{
|
||||||
char pic[36], fn[17];
|
char pic[36], fn[17];
|
||||||
@ -895,7 +1010,8 @@ bool TPrint_application::print_one(int file)
|
|||||||
}
|
}
|
||||||
if (i == _transtab.items ())
|
if (i == _transtab.items ())
|
||||||
toprint = "";
|
toprint = "";
|
||||||
else toprint = tr->_to;
|
else
|
||||||
|
toprint = tr->_to;
|
||||||
}
|
}
|
||||||
else if (ft->_flags & DATE_FLAG)
|
else if (ft->_flags & DATE_FLAG)
|
||||||
{
|
{
|
||||||
@ -929,7 +1045,8 @@ bool TPrint_application::print_one(int file)
|
|||||||
toprint = r.string (pict);
|
toprint = r.string (pict);
|
||||||
else if (ft->_flags & DEC_FLAG)
|
else if (ft->_flags & DEC_FLAG)
|
||||||
toprint = r.string (ft->_size, ft->_dec);
|
toprint = r.string (ft->_size, ft->_dec);
|
||||||
else toprint = r.string();
|
else
|
||||||
|
toprint = r.string ();
|
||||||
|
|
||||||
if (r.is_zero () && !_print_zero)
|
if (r.is_zero () && !_print_zero)
|
||||||
toprint.fill (' ');
|
toprint.fill (' ');
|
||||||
@ -1060,7 +1177,8 @@ bool TPrint_application::print_one(int file)
|
|||||||
return i == _maxrow + 1;
|
return i == _maxrow + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TPrint_application::menu(MENU_TAG m)
|
bool TPrint_application ::
|
||||||
|
menu (MENU_TAG m)
|
||||||
{
|
{
|
||||||
// funziona da se' fino a 20 voci della menubar
|
// funziona da se' fino a 20 voci della menubar
|
||||||
if (m >= BAR_ITEM (1) && m <= BAR_ITEM (20))
|
if (m >= BAR_ITEM (1) && m <= BAR_ITEM (20))
|
||||||
@ -1073,7 +1191,8 @@ bool TPrint_application::menu(MENU_TAG m)
|
|||||||
return !xvt_test_menu_tag (BAR_ITEM (2));
|
return !xvt_test_menu_tag (BAR_ITEM (2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TPrint_application::create()
|
bool TPrint_application ::
|
||||||
|
create ()
|
||||||
{
|
{
|
||||||
TApplication ::create ();
|
TApplication ::create ();
|
||||||
printer ().setfooterhandler (_pp_footer);
|
printer ().setfooterhandler (_pp_footer);
|
||||||
@ -1084,14 +1203,16 @@ bool TPrint_application::create()
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TPrint_application::destroy()
|
bool TPrint_application ::
|
||||||
|
destroy ()
|
||||||
{
|
{
|
||||||
user_destroy ();
|
user_destroy ();
|
||||||
TApplication ::destroy ();
|
TApplication ::destroy ();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::do_print(int n)
|
void TPrint_application ::
|
||||||
|
do_print (int n)
|
||||||
{
|
{
|
||||||
while (set_print (n))
|
while (set_print (n))
|
||||||
{
|
{
|
||||||
@ -1100,22 +1221,26 @@ void TPrint_application::do_print(int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::enable_print_menu()
|
void TPrint_application ::
|
||||||
|
enable_print_menu ()
|
||||||
{
|
{
|
||||||
enable_menu_item (M_FILE_PRINT, TRUE);
|
enable_menu_item (M_FILE_PRINT, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::disable_print_menu()
|
void TPrint_application ::
|
||||||
|
disable_print_menu ()
|
||||||
{
|
{
|
||||||
enable_menu_item (M_FILE_PRINT, FALSE);
|
enable_menu_item (M_FILE_PRINT, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::enable_setprint_menu()
|
void TPrint_application ::
|
||||||
|
enable_setprint_menu ()
|
||||||
{
|
{
|
||||||
enable_menu_item (BAR_ITEM (1), TRUE);
|
enable_menu_item (BAR_ITEM (1), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::disable_setprint_menu()
|
void TPrint_application ::
|
||||||
|
disable_setprint_menu ()
|
||||||
{
|
{
|
||||||
enable_menu_item (BAR_ITEM (1), FALSE);
|
enable_menu_item (BAR_ITEM (1), FALSE);
|
||||||
}
|
}
|
||||||
@ -1143,7 +1268,6 @@ TPrint_application::TPrint_application() : TApplication(), _transtab(10),
|
|||||||
_last_choice = BAR_ITEM (1);
|
_last_choice = BAR_ITEM (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TPrint_application ::~TPrint_application ()
|
TPrint_application ::~TPrint_application ()
|
||||||
{
|
{
|
||||||
reset_files ();
|
reset_files ();
|
||||||
|
1531
include/printer.cpp
1531
include/printer.cpp
File diff suppressed because it is too large
Load Diff
230
include/text.cpp
230
include/text.cpp
@ -10,47 +10,74 @@ public:
|
|||||||
// TArray _spots; // tokenstrings
|
// TArray _spots; // tokenstrings
|
||||||
char _bg, _fg;
|
char _bg, _fg;
|
||||||
|
|
||||||
_HotSpot(char fg, char bg) { _fg = fg; _bg = bg; }
|
_HotSpot (char fg, char bg)
|
||||||
virtual ~_HotSpot() {}
|
{
|
||||||
|
_fg = fg;
|
||||||
|
_bg = bg;
|
||||||
|
}
|
||||||
|
virtual ~ _HotSpot ()
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void TTextfile ::
|
||||||
void TTextfile::set_hotspots(char fg, char bg)
|
set_hotspots (char fg, char bg)
|
||||||
{
|
{
|
||||||
_HotSpot *hp = new _HotSpot (fg, bg);
|
_HotSpot *hp = new _HotSpot (fg, bg);
|
||||||
_hotspots.add (hp);
|
_hotspots.add (hp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
style TTextfile ::
|
||||||
style TTextfile::_trans_style(char ch)
|
_trans_style (char ch)
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case 'r': return normal; break;
|
case 'r':
|
||||||
case 'i': return italic; break;
|
return normal;
|
||||||
case 'b': return bold; break;
|
break;
|
||||||
case 'u': return underlined; break;
|
case 'i':
|
||||||
case 'o': return overstrike; break;
|
return italic;
|
||||||
case 'k': return smallcaps; break;
|
break;
|
||||||
default: return normal; break;
|
case 'b':
|
||||||
|
return bold;
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
return underlined;
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
return overstrike;
|
||||||
|
break;
|
||||||
|
case 'k':
|
||||||
|
return smallcaps;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return normal;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTextfile::_read_page(long n)
|
void TTextfile ::
|
||||||
|
_read_page (long n)
|
||||||
{
|
{
|
||||||
switch (_direction)
|
switch (_direction)
|
||||||
{
|
{
|
||||||
case down:
|
case down:
|
||||||
_page_start = n; break;
|
_page_start = n;
|
||||||
|
break;
|
||||||
case up:
|
case up:
|
||||||
_page_start = n + _page_size; break;
|
_page_start = n + _page_size;
|
||||||
|
break;
|
||||||
case updown:
|
case updown:
|
||||||
_page_start = n - (_page_size/2l); break;
|
_page_start = n - (_page_size / 2l);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_page_start < 0l) _page_start = 0l;
|
if (_page_start < 0l)
|
||||||
if ((_page_start + _page_size) > _lines) _page_end = _lines -1;
|
_page_start = 0l;
|
||||||
else _page_end = _page_start + _page_size - 1;
|
if ((_page_start + _page_size) > _lines)
|
||||||
|
_page_end = _lines - 1;
|
||||||
|
else
|
||||||
|
_page_end = _page_start + _page_size - 1;
|
||||||
|
|
||||||
// zap hotspots
|
// zap hotspots
|
||||||
_spots.destroy ();
|
_spots.destroy ();
|
||||||
@ -72,8 +99,8 @@ void TTextfile::_read_page(long n)
|
|||||||
TString hcol (6);
|
TString hcol (6);
|
||||||
// find hotspots and compile list
|
// find hotspots and compile list
|
||||||
|
|
||||||
|
int len = 0;
|
||||||
int len = 0; const char* cp;
|
const char *cp;
|
||||||
read_line (i, 0, FALSE);
|
read_line (i, 0, FALSE);
|
||||||
while (cp = piece ())
|
while (cp = piece ())
|
||||||
{
|
{
|
||||||
@ -84,7 +111,11 @@ void TTextfile::_read_page(long n)
|
|||||||
{
|
{
|
||||||
TToken_string *tts = new TToken_string (50);
|
TToken_string *tts = new TToken_string (50);
|
||||||
tts->add (i); // line number
|
tts->add (i); // line number
|
||||||
tts->add(len); tts->add(len + (int)strlen(cp) ); tts->add(cp); tts->add(z);
|
|
||||||
|
tts->add (len);
|
||||||
|
tts->add (len + (int) strlen (cp));
|
||||||
|
tts->add (cp);
|
||||||
|
tts->add (z);
|
||||||
_spots.add (tts);
|
_spots.add (tts);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -94,18 +125,22 @@ void TTextfile::_read_page(long n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTextfile::read_line(long n, long pos, bool pg)
|
void TTextfile ::
|
||||||
|
read_line (long n, long pos, bool pg)
|
||||||
{
|
{
|
||||||
CHECK (_isopen, "Attempt operation on closed file");
|
CHECK (_isopen, "Attempt operation on closed file");
|
||||||
CHECKD (n >= 0 && n < _lines, "Line not present", n);
|
CHECKD (n >= 0 && n < _lines, "Line not present", n);
|
||||||
|
|
||||||
if (pg && !_in_page(n)) _read_page(n);
|
if (pg && !_in_page (n))
|
||||||
|
_read_page (n);
|
||||||
|
|
||||||
TString *tp = (TString *) _page.objptr (int (n - _page_start));
|
TString *tp = (TString *) _page.objptr (int (n - _page_start));
|
||||||
if (tp == NULL) return;
|
if (tp == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
const char *sp = (const char *) (*tp);
|
const char *sp = (const char *) (*tp);
|
||||||
_item = 0; _line = "";
|
_item = 0;
|
||||||
|
_line = "";
|
||||||
int ndx = 0, p = 0;
|
int ndx = 0, p = 0;
|
||||||
bool first = TRUE;
|
bool first = TRUE;
|
||||||
_cur_line = n;
|
_cur_line = n;
|
||||||
@ -128,21 +163,30 @@ void TTextfile::read_line(long n, long pos, bool pg)
|
|||||||
while (ch && (ch == '@' || (ch == '$' && *sp == '[')))
|
while (ch && (ch == '@' || (ch == '$' && *sp == '[')))
|
||||||
{
|
{
|
||||||
if (ch == '@') // font style change ?
|
if (ch == '@') // font style change ?
|
||||||
|
|
||||||
{
|
{
|
||||||
style sss = _trans_style (*sp++);
|
style sss = _trans_style (*sp++);
|
||||||
if (sss == normal) stl = (long)col << 16; else stl |= (long)sss;
|
if (sss == normal)
|
||||||
|
stl = (long) col << 16;
|
||||||
|
else
|
||||||
|
stl |= (long) sss;
|
||||||
}
|
}
|
||||||
else if (ch == '$' && *sp == '[') // color change
|
else if (ch == '$' && *sp == '[') // color change
|
||||||
|
|
||||||
{
|
{
|
||||||
++sp; // eat '['
|
++sp; // eat '['
|
||||||
|
|
||||||
col = *sp++;
|
col = *sp++;
|
||||||
++sp; // eat ','
|
++sp; // eat ','
|
||||||
|
|
||||||
col |= ((int) (*sp++) << 8);
|
col |= ((int) (*sp++) << 8);
|
||||||
++sp; // eat ']'
|
++sp; // eat ']'
|
||||||
|
|
||||||
stl = (stl & 0x0000ffff) | ((long) col << 16);
|
stl = (stl & 0x0000ffff) | ((long) col << 16);
|
||||||
}
|
}
|
||||||
ch = *sp++;
|
ch = *sp++;
|
||||||
} // while
|
} // while
|
||||||
|
|
||||||
}
|
}
|
||||||
if (ch && p >= pos)
|
if (ch && p >= pos)
|
||||||
{
|
{
|
||||||
@ -157,9 +201,11 @@ void TTextfile::read_line(long n, long pos, bool pg)
|
|||||||
_item = 0;
|
_item = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TTextfile::line(long j, long pos)
|
const char *TTextfile ::
|
||||||
|
line (long j, long pos)
|
||||||
{
|
{
|
||||||
if (_cur_line != j) read_line(j);
|
if (_cur_line != j)
|
||||||
|
read_line (j);
|
||||||
*mytmpstr = '\0';
|
*mytmpstr = '\0';
|
||||||
_line.restart ();
|
_line.restart ();
|
||||||
for (int i = 0; i < _line.items (); i++)
|
for (int i = 0; i < _line.items (); i++)
|
||||||
@ -167,7 +213,8 @@ const char* TTextfile::line(long j, long pos)
|
|||||||
return strlen (mytmpstr) > (word) pos ? &(mytmpstr[pos]) : "";
|
return strlen (mytmpstr) > (word) pos ? &(mytmpstr[pos]) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
long TTextfile::get_attribute(int pos)
|
long TTextfile ::
|
||||||
|
get_attribute (int pos)
|
||||||
{
|
{
|
||||||
long stl = 0;
|
long stl = 0;
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
@ -177,42 +224,51 @@ long TTextfile::get_attribute(int pos)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int x = 0, nd = 0; const char* c;
|
int x = 0, nd = 0;
|
||||||
|
const char *c;
|
||||||
_line.restart ();
|
_line.restart ();
|
||||||
while (c = _line.get ())
|
while (c = _line.get ())
|
||||||
{
|
{
|
||||||
x += strlen (c);
|
x += strlen (c);
|
||||||
stl = _styles[nd++];
|
stl = _styles[nd++];
|
||||||
if ((x-1) >= pos) break; }
|
if ((x - 1) >= pos)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return stl;
|
return stl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TTextfile::get_style(int pos)
|
int TTextfile ::
|
||||||
|
get_style (int pos)
|
||||||
{
|
{
|
||||||
long x = get_attribute (pos);
|
long x = get_attribute (pos);
|
||||||
return (int) (x & 0x0000ffff);
|
return (int) (x & 0x0000ffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
char TTextfile::get_background(int pos)
|
char TTextfile ::
|
||||||
|
get_background (int pos)
|
||||||
{
|
{
|
||||||
long x = get_attribute (pos);
|
long x = get_attribute (pos);
|
||||||
return (char) (x >> 24);
|
return (char) (x >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
char TTextfile::get_foreground(int pos)
|
char TTextfile ::
|
||||||
|
get_foreground (int pos)
|
||||||
{
|
{
|
||||||
long x = get_attribute (pos);
|
long x = get_attribute (pos);
|
||||||
return (char) ((x >> 16) & 0x000000ff);
|
return (char) ((x >> 16) & 0x000000ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TTextfile::piece()
|
const char *TTextfile ::
|
||||||
|
piece ()
|
||||||
{
|
{
|
||||||
if (_item >= _line.items()) return NULL;
|
if (_item >= _line.items ())
|
||||||
|
return NULL;
|
||||||
return strcpy (mytmpstr, (const char *) _line.get (_item++));
|
return strcpy (mytmpstr, (const char *) _line.get (_item++));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TTextfile::word_at(long x, long y)
|
const char *TTextfile ::
|
||||||
|
word_at (long x, long y)
|
||||||
{
|
{
|
||||||
CHECK (_isopen, "Attempt operation on closed file");
|
CHECK (_isopen, "Attempt operation on closed file");
|
||||||
TString s (line (y));
|
TString s (line (y));
|
||||||
@ -223,22 +279,29 @@ const char* TTextfile::word_at(long x, long y)
|
|||||||
while (isspace (s[(int) x]))
|
while (isspace (s[(int) x]))
|
||||||
{
|
{
|
||||||
if (x == (s.len () - 1) && y < (_lines - 1l))
|
if (x == (s.len () - 1) && y < (_lines - 1l))
|
||||||
{ s = line(++y); x = 0l;}
|
{
|
||||||
else if (x < (s.len() - 1)) x++;
|
s = line (++y);
|
||||||
else break;
|
x = 0l;
|
||||||
}
|
}
|
||||||
while (isalnum(s[(int)x])) mytmpstr[x2++] = s[(int)x++];
|
else if (x < (s.len () - 1))
|
||||||
|
x++;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (isalnum (s[(int) x]))
|
||||||
|
mytmpstr[x2++] = s[(int) x++];
|
||||||
}
|
}
|
||||||
mytmpstr[x2] = '\0';
|
mytmpstr[x2] = '\0';
|
||||||
return mytmpstr;
|
return mytmpstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TTextfile ::
|
||||||
bool TTextfile::append(const char* l)
|
append (const char *l)
|
||||||
{
|
{
|
||||||
CHECK (_isopen, "Attempt operation on closed file");
|
CHECK (_isopen, "Attempt operation on closed file");
|
||||||
|
|
||||||
if (!_accept) return FALSE;
|
if (!_accept)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
fseek (_instr, 0l, SEEK_END);
|
fseek (_instr, 0l, SEEK_END);
|
||||||
fseek (_index, 0l, SEEK_END);
|
fseek (_index, 0l, SEEK_END);
|
||||||
@ -250,9 +313,11 @@ bool TTextfile::append(const char* l)
|
|||||||
error_box ("Errore di scrittura file temporaneo: scrittura interrotta");
|
error_box ("Errore di scrittura file temporaneo: scrittura interrotta");
|
||||||
freeze ();
|
freeze ();
|
||||||
}
|
}
|
||||||
fflush(_index); fflush(_instr);
|
fflush (_index);
|
||||||
|
fflush (_instr);
|
||||||
|
|
||||||
_lines++; _dirty = TRUE;
|
_lines++;
|
||||||
|
_dirty = TRUE;
|
||||||
|
|
||||||
if ((_lines) < (_page_start + _page_size))
|
if ((_lines) < (_page_start + _page_size))
|
||||||
{
|
{
|
||||||
@ -260,7 +325,8 @@ bool TTextfile::append(const char* l)
|
|||||||
_page.add (ll);
|
_page.add (ll);
|
||||||
_page_end++;
|
_page_end++;
|
||||||
|
|
||||||
int len = 0; const char* cp;
|
int len = 0;
|
||||||
|
const char *cp;
|
||||||
read_line (_lines - 1);
|
read_line (_lines - 1);
|
||||||
while (cp = piece ())
|
while (cp = piece ())
|
||||||
{
|
{
|
||||||
@ -271,8 +337,12 @@ bool TTextfile::append(const char* l)
|
|||||||
{
|
{
|
||||||
TToken_string *tts = new TToken_string (50);
|
TToken_string *tts = new TToken_string (50);
|
||||||
tts->add (_lines - 1l); // line number
|
tts->add (_lines - 1l); // line number
|
||||||
tts->add(len); tts->add(len + (int)strlen(cp) );
|
//
|
||||||
tts->add(cp); tts->add(z);
|
|
||||||
|
tts->add (len);
|
||||||
|
tts->add (len + (int) strlen (cp));
|
||||||
|
tts->add (cp);
|
||||||
|
tts->add (z);
|
||||||
_spots.add (tts);
|
_spots.add (tts);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -284,7 +354,8 @@ bool TTextfile::append(const char* l)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTextfile::close()
|
void TTextfile ::
|
||||||
|
close ()
|
||||||
{
|
{
|
||||||
CHECK (_isopen, "Attempt operation on closed file");
|
CHECK (_isopen, "Attempt operation on closed file");
|
||||||
fclose (_instr);
|
fclose (_instr);
|
||||||
@ -293,7 +364,8 @@ void TTextfile::close()
|
|||||||
_isopen = FALSE;
|
_isopen = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTextfile::print()
|
void TTextfile ::
|
||||||
|
print ()
|
||||||
{
|
{
|
||||||
CHECK (_isopen, "Attempt operation on closed file");
|
CHECK (_isopen, "Attempt operation on closed file");
|
||||||
warning_box ("Funzione non ancora implementata");
|
warning_box ("Funzione non ancora implementata");
|
||||||
@ -302,8 +374,8 @@ void TTextfile::print()
|
|||||||
// print
|
// print
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TTextfile ::
|
||||||
bool TTextfile::write(const char* path, TPoint* from, TPoint* to)
|
write (const char *path, TPoint * from, TPoint * to)
|
||||||
{
|
{
|
||||||
bool ok = FALSE;
|
bool ok = FALSE;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -318,28 +390,35 @@ bool TTextfile::write(const char* path, TPoint* from, TPoint* to)
|
|||||||
for (long j = starty; j <= endy; j++)
|
for (long j = starty; j <= endy; j++)
|
||||||
{
|
{
|
||||||
s = line (j);
|
s = line (j);
|
||||||
if (j == endy && endx == -1) endx = s.len();
|
if (j == endy && endx == -1)
|
||||||
|
endx = s.len ();
|
||||||
|
|
||||||
if (j == starty && j == endy) s = s.sub(startx,endx);
|
if (j == starty && j == endy)
|
||||||
else if (j == starty) s = s.mid(startx);
|
s = s.sub (startx, endx);
|
||||||
else if (j == endy) s = s.left(endx);
|
else if (j == starty)
|
||||||
|
s = s.mid (startx);
|
||||||
|
else if (j == endy)
|
||||||
|
s = s.left (endx);
|
||||||
|
|
||||||
fprintf (fp, "%s\n", (const char *) s);
|
fprintf (fp, "%s\n", (const char *) s);
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
else warning_box("Impossibile scrivere il file %s; scrittura fallita", path);
|
else
|
||||||
|
warning_box ("Impossibile scrivere il file %s; scrittura fallita", path);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TTextfile ::
|
||||||
void TTextfile::destroy()
|
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) fclose(_index);
|
if (_index)
|
||||||
if (_instr) fclose(_instr);
|
fclose (_index);
|
||||||
|
if (_instr)
|
||||||
|
fclose (_instr);
|
||||||
remove ((const char *) _filename);
|
remove ((const char *) _filename);
|
||||||
remove ((const char *) _indname);
|
remove ((const char *) _indname);
|
||||||
_page_start = _lines = 0l;
|
_page_start = _lines = 0l;
|
||||||
@ -359,15 +438,19 @@ void TTextfile::destroy()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TTextfile ::TTextfile (const char *file, int pagesize, direction preferred):
|
TTextfile ::TTextfile (const char *file, int pagesize, direction preferred):
|
||||||
_page_size (pagesize), _page (pagesize), _filename (file), _lines (0l),
|
_page_size (pagesize), _page (pagesize), _filename (file), _lines (0l),
|
||||||
_index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred),
|
_index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred),
|
||||||
_dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1),
|
_dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1),
|
||||||
_hotspots(4), _accept(TRUE)
|
_hotspots (4),
|
||||||
|
_accept (TRUE)
|
||||||
{
|
{
|
||||||
// open file & build index
|
// open file & build index
|
||||||
if (file == NULL) { _filename.temp(); _istemp = TRUE; }
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
_filename.temp ();
|
||||||
|
_istemp = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
_instr = fopen (_filename, "a+");
|
_instr = fopen (_filename, "a+");
|
||||||
_indname.temp ();
|
_indname.temp ();
|
||||||
@ -394,14 +477,13 @@ TTextfile::TTextfile(const char* file, int pagesize, direction preferred) :
|
|||||||
_isopen = TRUE;
|
_isopen = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TTextfile ::~TTextfile ()
|
TTextfile ::~TTextfile ()
|
||||||
{
|
{
|
||||||
if (_index) fclose(_index);
|
if (_index)
|
||||||
if (_instr) fclose(_instr);
|
fclose (_index);
|
||||||
if (_istemp) remove((const char*)_filename);
|
if (_instr)
|
||||||
|
fclose (_instr);
|
||||||
|
if (_istemp)
|
||||||
|
remove ((const char *) _filename);
|
||||||
remove ((const char *) _indname);
|
remove ((const char *) _indname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user