Modifiche sottosezioni con file collegato e menu ingresso

git-svn-id: svn://10.65.10.50/trunk@1454 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1995-06-07 10:47:05 +00:00
parent e8a228d9f9
commit 4e664d14c0
2 changed files with 153 additions and 66 deletions

@ -93,6 +93,24 @@ HIDDEN bool but_file_handler(TMask_field& f, KEY k)
return TRUE;
}
HIDDEN bool but_file_handler_sub(TMask_field& f, KEY k)
{
if (k == K_SPACE)
{
TRelation_description& r = form().rel_desc();
TEdit_field& e = f.mask().efield(f.dlg()-2);
TFieldref ref; ref = e.get();
if (r.choose_file(ref.file()))
{
ref.set_file(r.file_num());
f.mask().set(F_FILE1,r.file_desc());
}
}
return TRUE;
}
// Handler of F_BUT_FIELD field on mask
HIDDEN bool but_field_handler(TMask_field& f, KEY k)
{
@ -716,19 +734,18 @@ bool TForm_item::edit(TMask& m)
class TForm_subsection : public TForm_item
{
TPrint_section _ssec;
TPrint_section _ssec;
TString _name;
int _file_id; // ID del file su cui iterare in stampa se previsto
protected:
virtual void print_on(ostream& out) const;
public:
virtual int width() const;
virtual int height() const;
virtual bool parse(TScanner& s) { name(s.pop()); return _ssec.parse(s); }
virtual bool update() { return _ssec.update(); }
virtual bool parse(TScanner& s);
virtual bool update();
virtual bool edit(TMask& m);
virtual const char* class_name() const { return "SEZIONE"; }
@ -749,15 +766,69 @@ public:
TForm_subsection::TForm_subsection(TPrint_section* s, const char* nm) :
TForm_item(s), _ssec(&(s->form()), s->page_type()), _name(nm)
TForm_item(s), _ssec(&(s->form()), s->page_type(), TRUE), _file_id(-1), _name(nm)
{}
bool TForm_subsection::parse(TScanner& s)
{
name(s.pop());
_width = s.integer();
_height = s.integer();
_x = s.integer();
_y = s.integer();
if (s.popkey() == "FI") // FILE su cui iterare con next_match
_file_id = s.integer(); // TBI controllo alias
else s.push();
return _ssec.parse(s);
}
bool TForm_subsection::update()
{
bool ok = FALSE;
TRelation* rel = form().relation();
if (rel == NULL || _file_id == -1)
ok = _ssec.update();
else
{
int i = 0;
if (rel->is_first_match(_file_id))
do {
if (!(ok = _ssec.update()))
break;
_ssec.set_repeat_count(++i);
}
while (rel->next_match(_file_id));
_ssec.set_repeat_count(0);
}
return ok;
}
bool TForm_subsection::edit(TMask& m)
{
// mask con nome e bottone edit contents / annulla
TMask mu("ba2100u");
mu.set(F_CAPTION, _name);
mu.set(F_WIDTH, _width);
mu.set(F_HEIGHT, _height);
mu.set(F_X, _x);
mu.set(F_Y, _y);
mu.set_handler(F_BUT_FILE1, but_file_handler_sub);
if (_file_id != -1)
{
// set file description
form().rel_desc().set_cur_file(_file_id);
TString80 desc; desc << form().rel_desc().file_desc();
mu.set(F_FILE1, desc);
}
KEY k;
@ -769,14 +840,35 @@ bool TForm_subsection::edit(TMask& m)
if (mu.field(F_CAPTION).dirty())
_name = mu.get(F_CAPTION);
if (mu.field(F_WIDTH).dirty())
_width = mu.get_int(F_WIDTH);
if (mu.field(F_HEIGHT).dirty())
_height = mu.get_int(F_HEIGHT);
if (mu.field(F_X).dirty())
_x = mu.get_int(F_X);
if (mu.field(F_Y).dirty())
_y = mu.get_int(F_Y);
if (mu.field(F_FILE1).dirty())
{
if (mu.get(F_FILE1).empty())
_file_id = -1;
else
_file_id = form().rel_desc().file_num();
}
if (k == K_INS)
_ssec.edit(_name); // TBI god mode only if...
else if (k == K_DEL)
{
// remove myself
}
else if (k == K_ENTER)
break;
_ssec.edit(_name);
else if (k == K_DEL)
{
// remove myself
}
else if (k == K_ENTER)
break;
}
return k != K_ESC;
@ -785,30 +877,16 @@ bool TForm_subsection::edit(TMask& m)
void TForm_subsection::print_on(ostream& out) const
{
out << "SEZIONE " << _name << "\n";
out << "SEZIONE " << _name << ' ' << _width << ' ' << _height
<< ' ' << _x << ' ' << _y;
if (_file_id != -1)
out << " FILE " << _file_id;
out << "\n";
for (word i = 0; i < _ssec.fields(); i++)
out << _ssec.field(i);
out << "END" << "\n";
}
// ???
int TForm_subsection::width() const
{
int w = 0;
for (word i = 0; i < _ssec.fields(); i++)
if (_ssec.field(i).width() > w)
w = _ssec.field(i).width();
return w;
}
// ???
int TForm_subsection::height() const
{
int h = 0;
for (word i = 0; i < _ssec.fields(); i++)
h += _ssec.field(i).height();
return h;
out << "\nEND" << "\n";
}
// ???
@ -1342,8 +1420,9 @@ public:
TMask* TPrint_section::_msk = NULL;
TPrint_section::TPrint_section(TForm* f, pagetype pt)
: _height(0), _x(0), _y(0), _form(f), _page_type(pt), _dirty(FALSE)
TPrint_section::TPrint_section(TForm* f, pagetype pt, bool sub)
: _height(0), _x(0), _y(0), _form(f), _page_type(pt), _dirty(FALSE),
_subsection(sub), _repeat_count(0)
{}
TPrint_section::~TPrint_section()
@ -1376,9 +1455,9 @@ TPrintrow& TPrint_section::row(int num)
}
void TPrint_section::offset(int& x, int& y) const
{
{
if (x >= 0) x += _x;
if (y >= 0) y += _y;
if (y >= 0) y += _y + (_height * _repeat_count);
}
@ -1490,23 +1569,26 @@ bool TPrint_section::edit(const char* title)
{
_cur_form = _form;
TMask m("ba2100s");
m.set_caption(title);
m.set(F_HEIGHT, _height);
m.set(F_X, _x);
m.set(F_Y, _y);
if (m.run() == K_ESC)
return FALSE;
bool dirty = m.dirty() != 0;
if (dirty)
if (!_subsection)
{
_height = m.get_int(F_HEIGHT);
_x = m.get_int(F_X);
_y = m.get_int(F_Y);
TMask m("ba2100s");
m.set_caption(title);
m.set(F_HEIGHT, _height);
m.set(F_X, _x);
m.set(F_Y, _y);
if (m.run() == K_ESC)
return FALSE;
bool dirty = m.dirty() != 0;
if (dirty)
{
_height = m.get_int(F_HEIGHT);
_x = m.get_int(F_X);
_y = m.get_int(F_Y);
}
}
const word flags = 0x08 | (form().edit_level() > 1 ? 0x06 : 0x00);
@ -1553,7 +1635,7 @@ bool TPrint_section::edit(const char* title)
if (field(i).edit(*_msk))
{
field(i).print_on(a.row(i));
dirty = TRUE;
_dirty = TRUE;
}
break;
case K_CTRL + 'N':
@ -1570,7 +1652,7 @@ bool TPrint_section::edit(const char* title)
TToken_string s(128); item->print_on(s);
a.insert(s, i);
dirty = TRUE;
_dirty = TRUE;
}
}
break;
@ -1579,7 +1661,7 @@ bool TPrint_section::edit(const char* title)
{
_item.destroy(i, TRUE);
a.destroy(i);
dirty = TRUE;
_dirty = TRUE;
}
break;
default:
@ -1587,8 +1669,8 @@ bool TPrint_section::edit(const char* title)
}
}
set_dirty(dirty);
return dirty;
set_dirty(_dirty);
return _dirty;
}
void TPrint_section::print_on(ostream& out) const
@ -2179,9 +2261,9 @@ bool TForm::write_profile()
return TRUE;
}
TForm::TForm(const char* name, long code, int lev)
TForm::TForm(const char* name, long code, int lev, const char* desc)
: _name(name), _code(code), _relation(NULL), _cursor(NULL), _rel_desc(NULL),
_isnew(FALSE), _editlevel(lev)
_isnew(FALSE), _editlevel(lev), _desc(desc)
{
main_app().begin_wait();
@ -2199,7 +2281,7 @@ TForm::TForm(const char* name, long code, int lev)
// create new form
forms.put("TIPOPROF", _name);
forms.put("CODPROF", _code);
forms.put("DESC", _name);
forms.put("DESC", _desc);
forms.write();
}
else _desc = forms.get("DESC");

@ -44,8 +44,10 @@ class TPrint_section : public TArray
TForm* _form; // Form cui appartiene alla sezione
pagetype _page_type; // Tipo della pagina
bool _subsection; // e' una sottosezione
TArray _item; // Lista dei campi da stampare
int _repeat_count; // n. ripetizioni eseguite
const TPrint_section& copy(const TPrint_section& ps);
@ -66,6 +68,7 @@ public:
int offset_x() const { return _x; }
int offset_y() const { return _y; }
void offset(int& x, int& y) const;
void set_repeat_count(int x) { _repeat_count = x; }
virtual bool ok() const { return height() > 0 || fields() > 0; }
@ -83,7 +86,7 @@ public:
void set_dirty(bool d = TRUE) { _dirty = d; }
const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); }
TPrint_section(TForm* parent, pagetype pt);
TPrint_section(TForm* parent, pagetype pt, bool subsection = FALSE);
TPrint_section(const TPrint_section& ps) { copy(ps); }
virtual ~TPrint_section();
};
@ -149,6 +152,7 @@ public:
long code() const { return _code; }
bool edit_level() const { return _editlevel; }
void set_description(const char* s) { _desc = s; }
TRelation* relation() const { return _relation; }
TRelation_description& rel_desc() const;
@ -160,7 +164,8 @@ 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);
TForm(const char* form, long code = 0L, int editlevel = 0,
const char* desc = "");
virtual ~TForm();
};