Patch level : 2.2
Files correlati : Ricompilazione Demo : [ ] Commento : Corretto supoorto per stampa di campi ad altezza dinamica con font proporzionali Aggiunte ricerche filtrate git-svn-id: svn://10.65.10.50/trunk@13369 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
77dfd6d02a
commit
a2b8c7ca2e
@ -13,7 +13,7 @@ bool TAutomask::error_box(const char* fmt, ...)
|
||||
|
||||
if (is_sheetmask() && !is_running())
|
||||
{
|
||||
xvt_statbar_set(msg);
|
||||
xvtil_statbar_set(msg);
|
||||
beep();
|
||||
}
|
||||
else
|
||||
|
@ -46,7 +46,7 @@ bool TConfig_application::menu(MENU_TAG m)
|
||||
_last_choice = m;
|
||||
do_config((m - BAR_ITEM(0))/100);
|
||||
}
|
||||
return xvt_test_menu_tag(BAR_ITEM(2));
|
||||
return xvtil_test_menu_tag(BAR_ITEM(2));
|
||||
}
|
||||
|
||||
bool TConfig_application::user_create()
|
||||
|
@ -464,7 +464,7 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
|
||||
WINDOW win = xvt_win_create(wt, &r, (char*)caption, 0L, parent, wsf,
|
||||
EM_ALL, (EVENT_HANDLER)xi_event, (long)msk);
|
||||
CHECK(win, "Can't create an XVT window for an interface");
|
||||
xvt_set_font(win, NULL, 0, 0);
|
||||
xvtil_set_font(win, NULL, 0, 0);
|
||||
|
||||
XI_OBJ_DEF* def = xi_create_itf_def(ITF_CID, xi_event_handler, (XinRect *) &r, (char*)caption, (long)msk);
|
||||
CHECK(def, "Can't define an interface");
|
||||
@ -1416,7 +1416,7 @@ void TButton_control::create(WINDOW win, short cid,
|
||||
|
||||
char mnemonic = '\0';
|
||||
int underscore = -1;
|
||||
if (wc == WC_PUSHBUTTON)
|
||||
if (wc == WC_PUSHBUTTON || wc == WC_CHECKBUTTON)
|
||||
{
|
||||
underscore = txt.find('~');
|
||||
if (underscore < 0)
|
||||
@ -1429,11 +1429,6 @@ void TButton_control::create(WINDOW win, short cid,
|
||||
if (width <= 0) width = strlen(t)+3;
|
||||
|
||||
RCT rct; coord2rct(win, left, top, width, height, rct);
|
||||
if (wc == WC_PUSHBUTTON && height == 1) // Troppo bassi!
|
||||
{
|
||||
rct.top--;
|
||||
// rct.bottom++;
|
||||
}
|
||||
|
||||
const unsigned long attrib = flags2attr(flags);
|
||||
XI_OBJ_DEF* def = xi_add_button_def(NULL, cid, (XinRect *) &rct, attrib, (char*)t, cid);
|
||||
@ -1445,6 +1440,7 @@ void TButton_control::create(WINDOW win, short cid,
|
||||
case WC_PUSHBUTTON : def->v.btn->type = XIBT_BUTTON; break;
|
||||
case WC_CHECKBOX : def->v.btn->type = XIBT_CHECKBOX; break;
|
||||
case WC_RADIOBUTTON: def->v.btn->type = XIBT_RADIOBTN; break;
|
||||
case WC_CHECKBUTTON: def->v.btn->type = XIBT_BUTTON_CHECKBOX; break;
|
||||
default : def->v.btn->type = XIBT_TABBTN; break;
|
||||
}
|
||||
|
||||
@ -1463,12 +1459,32 @@ void TButton_control::create(WINDOW win, short cid,
|
||||
_obj = xi_create(container, def);
|
||||
CHECKD(_obj, "Can't create TButton_control ", cid);
|
||||
|
||||
// Aggiusta bottoni con icona a sinistra
|
||||
if (wc == WC_CHECKBOX || wc == WC_RADIOBUTTON)
|
||||
// Aggiusta bottoni
|
||||
switch (wc)
|
||||
{
|
||||
RCT& r = (RCT &) _obj->v.btn->rct;
|
||||
r.top++; r.bottom-=2;
|
||||
r.right += XI_FU_MULTIPLE / 2;
|
||||
case WC_PUSHBUTTON:
|
||||
if (height == 1)
|
||||
{
|
||||
XI_RCT& r = _obj->v.btn->rct;
|
||||
r.top--;
|
||||
}
|
||||
break;
|
||||
case WC_CHECKBUTTON:
|
||||
if (height == 1)
|
||||
{
|
||||
XI_RCT& r = _obj->v.btn->rct;
|
||||
r.bottom+=2;
|
||||
}
|
||||
break;
|
||||
case WC_CHECKBOX:
|
||||
case WC_RADIOBUTTON:
|
||||
{
|
||||
XI_RCT& r = _obj->v.btn->rct;
|
||||
r.top++; r.bottom-=2;
|
||||
r.right += XI_FU_MULTIPLE / 2;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
xi_dequeue();
|
||||
@ -1539,6 +1555,18 @@ bool TButton_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TButton_control::set_icon(unsigned int icon_up, unsigned int icon_dn)
|
||||
{
|
||||
if (icon_dn <= 0)
|
||||
icon_dn = icon_up;
|
||||
xi_set_icon(_obj, icon_up, icon_dn);
|
||||
_obj->v.btn->drawable = false;
|
||||
|
||||
const XI_RCT& rct = _obj->v.btn->rct;
|
||||
_obj->v.btn->icon_x = (rct.right - rct.left - 32) / 2 - 5;
|
||||
_obj->v.btn->icon_y = (rct.bottom - rct.top - 32) / 2 - 5;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TPushbutton_control
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1571,28 +1599,20 @@ void TPushbutton_control::set_caption(const char* c)
|
||||
if (*cap)
|
||||
{
|
||||
TControl::set_caption(cap);
|
||||
set_central_icon(0);
|
||||
set_icon(0);
|
||||
set_bmp(0, 0);
|
||||
_obj->v.btn->drawable = false;
|
||||
_obj->v.btn->fore_color = color;
|
||||
}
|
||||
}
|
||||
|
||||
void TPushbutton_control::set_central_icon(unsigned int hicon)
|
||||
{
|
||||
xi_set_icon(_obj, hicon, hicon);
|
||||
_obj->v.btn->icon_x = (_obj->v.btn->rct.right - _obj->v.btn->rct.left - 32) / 2 - 5;
|
||||
_obj->v.btn->icon_y = (_obj->v.btn->rct.bottom - _obj->v.btn->rct.top - 32) / 2 - 5;
|
||||
_obj->v.btn->drawable = false;
|
||||
}
|
||||
|
||||
void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
|
||||
{
|
||||
if (bmp_up > 0)
|
||||
{
|
||||
_bmp_up = (bmp_up > 0 && _picture->add(bmp_up)) ? bmp_up : 0;
|
||||
_bmp_dn = (bmp_dn > 0 && _picture->add(bmp_dn)) ? bmp_dn : _bmp_up;
|
||||
set_central_icon(0);
|
||||
set_icon(0);
|
||||
}
|
||||
else
|
||||
_bmp_up = _bmp_dn = 0;
|
||||
@ -1714,6 +1734,19 @@ TCheckbox_control::TCheckbox_control(WINDOW win, short cid,
|
||||
const char* flags, const char* text)
|
||||
{ create(win, cid, left, top, width, 1, flags, text, WC_CHECKBOX, NULL); }
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TCheckbutton_control
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TCheckbutton_control::TCheckbutton_control(WINDOW win, short cid,
|
||||
short left, short top, short width, int height,
|
||||
const char* flags, const char* text,
|
||||
short icon_up, short icon_dn)
|
||||
{
|
||||
create(win, cid, left, top, width, height, flags, text, WC_CHECKBUTTON, NULL);
|
||||
set_icon(icon_up, icon_dn);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TRadiobutton_control
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -2206,7 +2239,7 @@ void TDropDownList::create()
|
||||
#endif
|
||||
|
||||
// compute size in pixel of field (with button enclosed)
|
||||
RCT r; xi_get_rect(_obj, (XinRect *) &r);
|
||||
XI_RCT r; xi_get_rect(_obj, &r);
|
||||
|
||||
// Larghezza in pixel dell'edit field
|
||||
int len = r.right - r.left;
|
||||
@ -2237,7 +2270,7 @@ void TDropDownList::create()
|
||||
XI_ATR_VISIBLE|XI_ATR_ENABLED|XI_ATR_READONLY|XI_ATR_SELECTABLE,
|
||||
0, len, 80, "");
|
||||
|
||||
RCT l; xi_get_def_rect(lstdef, (XinRect *) &l);
|
||||
XI_RCT l; xi_get_def_rect(lstdef, &l);
|
||||
PNT p; p.h = r.left;
|
||||
WINDOW pwin = (WINDOW)xi_get_window(_obj->itf);
|
||||
RCT w; xvt_vobj_get_client_rect(pwin, &w);
|
||||
|
@ -208,6 +208,8 @@ public:
|
||||
int button_type() const;
|
||||
XI_OBJ* container() const;
|
||||
|
||||
void set_icon(unsigned int icon_up, unsigned int icon_dn = 0);
|
||||
|
||||
TButton_control() {}
|
||||
virtual ~TButton_control() {}
|
||||
};
|
||||
@ -218,7 +220,8 @@ class TPushbutton_control : public TButton_control
|
||||
|
||||
protected:
|
||||
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* xiev);
|
||||
|
||||
TPushbutton_control() { } // Internal use only
|
||||
|
||||
public:
|
||||
virtual void update();
|
||||
|
||||
@ -226,7 +229,6 @@ public:
|
||||
virtual void set_caption(const char* c);
|
||||
|
||||
void set_bmp(short up, short dn);
|
||||
void set_central_icon(unsigned int hicon);
|
||||
char mnemonic() const;
|
||||
|
||||
TPushbutton_control(WINDOW win, short cid,
|
||||
@ -287,6 +289,16 @@ public:
|
||||
virtual ~TCheckbox_control() {}
|
||||
};
|
||||
|
||||
class TCheckbutton_control : public TButton_control
|
||||
{
|
||||
public:
|
||||
TCheckbutton_control(WINDOW win, short cid,
|
||||
short left, short top, short width, int height,
|
||||
const char* flags, const char* text,
|
||||
short icon_up, short icon_dn);
|
||||
virtual ~TCheckbutton_control() {}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TDropDownList
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -574,6 +574,11 @@ const char *TTrec ::keydef (int key) const
|
||||
return (const char *) s;
|
||||
}
|
||||
|
||||
int TTrec::len() const
|
||||
{
|
||||
const int n = fields();
|
||||
return (n > 0 && n <= MaxFields) ? _rec->Fd[n - 1].RecOff + _rec->Fd[n - 1].Len : 0;
|
||||
}
|
||||
|
||||
#ifndef FOXPRO
|
||||
|
||||
|
@ -241,8 +241,7 @@ public:
|
||||
// @cmember Ritorna una stringa contenente la chiave
|
||||
const char* keydef(int key) const;
|
||||
// @cmember Ritorna la lunghezza del record
|
||||
int len() const
|
||||
{ return fields() > 0 ? _rec->Fd[fields() - 1].RecOff + _rec->Fd[fields() - 1].Len : 0; }
|
||||
int len() const;
|
||||
|
||||
#ifndef FOXPRO
|
||||
// @cmember Aggiorna la chiave. <p desc> e' una token string
|
||||
|
@ -641,9 +641,9 @@ BOOLEAN wpr(long data)
|
||||
WINDOW prwin = xvt_print_create_win(printer().get_printrcd(),"");
|
||||
long width_old,width_new;
|
||||
TString spc(128, 'm');
|
||||
xvt_set_font(prwin,st->name_1, XVT_FS_NONE, st->size_1);
|
||||
xvtil_set_font(prwin,st->name_1, XVT_FS_NONE, st->size_1);
|
||||
width_old = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 128);
|
||||
xvt_set_font(prwin,st->name_2, XVT_FS_NONE, st->size_2);
|
||||
xvtil_set_font(prwin,st->name_2, XVT_FS_NONE, st->size_2);
|
||||
width_new = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 128);
|
||||
st->ratio = (double)width_old / (double)width_new;
|
||||
xvt_vobj_destroy(prwin);
|
||||
|
@ -352,7 +352,7 @@ void TGolem_field::set_window_data(const char* data)
|
||||
|
||||
TPushbutton_control* btn = (TPushbutton_control*)_ctl;
|
||||
if (icon)
|
||||
btn->set_central_icon(icon);
|
||||
btn->set_icon(icon);
|
||||
else
|
||||
btn->set_bmp(BMP_OLE, 0);
|
||||
|
||||
|
@ -2024,7 +2024,13 @@ int TSystemisamfile::update(
|
||||
bool interactive) // @parm Indica se riportare i campi personalizzati (!interactive
|
||||
|
||||
{
|
||||
CHECK(newrec.len() != 0, "Can't update file with empty field info");
|
||||
if (newrec.len() == 0)
|
||||
{
|
||||
error_box(FR("Il nuovo tracciato per il file %d e' vuoto"), num());
|
||||
setstatus(_istrcerr);
|
||||
return status();
|
||||
}
|
||||
|
||||
int err = NOERR;
|
||||
|
||||
TTrec wrec(newrec);
|
||||
@ -2034,11 +2040,26 @@ int TSystemisamfile::update(
|
||||
const bool is_com = prefix().is_com();
|
||||
const bool toconvert = is_com ? dir.is_com() : dir.is_firm();
|
||||
|
||||
TTrec oldrec;
|
||||
TTrec oldrec;
|
||||
oldrec.get(num());
|
||||
|
||||
int lenr = wrec.len();
|
||||
if (oldrec.fields() < 0 || oldrec.fields() > MaxFields)
|
||||
{
|
||||
if (yesno_box(FR("Il file %d (%s)\n"
|
||||
"ha %d campi ed una lunghezza record di %d"
|
||||
"\nSi desidera azzerare il vecchio tracciato?"),
|
||||
num(), (const char*)filename(), oldrec.fields(), oldrec.len()))
|
||||
{
|
||||
oldrec.zero();
|
||||
}
|
||||
else
|
||||
{
|
||||
setstatus(_istrcerr);
|
||||
return status();
|
||||
}
|
||||
}
|
||||
|
||||
int lenr = wrec.len();
|
||||
if (lenr != 0)
|
||||
{
|
||||
const long lev = prefix().filelevel();
|
||||
@ -2069,11 +2090,11 @@ int TSystemisamfile::update(
|
||||
}
|
||||
}
|
||||
|
||||
const int oldfields = oldrec.fields();
|
||||
int wfields = wrec.fields();
|
||||
const int wfields = wrec.fields();
|
||||
int newfields = wfields;
|
||||
TToken_string def;
|
||||
|
||||
const int oldfields = oldrec.fields();
|
||||
for (int j = 0; j < oldfields; j++)
|
||||
{
|
||||
def = oldrec.fielddef(j);
|
||||
@ -2084,7 +2105,7 @@ int TSystemisamfile::update(
|
||||
if (newfields < MaxFields)
|
||||
wrec.update_fielddef(newfields++, def);
|
||||
else
|
||||
if(!yesno_box("Il campo %s non verra' preservato, devo continuare",
|
||||
if(!yesno_box(FR("Il campo %s non verra' preservato, continuare"),
|
||||
(const char *) def.get(0)))
|
||||
return NOERR;
|
||||
}
|
||||
@ -2131,8 +2152,7 @@ int TSystemisamfile::update(
|
||||
return err;
|
||||
}
|
||||
|
||||
TString s(256);
|
||||
s.format("Aggiornamento archivio %s", (const char*) fname);
|
||||
TString s; s << TR("Aggiornamento") << ' ' << fname;
|
||||
|
||||
const TRecnotype nitems = items();
|
||||
TProgind p(nitems > 0 ? nitems : 1, s, FALSE, TRUE, 70);
|
||||
@ -2150,7 +2170,6 @@ int TSystemisamfile::update(
|
||||
outfld.add(new TRecfield(nrec, fld_name), j);
|
||||
}
|
||||
|
||||
// const clock_t start_time = clock(); verificare
|
||||
for (first(); good(); next())
|
||||
{
|
||||
p.addstatus(1);
|
||||
|
@ -1787,6 +1787,30 @@ TBoolean_field& TMask::add_boolean (
|
||||
return *f;
|
||||
}
|
||||
|
||||
TCheckbutton_field& TMask::add_checkbutton (
|
||||
short id, // @parm Numero identificatore del campo da aggiungere
|
||||
int page, // @parm Pagina nel quale aggiungere il campo
|
||||
const char* prompt, // @parm Prompt del campo
|
||||
int x, // @parm Coordinata x (in caratteri)
|
||||
int y, // @parm Coordinata y (in caratteri)
|
||||
int dx, // @parm Larghezza del campo (in caratteri, default 9)
|
||||
int dy, // @parm Altezza del campo (in caratteri, default 1)
|
||||
const char* flags, // @parm Flag di controllo del campo (default "")
|
||||
short bmpup, // @parm Icona normale
|
||||
short bmpdn) // @parm Icona premuta
|
||||
|
||||
// @xref <mf TMask::add_static> <mf TMask::add_string> <mf TMask::add_number>
|
||||
// <mf TMask::add_date> <mf TMask::add_radio> <mf TMask::add_memo>
|
||||
{
|
||||
TCheckbutton_field* f = new TCheckbutton_field(this);
|
||||
f->construct(id, prompt, x, y, dy, _pagewin[page], flags, dx);
|
||||
if (bmpup > 0)
|
||||
((TCheckbutton_control*)f->_ctl)->set_icon(bmpup, bmpdn);
|
||||
add_field(f);
|
||||
return *f;
|
||||
}
|
||||
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Aggiunge runtime un campo numerico alla maschera
|
||||
|
@ -207,6 +207,7 @@ public:
|
||||
TButton_field& add_button (short id, int page, const char* prompt, int x, int y, int dx = 9, int dy = 1, const char* flags = "", short bmpup = 0, short bmpdn = 0);
|
||||
// @cmember Aggiunge runtime un campo boolean alla maschera
|
||||
TBoolean_field& add_boolean (short id, int page, const char* prompt, int x, int y, const char* flags = "");
|
||||
TCheckbutton_field& add_checkbutton (short id, int page, const char* prompt, int x, int y, int dx = 9, int dy = 1, const char* flags = "", short bmpup = 0, short bmpdn = 0);
|
||||
// @cmember Aggiunge runtime un campo radio button alla maschera
|
||||
TRadio_field& add_radio(short id, int page, const char* prompt, int x, int y, int dx, const char* codes, const char* items, const char* flags = "");
|
||||
// @cmember Aggiunge runtime un campo memo alla maschera
|
||||
|
@ -574,7 +574,7 @@ bool TMask_field::error_box(
|
||||
if (mask().is_sheetmask() && !mask().is_running())
|
||||
{
|
||||
xvt_dm_post_speech(_msg, 0, TRUE);
|
||||
xvt_statbar_set(_msg);
|
||||
xvtil_statbar_set(_msg);
|
||||
beep();
|
||||
}
|
||||
else
|
||||
@ -608,7 +608,7 @@ bool TMask_field::warning_box(
|
||||
if (mask().is_sheetmask() && !mask().is_running())
|
||||
{
|
||||
xvt_dm_post_speech(_msg, 1, TRUE);
|
||||
xvt_statbar_set(_msg);
|
||||
xvtil_statbar_set(_msg);
|
||||
beep();
|
||||
}
|
||||
else
|
||||
@ -1193,7 +1193,7 @@ void TButton_field::set_bmp(short up, short dn)
|
||||
|
||||
void TButton_field::set_central_icon(unsigned icon)
|
||||
{
|
||||
((TPushbutton_control*)_ctl)->set_central_icon(icon);
|
||||
((TPushbutton_control*)_ctl)->set_icon(icon);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1692,6 +1692,46 @@ bool TBoolean_field::on_key(KEY key)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TCheckbutton_field
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// Copiato da TButton::parse_item
|
||||
void TCheckbutton_field::parse_head(TScanner& scanner)
|
||||
{
|
||||
_ctl_data._width = scanner.integer();
|
||||
if (_ctl_data._width <= 0) _ctl_data._width = 10;
|
||||
_ctl_data._height = scanner.integer(); // Height
|
||||
if (_ctl_data._height <= 0) _ctl_data._height = 1;
|
||||
}
|
||||
|
||||
// Copiato da TButton::parse_item
|
||||
bool TCheckbutton_field::parse_item(TScanner& scanner)
|
||||
{
|
||||
if (scanner.key() == "PI")
|
||||
{
|
||||
const short bmp = (short)scanner.integer();
|
||||
if (_ctl_data._bmp_up == 0)
|
||||
_ctl_data._bmp_up = bmp;
|
||||
else
|
||||
_ctl_data._bmp_dn = bmp;
|
||||
return bmp > 0;
|
||||
}
|
||||
return TOperable_field::parse_item(scanner);
|
||||
}
|
||||
|
||||
void TCheckbutton_field::create(WINDOW parent)
|
||||
{
|
||||
_ctl = new TCheckbutton_control(parent, _ctl_data._dlg,
|
||||
_ctl_data._x, _ctl_data._y,
|
||||
_ctl_data._width+2, _ctl_data._height,
|
||||
_ctl_data._flags, _ctl_data._prompt,
|
||||
_ctl_data._bmp_up, _ctl_data._bmp_dn);
|
||||
}
|
||||
|
||||
TCheckbutton_field::TCheckbutton_field(TMask* mask) : TBoolean_field(mask)
|
||||
{ }
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBrowse_button
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -2080,12 +2120,15 @@ const char* TBrowse::get_input_field_names() const
|
||||
return _inp_fn;
|
||||
}
|
||||
|
||||
|
||||
const char* TBrowse::get_output_fields() const
|
||||
{
|
||||
return _out_id;
|
||||
}
|
||||
|
||||
const char* TBrowse::get_output_field_names() const
|
||||
{
|
||||
return _out_fn;
|
||||
}
|
||||
|
||||
// @doc INTERNAL
|
||||
|
||||
@ -2196,7 +2239,7 @@ int TBrowse::do_input(
|
||||
{
|
||||
work << _filter[i];
|
||||
if (_filter[i] == '-' && _filter[i + 1] == '>')
|
||||
filter_update = TRUE;
|
||||
filter_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3067,11 +3110,11 @@ bool TEdit_field::parse_item(TScanner& scanner)
|
||||
|
||||
if (scanner.key() == "CH")
|
||||
{
|
||||
scanner.pop();
|
||||
if (scanner.key() == "NO") _check = CHECK_NORMAL; else
|
||||
if (scanner.key() == "RE") _check = CHECK_REQUIRED; else
|
||||
if (scanner.key() == "FO") { _check = CHECK_REQUIRED; _forced = TRUE; } else
|
||||
if (scanner.key() == "SE") _check = CHECK_SEARCH;
|
||||
const TString& ct = scanner.popkey();
|
||||
if (ct == "NO") _check = CHECK_NORMAL; else
|
||||
if (ct == "RE") _check = CHECK_REQUIRED; else
|
||||
if (ct == "FO") { _check = CHECK_REQUIRED; _forced = TRUE; } else
|
||||
if (ct == "SE") _check = CHECK_SEARCH;
|
||||
else _check = CHECK_NONE;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -749,6 +749,17 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
class TCheckbutton_field : public TBoolean_field
|
||||
{
|
||||
protected:
|
||||
virtual void parse_head(TScanner& scanner);
|
||||
virtual bool parse_item(TScanner& scanner);
|
||||
virtual void create(WINDOW parent);
|
||||
|
||||
public:
|
||||
TCheckbutton_field(TMask* mask);
|
||||
virtual ~TCheckbutton_field() {}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBrowse_button
|
||||
@ -912,6 +923,9 @@ public:
|
||||
// @cmember Ritorna la lista completa dei campi di output
|
||||
const char* get_output_fields() const;
|
||||
|
||||
// @cmember Ritorna la lista completa dei nomi dei campi di output
|
||||
const char* get_output_field_names() const;
|
||||
|
||||
// @cmember Ritorna il numero di campi non vuoti e non filtrati
|
||||
int do_input(bool filter = false);
|
||||
|
||||
|
@ -969,7 +969,7 @@ void TSpreadsheet::notify_change()
|
||||
_edit_field = cell2field(NULL); // Ricalcola correttamente il campo corrente
|
||||
|
||||
notify(_cur_rec, K_SPACE);
|
||||
xvt_statbar_refresh();
|
||||
xvtil_statbar_refresh();
|
||||
set_dirty();
|
||||
}
|
||||
_row_dirty = _cell_dirty = TRUE; // Era tra le graffe
|
||||
|
@ -1554,7 +1554,7 @@ bool TPrint_application::menu(MENU_TAG m)
|
||||
}
|
||||
|
||||
// Se non esistono altre voci di menu termina l'applicazione
|
||||
return xvt_test_menu_tag (BAR_ITEM (2));
|
||||
return xvtil_test_menu_tag (BAR_ITEM (2));
|
||||
}
|
||||
|
||||
bool TPrint_application::create()
|
||||
|
@ -2026,7 +2026,7 @@ HIDDEN BOOLEAN calc_font_callback(long data)
|
||||
for (size = fd._size; size > 0; size--)
|
||||
{
|
||||
// Set print font
|
||||
xvt_set_font(win, fd._name, XVT_FS_NONE, size);
|
||||
xvtil_set_font(win, fd._name, XVT_FS_NONE, size);
|
||||
|
||||
const int w = xvt_dwin_get_text_width(win, (char*)(const char*)test, fd._columns);
|
||||
if (w <= pw)
|
||||
@ -2067,7 +2067,7 @@ HIDDEN BOOLEAN calc_cols_callback(long data)
|
||||
{
|
||||
long pw, ph, phr, pvr; // Printer width, height, horizontal and vertical resolution
|
||||
xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, printer().get_printrcd(), &ph, &pw, &pvr, &phr);
|
||||
xvt_set_font(win, printer().fontname(), XVT_FS_NONE, printer().get_char_size());
|
||||
xvtil_set_font(win, printer().fontname(), XVT_FS_NONE, printer().get_char_size());
|
||||
|
||||
// Compute maximum number of chars per line
|
||||
int mincol = 0,maxcol=MAX_PR_WIDTH;
|
||||
|
@ -223,18 +223,21 @@ void TPrintwin::paint_row(long j)
|
||||
|
||||
int pos = 0;
|
||||
|
||||
const char* cp;
|
||||
while((cp = _txt.piece()) != NULL)
|
||||
{
|
||||
int curr_style = -1;
|
||||
|
||||
for (const char* cp = _txt.piece(); cp; cp = _txt.piece())
|
||||
{
|
||||
const int st = _txt.get_style();
|
||||
const COLOR bg = trans_color(_txt.get_background());
|
||||
const COLOR fg = trans_color(_txt.get_foreground());
|
||||
set_color(fg, bg);
|
||||
|
||||
if (bg != fg) // Testo vero
|
||||
if (bg != fg) // Testo vero e visibile
|
||||
{
|
||||
// set_color(fg, bg); // l'ha appena fatta!
|
||||
set_font(printer().fontname(), st, _char_size);
|
||||
if (st != curr_style)
|
||||
{
|
||||
set_font(printer().fontname(), st, _char_size);
|
||||
curr_style = st;
|
||||
}
|
||||
|
||||
const char* beg = cp;
|
||||
while (*beg)
|
||||
@ -248,7 +251,7 @@ void TPrintwin::paint_row(long j)
|
||||
const char * end;
|
||||
for (end = beg; *end && (*end != ' ' || *(end+1) != ' '); end++)
|
||||
len++; // Misura stringa da stampare
|
||||
xvt_dwin_draw_text(win(), _hofs + LEN_SPACES(win(), pos), y, (char*)beg, len);
|
||||
xvt_dwin_draw_text(win(), _hofs + LEN_SPACES(win(), pos), y, beg, len);
|
||||
pos += len;
|
||||
beg = end;
|
||||
}
|
||||
@ -273,8 +276,6 @@ bool TPrintwin::print_band(
|
||||
|
||||
// @comm Di solito viene disegnata l'intera pagina, ma la cosa dipende dal driver di stampa
|
||||
{
|
||||
TPerformance_profiler timer("print_band");
|
||||
|
||||
const long first_row = (long)page * _formlen;
|
||||
const int rows = (r.bottom - r.top) / _chary;
|
||||
const int top = r.top / _chary;
|
||||
@ -353,7 +354,7 @@ TPrintwin::TPrintwin(TTextfile& txt)
|
||||
return;
|
||||
}
|
||||
|
||||
WINDOW prwin = xvt_print_create_win(_printrcd, (char*)(const char*)main_app().title());
|
||||
WINDOW prwin = xvt_print_create_win(_printrcd, main_app().title());
|
||||
if (prwin == NULL_WIN)
|
||||
{
|
||||
_aborted = TRUE;
|
||||
|
@ -68,7 +68,7 @@ protected:
|
||||
virtual void update();
|
||||
|
||||
// @cmember Aggiorna la barra di attesa
|
||||
void update_bar();
|
||||
virtual void update_bar();
|
||||
// @cmember Controlla se ha terminato la barra di attesa
|
||||
KEY check_stop();
|
||||
|
||||
|
@ -1603,7 +1603,7 @@ void TCursor_parser::parse_sortexpr(TToken_string& se)
|
||||
const char sep = se.separator();
|
||||
se.separator(' ');
|
||||
_instr.getline(se.get_buffer(), se.size());
|
||||
se.strip_d_spaces();
|
||||
se.strip_double_spaces();
|
||||
se.replace(' ', sep);
|
||||
se.separator(sep);
|
||||
|
||||
@ -2079,7 +2079,7 @@ TRecnotype TISAM_recordset::current_row() const
|
||||
TRecnotype TISAM_recordset::items() const
|
||||
{
|
||||
TCursor* c = cursor();
|
||||
return c != NULL ? c->items() : -1;
|
||||
return c != NULL ? c->items() : 0;
|
||||
}
|
||||
|
||||
unsigned int TISAM_recordset::columns() const
|
||||
|
@ -338,7 +338,7 @@ int TRelation_application::set_mode(int mode)
|
||||
break;
|
||||
}
|
||||
|
||||
xvt_statbar_set(t, TRUE);
|
||||
xvtil_statbar_set(t, TRUE);
|
||||
|
||||
return _mode;
|
||||
}
|
||||
|
@ -1052,8 +1052,6 @@ TRecnotype TCursor::buildcursor(TRecnotype rp)
|
||||
|
||||
const bool filtered = has_filter();
|
||||
const bool simple_filter = filtered && has_simple_filter();
|
||||
|
||||
|
||||
|
||||
while (!DB_index_eof(fhnd))
|
||||
{
|
||||
@ -1065,7 +1063,7 @@ TRecnotype TCursor::buildcursor(TRecnotype rp)
|
||||
break; // means that no more keys are available
|
||||
oldrecno=recno;
|
||||
|
||||
bool to_be_added = TRUE;
|
||||
bool to_be_added = true;
|
||||
|
||||
if (filtered)
|
||||
{
|
||||
@ -1927,7 +1925,7 @@ const char* TSorted_cursor::fill_sort_key(char* k)
|
||||
|
||||
bool TSorted_cursor::changed()
|
||||
{
|
||||
bool rt = FALSE;
|
||||
bool rt = false;
|
||||
if (_is_valid_expr)
|
||||
{
|
||||
rt = TCursor::changed();
|
||||
|
@ -51,17 +51,18 @@ int compute_font_match(WINDOW win, int size, int ppi, int cpi)
|
||||
|
||||
XVT_FNTID TReport_font::get_xvt_font(const TWindow& win) const
|
||||
{
|
||||
if (win.win() != _win_mapped)
|
||||
WINDOW w = win.win();
|
||||
if (w != _win_mapped)
|
||||
{
|
||||
int nSize = _size;
|
||||
|
||||
if (win.win() != 883) // Non e' una stampa!
|
||||
if (w != PRINTER_WIN) // Non e' una stampa!
|
||||
{
|
||||
const int cpi = 120 / DEFAULT_FONT_SIZE;
|
||||
const PNT pnt0 = win.log2dev(0,0);
|
||||
const PNT pnt1 = win.log2dev(cpi*100,100);
|
||||
const int ppi = pnt1.h - pnt0.h;
|
||||
const int best = compute_font_match(win.win(), (pnt1.v - pnt0.v), ppi, cpi);
|
||||
const int best = compute_font_match(w, (pnt1.v - pnt0.v), ppi, cpi);
|
||||
nSize = cpi * best / _cpi;
|
||||
}
|
||||
|
||||
@ -73,33 +74,33 @@ XVT_FNTID TReport_font::get_xvt_font(const TWindow& win) const
|
||||
TReport_font& myself = *(TReport_font*)this;
|
||||
myself.unmap();
|
||||
myself._fontid = fontid;
|
||||
myself._win_mapped = win.win();
|
||||
xvt_dwin_get_font_metrics(_win_mapped, &myself._leading, &myself._ascent, &myself._descent);
|
||||
myself._win_mapped = w;
|
||||
//xvt_dwin_get_font_metrics(w, &myself._leading, &myself._ascent, &myself._descent);
|
||||
}
|
||||
return _fontid;
|
||||
}
|
||||
|
||||
XVT_FNTID TReport_font::get_preview_font(const TWindow& win, const TPoint& res) const
|
||||
{
|
||||
if (win.win() != _win_mapped)
|
||||
WINDOW w = win.win();
|
||||
if (w != _win_mapped)
|
||||
{
|
||||
const int cpi = 120 / DEFAULT_FONT_SIZE;
|
||||
const PNT pnt0 = win.log2dev(0,0);
|
||||
const PNT pnt1 = win.log2dev(res.x,res.y);
|
||||
const int ppi = pnt1.h - pnt0.h;
|
||||
const int best = compute_font_match(win.win(), (pnt1.v - pnt0.v), ppi, cpi);
|
||||
const int best = compute_font_match(w, (pnt1.v - pnt0.v), ppi, cpi);
|
||||
const int nSize = cpi * best / _cpi;
|
||||
|
||||
XVT_FNTID fontid = xvt_font_create();
|
||||
xvt_font_set_family(fontid, (char*)(const char*)_name);
|
||||
xvt_font_set_family(fontid, _name);
|
||||
xvt_font_set_size(fontid, nSize);
|
||||
xvt_font_set_style(fontid, _style);
|
||||
|
||||
TReport_font& myself = *(TReport_font*)this;
|
||||
myself.unmap();
|
||||
myself._fontid = fontid;
|
||||
myself._win_mapped = win.win();
|
||||
xvt_dwin_get_font_metrics(_win_mapped, &myself._leading, &myself._ascent, &myself._descent);
|
||||
myself._win_mapped = w;
|
||||
//xvt_dwin_get_font_metrics(_win_mapped, &myself._leading, &myself._ascent, &myself._descent);
|
||||
}
|
||||
return _fontid;
|
||||
}
|
||||
@ -503,7 +504,7 @@ TPoint TReport_section::compute_size() const
|
||||
const TReport_field& rf = field(i);
|
||||
if (rf.active() && rf.shown())
|
||||
{
|
||||
const TRectangle r = rf.get_draw_rect();
|
||||
const TRectangle& r = rf.get_draw_rect();
|
||||
if (_size.x <= 0 && r.right() > s.x) // Richiesto calcolo larghezza
|
||||
s.x = r.right();
|
||||
if (_size.y <= 0 && r.bottom() > s.y) // Richiesto calcolo altezza
|
||||
@ -540,7 +541,16 @@ bool TReport_section::load_fields()
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TReport_section::execute_prescript()
|
||||
void TReport_section::init_dynamic_heights(const TBook& book)
|
||||
{
|
||||
for (int i = 0; i < items(); i++)
|
||||
{
|
||||
TReport_field& f = field(i);
|
||||
f.compute_draw_rect(book);
|
||||
}
|
||||
}
|
||||
|
||||
bool TReport_section::execute_prescript(const TBook& book)
|
||||
{
|
||||
bool ok = true;
|
||||
if (active())
|
||||
@ -555,6 +565,8 @@ bool TReport_section::execute_prescript()
|
||||
{
|
||||
TReport_field& f = field(i);
|
||||
ok = f.execute_prescript();
|
||||
if (ok && f.dynamic_height())
|
||||
f.compute_draw_rect(book); // Serve fondamentalmente per MESSAGE _DESCRIGA
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
@ -578,7 +590,8 @@ void TReport_section::print(TBook& book) const
|
||||
{
|
||||
if (print_tools(book))
|
||||
{
|
||||
TRectangle rct; compute_rect(rct);
|
||||
TRectangle rct;
|
||||
compute_rect(rct);
|
||||
if (_size.x <= 0)
|
||||
rct.set_width(book.logical_page_width());
|
||||
if (type() == 'B' && level() <= 0)
|
||||
@ -1097,22 +1110,6 @@ void TReport_field::set_dynamic_height(bool dh)
|
||||
bool TReport_field::dynamic_height() const
|
||||
{ return _dynamic_height; }
|
||||
|
||||
const TRectangle& TReport_field::get_draw_rect() const
|
||||
{
|
||||
TRectangle& rct = ((TReport_field*)this)->_draw_rct;
|
||||
if (dynamic_height())
|
||||
{
|
||||
TParagraph_string str(formatted_text(), rct.width()/100-1); // Sto un po' scarso
|
||||
int h = str.items() * 100;
|
||||
if (h <= 0)
|
||||
h = 100;
|
||||
if (h > _rct.height())
|
||||
h = _rct.height();
|
||||
rct.set_height(h);
|
||||
}
|
||||
return rct;
|
||||
}
|
||||
|
||||
const TReport_font& TReport_field::font() const
|
||||
{
|
||||
return _font != NULL ? *_font : _section->font();
|
||||
@ -1401,10 +1398,8 @@ const TString& TReport_field::formatted_text() const
|
||||
case 'V':
|
||||
{
|
||||
TCurrency cur; get_currency(cur);
|
||||
TString& tmp = get_tmp_string();
|
||||
const bool dotted = _picture.find('.') > 0;
|
||||
tmp = cur.string(dotted);
|
||||
return tmp;
|
||||
return get_tmp_string() = cur.string(dotted);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -1421,7 +1416,6 @@ const TString& TReport_field::formatted_text() const
|
||||
{
|
||||
TString& tmp = get_tmp_string();
|
||||
tmp = _var.as_string();
|
||||
tmp.strip_d_spaces();
|
||||
tmp.replace(char(0xB6), '\n');
|
||||
tmp.rtrim();
|
||||
return tmp;
|
||||
@ -1444,14 +1438,36 @@ bool TReport_field::print_tools(TBook& book) const
|
||||
return visible;
|
||||
}
|
||||
|
||||
void TReport_field::print_rect(TBook& book) const
|
||||
const TRectangle& TReport_field::compute_draw_rect(const TBook& book)
|
||||
{
|
||||
TRectangle& r = _draw_rct;
|
||||
r = _rct;
|
||||
if (dynamic_height())
|
||||
{
|
||||
const TString& txt = formatted_text();
|
||||
if (!txt.blank())
|
||||
{
|
||||
TString_array para;
|
||||
book.compute_text_frame(formatted_text(), print_font(), r, para);
|
||||
if (r.height() > get_rect().height())
|
||||
r.set_height(get_rect().height());
|
||||
if (r.height() < 100)
|
||||
r.set_height(100);
|
||||
}
|
||||
else
|
||||
r.set_height(100);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
const TRectangle& TReport_field::print_rect(const TRectangle& rect, TBook& book) const
|
||||
{
|
||||
if (pattern() == PAT_SOLID && shade_offset() != 0)
|
||||
{
|
||||
book.set_pen(COLOR_GRAY, 0);
|
||||
const COLOR color = blend_colors(section().back_color(), COLOR_BLACK, 0.5);
|
||||
book.set_brush(color, PAT_SOLID);
|
||||
TRectangle rct = get_draw_rect();
|
||||
TRectangle rct = rect;
|
||||
rct += TPoint(shade_offset(), shade_offset() * section().report().print_lpi() / print_font().cpi());
|
||||
if (radius() > 0)
|
||||
book.draw_round_rectangle(rct, radius());
|
||||
@ -1461,12 +1477,18 @@ void TReport_field::print_rect(TBook& book) const
|
||||
|
||||
if (print_tools(book))
|
||||
{
|
||||
const TRectangle& rct = get_draw_rect();
|
||||
if (radius() > 0)
|
||||
book.draw_round_rectangle(rct, radius());
|
||||
book.draw_round_rectangle(rect, radius());
|
||||
else
|
||||
book.draw_rectangle(rct);
|
||||
book.draw_rectangle(rect);
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
const TRectangle& TReport_field::print_rect(TBook& book) const
|
||||
{
|
||||
const TRectangle& rect = get_draw_rect();
|
||||
return print_rect(rect, book);
|
||||
}
|
||||
|
||||
void TReport_field::print(TBook& book) const
|
||||
@ -1494,12 +1516,13 @@ void TReport_field::print(TBook& book) const
|
||||
case 'I':
|
||||
{
|
||||
const TString& name = get().as_string();
|
||||
book.draw_image(get_draw_rect(), name);
|
||||
const TRectangle& rct = get_draw_rect();
|
||||
book.draw_image(rct, name);
|
||||
if (border() > 0)
|
||||
{
|
||||
book.set_pen(fore_color(), border()-1);
|
||||
book.set_brush(COLOR_WHITE, PAT_HOLLOW);
|
||||
book.draw_rectangle(get_draw_rect());
|
||||
book.draw_rectangle(rct);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1514,34 +1537,51 @@ void TReport_field::print(TBook& book) const
|
||||
print_rect(book);
|
||||
break;
|
||||
case 'T':
|
||||
print_rect(book);
|
||||
if (!_picture.blank())
|
||||
{
|
||||
book.set_font(print_font());
|
||||
const TRectangle& pr = print_rect(book); // Calcolo rettangolo dopo aver settato il font!
|
||||
book.set_text_align(horizontal_alignment(), vertical_alignment());
|
||||
book.set_text_color(fore_color(), back_color());
|
||||
book.draw_text(get_draw_rect(), _picture);
|
||||
book.draw_text(pr, _picture);
|
||||
}
|
||||
else
|
||||
print_rect(book);
|
||||
break;
|
||||
case 'N':
|
||||
if (field() == "#BOOKPAGES")
|
||||
{
|
||||
print_rect(book);
|
||||
book.draw_book_pages(get_draw_rect());
|
||||
const TRectangle& pr = print_rect(book);
|
||||
book.draw_book_pages(pr);
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
print_rect(book);
|
||||
const TString& str = formatted_text();
|
||||
if (!str.blank())
|
||||
{
|
||||
book.set_font(print_font());
|
||||
book.set_text_align(horizontal_alignment(), vertical_alignment());
|
||||
book.set_text_color(fore_color(), back_color());
|
||||
book.draw_text(get_draw_rect(), str);
|
||||
if (link().not_empty())
|
||||
book.draw_link(get_draw_rect(), str, link());
|
||||
if (dynamic_height() || _rct.height() > 100) // Multiriga?
|
||||
{
|
||||
TString_array para;
|
||||
TRectangle rect = get_draw_rect();
|
||||
book.compute_text_frame(str, print_font(), rect, para);
|
||||
print_rect(_draw_rct, book); // Stampa eventuale cornice
|
||||
book.draw_text(_draw_rct, para); // Stampa paragrafo
|
||||
}
|
||||
else
|
||||
{
|
||||
const TRectangle& pr = print_rect(book);
|
||||
book.draw_text(pr, str);
|
||||
if (link().not_empty())
|
||||
book.draw_link(pr, str, link());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_rect(book);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2708,19 +2748,21 @@ void TReport::msg_firm(TVariant_stack& stack)
|
||||
}
|
||||
if (in=="TEL")
|
||||
{
|
||||
TString valore;
|
||||
|
||||
TString valore(16);
|
||||
valore = ditta.get(NDT_PTEL);
|
||||
valore << "-" << ditta.get(NDT_TEL);
|
||||
if (valore.not_empty())
|
||||
valore << '-';
|
||||
valore << ditta.get(NDT_TEL);
|
||||
cf.set(valore);
|
||||
return;
|
||||
}
|
||||
if (in=="FAX")
|
||||
{
|
||||
TString valore;
|
||||
|
||||
TString valore(16);
|
||||
valore = ditta.get(NDT_PFAX);
|
||||
valore << "-" << ditta.get(NDT_FAX);
|
||||
if (valore.not_empty())
|
||||
valore << '-';
|
||||
valore << ditta.get(NDT_FAX);
|
||||
cf.set(valore);
|
||||
return;
|
||||
}
|
||||
@ -2756,9 +2798,8 @@ void TReport::msg_firm(TVariant_stack& stack)
|
||||
return;
|
||||
}
|
||||
|
||||
key = anag.get(ANA_STATORES); key << "|" << is_fisc ? anag.get(ANA_COMRF) : anag.get(ANA_COMRES);
|
||||
|
||||
const TRectype & comune = cache().get(LF_COMUNI, key);
|
||||
key.cut(0) << anag.get(ANA_STATORES) << '|' << anag.get(is_fisc ? ANA_COMRF : ANA_COMRES);
|
||||
const TRectype& comune = cache().get(LF_COMUNI, key);
|
||||
|
||||
if (in=="COM")
|
||||
{
|
||||
|
@ -33,13 +33,13 @@ class TReport_font : public TSortable
|
||||
{
|
||||
enum { DEFAULT_FONT_SIZE = 10 };
|
||||
|
||||
TString _name;
|
||||
TString80 _name;
|
||||
int _size, _cpi;
|
||||
XVT_FONT_STYLE_MASK _style;
|
||||
|
||||
WINDOW _win_mapped;
|
||||
XVT_FNTID _fontid;
|
||||
int _leading, _ascent, _descent;
|
||||
// int _leading, _ascent, _descent;
|
||||
|
||||
protected:
|
||||
virtual int compare(const TSortable& s) const;
|
||||
@ -54,9 +54,9 @@ public:
|
||||
XVT_FNTID get_preview_font(const TWindow& win, const TPoint& res) const;
|
||||
void unmap();
|
||||
|
||||
int leading() const { return _leading; }
|
||||
int ascent() const { return _ascent; }
|
||||
int descent() const { return _descent; }
|
||||
//int leading() const { return _leading; }
|
||||
//int ascent() const { return _ascent; }
|
||||
//int descent() const { return _descent; }
|
||||
|
||||
void save(TXmlItem& root) const;
|
||||
bool load(const TXmlItem& root);
|
||||
@ -246,7 +246,8 @@ public:
|
||||
void compute_print_font(const TReport_font& oldfont, const TReport_font& newfont);
|
||||
|
||||
bool load_fields();
|
||||
bool execute_prescript();
|
||||
void init_dynamic_heights(const TBook& book);
|
||||
bool execute_prescript(const TBook& book);
|
||||
bool execute_postscript();
|
||||
void print(TBook& book) const;
|
||||
void print_clipped(TBook& book, long top, long bottom) const;
|
||||
@ -361,7 +362,9 @@ public:
|
||||
|
||||
void set_draw_pos(long x, long y);
|
||||
void set_draw_size(long x, long y);
|
||||
const TRectangle& get_draw_rect() const;
|
||||
|
||||
const TRectangle& compute_draw_rect(const TBook& book);
|
||||
const TRectangle& get_draw_rect() const { return _draw_rct; }
|
||||
|
||||
void set_groups(const TString& groups);
|
||||
const TString& groups() const;
|
||||
@ -400,9 +403,10 @@ public:
|
||||
bool selected() const { return _selected; }
|
||||
void offset(const TPoint& pt);
|
||||
|
||||
virtual bool print_tools(TBook& book) const;
|
||||
virtual void print_rect(TBook& book) const;
|
||||
virtual void print(TBook& book) const;
|
||||
bool print_tools(TBook& book) const;
|
||||
const TRectangle& print_rect(const TRectangle& rect, TBook& book) const;
|
||||
const TRectangle& print_rect(TBook& book) const;
|
||||
void print(TBook& book) const;
|
||||
|
||||
void save(TXmlItem& root) const;
|
||||
bool load(const TXmlItem& root);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <progind.h>
|
||||
#include <reprint.h>
|
||||
#include <statbar.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include <bagn003.h>
|
||||
|
||||
@ -16,41 +17,47 @@ static bool _print_aborted = false;
|
||||
// Utility
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
void advanced_draw_justified_text(TWindow& win, const char* text, short x, short y, short dx)
|
||||
static void advanced_draw_justified_text_line(TWindow& win, const char* text, short x, short y, short dx)
|
||||
{
|
||||
TString txt(text); txt.rtrim();
|
||||
TString txt(text); txt.rtrim();
|
||||
int spaces = 0;
|
||||
for (int s = 0; txt[s]; s++)
|
||||
if (isspace(txt[s])) spaces++;
|
||||
const int tw = xvt_dwin_get_text_width(win.win(), txt, -1);
|
||||
if (tw < dx && spaces > 0)
|
||||
|
||||
WINDOW w = win.win();
|
||||
if (spaces > 0)
|
||||
{
|
||||
txt << ' '; // Aggiunge spazio finale
|
||||
const double kspc = double(dx - tw) / spaces;
|
||||
int start = 0;
|
||||
double kx = x;
|
||||
for (int i = 0; txt[i]; i++)
|
||||
const int tw = xvt_dwin_get_text_width(w, txt, -1);
|
||||
if (tw < dx)
|
||||
{
|
||||
if (isspace(txt[i]))
|
||||
txt << ' '; // Aggiunge spazio finale
|
||||
const double kspc = double(dx - tw) / spaces;
|
||||
int start = 0;
|
||||
double kx = x;
|
||||
for (int i = 0; txt[i]; i++)
|
||||
{
|
||||
const bool last_word = txt[i+1] == '\0';
|
||||
const TString& parola = txt.sub(start, i + (last_word ? 0 : 1));
|
||||
const int lw = xvt_dwin_get_text_width(win.win(), parola, -1);
|
||||
if (last_word) // ultima parola
|
||||
kx = x+dx-lw;
|
||||
xvt_dwin_draw_text(win.win(), int(kx+0.5), y, parola, -1);
|
||||
kx += lw + kspc;
|
||||
start = i+1;
|
||||
if (isspace(txt[i]))
|
||||
{
|
||||
const bool last_word = txt[i+1] == '\0';
|
||||
const TString& parola = txt.sub(start, i + (last_word ? 0 : 1));
|
||||
const int lw = xvt_dwin_get_text_width(w, parola, -1);
|
||||
if (last_word) // ultima parola
|
||||
kx = x+dx-lw;
|
||||
xvt_dwin_draw_text(w, int(kx+0.5), y, parola, -1);
|
||||
kx += lw + kspc;
|
||||
start = i+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
xvt_dwin_draw_text(win.win(), x, y, text, -1);
|
||||
xvt_dwin_draw_text(w, x, y, txt, -1);
|
||||
}
|
||||
|
||||
void advanced_draw_text(TWindow& win, const char* text, const RCT& r,
|
||||
char halign, char valign)
|
||||
void advanced_draw_text_line(TWindow& win, const char* text, const RCT& r, char halign, char valign)
|
||||
{
|
||||
WINDOW w = win.win();
|
||||
|
||||
const short dx = r.right-r.left;
|
||||
const short dy = r.bottom-r.top;
|
||||
short x = r.left;
|
||||
@ -58,7 +65,7 @@ void advanced_draw_text(TWindow& win, const char* text, const RCT& r,
|
||||
|
||||
if (halign != 'L')
|
||||
{
|
||||
const int tw = xvt_dwin_get_text_width(win.win(), text, -1);
|
||||
const int tw = xvt_dwin_get_text_width(w, text, -1);
|
||||
switch (halign)
|
||||
{
|
||||
case 'C': x += (dx - tw)/2; break;
|
||||
@ -69,7 +76,7 @@ void advanced_draw_text(TWindow& win, const char* text, const RCT& r,
|
||||
|
||||
// Text Height
|
||||
int leading, ascent, descent;
|
||||
xvt_dwin_get_font_metrics(win.win(), &leading, &ascent, &descent);
|
||||
xvt_dwin_get_font_metrics(w, &leading, &ascent, &descent);
|
||||
switch (valign)
|
||||
{
|
||||
case 'C': y -= (dy - ascent)/2; break;
|
||||
@ -77,54 +84,43 @@ void advanced_draw_text(TWindow& win, const char* text, const RCT& r,
|
||||
default : y -= descent; break;
|
||||
}
|
||||
|
||||
RCT orig;
|
||||
|
||||
xvt_dwin_get_clip(win.win(), &orig);
|
||||
RCT orig; xvt_dwin_get_clip(w, &orig);
|
||||
const bool restore_clip = !xvt_rect_is_empty(&orig);
|
||||
if (restore_clip)
|
||||
{
|
||||
RCT clipper;
|
||||
xvt_rect_intersect(&clipper, &orig, (RCT*)&r);
|
||||
xvt_dwin_set_clip(win.win(), (RCT*)&clipper);
|
||||
RCT clipper;
|
||||
xvt_rect_intersect(&clipper, &orig, (RCT*)&r);
|
||||
xvt_dwin_set_clip(w, (RCT*)&clipper);
|
||||
}
|
||||
else
|
||||
xvt_dwin_set_clip(win.win(), (RCT*)&r);
|
||||
xvt_dwin_set_clip(w, (RCT*)&r);
|
||||
|
||||
if (halign == 'J')
|
||||
advanced_draw_justified_text(win, text, x, y, dx);
|
||||
advanced_draw_justified_text_line(win, text, x, y, dx);
|
||||
else
|
||||
xvt_dwin_draw_text(win.win(), x, y, text, -1);
|
||||
xvt_dwin_draw_text(w, x, y, text, -1);
|
||||
|
||||
if (restore_clip)
|
||||
xvt_dwin_set_clip(win.win(), &orig);
|
||||
xvt_dwin_set_clip(w, &orig);
|
||||
else
|
||||
xvt_dwin_set_clip(win.win(), NULL);
|
||||
xvt_dwin_set_clip(w, NULL);
|
||||
}
|
||||
|
||||
void advanced_draw_paragraph(TWindow& win, TString& para, const RCT& rct,
|
||||
void advanced_draw_paragraph(TWindow& win, const TString_array& para, const RCT& rct,
|
||||
char halign, char valign, int default_10row_height)
|
||||
{
|
||||
const bool acapo = para.find('\n') >= 0;
|
||||
|
||||
int leading, ascent, descent;
|
||||
xvt_dwin_get_font_metrics(win.win(), &leading, &ascent, &descent);
|
||||
|
||||
int ky10 = (leading + ascent + descent) * 10;
|
||||
// Aggiusta l'altezza di una riga standard, se necessario
|
||||
if (ky10 < default_10row_height && ky10 > 80*default_10row_height/100)
|
||||
ky10 = default_10row_height;
|
||||
|
||||
const int rct_height = rct.bottom - rct.top;
|
||||
int rows = (rct_height * 11) / ky10; // Sto abbondante del 10% (*11/10) altrimenti risulta spesso 0
|
||||
|
||||
if (acapo || rows > 1) // Devo scrivere piu' righe?
|
||||
const int rows = para.items();
|
||||
if (rows > 1) // Devo scrivere piu' righe?
|
||||
{
|
||||
const int kx10 = xvt_dwin_get_text_width(win.win(), "MMMMMMMMMM", 10);
|
||||
const unsigned columns = (rct.right - rct.left) * 10 / kx10;
|
||||
int leading, ascent, descent;
|
||||
xvt_dwin_get_font_metrics(win.win(), &leading, &ascent, &descent);
|
||||
|
||||
int ky10 = (leading + ascent + descent) * 10;
|
||||
// Aggiusta l'altezza di una riga standard, se necessario
|
||||
if (ky10 < default_10row_height && ky10 > 80*default_10row_height/100)
|
||||
ky10 = default_10row_height;
|
||||
|
||||
TParagraph_string str(para, columns);
|
||||
if (str.items() < rows)
|
||||
rows = str.items();
|
||||
const int rct_height = rct.bottom - rct.top;
|
||||
|
||||
int ybase = rct.top;
|
||||
switch (valign)
|
||||
@ -136,17 +132,24 @@ void advanced_draw_paragraph(TWindow& win, TString& para, const RCT& rct,
|
||||
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
RCT rctline = rct;
|
||||
rctline.top = ybase + (ky10 * row) / 10;
|
||||
rctline.bottom = rctline.top + ky10 / 10;
|
||||
const char* line = str.get();
|
||||
if (halign == 'J' && (row == rows-1 || strlen(line) < columns/2))
|
||||
halign = 'L';
|
||||
advanced_draw_text(win, line, rctline, halign, 'T');
|
||||
const int top = ybase + (ky10 * row) / 10;
|
||||
if (top < rct.bottom)
|
||||
{
|
||||
RCT rctline = rct;
|
||||
rctline.top = top;
|
||||
rctline.bottom = top + ky10 / 10;
|
||||
const TString& line = para.row(row);
|
||||
char ha = halign;
|
||||
if (ha == 'J' && row == rows-1) // Ultima riga non "giustificabile"
|
||||
ha = 'L';
|
||||
advanced_draw_text_line(win, line, rctline, ha, 'T');
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
advanced_draw_text(win, para, rct, halign, valign);
|
||||
advanced_draw_text_line(win, para.row(0), rct, halign, valign);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -352,15 +355,16 @@ void TPrint_preview_window::popup_menu(EVENT* ep)
|
||||
|
||||
void TPrint_preview_window::page_select()
|
||||
{
|
||||
TMask m("Ricerca", 1, 28, 4);
|
||||
m.add_number(101, 0, "Pagina ", 1, 1, 4, "U").check_type(CHECK_REQUIRED);
|
||||
TMask m(TR("Ricerca"), 1, 28, 4);
|
||||
m.add_number(101, 0, TR("Pagina "), 1, 1, 4, "U").check_type(CHECK_REQUIRED);
|
||||
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
|
||||
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
|
||||
if (m.run())
|
||||
{
|
||||
_page = m.get_int(101);
|
||||
if (_page < 1) _page = 1;
|
||||
if (_page > _book->pages()) _page = _book->pages();
|
||||
if (_page > _book->pages())
|
||||
_page = _book->pages();
|
||||
}
|
||||
}
|
||||
|
||||
@ -718,7 +722,7 @@ public:
|
||||
|
||||
TWindow_printer::TWindow_printer(PRINT_RCD* rcd)
|
||||
{
|
||||
WINDOW prwin = xvt_print_create_win(rcd, (char*)(const char*)"Printing");
|
||||
WINDOW prwin = xvt_print_create_win(rcd, "Stampa");
|
||||
set_win(prwin);
|
||||
_pixmap = true;
|
||||
}
|
||||
@ -727,7 +731,7 @@ TWindow_printer::~TWindow_printer()
|
||||
{
|
||||
if (win() != NULL_WIN)
|
||||
{
|
||||
xvt_vobj_destroy(win());
|
||||
xvt_vobj_destroy(win());
|
||||
set_win(NULL_WIN);
|
||||
}
|
||||
}
|
||||
@ -736,6 +740,83 @@ TWindow_printer::~TWindow_printer()
|
||||
// Writing a page
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// Converte da coordinate logiche (1/100 caratteri) a coordinate fisiche
|
||||
TPoint TBook::log2dev(const TPoint& ptlog) const
|
||||
{
|
||||
TPoint ptdev;
|
||||
ptdev.x = (ptlog.x * _phr) / (100 * cpi());
|
||||
ptdev.y = (ptlog.y * _pvr) / (100 * lpi());
|
||||
return ptdev;
|
||||
}
|
||||
|
||||
int TBook::compute_text_frame(const TString& tmp, const TReport_font& font, TRectangle& rect, TString_array& para) const
|
||||
{
|
||||
// Calcola la larghezza massima e l'altezza di 10 righe
|
||||
const TRectangle rect_riga(0,0,rect.width(),1000);
|
||||
const TPoint size = log2dev(rect_riga.size());
|
||||
const int max_row_width = size.x;
|
||||
const int def_10row_height = size.y;
|
||||
|
||||
WINDOW w = _printwin->win();
|
||||
CHECK(w == PRINTER_WIN, "Finestra di stampa non valida");
|
||||
xvt_dwin_set_font(w, font.get_xvt_font(*_printwin));
|
||||
int leading, ascent, descent;
|
||||
xvt_dwin_get_font_metrics(w, &leading, &ascent, &descent);
|
||||
int ky10 = (leading + ascent + descent) * 10;
|
||||
// Aggiusta l'altezza di 10 righe standard, se necessario
|
||||
if (ky10 < def_10row_height && ky10 > 75*def_10row_height/100)
|
||||
ky10 = def_10row_height;
|
||||
|
||||
TToken_string p(tmp, '\n');
|
||||
FOR_EACH_TOKEN(p, line)
|
||||
para.add(line);
|
||||
for (int i = 0; i < para.items(); i++)
|
||||
{
|
||||
TString& row = para.row(i);
|
||||
int pix = xvt_dwin_get_text_width(w, row, -1);
|
||||
if (pix > max_row_width)
|
||||
{
|
||||
int good_len = 0;
|
||||
const int first_space = row.find(' ');
|
||||
if (first_space >= 0)
|
||||
{
|
||||
// Linea con almeno uno spazio
|
||||
for (int i = first_space; row[i]; i++) if (row[i] == ' ')
|
||||
{
|
||||
pix = xvt_dwin_get_text_width(w, row, i);
|
||||
if (pix <= max_row_width)
|
||||
good_len = i;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Linea senza spazi
|
||||
for (good_len = row.len() * max_row_width / w + 1; good_len > 0; good_len--)
|
||||
{
|
||||
const int pix = xvt_dwin_get_text_width(w, row, good_len);
|
||||
if (pix < max_row_width)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TString next_row = row.mid(good_len);
|
||||
next_row.ltrim();
|
||||
para.insert(next_row, i+1);
|
||||
row.cut(good_len);
|
||||
}
|
||||
}
|
||||
|
||||
int h = para.items() * ky10 * 100 / def_10row_height;
|
||||
const int resto = h % 100;
|
||||
if (resto != 0)
|
||||
h += 100-resto;
|
||||
rect.set_height(h);
|
||||
|
||||
return ky10;
|
||||
}
|
||||
|
||||
TPoint TBook::page_size() const
|
||||
{
|
||||
return TPoint(_pw, _ph);
|
||||
@ -827,6 +908,21 @@ void TBook::draw_text(const TRectangle& r, const char* txt)
|
||||
}
|
||||
}
|
||||
|
||||
void TBook::draw_text(const TRectangle& r, const TString_array& txt)
|
||||
{
|
||||
if (!txt.empty())
|
||||
{
|
||||
define_frame(r);
|
||||
*_out << "<text>" << endl;
|
||||
for (int i = 0; i < txt.items(); i++)
|
||||
{
|
||||
const char* line = txt.row(i);
|
||||
*_out << line << endl;
|
||||
}
|
||||
*_out << "</text>" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void TBook::draw_book_pages(const TRectangle& r)
|
||||
{
|
||||
define_frame(r);
|
||||
@ -961,11 +1057,12 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
if (page <= 0 || page > pages())
|
||||
return false;
|
||||
|
||||
const bool preview = win.win() != 883;
|
||||
WINDOW w = win.win();
|
||||
const bool preview = w != PRINTER_WIN;
|
||||
RCT visible;
|
||||
if (preview)
|
||||
{
|
||||
xvt_vobj_get_client_rect(win.win(), &visible);
|
||||
xvt_vobj_get_client_rect(w, &visible);
|
||||
TPrint_preview_window& pw = (TPrint_preview_window&)win;
|
||||
pw.alinks().destroy();
|
||||
}
|
||||
@ -974,7 +1071,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
TString str(buffer_size);
|
||||
char* buffer = str.get_buffer();
|
||||
|
||||
TString stringona; // Testo completo di un campo
|
||||
TString_array paragrafo; // Testo completo di un campo
|
||||
|
||||
// Calcolo altezza riga standard
|
||||
const TRectangle rect_riga(0,0,1000,1000);
|
||||
@ -1027,7 +1124,6 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
|
||||
if (!stringona.blank() && rct.right > rct.left) // Possono esserci campi chiave nascosti
|
||||
{
|
||||
WINDOW w = win.win();
|
||||
DRAW_CTOOLS dct;
|
||||
xvt_dwin_get_draw_ctools(w, &dct);
|
||||
|
||||
@ -1037,7 +1133,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
xvt_font_set_style(newfont, xvt_font_get_style(oldfont) | XVT_FS_UNDERLINE);
|
||||
xvt_dwin_set_font(w, newfont);
|
||||
win.set_color(COLOR_BLUE, dct.back_color);
|
||||
advanced_draw_text(win, stringona, rct, _horizontal_alignment, _vertical_alignment);
|
||||
advanced_draw_text_line(win, stringona, rct, _horizontal_alignment, _vertical_alignment);
|
||||
win.set_color(dct.fore_color, dct.back_color);
|
||||
xvt_dwin_set_font(w, oldfont);
|
||||
}
|
||||
@ -1058,15 +1154,15 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
}
|
||||
if (str.starts_with("<clip"))
|
||||
{
|
||||
xvt_dwin_set_clip(win.win(), &rct);
|
||||
xvt_dwin_set_clip(w, &rct);
|
||||
} else
|
||||
if (str.starts_with("</clip"))
|
||||
{
|
||||
xvt_dwin_set_clip(win.win(), NULL);
|
||||
xvt_dwin_set_clip(w, NULL);
|
||||
} else
|
||||
if (str == "<ellipse/>")
|
||||
{
|
||||
xvt_dwin_draw_oval(win.win(), &rct);
|
||||
xvt_dwin_draw_oval(w, &rct);
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<frame "))
|
||||
@ -1079,14 +1175,14 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
}
|
||||
if (str.starts_with("<font "))
|
||||
{
|
||||
TString name = XVT_FFN_COURIER; get_xml_string(str, "name", name);
|
||||
TString80 name = XVT_FFN_COURIER; get_xml_string(str, "name", name);
|
||||
const int size = get_xml_int(str, "size", 12);
|
||||
const XVT_FONT_STYLE_MASK style = get_xml_int(str, "style", 0);
|
||||
TReport_font font; font.create(name, size, style);
|
||||
if (win.win() == 883)
|
||||
xvt_dwin_set_font(win.win(), font.get_xvt_font(win));
|
||||
if (preview)
|
||||
xvt_dwin_set_font(w, font.get_preview_font(win, page_res()));
|
||||
else
|
||||
xvt_dwin_set_font(win.win(), font.get_preview_font(win, page_res()));
|
||||
xvt_dwin_set_font(w, font.get_xvt_font(win));
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<image "))
|
||||
@ -1094,21 +1190,21 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
TString name; get_xml_string(str, "src", name);
|
||||
TImage* img = _images.image(name);
|
||||
if (img != NULL)
|
||||
img->draw(win.win(), rct);
|
||||
img->draw(w, rct);
|
||||
continue;
|
||||
}
|
||||
if (str == "<line/>")
|
||||
{
|
||||
PNT fr = { rct.top, rct.left };
|
||||
PNT to = { rct.bottom, rct.right };
|
||||
xvt_dwin_draw_set_pos(win.win(), fr);
|
||||
xvt_dwin_draw_line(win.win(), to);
|
||||
const PNT fr = { rct.top, rct.left };
|
||||
const PNT to = { rct.bottom, rct.right };
|
||||
xvt_dwin_draw_set_pos(w, fr);
|
||||
xvt_dwin_draw_line(w, to);
|
||||
continue;
|
||||
}
|
||||
if (str == "<pages/>")
|
||||
{
|
||||
TString8 str; str.format("%u", pages());
|
||||
advanced_draw_text(win, str, rct, _horizontal_alignment, _vertical_alignment);
|
||||
advanced_draw_text_line(win, str, rct, _horizontal_alignment, _vertical_alignment);
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<pen "))
|
||||
@ -1121,16 +1217,16 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
win.hide_pen();
|
||||
else
|
||||
{
|
||||
if (win.win() == 883)
|
||||
win.set_pen(col, width * _phr / 72); // Converte width in 72' di pollice
|
||||
else
|
||||
if (preview)
|
||||
win.set_pen(col, width);
|
||||
else
|
||||
win.set_pen(col, width * _phr / 72); // Converte width in 72' di pollice
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (str == "<rectangle/>")
|
||||
{
|
||||
xvt_dwin_draw_rect(win.win(), &rct);
|
||||
xvt_dwin_draw_rect(w, &rct);
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<rounded_rectangle"))
|
||||
@ -1140,22 +1236,20 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
const TRectangle rr(0,0,radius,radius);
|
||||
RCT re; win.log2dev(rr, re);
|
||||
const int rad = (re.right-re.left) * lpi() / (cpi() * 2);
|
||||
xvt_dwin_draw_roundrect(win.win(), &rct, rad, rad);
|
||||
xvt_dwin_draw_roundrect(w, &rct, rad, rad);
|
||||
continue;
|
||||
}
|
||||
if (str == "<text>")
|
||||
{
|
||||
stringona.cut(0);
|
||||
paragrafo.destroy();
|
||||
while (!ifs.eof())
|
||||
{
|
||||
ifs.getline(buffer, str.size());
|
||||
if (str == "</text>")
|
||||
break;
|
||||
if (stringona.not_empty())
|
||||
stringona << '\n';
|
||||
stringona << str;
|
||||
paragrafo.add(str);
|
||||
}
|
||||
advanced_draw_paragraph(win, stringona, rct,
|
||||
advanced_draw_paragraph(win, paragrafo, rct,
|
||||
_horizontal_alignment, _vertical_alignment,
|
||||
default_10row_height);
|
||||
continue;
|
||||
@ -1342,11 +1436,19 @@ bool TBook::init()
|
||||
return error_box(TR("Dimensioni pagina NULLE"));
|
||||
|
||||
bool ok = true;
|
||||
if (_pvr < 96 || _phr < 96) // Risoluzione di Acrobat Writer
|
||||
if (_pvr < 96 || _phr < 96) // Risoluzione minima di Acrobat Writer
|
||||
{
|
||||
ok = yesno_box(FR("Stampante obsoleta o non adeguatamente configurata:\n"
|
||||
"Risoluzione %ldx%ld. Continuare ugualmente?"), _phr, _pvr);
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
if (_printwin != NULL)
|
||||
delete _printwin;
|
||||
_printwin = new TWindow_printer(_rcd);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -1356,10 +1458,6 @@ bool TBook::main_loop()
|
||||
if (!init())
|
||||
return false;
|
||||
|
||||
TWindow_printer win(_rcd);
|
||||
if (!win.ok())
|
||||
return false;
|
||||
|
||||
if (_pageto < _pagefrom)
|
||||
_pageto = pages();
|
||||
|
||||
@ -1370,7 +1468,7 @@ bool TBook::main_loop()
|
||||
{
|
||||
if (xvt_print_open_page(_rcd))
|
||||
{
|
||||
print_page(win, page);
|
||||
print_page(*_printwin, page);
|
||||
xvt_print_close_page(_rcd);
|
||||
}
|
||||
else
|
||||
@ -1458,7 +1556,7 @@ bool TBook::print_or_preview()
|
||||
TBook::TBook(const char* name)
|
||||
: _out(NULL), _is_temporary(false),
|
||||
_pw(0), _ph(0), _pvr(0), _phr(0),
|
||||
_pages(0), _page(0)
|
||||
_pages(0), _page(0), _rcd(NULL), _printwin(NULL)
|
||||
{
|
||||
_file = name;
|
||||
if (_file.blank())
|
||||
@ -1477,21 +1575,57 @@ TBook::~TBook()
|
||||
if (_is_temporary)
|
||||
xvt_fsys_removefile(_file);
|
||||
}
|
||||
if (_printwin != NULL)
|
||||
delete _printwin;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TPrintind
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TPrintind : public TProgind
|
||||
{
|
||||
TArray _modules;
|
||||
|
||||
protected:
|
||||
virtual void update_bar();
|
||||
|
||||
public:
|
||||
TPrintind(long n, const char* msg);
|
||||
};
|
||||
|
||||
void TPrintind::update_bar()
|
||||
{
|
||||
TProgind::update_bar();
|
||||
|
||||
const int m = _modules.items();
|
||||
if (m > 0)
|
||||
{
|
||||
const int n = _status * 100 / _max;
|
||||
const TImage& img = (const TImage&)_modules[n%m];
|
||||
RCT r; get_bar_rct(r);
|
||||
img.draw(win(), r.right - img.width(), r.bottom + 2);
|
||||
}
|
||||
}
|
||||
|
||||
TPrintind::TPrintind(long n, const char* msg) : TProgind(n, msg, true, true)
|
||||
{
|
||||
if (ADVANCED_GRAPHICS)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
TImage* img = new TImage(BMP_MODULE1 + i);
|
||||
img->convert_transparent_color(MASK_BACK_COLOR);
|
||||
_modules.add(img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TReport_book
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// Converte da coordinate logiche (1/100 caratteri) a coordinate fisiche
|
||||
TPoint TReport_book::log2dev(const TPoint& ptlog) const
|
||||
{
|
||||
TPoint ptdev;
|
||||
ptdev.x = (ptlog.x * _phr) / (100 * cpi());
|
||||
ptdev.y = (ptlog.y * _pvr) / (100 * lpi());
|
||||
return ptdev;
|
||||
}
|
||||
|
||||
void TReport_book::define_frame(const TRectangle& r)
|
||||
{
|
||||
TPoint ptlog = r; ptlog += _delta;
|
||||
@ -1618,6 +1752,7 @@ long TReport_book::print_section(TReport_section& rs)
|
||||
return -1;
|
||||
|
||||
rs.load_fields();
|
||||
rs.init_dynamic_heights(*this);
|
||||
|
||||
// Non sono sicuro se vada prima di load_fields o dopo execute_prescript
|
||||
if (!rs.condition().blank())
|
||||
@ -1628,7 +1763,7 @@ long TReport_book::print_section(TReport_section& rs)
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (!rs.execute_prescript())
|
||||
if (!rs.execute_prescript(*this))
|
||||
{
|
||||
_print_aborted = true;
|
||||
return -1;
|
||||
@ -1711,22 +1846,28 @@ long TReport_book::print_section(TReport_section& rs)
|
||||
|
||||
bool TReport_book::init(TReport& rep)
|
||||
{
|
||||
if (!TBook::init())
|
||||
return false;
|
||||
|
||||
// Controlla orientamento della carta prima di inizializzare
|
||||
const int report_orientation = rep.orientation();
|
||||
if (report_orientation > 0)
|
||||
{
|
||||
const int priter_orientation = _ph > _pw ? 1 : 2;
|
||||
if (report_orientation != priter_orientation)
|
||||
PRINT_RCD* rcd = printer().get_printrcd();
|
||||
if (xvt_print_is_valid(rcd))
|
||||
{
|
||||
// Scambia orientamento della carta
|
||||
xvt_app_escape(XVT_ESC_SET_PRINTER_INFO, _rcd, &_pw, &_ph, NULL, NULL);
|
||||
// Rilegge parametri cambiati
|
||||
xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, _rcd, &_ph, &_pw, &_pvr, &_phr);
|
||||
long ph, pw, phr, pvr;
|
||||
xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, rcd, &ph, &pw, &phr, &pvr);
|
||||
const int priter_orientation = ph > pw ? 1 : 2;
|
||||
if (report_orientation != priter_orientation)
|
||||
{
|
||||
// Scambia orientamento della carta
|
||||
xvt_app_escape(XVT_ESC_SET_PRINTER_INFO, rcd, &pw, &ph, NULL, NULL);
|
||||
// I parametri verranno riletti dalla TBook::init()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!TBook::init())
|
||||
return false;
|
||||
|
||||
_report = &rep;
|
||||
if (rep.use_printer_font())
|
||||
rep.load_printer_font();
|
||||
@ -1809,7 +1950,7 @@ bool TReport_book::add(TReport& rep, bool progind)
|
||||
|
||||
TProgind* pi = NULL;
|
||||
if (progind)
|
||||
pi = new TProgind(rex->items(), msg, true, true);
|
||||
pi = new TPrintind(rex->items(), msg);
|
||||
|
||||
TString_array oldgroup, newgroup;
|
||||
const int max_group = _report->find_max_level('H');
|
||||
|
@ -24,11 +24,13 @@ class TBook : public TObject
|
||||
|
||||
protected:
|
||||
PRINT_RCD* _rcd;
|
||||
TWindow* _printwin;
|
||||
long _ph, _pw, _pvr, _phr;
|
||||
bool _page_is_open;
|
||||
|
||||
virtual void define_frame(const TRectangle& rect);
|
||||
virtual bool init();
|
||||
TPoint log2dev(const TPoint& ptlog) const;
|
||||
|
||||
public:
|
||||
virtual bool open_page();
|
||||
@ -46,10 +48,12 @@ public:
|
||||
virtual void draw_line(const TRectangle& rect);
|
||||
virtual void draw_image(const TRectangle& rect, const char* filename);
|
||||
virtual void draw_text(const TRectangle& rect, const char* text);
|
||||
virtual void draw_text(const TRectangle& rect, const TString_array& text);
|
||||
virtual void draw_link(const TRectangle& rect, const char* text, const char* link);
|
||||
virtual void draw_book_pages(const TRectangle& r);
|
||||
virtual void set_clip(long top, long bottom);
|
||||
|
||||
virtual int compute_text_frame(const TString& txt, const TReport_font& font, TRectangle& rect, TString_array& para) const;
|
||||
|
||||
TPoint page_size() const;
|
||||
TPoint page_res() const;
|
||||
size_t page() const { return _page; }
|
||||
@ -84,7 +88,6 @@ protected:
|
||||
virtual bool open_page();
|
||||
virtual bool close_page();
|
||||
|
||||
TPoint log2dev(const TPoint& ptlog) const;
|
||||
virtual void define_frame(const TRectangle& r);
|
||||
virtual bool on_link(const TReport_link& lnk);
|
||||
|
||||
@ -108,9 +111,8 @@ public:
|
||||
|
||||
bool advanced_set_draw_tools(TWindow& win, PAT_STYLE pat, int border, COLOR fore, COLOR back);
|
||||
void advanced_draw_rect(TWindow& win, const RCT& r, PAT_STYLE pat, int border, COLOR fore, COLOR back, int radius, int shade);
|
||||
void advanced_draw_text(TWindow& win, const char* text, const RCT& r,
|
||||
char halign, char valign);
|
||||
void advanced_draw_paragraph(TWindow& win, TString& text, const RCT& r,
|
||||
void advanced_draw_text_line(TWindow& win, const char* text, const RCT& r, char halign, char valign);
|
||||
void advanced_draw_paragraph(TWindow& win, const TString_array& text, const RCT& r,
|
||||
char halign, char valign, int default_row_height);
|
||||
|
||||
#endif
|
||||
|
@ -755,7 +755,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
|
||||
if (cid >= FIRST_FIELD)
|
||||
{
|
||||
if (rec < items())
|
||||
if (rec >= 0 && rec < items())
|
||||
{
|
||||
const int col = cid - FIRST_FIELD;
|
||||
switch (_type[col])
|
||||
@ -802,6 +802,8 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
else
|
||||
_sheet->get_cell_colors(rec, col, xiev->v.cell_request.color, xiev->v.cell_request.back_color);
|
||||
}
|
||||
else
|
||||
refused = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -993,6 +995,8 @@ void TQuery_field::create(WINDOW parent)
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSheet
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#define DLG_QUERY 25883
|
||||
|
||||
TSheet::TSheet(short x, short y, short dx, short dy,
|
||||
const char* title, const char* head,
|
||||
@ -1001,7 +1005,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
|
||||
_sheet(NULL), _select_row(-1), _parked(-1)
|
||||
{
|
||||
TQuery_field* qf = new TQuery_field(this);
|
||||
qf->construct(25883, head, 1, sht_y, -3, win(), "", -1);
|
||||
qf->construct(DLG_QUERY, head, 1, sht_y, -3, win(), "", -1);
|
||||
fields_array().add(qf);
|
||||
_sheet = qf->sheet();
|
||||
|
||||
@ -1365,8 +1369,7 @@ TCursor_sheet::TCursor_sheet(TCursor* cursor, const char* fields,
|
||||
const char* title, const char* head,
|
||||
byte buttons, short sht_y, WINDOW parent)
|
||||
: TSheet(sht_y ? 3 : 0, sht_y ? 3 : 0, sht_y ? -3 : 0, sht_y ? -3 : 0,
|
||||
title, head, buttons, sht_y, parent),
|
||||
_records(cursor->items()), _cursor(cursor)
|
||||
title, head, buttons, sht_y, parent), _cursor(cursor)
|
||||
{
|
||||
TToken_string fldlst(fields);
|
||||
int campo = 0;
|
||||
@ -1396,11 +1399,9 @@ HIDDEN bool _can_post = FALSE;
|
||||
|
||||
KEY TCursor_sheet::run()
|
||||
{
|
||||
_records = _cursor->items();
|
||||
_cursor->freeze(TRUE);
|
||||
|
||||
|
||||
select(_cursor->pos());
|
||||
// post_select(_cursor->pos());
|
||||
_can_post = TRUE;
|
||||
|
||||
const KEY k = TSheet::run();
|
||||
@ -1408,6 +1409,8 @@ KEY TCursor_sheet::run()
|
||||
return k;
|
||||
}
|
||||
|
||||
long TCursor_sheet::get_items() const
|
||||
{ return _cursor ? _cursor->items() : 0; }
|
||||
|
||||
void TCursor_sheet::get_row(long row, TToken_string& l)
|
||||
{
|
||||
@ -1440,6 +1443,38 @@ bool TCursor_sheet::get_cell_colors(int row, int col, COLOR& fore, COLOR& back)
|
||||
|
||||
HIDDEN TBrowse_sheet* _cur_browse = NULL;
|
||||
|
||||
void TBrowse_sheet::add_custom_filter(const char* regexp)
|
||||
{
|
||||
TString filter = _original_filter;
|
||||
if (regexp && *regexp)
|
||||
{
|
||||
if (_original_filter.not_empty())
|
||||
{
|
||||
filter.insert("(");
|
||||
filter << ")&&(";
|
||||
}
|
||||
filter << regexp;
|
||||
if (_original_filter.not_empty())
|
||||
filter << ')';
|
||||
}
|
||||
if (filter != cursor()->filter())
|
||||
{
|
||||
TCursor& c = *cursor();
|
||||
c.freeze(false);
|
||||
c.setfilter(filter, true);
|
||||
c.items();
|
||||
c.freeze(true);
|
||||
|
||||
// Forzo un aggiornamento a basso livello
|
||||
TQuery_field& qf = (TQuery_field&)TMask::field(DLG_QUERY);
|
||||
XI_OBJ* obj = qf.sheet()->xi_object();
|
||||
xi_scroll_percent(obj, 100);
|
||||
xi_scroll_percent(obj, 0);
|
||||
|
||||
_sel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool TBrowse_sheet::browse_field_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
long rec = -1;
|
||||
@ -1473,14 +1508,14 @@ bool TBrowse_sheet::browse_field_handler(TMask_field& f, KEY k)
|
||||
rec = b->cursor()->read(_isgteq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rec >= 0 && rec != _cur_browse->selected())
|
||||
{
|
||||
_cur_browse->select(rec); // Non mettere post_select
|
||||
_can_post = TRUE;
|
||||
|
||||
RCT r; f.get_rect(r);
|
||||
xvt_dwin_invalidate_rect(f.parent(), &r);
|
||||
xvt_dwin_invalidate_rect(f.parent(), &r); // Non ricordo a cosa serva aggiornare il campo di testo
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -1505,10 +1540,38 @@ bool TBrowse_sheet::last_browse_field_handler(TMask_field& f, KEY k)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TBrowse_sheet::filter_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
TString expr; // Espressione di filtro complessiva
|
||||
if (!f.get().empty()) // Filtro attivato!
|
||||
{
|
||||
const short id = f.dlg()-1000;
|
||||
TString e = f.mask().get(id); // Espressione regolare
|
||||
e.strip("\"'"); // Tolgo caratteri che potrebbero dare problemi
|
||||
if (!e.blank())
|
||||
{
|
||||
const TBrowse& b = *_cur_browse->field().browse();
|
||||
TToken_string ids = b.get_input_fields();
|
||||
const int pos = ids.get_pos(id);
|
||||
if (pos >= 0)
|
||||
{
|
||||
TToken_string fns = b.get_output_field_names();
|
||||
expr << fns.get(pos) << "?=\"" << e << '"';
|
||||
}
|
||||
}
|
||||
if (expr.empty())
|
||||
f.reset();
|
||||
}
|
||||
_cur_browse->add_custom_filter(expr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Gestisce l'handler della finestra
|
||||
@ -1581,7 +1644,7 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
|
||||
TEdit_field* f, TToken_string& sibling)
|
||||
: TCursor_sheet(cursor, fields, title, head, buttons,
|
||||
f->browse() ? f->browse()->input_fields() : 1),
|
||||
_field(f), _sel(0)
|
||||
_field(f), _sel(0), _original_filter(cursor->filter())
|
||||
{
|
||||
TBrowse* browse = f->browse();
|
||||
if (browse == NULL)
|
||||
@ -1642,7 +1705,7 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
|
||||
}
|
||||
p.left_just(16);
|
||||
|
||||
TString16 flags;
|
||||
TString8 flags;
|
||||
if (c.roman()) flags << 'M';
|
||||
if (c.right_justified()) flags << 'R';
|
||||
if (c.uppercase()) flags << 'U';
|
||||
@ -1653,7 +1716,12 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
|
||||
switch (c.class_id())
|
||||
{
|
||||
case CLASS_EDIT_FIELD:
|
||||
e = &add_string(c.dlg(), 0, p, 1, y++, csize, flags, csize > 50 ? 50 : csize);
|
||||
{
|
||||
const int sz = csize > 50 ? 50 : csize; // Dimensione del campo di ricerca
|
||||
e = &add_string(c.dlg(), 0, p, 1, y++, csize, flags, sz);
|
||||
// Aggiunge campo con le icone di filtraggio
|
||||
add_checkbutton(c.dlg()+1000, 0, "", sz+18, y-1, 2, 1, "", 10112, 10113).set_handler(filter_handler);
|
||||
}
|
||||
break;
|
||||
case CLASS_ZOOM_FIELD:
|
||||
e = &add_string(c.dlg(), 0, p, 1, y++, 32000, flags, 50);
|
||||
|
@ -168,8 +168,6 @@ class TCursor_sheet : public TSheet
|
||||
{
|
||||
// @cmember:(INTERNAL) Array di <c TRecfield>
|
||||
TArray _fields;
|
||||
// @cmember:(INTERNAL) Numero del records collegato al cursore
|
||||
long _records;
|
||||
|
||||
// @cmember:(INTERNAL) Cursore da cui prelevare i dati
|
||||
TCursor* _cursor;
|
||||
@ -180,8 +178,7 @@ class TCursor_sheet : public TSheet
|
||||
protected: // TSheet
|
||||
|
||||
// @cmember Ritorna il numero dei records del cursore
|
||||
virtual long get_items() const
|
||||
{ return _records; }
|
||||
virtual long get_items() const;
|
||||
|
||||
// @cmember Ritorna la riga n
|
||||
virtual void get_row(long n, TToken_string& row);
|
||||
@ -224,6 +221,8 @@ class TBrowse_sheet : public TCursor_sheet
|
||||
{
|
||||
// @cmember:(INTERNAL) Campi collegati ai campi editabili (vedi <c TEdit_field>)
|
||||
TEdit_field* const _field;
|
||||
// @cmember:(INTERNAL) filtro originale del cursore
|
||||
TString _original_filter;
|
||||
|
||||
// @cmember:(INTERNAL) Campo di ricerca attuale (Tag button selezionato)
|
||||
int _sel;
|
||||
@ -241,8 +240,11 @@ protected:
|
||||
TEdit_field& field()
|
||||
{ return *_field; }
|
||||
|
||||
void add_custom_filter(const char* regexp);
|
||||
|
||||
static bool browse_field_handler(TMask_field& f, KEY k);
|
||||
static bool last_browse_field_handler(TMask_field& f, KEY k);
|
||||
static bool filter_handler(TMask_field& f, KEY k);
|
||||
|
||||
// @access Public Member
|
||||
public:
|
||||
|
@ -105,13 +105,12 @@ int TString::make_room(
|
||||
const int spare = size() - lun;
|
||||
if (spare < s)
|
||||
{
|
||||
long new_size = long(lun) + long(s);
|
||||
if (new_size > MAX_SIZE)
|
||||
fatal_box("Stringa di lunghezza eccessiva (> %ld)", MAX_SIZE);
|
||||
new_size = 3L * new_size / 2L;
|
||||
const int min_size = lun + s;
|
||||
int new_size = 3 * min_size / 2;
|
||||
if (new_size > MAX_SIZE)
|
||||
new_size = MAX_SIZE;
|
||||
|
||||
if (new_size < min_size)
|
||||
fatal_box("Stringa di lunghezza eccessiva (%ld)", min_size);
|
||||
resize(int(new_size), TRUE);
|
||||
}
|
||||
return lun;
|
||||
@ -228,9 +227,9 @@ TString& TString::strip(
|
||||
|
||||
{
|
||||
int j = 0;
|
||||
for (int i = 0; _str[i]; i++)
|
||||
for (const char* s = _str; *s; s++)
|
||||
{
|
||||
char c = _str[i];
|
||||
const char& c = *s;
|
||||
if (strchr(k, c) == NULL)
|
||||
_str[j++] = c;
|
||||
}
|
||||
@ -240,25 +239,28 @@ TString& TString::strip(
|
||||
|
||||
bool TString::blank() const
|
||||
{
|
||||
for (int i = 0; _str[i]; i++)
|
||||
if (!is_space(_str[i]))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
for (const char* s = _str; *s; s++)
|
||||
if (!is_space(*s))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
TString& TString::strip_spaces()
|
||||
{
|
||||
char instring = '\0';
|
||||
int j = 0;
|
||||
for (int i = 0; _str[i]; i++)
|
||||
for (const char* s = _str; *s; s++)
|
||||
{
|
||||
char c = _str[i];
|
||||
if (is_space(c) && !instring) continue;
|
||||
const char& c = *s;
|
||||
if (is_space(c) && !instring)
|
||||
continue;
|
||||
if (c == '"' || c == '\'')
|
||||
{
|
||||
if (instring == c) instring = '\0';
|
||||
if (instring == c)
|
||||
instring = '\0';
|
||||
else
|
||||
if (instring == '\0') instring = c;
|
||||
if (instring == '\0')
|
||||
instring = c;
|
||||
}
|
||||
_str[j++] = c;
|
||||
}
|
||||
@ -266,22 +268,26 @@ TString& TString::strip_spaces()
|
||||
return *this;
|
||||
}
|
||||
|
||||
TString& TString::strip_d_spaces()
|
||||
TString& TString::strip_double_spaces()
|
||||
{
|
||||
int j = 0;
|
||||
bool spc = FALSE;
|
||||
for (int i = 0; _str[i]; i++)
|
||||
bool spc = false;
|
||||
for (const char* s = _str; *s; s++)
|
||||
{
|
||||
char c = _str[i];
|
||||
const char& c = *s;
|
||||
if (is_space(c))
|
||||
{
|
||||
if (spc)
|
||||
continue;
|
||||
else
|
||||
spc = TRUE;
|
||||
spc = true;
|
||||
}
|
||||
else
|
||||
if (spc) spc = FALSE;
|
||||
spc = false;
|
||||
_str[j++] = c;
|
||||
}
|
||||
if (spc) // Toglie eventuale spazio finale
|
||||
j--;
|
||||
_str[j] = '\0';
|
||||
return *this;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
// @cmember Elimina tutti gli spazi non contenuti tra apici singoli o doppi
|
||||
TString& strip_spaces();
|
||||
// @cmember Elimina tutti gli spazi doppi
|
||||
TString& strip_d_spaces();
|
||||
TString& strip_double_spaces();
|
||||
// @cmember Elimina gli spazi da sinistra o i primi n caratteri (da sinistra).
|
||||
TString& ltrim(int n = 0);
|
||||
// @cmember Elimina gli spazi da destra o i primi n caratteri (da destra).
|
||||
|
@ -8,10 +8,15 @@
|
||||
// TPerformance_profiler
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef DBG
|
||||
static int _depth = 0;
|
||||
#endif
|
||||
|
||||
TPerformance_profiler::TPerformance_profiler(const char* desc, bool trc)
|
||||
: _desc(desc), _trc(trc)
|
||||
{
|
||||
#ifdef DBG
|
||||
_depth++;
|
||||
_start = clock();
|
||||
|
||||
if (!_trc)
|
||||
@ -37,7 +42,7 @@ void TPerformance_profiler::show() const
|
||||
{
|
||||
#ifdef DBG
|
||||
const double s = double(clock() - _start) / CLOCKS_PER_SEC;
|
||||
|
||||
|
||||
int hour = 0, min = 0;
|
||||
int sec = int(s);
|
||||
const int cent = int((s - sec)*100);
|
||||
@ -52,20 +57,28 @@ void TPerformance_profiler::show() const
|
||||
min = sec / 60;
|
||||
sec -= min * 60;
|
||||
}
|
||||
|
||||
|
||||
TString256 msg = _desc;
|
||||
msg.format("%s %02d:%02d:%02d.%02d", (const char*)_desc, hour, min, sec, cent);
|
||||
|
||||
if (_trc)
|
||||
__trace(msg);
|
||||
else
|
||||
statbar_set_title(TASK_WIN, msg);
|
||||
{
|
||||
if (_depth <= 1)
|
||||
{
|
||||
statbar_set_title(TASK_WIN, msg);
|
||||
if (s > 0)
|
||||
xvt_sys_sleep(500);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TPerformance_profiler::~TPerformance_profiler()
|
||||
{
|
||||
show();
|
||||
_depth--;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -570,4 +583,16 @@ istream & eatwhite(istream & i)
|
||||
}
|
||||
#endif
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_power_station()
|
||||
{
|
||||
const char* ranger[] = { "ARCHIMEDE", "BATMOBILE", "KIRK", "SPOCK", "UHURA", NULL };
|
||||
char hostname[256]; xvt_sys_get_host_name(hostname, sizeof(hostname));
|
||||
for (int i = 0; ranger[i]; i++)
|
||||
{
|
||||
if (xvt_str_compare_ignoring_case(hostname, ranger[i]) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ bool make_dir(const char* dir);
|
||||
bool remove_file(const char* file);
|
||||
int list_files(const char* mask, TString_array& result);
|
||||
bool input_filename(TFilename& file);
|
||||
bool is_power_station();
|
||||
|
||||
const char* encode(const char* data);
|
||||
const char* decode(const char* data);
|
||||
|
@ -235,7 +235,7 @@ void TViswin::exec_link()
|
||||
TPrint_application& papp = (TPrint_application&)main_app();
|
||||
papp.repeat_print();
|
||||
papp.current_cursor()->update();
|
||||
xvt_statbar_refresh ();
|
||||
xvtil_statbar_refresh ();
|
||||
stop_run(K_ENTER);
|
||||
}
|
||||
}
|
||||
@ -264,7 +264,7 @@ void TViswin::display_link (long y, long x1, long x2, const char *d)
|
||||
if (in_update) return;
|
||||
|
||||
TString80 dd; dd.strncpy(d, 50);
|
||||
xvt_statbar_set(dd);
|
||||
xvtil_statbar_set(dd);
|
||||
|
||||
if (_link_button)
|
||||
{
|
||||
@ -298,8 +298,8 @@ void TViswin::erase_link (
|
||||
|
||||
if (!in_update)
|
||||
{
|
||||
xvt_statbar_set("");
|
||||
xvt_statbar_refresh();
|
||||
xvtil_statbar_set("");
|
||||
xvtil_statbar_refresh();
|
||||
}
|
||||
|
||||
if (_link_button)
|
||||
@ -1306,8 +1306,8 @@ void TViswin::on_button(short dlg)
|
||||
abort_print();
|
||||
else
|
||||
{
|
||||
xvt_statbar_set("");
|
||||
xvt_statbar_refresh();
|
||||
xvtil_statbar_set("");
|
||||
xvtil_statbar_refresh();
|
||||
stop_run(K_ENTER);
|
||||
}
|
||||
break;
|
||||
@ -1385,8 +1385,8 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
dispatch_e_char(win, CTRL_E);
|
||||
break;
|
||||
case M_VISWIN_PRINT: // stampa
|
||||
xvt_statbar_set ("");
|
||||
xvt_statbar_refresh ();
|
||||
xvtil_statbar_set ("");
|
||||
xvtil_statbar_refresh ();
|
||||
stop_run(CTRL_S);
|
||||
break;
|
||||
case M_SHOW_RULERS: // mostra righelli
|
||||
@ -1398,8 +1398,8 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
check_menu_item(M_SHOW_BUTTONS, _showbuts);
|
||||
break;
|
||||
case M_VISWIN_QUIT: // chiudi
|
||||
xvt_statbar_set ("");
|
||||
xvt_statbar_refresh ();
|
||||
xvtil_statbar_set ("");
|
||||
xvtil_statbar_refresh ();
|
||||
stop_run (K_ENTER);
|
||||
break;
|
||||
case M_VISWIN_COPY: // copia nella clipboard
|
||||
@ -1915,8 +1915,8 @@ bool TViswin::on_key(KEY key)
|
||||
abort_print ();
|
||||
else
|
||||
{
|
||||
xvt_statbar_set ("");
|
||||
xvt_statbar_refresh ();
|
||||
xvtil_statbar_set ("");
|
||||
xvtil_statbar_refresh ();
|
||||
stop_run (K_ESC);
|
||||
}
|
||||
break;
|
||||
|
@ -61,6 +61,11 @@ bool TRectangle::contains(const TPoint& p) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TRectangle::contains(const TRectangle& r) const
|
||||
{
|
||||
return r.left() >= left() && r.right() <= right() && r.top() >= top() && r.bottom() < bottom();
|
||||
}
|
||||
|
||||
bool TRectangle::intersects(const TRectangle& r) const
|
||||
{
|
||||
if (left() > r.right()) return false;
|
||||
@ -408,7 +413,7 @@ WINDOW TWindow::create(
|
||||
if (parent == NULL_WIN) parent = TASK_WIN;
|
||||
if (parent == TASK_WIN) flags |= WSF_INVISIBLE;
|
||||
|
||||
_win = xvt_create_window(
|
||||
_win = xvtil_create_window(
|
||||
wt,
|
||||
x, y, dx, dy,
|
||||
title,
|
||||
@ -815,7 +820,7 @@ void TWindow::set_font(
|
||||
int style, // @parm Stile del font (default 0)
|
||||
int dim) // @parm Dimensione del font (default 0)
|
||||
{
|
||||
xvt_set_font(win(), family, style, dim);
|
||||
xvtil_set_font(win(), family, style, dim);
|
||||
_base_char_width = 0L;
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
void set_bounds(long left, long top, long right, long bottom);
|
||||
|
||||
bool contains(const TPoint& p) const;
|
||||
bool contains(const TRectangle& r) const;
|
||||
bool intersects(const TRectangle& r) const;
|
||||
void merge(const TRectangle& r);
|
||||
bool is_empty() const { return _size.x == 0 || _size.y == 0; }
|
||||
|
@ -429,7 +429,7 @@ void customize_controls(
|
||||
// @doc INTERNAL
|
||||
|
||||
// @func Permette di settare il font attivo nella finestra
|
||||
void xvt_set_font(
|
||||
void xvtil_set_font(
|
||||
WINDOW win, // @parm Finestra nella quale settare il font
|
||||
const char* family, // @parm Nome del font da settare
|
||||
int style, // @parm Stile da applicare al font
|
||||
@ -458,6 +458,7 @@ void xvt_set_font(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void xvt_draw_rect(WINDOW win, const RCT& rect, COLOR lt, COLOR rb, short depth)
|
||||
{
|
||||
RCT r = rect;
|
||||
@ -512,14 +513,14 @@ void xvt_draw_rect(WINDOW win, const RCT& rect, COLOR lt, COLOR rb, short depth)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// @doc INTERNAL
|
||||
|
||||
// @func Permette di creare una finestra
|
||||
//
|
||||
// @rdesc Ritorna l'identificatore della finestra creata
|
||||
WINDOW xvt_create_window(
|
||||
WINDOW xvtil_create_window(
|
||||
WIN_TYPE wt, // @parm Tipo di finestra da creare
|
||||
short x, // @parm Coordinata x della finestra (espresso in caratteri)
|
||||
short y, // @parm Coordinata y della finestra (espresso in caratteri)
|
||||
@ -562,7 +563,7 @@ HIDDEN WINDOW _statbar = NULL_WIN;
|
||||
// @func Permette di creare la barra di stato del programma
|
||||
//
|
||||
// @rdesc Ritorna l'identificatore della barra di stato creata
|
||||
WINDOW xvt_create_statbar()
|
||||
WINDOW xvtil_create_statbar()
|
||||
// @xref <f xvt_statbar_set> <f xvt_statbar_refresh>
|
||||
{
|
||||
CHECK(_statbar == NULL_WIN, "Onli uan statbar, plis");
|
||||
@ -589,7 +590,7 @@ WINDOW xvt_create_statbar()
|
||||
// @doc INTERNAL
|
||||
|
||||
// @func Permette di settare una finestra con la barra di stato
|
||||
void xvt_statbar_set(
|
||||
void xvtil_statbar_set(
|
||||
const char* text, // @parm Testo da inserire nella barra di stato
|
||||
bool def) // @parm (default FALSE)
|
||||
|
||||
@ -613,7 +614,7 @@ void xvt_statbar_set(
|
||||
// @doc INTERNAL
|
||||
|
||||
// @func Setta il testo standard della barra di stato
|
||||
void xvt_statbar_refresh()
|
||||
void xvtil_statbar_refresh()
|
||||
|
||||
// @xref <f xvt_create_statbar> <f xvt_statbar_set>
|
||||
{
|
||||
@ -648,7 +649,7 @@ HIDDEN bool test_menu_tag(MENU_ITEM* mi, MENU_TAG tag)
|
||||
//
|
||||
// @flag TRUE | Se esiste la voce di menu'
|
||||
// @flag FALSE | Se non esiste la voce di menu'
|
||||
bool xvt_test_menu_tag(
|
||||
bool xvtil_test_menu_tag(
|
||||
MENU_TAG tag) // @parm Menu' nel quale cercare la voce
|
||||
|
||||
{
|
||||
|
@ -23,56 +23,54 @@ const long E_ADDLINE = 488L;
|
||||
|
||||
RCT& resize_rect(short x, short y, short dx, short dy, WIN_TYPE wt, WINDOW parent);
|
||||
|
||||
void xvt_draw_rect(WINDOW w, const RCT& r, COLOR c1, COLOR c2, short depth = 1);
|
||||
|
||||
WINDOW xvt_create_window
|
||||
WINDOW xvtil_create_window
|
||||
(
|
||||
WIN_TYPE wt,
|
||||
short x, short y, short dx, short dy,
|
||||
const char* caption,
|
||||
int menu, WINDOW parent,
|
||||
long flags,
|
||||
EVENT_HANDLER eh,
|
||||
long app_data
|
||||
);
|
||||
WIN_TYPE wt,
|
||||
short x, short y, short dx, short dy,
|
||||
const char* caption,
|
||||
int menu, WINDOW parent,
|
||||
long flags,
|
||||
EVENT_HANDLER eh,
|
||||
long app_data
|
||||
);
|
||||
|
||||
WINDOW xvt_create_statbar();
|
||||
void xvt_statbar_set(const char* text, bool def = FALSE);
|
||||
void xvt_statbar_refresh();
|
||||
WINDOW xvtil_create_statbar();
|
||||
void xvtil_statbar_set(const char* text, bool def = FALSE);
|
||||
void xvtil_statbar_refresh();
|
||||
|
||||
void beep(int severity = 0);
|
||||
void do_events();
|
||||
void beep(int severity = 0);
|
||||
void do_events();
|
||||
|
||||
void set_xvt_hooks();
|
||||
void ignore_xvt_errors(bool ie);
|
||||
|
||||
void customize_colors();
|
||||
void customize_controls(bool on);
|
||||
void set_xvt_hooks();
|
||||
void ignore_xvt_errors(bool ie);
|
||||
|
||||
KEY e_char_to_key(const EVENT* ep);
|
||||
void dispatch_event(WINDOW win, const EVENT& e, bool post);
|
||||
void dispatch_e_menu(WINDOW win, MENU_TAG item);
|
||||
void dispatch_e_char(WINDOW win, KEY key);
|
||||
void dispatch_e_scroll(WINDOW win, KEY key);
|
||||
|
||||
void begin_wait();
|
||||
void end_wait();
|
||||
void customize_colors();
|
||||
void customize_controls(bool on);
|
||||
|
||||
// One-liner for waiting!
|
||||
class TWait_cursor
|
||||
{
|
||||
public:
|
||||
TWait_cursor() { ::begin_wait(); }
|
||||
~TWait_cursor() { ::end_wait(); }
|
||||
};
|
||||
KEY e_char_to_key(const EVENT* ep);
|
||||
void dispatch_event(WINDOW win, const EVENT& e, bool post);
|
||||
void dispatch_e_menu(WINDOW win, MENU_TAG item);
|
||||
void dispatch_e_char(WINDOW win, KEY key);
|
||||
void dispatch_e_scroll(WINDOW win, KEY key);
|
||||
|
||||
void xvt_set_font(WINDOW win, const char* family, int style, int dim = 0);
|
||||
bool xvt_test_menu_tag(MENU_TAG tag);
|
||||
void begin_wait();
|
||||
void end_wait();
|
||||
|
||||
COLOR trans_color(char c);
|
||||
PAT_STYLE trans_brush(char p);
|
||||
PEN_STYLE trans_pen (char p);
|
||||
// One-liner for waiting!
|
||||
class TWait_cursor
|
||||
{
|
||||
public:
|
||||
TWait_cursor() { ::begin_wait(); }
|
||||
~TWait_cursor() { ::end_wait(); }
|
||||
};
|
||||
|
||||
extern short CHARX, CHARY, BASEY, ROWY;
|
||||
void xvtil_set_font(WINDOW win, const char* family, int style, int dim = 0);
|
||||
bool xvtil_test_menu_tag(MENU_TAG tag);
|
||||
|
||||
COLOR trans_color(char c);
|
||||
PAT_STYLE trans_brush(char p);
|
||||
PEN_STYLE trans_pen (char p);
|
||||
|
||||
extern short CHARX, CHARY, BASEY, ROWY;
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user