Aggiunto metodo TPrint_section::find_first_col() che ritorna l'id della
prima colonna stampabile. Aggiunto TForm_item::_col_head, per memorizzare le intestazioni di sezioni COLUNWISE. Modificata la gestione delle intestazioni e delle larghezze colonna in sezioni COLUMNWISE (metodi genera_intestazioni(), tab() e altri). git-svn-id: svn://10.65.10.50/trunk@2412 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
95e5651d04
commit
96ef959b91
105
include/form.cpp
105
include/form.cpp
@ -24,12 +24,12 @@
|
||||
// per lo sheet di edit campi
|
||||
HIDDEN const int idt_id = 101;
|
||||
HIDDEN const int dsc_id = 102;
|
||||
HIDDEN const int int_id = 103;
|
||||
HIDDEN const int prn_id = 104;
|
||||
HIDDEN const int yps_id = 105;
|
||||
HIDDEN const int len_id = 106;
|
||||
HIDDEN const int xps_id = 107;
|
||||
HIDDEN const int col_id = 108;
|
||||
HIDDEN const int prn_id = 103;
|
||||
HIDDEN const int yps_id = 104;
|
||||
HIDDEN const int len_id = 105;
|
||||
HIDDEN const int xps_id = 106;
|
||||
HIDDEN const int col_id = 107;
|
||||
HIDDEN const int int_id = 108;
|
||||
HIDDEN const int spc_id = 109;
|
||||
HIDDEN const int fnl_id = 110;
|
||||
HIDDEN const int fnr_id = 111;
|
||||
@ -526,9 +526,10 @@ bool TForm_item::read_from(const TRectype& prof)
|
||||
if (i == special.items()-1)
|
||||
{
|
||||
TToken_string fink(special.get(i));
|
||||
_ofs = fink.get_int(0);
|
||||
_flag.finkl = fink.get_char(1) == 'X';
|
||||
_flag.finkr = fink.get_char(2) == 'X';
|
||||
_col_head = fink.get(0);
|
||||
_ofs = fink.get_int(1);
|
||||
_flag.finkl = fink.get_char(2) == 'X';
|
||||
_flag.finkr = fink.get_char(3) == 'X';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -585,7 +586,8 @@ void TForm_item::print_on(TRectype& prof)
|
||||
special.add(sp);
|
||||
}
|
||||
}
|
||||
TString fink(8);
|
||||
TString fink;
|
||||
fink << _col_head << "|";
|
||||
fink << _ofs << "|"; fink << (_flag.finkl ? "X" : " ") <<"|";
|
||||
fink << (_flag.finkr ? "X" : " ");
|
||||
special.add(fink);
|
||||
@ -603,7 +605,7 @@ void TForm_item::string_at(int x, int y, const char* s)
|
||||
{
|
||||
if (shown())
|
||||
{
|
||||
if (section().columnwise()) x += _ofs;
|
||||
if (section().columnwise()) x += _ofs + _section->ofspc();
|
||||
TPrintrow& row = section().row(y-1); // Seleziona riga di stampa
|
||||
|
||||
if (_width > 0 && strlen(s) > (word)_width) // Tronca testo se necessario
|
||||
@ -772,9 +774,12 @@ void TForm_item::print_on_sheet_row(TToken_string& tt) const
|
||||
{
|
||||
TString tmp(80);
|
||||
tt.add(_id, idt_id - 101);
|
||||
tt.add(_desc, /*_section->columnwise() ? int_id - 101 : */dsc_id - 101);
|
||||
tt.add(_desc, dsc_id - 101);
|
||||
tt.add(_x, _section->columnwise() ? col_id - 101 : xps_id - 101);
|
||||
tt.add(_y, _section->columnwise() ? len_id - 101 : yps_id - 101);
|
||||
if (_section->columnwise())
|
||||
tt.add(_width, len_id - 101);
|
||||
else
|
||||
tt.add(_y, yps_id - 101);
|
||||
tt.add(class_name(), typ_id - 101);
|
||||
tt.add(shown() ? " " : "X", prn_id - 101);
|
||||
tmp = example(); tt.add(tmp, frm_id - 101);
|
||||
@ -784,6 +789,7 @@ void TForm_item::print_on_sheet_row(TToken_string& tt) const
|
||||
tt.add(_ofs, spc_id -101);
|
||||
tt.add(finkl() ? " " : "X", fnl_id -101);
|
||||
tt.add(finkr() ? " " : "X", fnr_id -101);
|
||||
tt.add(_col_head, int_id - 101);
|
||||
}
|
||||
}
|
||||
|
||||
@ -793,13 +799,11 @@ void TForm_item::print_on(TMask& m)
|
||||
m.set(F_ID, id());
|
||||
m.set(F_KEY, key());
|
||||
m.set(F_X, _x);
|
||||
if (!_section->columnwise())
|
||||
m.set(F_Y, _y);
|
||||
m.set(F_Y, _y);
|
||||
m.set(F_PROMPT, _prompt);
|
||||
m.set(F_WIDTH, _width);
|
||||
if (_section->columnwise())
|
||||
m.set(F_WIDTH, _y);
|
||||
else
|
||||
m.set(F_WIDTH, _width);
|
||||
m.set(F_INTEST, _col_head);
|
||||
m.set(F_HEIGHT, _height);
|
||||
m.set(F_SPACES, _ofs);
|
||||
|
||||
@ -813,13 +817,11 @@ void TForm_item::read_from(const TMask& m)
|
||||
{
|
||||
_desc = m.get(F_KEY);
|
||||
_x = atoi(m.get(F_X));
|
||||
if (!_section->columnwise())
|
||||
_y = atoi(m.get(F_Y));
|
||||
_y = atoi(m.get(F_Y));
|
||||
_prompt = m.get(F_PROMPT);
|
||||
_width = atoi(m.get(F_WIDTH));
|
||||
if (_section->columnwise())
|
||||
_y = atoi(m.get(F_WIDTH));
|
||||
else
|
||||
_width = atoi(m.get(F_WIDTH));
|
||||
_col_head = m.get(F_INTEST);
|
||||
_height = atoi(m.get(F_HEIGHT));
|
||||
_id = atoi(m.get(F_ID));
|
||||
_ofs = atoi(m.get(F_SPACES));
|
||||
@ -834,9 +836,12 @@ void TForm_item::read_from(const TMask& m)
|
||||
void TForm_item::read_from(TToken_string& s)
|
||||
{
|
||||
_id = s.get_int(idt_id - 101);
|
||||
_desc = /*_section->columnwise() ? s.get(int_id - 101) : */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);
|
||||
_y = _section->columnwise() ? s.get_int(len_id - 101) : s.get_int(yps_id - 101);
|
||||
if (_section->columnwise())
|
||||
_width = s.get_int(len_id - 101);
|
||||
else
|
||||
_y = s.get_int(yps_id - 101);
|
||||
_ofs = s.get_int(spc_id - 101);
|
||||
_flag.set_shown(s.get(prn_id - 101)[0] != 'X');
|
||||
|
||||
@ -844,6 +849,7 @@ void TForm_item::read_from(TToken_string& s)
|
||||
{
|
||||
_flag.set_finkl(s.get(fnl_id - 101)[0] != 'X');
|
||||
_flag.set_finkr(s.get(fnr_id - 101)[0] != 'X');
|
||||
_col_head = s.get(int_id - 101);
|
||||
}
|
||||
set_dirty();
|
||||
}
|
||||
@ -1165,7 +1171,7 @@ bool TForm_string::parse_item(TScanner& scanner)
|
||||
|
||||
if (scanner.key() == "PI")
|
||||
{
|
||||
_picture = scanner.string();
|
||||
set_picture(scanner.string());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1415,6 +1421,7 @@ public:
|
||||
|
||||
void set_decimals(int d) { _height = d; }
|
||||
virtual const char* example() const;
|
||||
virtual void set_picture(const char* p);
|
||||
|
||||
TForm_number(TPrint_section* section) : TForm_string(section) {}
|
||||
virtual ~TForm_number() {}
|
||||
@ -1423,10 +1430,7 @@ public:
|
||||
|
||||
bool TForm_number::parse_head(TScanner& scanner)
|
||||
{
|
||||
TForm_item::parse_head(scanner);
|
||||
_height = _width; // Decimals
|
||||
_width = 0;
|
||||
return TRUE;
|
||||
return TForm_item::parse_head(scanner);
|
||||
}
|
||||
|
||||
|
||||
@ -1507,6 +1511,13 @@ void TForm_number::apply_format(real& n , TString& s) const
|
||||
else s = n.string();
|
||||
}
|
||||
|
||||
void TForm_number::set_picture(const char *p)
|
||||
{
|
||||
TForm_string::set_picture(p);
|
||||
const int comma = picture().find(',');
|
||||
if (comma > 0) set_decimals(picture().len() - comma -1);
|
||||
}
|
||||
|
||||
const char* TForm_number::example() const
|
||||
{
|
||||
real n("123456789120.00"); n.round(2);
|
||||
@ -2054,7 +2065,7 @@ int TPrint_section::tab(int col)
|
||||
if (field(i).shown())
|
||||
{
|
||||
CHECKD (field(i)._x < MAXCOLUMNS, "Colonna ammessa e non concessa: ", field(i)._x);
|
||||
_tab[field(i)._x] = field(i)._y + 1; // one is for separation
|
||||
_tab[field(i)._x] = field(i)._width + 1; // one is for separation
|
||||
if (field(i)._x > maxcolreached) maxcolreached = field(i)._x;
|
||||
_nfld++;
|
||||
}
|
||||
@ -2077,6 +2088,23 @@ int TPrint_section::tab(int col)
|
||||
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)
|
||||
{
|
||||
if (x >= 0)
|
||||
@ -3308,7 +3336,7 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, const int* rows)
|
||||
int x = f.x();
|
||||
|
||||
if (x < start) start = x;
|
||||
if (x > end) { end = x; wlast = f.y(); }
|
||||
if (x > end) { end = x; wlast = f.width(); }
|
||||
cols[j++] = f.finkl() ? -x : x;
|
||||
}
|
||||
|
||||
@ -3368,26 +3396,21 @@ bool TForm::genera_intestazioni(pagetype p, short y)
|
||||
|
||||
TPrint_section* header = exist('H', p);
|
||||
if (header == NULL) return FALSE;
|
||||
|
||||
const int min_col_id = body->find_first_col();
|
||||
body->reset_tabs();
|
||||
const word items = body->fields();
|
||||
bool firstcolumn = TRUE;
|
||||
for (word j=0;j<items;j++)
|
||||
{// Scans all body items to print, and append header items...
|
||||
TForm_item& fi = body->field(j);
|
||||
if (!fi.shown())
|
||||
continue;
|
||||
TForm_string* s = new TForm_string(header);
|
||||
int x = fi.x() + body->ofspc();
|
||||
s->id() = -1;
|
||||
int x = fi.x() + body->ofspc();
|
||||
if (fi.id() == min_col_id) x++;
|
||||
s->set_x(x);
|
||||
if (firstcolumn)
|
||||
{
|
||||
s->set_x(x+1);
|
||||
firstcolumn=FALSE;
|
||||
}
|
||||
s->y() = y;
|
||||
s->set_prompt(fi.key());
|
||||
s->set_prompt(fi.col_head());
|
||||
s->temp() = TRUE;
|
||||
header->add_field(s);
|
||||
}
|
||||
|
@ -297,6 +297,7 @@ public:
|
||||
bool columnwise() const { return _columnwise; }
|
||||
// ritorna l'offset della colonna corrispondente se columnwise
|
||||
int tab(int col);
|
||||
int find_first_col();
|
||||
void reset_tabs();
|
||||
|
||||
const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); }
|
||||
@ -318,7 +319,7 @@ protected:
|
||||
|
||||
short _id, _x, _y, _width, _height, _effective_height, _ofs;
|
||||
TString _prompt;
|
||||
TString _desc;
|
||||
TString _desc, _col_head;
|
||||
TString_array _message;
|
||||
|
||||
virtual void print_on(ostream& out) const;
|
||||
@ -386,7 +387,9 @@ public:
|
||||
|
||||
// example() ritorna un esempio del formato corrente
|
||||
virtual const char* example() const { return ""; }
|
||||
|
||||
|
||||
const TString& col_head() const {CHECK(_section->columnwise(),"La sezione non e' COLUMNWISE"); return _col_head;}
|
||||
void set_col_head(const char* s) {CHECK(_section->columnwise(),"La sezione non e' COLUMNWISE"); _col_head = s;}
|
||||
const TString& prompt() const { return _prompt; }
|
||||
void set_prompt(const char* s) { _prompt = s; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user