Inserito il salvataggio della fincatura per ogni form.

Ristrutturazione metodi TForm_item::x(), aggiunta metodi set_x(), get_column()
e set_column.


git-svn-id: svn://10.65.10.50/trunk@2397 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1996-01-05 18:39:12 +00:00
parent 79beff094f
commit 60617a3661
2 changed files with 69 additions and 28 deletions

View File

@ -14,6 +14,10 @@
#include <sheet.h>
#include <utility.h>
#ifndef __DEFMASK_H
#include <defmask.h>
#endif
#include "../ba/bafrm.h"
#include "../sc/sc21pec.h"
@ -744,9 +748,9 @@ bool TForm_item::update()
for (int i = prompt.len()-2; i >= 0; i--)
if (prompt[i] != '#') break;
prompt.cut(i+1);
string_at(_x, _y, prompt);
string_at(x(), _y, prompt);
}
else string_at(_x, _y, _prompt);
else string_at(x(), _y, _prompt);
return TRUE;
}
@ -772,7 +776,7 @@ 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, /*_section->columnwise() ? int_id - 101 : */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);
tt.add(class_name(), typ_id - 101);
@ -836,7 +840,7 @@ 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 = /*_section->columnwise() ? s.get(int_id - 101) : */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);
_ofs = s.get_int(spc_id - 101);
@ -872,8 +876,10 @@ bool TForm_item::edit(TMask& m)
m.enable_page(1, godmode);
m.enable(-7, godmode);
m.enable(F_ID, godmode);
m.enable(F_KEY,godmode);
m.enable(F_Y,!_section->columnwise());
m.enable(F_WIDTH,_section->columnwise());
m.enable(F_INTEST,_section->columnwise());
if (_flag.memo)
{
m.disable(F_PROMPT);
@ -910,7 +916,7 @@ void TForm_item::set_picture(const char*)
CHECK(0, "Can't set the picture of a generic form item!");
}
short TForm_item::x() const
short TForm_item::x()
{
if (_section == NULL || !_section->columnwise())
return _x;
@ -1281,7 +1287,7 @@ void TForm_string::put_paragraph(const char* s)
TParagraph_string p(s, width());
int i = _prompt.not_empty() ? 1 : 0;
for (; (s = p.get()) != NULL && i < height(); i++)
string_at(_x, _y+i, s);
string_at(x(), _y+i, s);
}
else
string_at(-1, _y, s);
@ -1757,7 +1763,7 @@ bool TForm_list::update()
{
const char* c = _values.get(pos);
if (c == NULL) c = val;
if (c) string_at(_x, _y, c);
if (c) string_at(x(), _y, c);
}
}
@ -2368,8 +2374,7 @@ bool TPrint_section::detail_field_notify (TSheet_field& s, int r, KEY k)
{
warning_box("Numero di colonna non accettabile (deve essere da 1 a %u)", sec.fields());
return FALSE;
}
}
// ??? type changed ???
if (strcmp(tt.get(typ_id - 101), fld->class_name()) != 0)
{
@ -2457,7 +2462,8 @@ bool TPrint_section::edit(const char* title)
if (_columnwise)
{
ms.delete_column(dsc_id); ms.sheet_mask().hide(dsc_id);
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(yps_id); ms.sheet_mask().hide(yps_id);
}
@ -2483,6 +2489,7 @@ bool TPrint_section::edit(const char* title)
// handlers
ms.set_notify(detail_field_notify);
ms.sheet_mask().set_handler(100, detail_field_handler);
if (_form->edit_level()<=1) ms.sheet_mask().disable(DLG_DELREC);
TToken_string tt(128);
@ -2518,8 +2525,33 @@ bool TPrint_section::edit(const char* title)
printer().set_char_size(form().fontsize());
m.set_handler(F_FONT,font_handler);
if (m.run() == K_ESC)
return FALSE;
if(_columnwise)
{
bool ok = FALSE;
while (m.run() != K_ESC)
{
TSheet_field& ms = (TSheet_field&)m.field(F_FIELDS);
const int items = ms.items();
for (int i=0; i<items && !ok; i++)
{
TToken_string& tt = ms.row(i);
if (tt.get_char(prn_id - 101)=='X')
continue;
else
if (tt.get_int(col_id-101) != 1)
{
error_box("La prima colonna stampabile deve essere numerata con 1");
break;
} else ok = TRUE;
}
if (i==items && !ok) error_box("Selezionare almeno una colonna stampabile.");
if (ok) break;
}
if (!ok) return FALSE;
}
else
if (m.run() == K_ESC)
return FALSE;
bool dirty = m.dirty() != 0;
@ -2614,7 +2646,7 @@ bool TPrint_section::edit(const char* title)
real x_pos;
x_pos = value * prm.ratio;
x_pos.round();
fi.x() = (short)x_pos.integer();
fi.set_x((short)x_pos.integer());
fi.set_dirty();
}
}
@ -3248,10 +3280,10 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, int* rows)
for (int i = 0; i < (int)body->fields(); i++)
{
const TForm_item& f = body->field(i);
TForm_item& f = body->field(i);
if (!f.shown()) continue;
const int x = f.x();
int x = f.x();
if (x < start) start = x;
if (x > end) { end = x; wlast = f.y(); }
@ -3264,7 +3296,7 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, int* rows)
if (cols[i] != start && cols[i] > 0)
{
TForm_line* l = new TForm_line(grs);
l->x() = cols[i]-1 + body->ofspc();
l->set_x(cols[i]-1 + body->ofspc());
l->y() = (word)y1;
l->id() = -1;
l->width() = 1;
@ -3279,7 +3311,7 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, int* rows)
if (start != 999 && end != 0)
{
TForm_box* l = new TForm_box(grs);
l->x() = start + body->ofspc();
l->set_x(start + body->ofspc());
l->y() = (word)y1;
l->id() = -1;
l->width() = (int)(end + wlast - start + 1);
@ -3294,7 +3326,7 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, int* rows)
for (i = 0; rows[i]; i++)
{
TForm_line* l = new TForm_line(grs);
l->x() = start + body->ofspc();
l->set_x(start + body->ofspc());
l->y() = (word)rows[i];
l->id() = -1;
l->width() = (int)(end + wlast - start + 1);
@ -3320,16 +3352,16 @@ bool TForm::genera_intestazioni(pagetype p, short y)
bool firstcolumn = TRUE;
for (word j=0;j<items;j++)
{// Scans all body items to print, and append header items...
const TForm_item& fi = body->field(j);
TForm_item& fi = body->field(j);
if (!fi.shown())
continue;
TForm_string* s = new TForm_string(header);
const int x = fi.x() + body->ofspc();
int x = fi.x() + body->ofspc();
s->id() = -1;
s->x() = x;
s->set_x(x);
if (firstcolumn)
{
s->x() += 1;
s->set_x(x+1);
firstcolumn=FALSE;
}
s->y() = y;
@ -3636,6 +3668,7 @@ bool TForm::read_profile()
_ipx = prof.get_int("IPX");
_ipy = prof.get_int("IPY");
_fpx = prof.get_int("FPX");
set_fincatura(prof.get("GRID"));
}
}
return TRUE;
@ -3661,6 +3694,9 @@ bool TForm::write_profile()
form.put("IPX", _ipx);
form.put("IPY", _ipy);
form.put("FPX", _fpx);
TString16 fk(_fink);
fk.cut(11);
form.put("GRID", fk);
form.rewrite();
_dirty=FALSE;
}
@ -3728,9 +3764,9 @@ void TForm::init()
_ipy= 0;
_fpx= 0;
_arrange= TRUE;
set_fincatura(printer().get_fincatura());
set_fincatura("+++++++++-|");
_dirty= FALSE;
_background_mode = printer().isgraphics() ? graphics : texto;
_background_mode = printer().isgraphics() ? graphics : testo;
}
void TForm::read(const char* name, const char* code, int lev, const char* desc)
@ -3765,6 +3801,9 @@ void TForm::read(const char* name, const char* code, int lev, const char* desc)
forms.put("IPX", _ipx);
forms.put("IPY", _ipy);
forms.put("FPX", _fpx);
TString16 fk(_fink);
fk.cut(11);
forms.put("GRID",fk);
forms.write();
}
else _desc = forms.get("DESC");

View File

@ -29,7 +29,7 @@ class TCursor;
#endif
enum pagetype { odd_page, even_page, first_page, last_page };
enum bkg_mode { none, texto, graphics } ;
enum bkg_mode { none, testo, graphics } ;
pagetype char2page(char); // prototipo della funzione che converte dalla notazione carattere al corrispondente enum pagetype
class TForm;
@ -350,11 +350,13 @@ public:
virtual bool& temp() { return _temp; };
virtual bool temp() const { return _temp; };
virtual short& x() { return _x; };
virtual short x() const;
// virtual short& x() { return _x; };
virtual void set_x(short x) {_x=x;}
virtual short x();
virtual short& y() { return _y; }
virtual short y() const { return _y; }
virtual short get_column() { CHECK(_section->columnwise(),"La sezione non e' COLUMNWISE"); return _x; }
virtual void set_column(short c) { CHECK(_section->columnwise(),"La sezione non e' COLUMNWISE"); _x = c;}
virtual const int fields() { return 0;}
bool shown() const { return _flag.shown; }