Sostituito membro _section_mask con metodo section_mask() virtuale.

Spostata in protected la exist(); aggiunti metodi pre_edit_checks() e
post_edit_checks() per effettuare controlli non standard sull'editing
di sezione. Rimossi metodi remove_temp_items(), put_examples() e
remove_examples(). Aggiunto membro _ofsvr in TPrint_section per l'offset
verticale intestazione colonna. Rimossa la find_first_col().
Corretta visualizzazione esempi data, rimossa la gestione degli specials
di default, corretta la gestione della prima colonna COLUMNWISE; corretto
metodo TForm_item::x() per COLUMNWISE (ora ritorna la coordinata x +
l'ooffset prima colonna); aggiunta la gestione della larghezza campo
anche in sezioni non COLUMNWISE. Corretta la visualizzazione delle
stringhe di esempio. Corretta la gestione dello sheet di selezione ed
edit dei form_items. Ristrutturata la TPrint_section::edit() per effettuare
controlli non standard.


git-svn-id: svn://10.65.10.50/trunk@2446 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1996-01-13 10:44:36 +00:00
parent 32f7ff9449
commit 1ceeb20a33
2 changed files with 186 additions and 264 deletions

View File

@ -19,15 +19,14 @@
#endif #endif
#include "../ba/bafrm.h" #include "../ba/bafrm.h"
#include "../sc/sc21pec.h"
// per lo sheet di edit campi // per lo sheet di edit campi
HIDDEN const int idt_id = 101; HIDDEN const int idt_id = 101;
HIDDEN const int dsc_id = 102; HIDDEN const int dsc_id = 102;
HIDDEN const int prn_id = 103; HIDDEN const int prn_id = 103;
HIDDEN const int yps_id = 104; HIDDEN const int yps_id = 104;
HIDDEN const int len_id = 105; HIDDEN const int xps_id = 105;
HIDDEN const int xps_id = 106; HIDDEN const int len_id = 106;
HIDDEN const int col_id = 107; HIDDEN const int col_id = 107;
HIDDEN const int int_id = 108; HIDDEN const int int_id = 108;
HIDDEN const int spc_id = 109; HIDDEN const int spc_id = 109;
@ -207,7 +206,8 @@ HIDDEN bool dateformat_handler(TMask_field& f, KEY k)
fmt[4] = m.get(F_DSEP)[0]; fmt[4] = m.get(F_DSEP)[0];
fmt[5] = '\0'; fmt[5] = '\0';
const TFormatted_date ex(TODAY, 0, 0, fmt); const TDate d(TODAY);
const TFormatted_date ex(d,fmt);
m.set(F_DEXAMPLE, ex.string()); m.set(F_DEXAMPLE, ex.string());
} }
return TRUE; return TRUE;
@ -455,24 +455,6 @@ bool TForm_item::parse(TScanner& scanner)
while (ok && scanner.popkey() != "EN") while (ok && scanner.popkey() != "EN")
ok = parse_item(scanner); ok = parse_item(scanner);
if (section().columnwise())
{
// look for compulsory SPECIALs and fick them in its cul if absent
if (!_special.is_key("XHEAD"))
_special.add("XHEAD",new TToken_string("NUMERO|0|Spostamento orizzontale intestazione in colonna/2/0"));
if (!_special.is_key("YHEAD"))
_special.add("YHEAD",new TToken_string("NUMERO|-1|Spostamento verticale intestazione in testata /2/0"));
if (!_special.is_key("DHEAD"))
{
TToken_string* tt = new TToken_string(128);
TString k(key());
tt->add("STRINGA");
tt->add(k);
tt->add("Intestazione colonna corrispondente/40");
_special.add("DHEAD",tt);
}
}
return ok; return ok;
} }
@ -605,7 +587,7 @@ void TForm_item::string_at(int x, int y, const char* s)
{ {
if (shown()) if (shown())
{ {
if (section().columnwise()) x += _ofs + _section->ofspc(); if (section().columnwise()) x += _ofs;
TPrintrow& row = section().row(y-1); // Seleziona riga di stampa TPrintrow& row = section().row(y-1); // Seleziona riga di stampa
if (_width > 0 && strlen(s) > (word)_width) // Tronca testo se necessario if (_width > 0 && strlen(s) > (word)_width) // Tronca testo se necessario
@ -776,9 +758,8 @@ void TForm_item::print_on_sheet_row(TToken_string& tt) const
tt.add(_id, idt_id - 101); tt.add(_id, idt_id - 101);
tt.add(_desc, dsc_id - 101); tt.add(_desc, dsc_id - 101);
tt.add(_x, _section->columnwise() ? col_id - 101 : xps_id - 101); tt.add(_x, _section->columnwise() ? col_id - 101 : xps_id - 101);
if (_section->columnwise())
tt.add(_width, len_id - 101); tt.add(_width, len_id - 101);
else if (!_section->columnwise())
tt.add(_y, yps_id - 101); tt.add(_y, yps_id - 101);
tt.add(class_name(), typ_id - 101); tt.add(class_name(), typ_id - 101);
tt.add(shown() ? " " : "X", prn_id - 101); tt.add(shown() ? " " : "X", prn_id - 101);
@ -838,15 +819,14 @@ void TForm_item::read_from(TToken_string& s)
_id = s.get_int(idt_id - 101); _id = s.get_int(idt_id - 101);
_desc = s.get(dsc_id - 101); _desc = s.get(dsc_id - 101);
_x = _section->columnwise() ? s.get_int(col_id - 101) : s.get_int(xps_id - 101); _x = _section->columnwise() ? s.get_int(col_id - 101) : s.get_int(xps_id - 101);
if (_section->columnwise())
_width = s.get_int(len_id - 101); _width = s.get_int(len_id - 101);
else if (!_section->columnwise())
_y = s.get_int(yps_id - 101); _y = s.get_int(yps_id - 101);
_ofs = s.get_int(spc_id - 101);
_flag.set_shown(s.get(prn_id - 101)[0] != 'X'); _flag.set_shown(s.get(prn_id - 101)[0] != 'X');
if (_section->columnwise()) if (_section->columnwise())
{ {
_ofs = s.get_int(spc_id - 101);
_flag.set_finkl(s.get(fnl_id - 101)[0] != 'X'); _flag.set_finkl(s.get(fnl_id - 101)[0] != 'X');
_flag.set_finkr(s.get(fnr_id - 101)[0] != 'X'); _flag.set_finkr(s.get(fnr_id - 101)[0] != 'X');
_col_head = s.get(int_id - 101); _col_head = s.get(int_id - 101);
@ -878,7 +858,6 @@ bool TForm_item::edit(TMask& m)
m.enable(F_ID, godmode); m.enable(F_ID, godmode);
m.enable(F_KEY,godmode); m.enable(F_KEY,godmode);
m.enable(F_Y,!_section->columnwise()); m.enable(F_Y,!_section->columnwise());
m.enable(F_WIDTH,_section->columnwise());
m.enable(F_INTEST,_section->columnwise()); m.enable(F_INTEST,_section->columnwise());
if (_flag.memo) if (_flag.memo)
{ {
@ -886,8 +865,6 @@ bool TForm_item::edit(TMask& m)
m.hide(F_PROMPT); m.hide(F_PROMPT);
m.enable(F_MEMO); m.enable(F_MEMO);
m.show(F_MEMO); m.show(F_MEMO);
m.enable(F_WIDTH);
m.show(F_WIDTH);
m.enable(F_HEIGHT); m.enable(F_HEIGHT);
m.show(F_HEIGHT); m.show(F_HEIGHT);
} }
@ -926,7 +903,7 @@ short TForm_item::x()
{ {
if (_section == NULL || !_section->columnwise()) if (_section == NULL || !_section->columnwise())
return _x; return _x;
return _section->tab(_x-1); return _section->tab(_x-1) + _section->ofspc();
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -1394,8 +1371,10 @@ bool TForm_string::update()
const char* TForm_string::example() const const char* TForm_string::example() const
{ {
TString prova("Stringa esempio"); TString prova("XXXXXXXXXXXXXXXXXXXXXXXXXX");
apply_format(prova, picture()); apply_format(prova, picture());
const int w = width();
if (prova.size() > w && w > 0) prova.cut(w);
return strcpy(__tmp_string, prova); return strcpy(__tmp_string, prova);
} }
@ -1995,7 +1974,7 @@ TMask* TPrint_section::_msk = NULL;
TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, bool sub) TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, bool sub)
: _height(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE), : _height(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE),
_subsection(sub), _repeat_count(0), _ofspc(0), _nfld(0), _temp(0), _subsection(sub), _repeat_count(0), _ofspc(0), _ofsvr(0), _nfld(0), _temp(0),
_columnwise(FALSE) _columnwise(FALSE)
{ {
reset_tabs(); reset_tabs();
@ -2058,7 +2037,7 @@ int TPrint_section::tab(int col)
{ {
// compute column offset // compute column offset
_nfld = 0; _nfld = 0;
_tab[0] = 1; _tab[0] = 2;
short maxcolreached = 0; short maxcolreached = 0;
for (word i = 0; i < fields(); i++) for (word i = 0; i < fields(); i++)
{ {
@ -2088,23 +2067,6 @@ int TPrint_section::tab(int col)
return ret; return ret;
} }
int TPrint_section::find_first_col()
{
int col = MAXCOLUMNS;
int id = -1;
const int items = fields();
for (int i = 0; i<items; i++)
{
TForm_item& fi = field(i);
if (fi.shown() && fi.get_column() < col)
{
col = fi.get_column();
id = fi.id();
}
}
return id;
}
void TPrint_section::offset(int& x, int& y) void TPrint_section::offset(int& x, int& y)
{ {
if (x >= 0) if (x >= 0)
@ -2197,6 +2159,7 @@ bool TPrint_section::read_from(const TRectype& prof)
bool changed = FALSE; bool changed = FALSE;
const word h = (word)prof.get_int("HGT"); const word h = (word)prof.get_int("HGT");
const word l = (word)prof.get_int("LEN"); const word l = (word)prof.get_int("LEN");
const word y = (word)prof.get_int("Y");
if (_height != h) if (_height != h)
{ {
_height = h; _height = h;
@ -2207,6 +2170,11 @@ bool TPrint_section::read_from(const TRectype& prof)
_ofspc = l; _ofspc = l;
changed = TRUE; changed = TRUE;
} }
if (_ofsvr != y)
{
_ofsvr = y;
changed = TRUE;
}
return changed; return changed;
} }
@ -2215,7 +2183,7 @@ void TPrint_section::print_on(TRectype& prof)
CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM"); CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM");
prof.put("ID", 0); prof.put("ID", 0);
prof.put("X", 0); prof.put("X", 0);
prof.put("Y", 0); prof.put("Y", _ofsvr);
prof.put("LEN", _ofspc); prof.put("LEN", _ofspc);
prof.put("HGT", _height); prof.put("HGT", _height);
} }
@ -2258,11 +2226,38 @@ bool TPrint_section::detail_field_handler(TMask_field& f, KEY k)
{ {
if (k == K_SPACE) if (k == K_SPACE)
{ {
bool consider_sheet_mask = FALSE;
if (f.mask().is_running()) // Se la maschera di editing dello sheet e' running
consider_sheet_mask = TRUE; // allora deve tener conto anche di essa per l'I/O
// to avoid kasinations with recursion // to avoid kasinations with recursion
TPrint_section& section = ::section(); TPrint_section& section = ::section();
TSheet_field& ms = *f.mask().get_sheet(); TSheet_field& ms = *f.mask().get_sheet();
int field = ms.selected(); int field = ms.selected();
TToken_string& tt = ms.row(field); TToken_string& tt = ms.row(field);
TToken_string tt_mask(tt);
if (consider_sheet_mask)
{
TMask& msheet = f.mask();
tt_mask.add(msheet.get(idt_id), idt_id - 101);
tt_mask.add(msheet.get(dsc_id), dsc_id - 101);
tt_mask.add(msheet.get(len_id), len_id - 101);
tt_mask.add(msheet.get(prn_id), prn_id - 101);
if (section.columnwise())
{
tt_mask.add(msheet.get(col_id), col_id - 101);
tt_mask.add(msheet.get(spc_id), spc_id -101);
tt_mask.add(msheet.get(int_id), int_id - 101);
tt_mask.add(msheet.get(fnl_id), fnl_id -101);
tt_mask.add(msheet.get(fnr_id), fnr_id -101);
}
else
{
tt_mask.add(msheet.get(xps_id), xps_id - 101);
tt_mask.add(msheet.get(yps_id), yps_id - 101);
}
}
TMask msk("ba2100f"); TMask msk("ba2100f");
@ -2352,7 +2347,10 @@ bool TPrint_section::detail_field_handler(TMask_field& f, KEY k)
} }
} }
} }
if (consider_sheet_mask)
fi.read_from(tt_mask);
else
fi.read_from(tt);
fi.edit(msk); fi.edit(msk);
// check specials // check specials
@ -2384,8 +2382,32 @@ bool TPrint_section::detail_field_handler(TMask_field& f, KEY k)
} }
} }
// reset stominchione if (!consider_sheet_mask)
fi.print_on_sheet_row(tt); fi.print_on_sheet_row(tt);
else
{
TMask& msheet = f.mask();
fi.print_on_sheet_row(tt_mask);
msheet.set(idt_id, tt_mask.get_int(idt_id - 101));
msheet.set(dsc_id, tt_mask.get(dsc_id - 101));
msheet.set(len_id, tt_mask.get_int(len_id - 101));
msheet.set(prn_id, tt_mask.get(prn_id - 101));
msheet.set(frm_id, fi.example());
if (section.columnwise())
{
msheet.set(spc_id, tt_mask.get_int(spc_id - 101));
msheet.set(col_id, tt_mask.get_int(col_id - 101));
msheet.set(int_id, tt_mask.get(int_id - 101));
msheet.set(fnl_id, tt_mask.get(fnl_id - 101));
msheet.set(fnr_id, tt_mask.get(fnr_id - 101));
}
else
{
msheet.set(xps_id, tt_mask.get_int(xps_id - 101));
msheet.set(yps_id, tt_mask.get_int(yps_id - 101));
}
}
ms.force_update(); ms.force_update();
@ -2478,8 +2500,8 @@ bool TPrint_section::detail_field_notify (TSheet_field& s, int r, KEY k)
bool TPrint_section::edit(const char* title) bool TPrint_section::edit(const char* title)
{ {
const bool is_ba_editor = _form->section_mask() == "ba"; const bool is_ba_editor = TString(_form->section_mask()).left(2) == "ba";
bool des_dirty = FALSE; bool nstd_dirty = FALSE;
_cur_form = _form; _cur_form = _form;
_cur_sect = this; _cur_sect = this;
@ -2488,6 +2510,10 @@ bool TPrint_section::edit(const char* title)
TMask m(_form->section_mask()); TMask m(_form->section_mask());
m.set_caption(title); m.set_caption(title);
m.set(F_HEIGHT, _height); m.set(F_HEIGHT, _height);
m.set(F_OFSPC, _ofspc);
m.set(F_OFSVR, _ofsvr);
if (is_ba_editor)
{
m.set(F_X, form().offset_x()); m.set(F_X, form().offset_x());
m.set(F_Y, form().offset_y()); m.set(F_Y, form().offset_y());
m.set(F_CTP, format("%c",form().char_to_pos())); m.set(F_CTP, format("%c",form().char_to_pos()));
@ -2495,32 +2521,15 @@ bool TPrint_section::edit(const char* title)
m.set(F_IPY, form().ipy()); m.set(F_IPY, form().ipy());
m.set(F_FPX, form().fpx()); m.set(F_FPX, form().fpx());
m.set(F_FLEN, printer().formlen()); m.set(F_FLEN, printer().formlen());
m.set(F_OFSPC, _ofspc);
// Carica i valori dei campi testo costanti (se non e' il formeditor normale)
if (!is_ba_editor)
{ // Se sta editando il body abilita i primi 4, se sta editando il footer abilita l'ultimo
if (_sec_type == 'B')
m.enable(-2);
if (_sec_type == 'F')
m.enable(-3);
if (_form->exist('H', last_page))
{
m.set(F_DES1,_form->find_field('H',last_page,PEC_SALDO).prompt());
m.set(F_DES2,_form->find_field('H',last_page,PEC_RITENUTE).prompt());
m.set(F_DES3,_form->find_field('H',last_page,PEC_ABBUONI).prompt());
m.set(F_DES4,_form->find_field('H',last_page,PEC_DIFFCAM).prompt());
m.set(F_DES5,_form->find_field('H',last_page,PEC_RIPORTO).prompt());
} }
} else
_form->pre_edit_checks(m,_cur_sect);
// still unused: will need to be shown if section is columnwise; no
// provision for saving yet (should be in form, with a field for each pos)
TSheet_field& ms = (TSheet_field&)m.field(F_FIELDS); TSheet_field& ms = (TSheet_field&)m.field(F_FIELDS);
m.hide(F_OFSVR);//Offset verticale, per _columnwise. Non ancora usato.
if (_columnwise) if (_columnwise)
{ {
m.disable(F_HEIGHT); m.disable(F_HEIGHT);
//ms.delete_column(dsc_id); ms.sheet_mask().hide(dsc_id);
ms.delete_column(xps_id); ms.sheet_mask().hide(xps_id); ms.delete_column(xps_id); ms.sheet_mask().hide(xps_id);
ms.delete_column(yps_id); ms.sheet_mask().hide(yps_id); ms.delete_column(yps_id); ms.sheet_mask().hide(yps_id);
} }
@ -2528,7 +2537,6 @@ bool TPrint_section::edit(const char* title)
{ {
m.hide(F_OFSPC); m.hide(F_OFSPC);
ms.delete_column(int_id); ms.sheet_mask().hide(int_id); ms.delete_column(int_id); ms.sheet_mask().hide(int_id);
ms.delete_column(len_id); ms.sheet_mask().hide(len_id);
ms.delete_column(col_id); ms.sheet_mask().hide(col_id); ms.delete_column(col_id); ms.sheet_mask().hide(col_id);
ms.delete_column(spc_id); ms.sheet_mask().hide(spc_id); ms.delete_column(spc_id); ms.sheet_mask().hide(spc_id);
ms.delete_column(fnl_id); ms.sheet_mask().hide(fnl_id); ms.delete_column(fnl_id); ms.sheet_mask().hide(fnl_id);
@ -2559,6 +2567,7 @@ bool TPrint_section::edit(const char* title)
ms.row(-1) = tt; ms.row(-1) = tt;
} }
if (is_ba_editor)
{ {
const int MAX_FAMILIES = 128; const int MAX_FAMILIES = 128;
char* family[MAX_FAMILIES]; char* family[MAX_FAMILIES];
@ -2578,10 +2587,10 @@ bool TPrint_section::edit(const char* title)
lst.replace_items(pn1, pn2); lst.replace_items(pn1, pn2);
if (!font_found) warning_box("Il font %s non esiste per la stampante di default.",(const char*) form().fontname()); if (!font_found) warning_box("Il font %s non esiste per la stampante di default.",(const char*) form().fontname());
lst.set(form().fontname()); lst.set(form().fontname());
}
printer().set_char_size(form().fontsize()); printer().set_char_size(form().fontsize());
m.set_handler(F_FONT,font_handler); m.set_handler(F_FONT,font_handler);
}
if(_columnwise) if(_columnwise)
{ {
bool ok = FALSE; bool ok = FALSE;
@ -2607,27 +2616,7 @@ bool TPrint_section::edit(const char* title)
if (dirty) if (dirty)
{ {
// Salva i valori dei campi testo costanti (se non e' il formeditor normale) // Controlli da fare sempre a prescindere dal form editor
if (!is_ba_editor && _form->exist('H', last_page))
{
_form->section('H',last_page).set_dirty();
TForm_item& saldo = _form->find_field('H',last_page,PEC_SALDO);
TForm_item& abbuoni = _form->find_field('H',last_page,PEC_RITENUTE);
TForm_item& diffcam = _form->find_field('H',last_page,PEC_ABBUONI);
TForm_item& ritenute = _form->find_field('H',last_page,PEC_DIFFCAM);
TForm_item& riporto = _form->find_field('H',last_page,PEC_RIPORTO);
saldo.set_prompt(m.get(F_DES1));
saldo.set_dirty();
abbuoni.set_prompt(m.get(F_DES2));
abbuoni.set_dirty();
diffcam.set_prompt(m.get(F_DES3));
diffcam.set_dirty();
ritenute.set_prompt(m.get(F_DES4));
ritenute.set_dirty();
riporto.set_prompt(m.get(F_DES5));
riporto.set_dirty();
des_dirty = TRUE;
}
if (_height != (word)m.get_int(F_HEIGHT) ) if (_height != (word)m.get_int(F_HEIGHT) )
{ {
_height = m.get_int(F_HEIGHT); _height = m.get_int(F_HEIGHT);
@ -2638,6 +2627,13 @@ bool TPrint_section::edit(const char* title)
_ofspc = m.get_int(F_OFSPC); _ofspc = m.get_int(F_OFSPC);
_dirty=TRUE; _dirty=TRUE;
} }
if (_ofsvr != (word)m.get_int(F_OFSVR) )
{
_ofsvr = m.get_int(F_OFSVR);
_dirty=TRUE;
}
if (is_ba_editor)
{ // Controlli solo se il form editor e' quello base
if (m.get_int(F_X) != form().offset_x() || m.get_int(F_Y) != form().offset_y()) if (m.get_int(F_X) != form().offset_x() || m.get_int(F_Y) != form().offset_y())
{ {
form().offset_x() = m.get_int(F_X); form().offset_x() = m.get_int(F_X);
@ -2659,7 +2655,6 @@ bool TPrint_section::edit(const char* title)
TString80 name(m.get(F_FONT)); TString80 name(m.get(F_FONT));
int size = m.get_int(F_SIZE); int size = m.get_int(F_SIZE);
if (size==0) size = form().fontsize();
if (name != form().fontname() || size != form().fontsize()) if (name != form().fontname() || size != form().fontsize())
{ {
if (!form().dirty()) form().set_dirty(); if (!form().dirty()) form().set_dirty();
@ -2704,6 +2699,8 @@ bool TPrint_section::edit(const char* title)
} }
} }
} }
} else // controlli se l'editor non e' quello base
nstd_dirty = _form->post_edit_checks(m,_cur_sect);
} }
} }
@ -2734,7 +2731,7 @@ bool TPrint_section::edit(const char* title)
_dirty |= field(j).dirty(); _dirty |= field(j).dirty();
set_dirty(_dirty); set_dirty(_dirty);
return (_dirty || des_dirty); return (_dirty || nstd_dirty);
} }
void TPrint_section::print_on(ostream& out) const void TPrint_section::print_on(ostream& out) const
@ -3346,7 +3343,7 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, const int* rows)
if (cols[i] != start && cols[i] > 0) if (cols[i] != start && cols[i] > 0)
{ {
TForm_line* l = new TForm_line(grs); TForm_line* l = new TForm_line(grs);
l->set_x(cols[i]-1 + body->ofspc()); l->set_x(cols[i]-1);
l->y() = (word)y1; l->y() = (word)y1;
l->id() = -1; l->id() = -1;
l->width() = 1; l->width() = 1;
@ -3361,10 +3358,10 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, const int* rows)
if (start != 999 && end != 0) if (start != 999 && end != 0)
{ {
TForm_box* l = new TForm_box(grs); TForm_box* l = new TForm_box(grs);
l->set_x(start + body->ofspc()); l->set_x(start-1);
l->y() = (word)y1; l->y() = (word)y1;
l->id() = -1; l->id() = -1;
l->width() = (int)(end + wlast - start + 1); l->width() = (int)(end + wlast - start + 2);
l->height() = (int)(y2 - y1 + 1); l->height() = (int)(y2 - y1 + 1);
l->set("@B@R"); l->set("@B@R");
l->temp() = TRUE; l->temp() = TRUE;
@ -3376,10 +3373,10 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, const int* rows)
for (i = 0; rows[i]; i++) for (i = 0; rows[i]; i++)
{ {
TForm_line* l = new TForm_line(grs); TForm_line* l = new TForm_line(grs);
l->set_x(start + body->ofspc()); l->set_x(start-1);
l->y() = (word)rows[i]; l->y() = (word)rows[i];
l->id() = -1; l->id() = -1;
l->width() = (int)(end + wlast - start + 1); l->width() = (int)(end + wlast - start + 2);
l->height() = 1; l->height() = 1;
l->set("@R"); l->set("@R");
l->temp() = TRUE; l->temp() = TRUE;
@ -3396,7 +3393,6 @@ bool TForm::genera_intestazioni(pagetype p, short y)
TPrint_section* header = exist('H', p); TPrint_section* header = exist('H', p);
if (header == NULL) return FALSE; if (header == NULL) return FALSE;
const int min_col_id = body->find_first_col();
body->reset_tabs(); body->reset_tabs();
const word items = body->fields(); const word items = body->fields();
for (word j=0;j<items;j++) for (word j=0;j<items;j++)
@ -3406,9 +3402,7 @@ bool TForm::genera_intestazioni(pagetype p, short y)
continue; continue;
TForm_string* s = new TForm_string(header); TForm_string* s = new TForm_string(header);
s->id() = -1; s->id() = -1;
int x = fi.x() + body->ofspc(); s->set_x(fi.x());
if (fi.id() == min_col_id) x++;
s->set_x(x);
s->y() = y; s->y() = y;
s->set_prompt(fi.col_head()); s->set_prompt(fi.col_head());
s->temp() = TRUE; s->temp() = TRUE;
@ -3417,77 +3411,6 @@ bool TForm::genera_intestazioni(pagetype p, short y)
return TRUE; return TRUE;
} }
void TForm::remove_temp_items(char sec, pagetype p)
{
TPrint_section* s = exist(sec,p);
if (s!=NULL)
{
const word items = s->fields();
for (word j=0;j<items; j++)
{
if (s->field(j).temp())
s->destroy_field(j,FALSE);
}
s->field_array().pack();
}
}
void TForm::put_examples(char sez, pagetype p)
{
TPrint_section* s = exist(sez,p);
if (s!=NULL)
{
const word items = s->fields();
for (word i=0;i<items;i++)
{
TForm_item& fi = s->field(i);
if (fi.fields()!=0) continue;
if (fi.memo())
fi.set(fi.memo_info());
else
if (fi.prompt().empty())
{
if (fi.class_name() == "DATA")
{
const TDate d(TODAY);
fi.set(d);
}
else
if (fi.class_name() == "NUMERO")
{
fi.set_prompt(fi.example());
fi.temp() = TRUE;
}
else
fi.set(fi.key());
}
}
}
}
void TForm::remove_examples(char sez, pagetype p)
{
TPrint_section* s = exist(sez,p);
if (s!=NULL)
{
const word items = s->fields();
for (word i=0;i<items;i++)
{
TForm_item& fi = s->field(i);
if (fi.fields()!=0) continue;
if (fi.memo())
fi.set("");
else
if (fi.class_name() == "NUMERO" && fi.temp())
{
fi.set_prompt("");
fi.temp() = FALSE;
}
}
}
}
// Stampa gli items dal from a to // Stampa gli items dal from a to
// se to < 0 stampa fino alla fine del file // se to < 0 stampa fino alla fine del file
@ -3797,7 +3720,6 @@ void TForm::init()
_isnew= FALSE; _isnew= FALSE;
_fontname= "Roman 17cpi"; _fontname= "Roman 17cpi";
_fontsize= 12; _fontsize= 12;
_section_mask = "ba2100s";
_x= 0; _x= 0;
_y= 0; _y= 0;
_char_to_pos= '\0'; _char_to_pos= '\0';

View File

@ -51,7 +51,6 @@ class TForm : public TObject
TString _name; // Profile name TString _name; // Profile name
TString _code; // Profile code TString _code; // Profile code
TString _fontname; // Font name TString _fontname; // Font name
TString _section_mask;// Maschera per la sezione
int _fontsize; // Font size int _fontsize; // Font size
int _x, _y; // Offset validi per tutte le sezioni int _x, _y; // Offset validi per tutte le sezioni
char _char_to_pos; // Carattere utilizzato per il posizionamento dei moduli char _char_to_pos; // Carattere utilizzato per il posizionamento dei moduli
@ -77,7 +76,6 @@ class TForm : public TObject
TString _desc; // form description TString _desc; // form description
char _fink[11]; // finkatur characters char _fink[11]; // finkatur characters
TPrint_section* exist(char s, pagetype t, bool create = FALSE); // Can be NULL
static void header_handler(TPrinter& p); static void header_handler(TPrinter& p);
static void footer_handler(TPrinter& p); static void footer_handler(TPrinter& p);
@ -91,6 +89,7 @@ class TForm : public TObject
bool ps_change_number_format(TPrint_section& s, int w, int dec, const char* p); bool ps_change_number_format(TPrint_section& s, int w, int dec, const char* p);
protected: protected:
TPrint_section* exist(char s, pagetype t, bool create = FALSE); // Can be NULL
void init(); // inizializza il form void init(); // inizializza il form
void read(const char* form, const char* code = "", int editlevel = 0, const char* desc = ""); // carica il form dal file specificato void read(const char* form, const char* code = "", int editlevel = 0, const char* desc = ""); // carica il form dal file specificato
@ -112,6 +111,9 @@ protected:
bool parse_general(TScanner&); bool parse_general(TScanner&);
void print_general(ostream& out) const; void print_general(ostream& out) const;
virtual void extended_parse_general(TScanner&) {} // Used to parse non-standard items in general section virtual void extended_parse_general(TScanner&) {} // Used to parse non-standard items in general section
// Queste due funzioni vengono chiamate per controlli non standard nell'edit della sezione
virtual void pre_edit_checks(TMask&m, TPrint_section* sec) {}
virtual bool post_edit_checks(TMask& m, TPrint_section* sec) {return FALSE;}
bool read_profile(); bool read_profile();
bool write_profile(); bool write_profile();
@ -136,9 +138,6 @@ public:
// Genera le righe di intestazione colonna alla riga indicata, vale per COLUMNWISE // Genera le righe di intestazione colonna alla riga indicata, vale per COLUMNWISE
// I form_items di intestazione vengono aggiunti alla sezione header di tipo p con ID -1 // I form_items di intestazione vengono aggiunti alla sezione header di tipo p con ID -1
bool genera_intestazioni(pagetype p, short y); bool genera_intestazioni(pagetype p, short y);
void remove_temp_items(char sec, pagetype p);
void put_examples(char sec, pagetype p);
void remove_examples(char sec, pagetype p);
bool print(long from = 0L, long to = -1L); bool print(long from = 0L, long to = -1L);
TArray& body() { return _body; } TArray& body() { return _body; }
@ -149,7 +148,7 @@ public:
const TString& name() const { return _name; } const TString& name() const { return _name; }
const TString& code() const { return _code; } const TString& code() const { return _code; }
TString& section_mask() { return _section_mask; } virtual const char* section_mask() { return "ba2100s"; }
bool edit_level() const { return _editlevel; } bool edit_level() const { return _editlevel; }
void set_edit_level(int n) { _editlevel = n; } void set_edit_level(int n) { _editlevel = n; }
void set_description(const char* s) { _desc = s; } void set_description(const char* s) { _desc = s; }
@ -225,7 +224,8 @@ class TPrint_section : public TArray
static TMask* _msk; static TMask* _msk;
word _height; // Altezza della sezione word _height; // Altezza della sezione
word _ofspc; // Offset prima colonna (still ignored) word _ofspc; // Offset prima colonna
word _ofsvr; // Offset verticale intestazione colonna
word _nfld; // number of columns if columnwise word _nfld; // number of columns if columnwise
bool _dirty; // Flag di modifica parametri bool _dirty; // Flag di modifica parametri
bool _columnwise; // Columnwise field specification bool _columnwise; // Columnwise field specification
@ -276,6 +276,7 @@ public:
word columns() { tab(0); return _nfld; } word columns() { tab(0); return _nfld; }
word height() const { return _height; } word height() const { return _height; }
word ofspc() const { return _ofspc; } word ofspc() const { return _ofspc; }
word ofsvr() const { return _ofsvr; }
void offset(int& x, int& y); void offset(int& x, int& y);
void set_repeat_count(int x) { _repeat_count = x; } void set_repeat_count(int x) { _repeat_count = x; }
@ -297,7 +298,6 @@ public:
bool columnwise() const { return _columnwise; } bool columnwise() const { return _columnwise; }
// ritorna l'offset della colonna corrispondente se columnwise // ritorna l'offset della colonna corrispondente se columnwise
int tab(int col); int tab(int col);
int find_first_col();
void reset_tabs(); void reset_tabs();
const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); } const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); }