Rif. mod. 95/42. Modifiche apportate a form.cpp parallelamente ai sorgenti

ba2100 e ba2500 per quanto riguarda gli editor dei profili per deleghe
ed editor dei profili per estratto conto.
Queste le modifiche richieste da Paolo per una migliore funzionalita':
  - cambiata intestazione dello sheet di selezione items del form.
  - cambiata la maschere ba2100f.uml per aggiungere la
	visualizzazione della lunghezza del foglio.
Queste le modifiche apportate per l'iniziale implementazione del form
editor per i profili di estratto conto:
  - aggiunto calcolo e controllo, in inserimento, della somma della
    lunghezze delle sezioni di uno stesso tipo di pagina
  - aggiunto un analogo controllo in TForm::print()
  - cambiato metodo TForm::section() per la selezione del paramtero "p"
	poiche' causava alcune incongruenze quando tenta di calcolare la
	lunghezza usata dal form.
  - cambiata  TForm::height(): aggiunto un controllo sull'esistenza
	della pagina e sezione
  - cambiato il tipo del membro _code da long a TString, poiche' e'
	cambiata il tipo del campo sul tracciato record


git-svn-id: svn://10.65.10.50/trunk@1965 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1995-10-16 17:52:24 +00:00
parent efb0bd7ab7
commit e63e7df847
2 changed files with 50 additions and 22 deletions

View File

@ -571,10 +571,9 @@ void TForm_item::print_on(TToken_string& row) const
{
row.cut(0);
row.add(id());
row.add(class_name());
row.add(key());
row.add(_y);
row.add(_x);
row.add(key());
if (form().edit_level() > 1)
{
@ -1078,7 +1077,7 @@ class TForm_number : public TForm_string
protected: // TForm_string
virtual const char* class_name() const { return "NUMERO"; }
virtual bool parse_head(TScanner& scanner);
virtual bool update();
virtual bool update();
virtual int height() const { return 0; }
protected:
@ -1653,6 +1652,14 @@ bool TPrint_section::edit(const char* title)
m.set(F_HEIGHT, _height);
m.set(F_X, form().offset_x());
m.set(F_Y, form().offset_y());
m.set(F_FLEN, printer().formlen());
// Calcola la sommatoria delle lunghezze delle varie sezioni di questa pagina...
int sum=form().height(_page_type);
if (_sec_type == 'G') sum = _height; // Se e' grafic section ho tutto il foglio a disposizione!
// ... devo pero' sottrarre la lunghezza della sezione corrente...
sum -= _height; //N.B. non e' mai negativo, perche' form().height() ritorna la lunghezza compresa la sezione corrente!!
// ... il risultato lo decurto dalla lunghezza del foglio ed ottengo la lunghezza disponibile.
m.set(F_FLENAV, printer().formlen() - sum);
{
const int MAX_FAMILIES = 128;
@ -1746,7 +1753,7 @@ bool TPrint_section::edit(const char* title)
const word flags = 0x08 | (form().edit_level() > 1 ? 0x06 : 0x00);
TString80 caption("ID@4|Tipo@8|Riga@R|Col.@R|Descrizione@40|Nascosto");
TString80 caption("ID@4|Descrizione@40|Riga@R|Col.@R|Non stampare");
if (form().edit_level() > 1) caption << "|Gr.@R|Campo@16";
TArray_sheet a(-1, -1, 0, 0, title, caption, flags);
@ -2136,10 +2143,13 @@ TForm_item& TForm::find_field(char s, pagetype t, short id) const
TPrint_section& TForm::section(char s, word p)
{
pagetype pos = odd_page;
if (p == 0 && exist(s, last_page)) pos = last_page;
if (p == 1 && exist(s, first_page)) pos = first_page;
if (pos == odd_page && (p & 0x1) == 0 && exist(s, even_page)) pos = even_page;
pagetype pos = odd_page;
// It was p==0
if (p == 3 && exist(s, last_page)) pos = last_page;
// It was p==1
if (p == 2 && exist(s, first_page)) pos = first_page;
// It was pos == odd_page && (p & 0x1) == 0
if (p == 1 && exist(s, even_page)) pos = even_page;
TPrint_section* sec = exist(s, pos, TRUE);
return *sec;
@ -2254,6 +2264,24 @@ bool TForm::print(long from, long to)
TPrinter& pr = printer(); // Setta handlers
pr.setheaderhandler(header_handler);
pr.setfooterhandler(footer_handler);
for (pagetype t = odd_page; t <= last_page; t = pagetype(t+1))
{
if (height(t)> (word)pr.formlen())
{
TString s("La lunghezza totale della sezione ");
switch ( t )
{
case odd_page: s << "standard"; break;
case even_page: s << "pagine pari"; break;
case first_page: s << "prima pagina"; break;
case last_page: s << "ultima pagina"; break;
default: break;
}
s << " eccede la lunghezza reale del foglio.";
message_box(s);
}
}
pr.formlen(height(odd_page));
pr.set_char_size(_fontsize); // Set font name and size
pr.set_fontname(_fontname); // according to current form
const bool was_open = pr.isopen();
@ -2356,18 +2384,18 @@ void TForm::print_on(ostream& out) const
}
word TForm::height()
word TForm::height(word page)
{
word h = 0;
if (_back.items() == 0)
{
if (_head.items())
h += section('H', 1).height();
if (_body.items())
h += section('B', 1).height();
if (_foot.items())
h += section('F', 1).height();
if (_head.items() && exist('H', pagetype(page)) != NULL)
h += section('H', page).height();
if (_body.items() && exist('B', pagetype(page)) != NULL)
h += section('B', page).height();
if (_foot.items() && exist('F', pagetype(page)) != NULL)
h += section('F', page).height();
}
else
h = printer().formlen();
@ -2489,14 +2517,14 @@ bool TForm::write_profile()
return TRUE;
}
TForm::TForm(const char* name, long code, int lev, const char* desc)
TForm::TForm(const char* name, const char* code, int lev, const char* desc)
: _name(name), _code(code), _relation(NULL), _cursor(NULL), _rel_desc(NULL),
_isnew(FALSE), _editlevel(lev), _desc(desc), _fontname("Courier New"),
_fontsize(12), _x(0), _y(0), _dirty(FALSE)
{
main_app().begin_wait();
if (_code > 0)
if (_code != "")
{
// extract base form name
TLocalisamfile forms(LF_FORM);
@ -2547,7 +2575,7 @@ TForm::TForm(const char* name, long code, int lev, const char* desc)
ok = ps->parse(scanner); // Parse section
}
if (_code > 0)
if (_code != "")
read_profile(); // read from LF_RFORM file
main_app().end_wait();

View File

@ -93,7 +93,7 @@ class TForm : public TObject
friend class TPrint_section;
TString16 _name; // Profile name
long _code; // Profile code
TString16 _code; // Profile code
TString80 _fontname; // Font name
int _fontsize; // Font size
int _x, _y; // Offset validi per tutte le sezioni
@ -123,7 +123,7 @@ class TForm : public TObject
protected:
// H = Header, B = Body, F = Footer, R = Relation
TPrint_section& section(char s = 'B', word page = 1);
word height(); // Height of first page
word height(word page = 1); // Height of first page
void print_section(ostream& out, char s) const;
virtual void print_on(ostream& out) const;
@ -153,7 +153,7 @@ public:
bool print(long from = 0L, long to = -1L);
const TString& name() const { return _name; }
long code() const { return _code; }
const TString& code() const { return _code; }
bool edit_level() const { return _editlevel; }
void set_description(const char* s) { _desc = s; }
@ -174,7 +174,7 @@ public:
// if code == NULL it's a base form
// otherwise it's integrated by a file definition
TForm(const char* form, long code = 0L, int editlevel = 0, const char* desc = "");
TForm(const char* form, const char * code = "", int editlevel = 0, const char* desc = "");
virtual ~TForm();
};