controls.cpp Aggiustata altezza text e group controls

mask.cpp       Corretta autosave in modo che salvi "in avanti"
maskfld.*      Aggiunte alcune is_kind_of
msksheet.cpp   Corretta force_update


git-svn-id: svn://10.65.10.50/trunk@2824 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-05-15 10:26:42 +00:00
parent b619a73636
commit fbc771205a
5 changed files with 63 additions and 36 deletions

View File

@ -802,13 +802,12 @@ TText_control::TText_control(WINDOW win, short cid,
COLOR color;
TString t = parse_caption(text, bold, color);
t.rtrim();
if (width <= 0)
{
if (width <= 0)
width = t.len();
if (bold)
width = 4 * width / 3;
}
XI_RCT rct; coord2rct(win, left, top, width, height, rct); rct.right += XI_FU_MULTIPLE / 2;
XI_RCT rct; coord2rct(win, left, top, width, height, rct);
rct.right += bold ? (width*XI_FU_MULTIPLE/4) : XI_FU_MULTIPLE/2;
const unsigned long attrib = flags2attr(flags);
XI_OBJ_DEF* def = xi_add_text_def(NULL, cid, &rct, attrib, (char*)(const char*)t);
CHECKS(def, "Can't create the definition of TText_control:", text);
@ -817,7 +816,11 @@ TText_control::TText_control(WINDOW win, short cid,
def->v.text->font_id = xvt_default_font(TRUE);
_obj = xi_create(get_interface(win), def);
CHECKS(_obj, "Can't create TText_control ", text);
// Alza di un pixel il rettangolo per allinearlo meglio agli edit field
RCT& tr = _obj->v.text->rct;
tr.top--; tr.bottom--;
xi_dequeue();
xi_tree_free(def);
}
@ -850,12 +853,21 @@ TGroupbox_control::TGroupbox_control(WINDOW win, short cid,
def->v.rect->hilight_color = MASK_LIGHT_COLOR;
def->v.rect->back_color = MASK_BACK_COLOR;
def->v.rect->shadow_color = MASK_DARK_COLOR;
def->v.rect->well = strchr(flags, 'R') ? FALSE : TRUE;
const bool erre = strchr(flags, 'R') != NULL;
if (erre)
{
def->v.rect->well = TRUE; // Mette in rilievo il rettangolo
change_attrib(XI_ATR_RJUST, FALSE, _obj); // Toglie l'erroneo allineamento a destra del titolo
}
_rct = xi_create(get_interface(win), def);
CHECKD(_rct, "Can't create Groupbox_control ", cid);
RCT& rt = _obj->v.text->rct;
rt.top--; rt.bottom--;
xi_dequeue();
xi_tree_free(def);
xi_tree_free(def);
}
void TGroupbox_control::show(bool on)
@ -1184,7 +1196,7 @@ void TPushbutton_control::update()
{
PNT p; p.v = y; p.h = px;
xvt_dwin_draw_set_pos(w, p);
p.h += i.height();
p.v += i.height();
xvt_dwin_draw_line(w, p);
}
}
@ -1235,13 +1247,13 @@ TRadiobutton_control::TRadiobutton_control(WINDOW win, short cid,
XI_RCT rct; coord2rct(win, left, top, width, height, rct);
// Aggiusta rettangolo in modo da centrare i bottoni
const int extra = (rct.bottom - rct.top - tot * XI_FU_MULTIPLE) / 2;
const int extra = rct.bottom - rct.top - tot * XI_FU_MULTIPLE;
if (extra > 0)
{
rct.top += extra;
rct.bottom -= extra;
}
rct.top += extra / 2;
else
if (extra < 0)
rct.bottom -= extra;
XI_OBJ_DEF* def = xi_add_container_def(NULL, cid, &rct, orient, cid);
def->app_data = (long)this;

View File

@ -99,8 +99,8 @@ void TMask::read_mask(
CHECKD(_pages < MAX_PAGES, "Maschera con troppe pagine: ", _pages);
WINDOW w = read_page(scanner, FALSE);
char* title = &__tmp_string[512];
xvt_vobj_get_title(w, title, 80);
TString title(80);
xvt_vobj_get_title(w, (char*)(const char*)title, title.size());
captions.add(title);
_pagewin[_pages++] = w;
@ -698,20 +698,20 @@ WINDOW TMask::read_page(
}
bool orecchie = _pagewin[0] != NULL_WIN || toolwin();
if (!orecchie && !toolbar)
if (!orecchie && !toolbar) // Controlla se la maschera ha piu' di una pagina
{
const streampos pos = scanner.tellg();
const TString& l = scanner.line();
const streampos pos = scanner.tellg(); // Memorizza posizione dello scanner
TString l(scanner.line().left(2));
while (l != "EN" && l.not_empty())
{
if (l == "PA")
if (l == "PA") // Ho trovato un'altra pagina!
{
orecchie = TRUE;
orecchie = TRUE; // Quindi devo metterci le orecchie
break;
}
scanner.line();
l = scanner.line().left(2);
}
scanner.seekg(pos);
scanner.seekg(pos); // Ripristin aposizione dello scanner
}
WINDOW w;
@ -900,13 +900,13 @@ void TMask::set(short fld_id, long n, bool hit)
void TMask::set(short fld_id, const real& n, bool hit)
{
CHECK(field(fld_id).class_id() == CLASS_REAL_FIELD, "Can't set a real value in a non-number field");
CHECK(field(fld_id).is_kind_of(CLASS_REAL_FIELD), "Can't set a real value in a non-number field");
set(fld_id, n.string(), hit);
}
void TMask::set(short fld_id, const TDate& d, bool hit)
{
CHECK(field(fld_id).class_id() == CLASS_DATE_FIELD, "Can't set a date in a non-date field");
CHECK(field(fld_id).is_kind_of(CLASS_DATE_FIELD), "Can't set a date in a non-date field");
set(fld_id, d.string(), hit);
}
@ -944,7 +944,8 @@ void TMask::enable(
f.enable(on);
}
}
else field(fld_id).enable(on);
else
field(fld_id).enable(on);
}
@ -1101,7 +1102,8 @@ void TMask::show_default(
void TMask::autoload(const TRelation& r)
{
for (int i = fields()-1; i >= 0; i--)
const int max = fields();
for (int i = 0; i < max; i++)
{
TMask_field& f = fld(i);
if (f.is_editable())
@ -1111,8 +1113,9 @@ void TMask::autoload(const TRelation& r)
void TMask::autosave(TRelation& r) const
{
for (int i = fields()-1; i >= 0; i--)
{
const int max = fields();
for (int i = 0; i < max; i++)
{
TMask_field& f = fld(i);
if (f.is_editable())
@ -1609,7 +1612,6 @@ void TMask::copy_values(
}
}
const char* TMask::get_caption() const
{
char* title = &__tmp_string[512];

View File

@ -2922,6 +2922,10 @@ TDate_field::TDate_field(TMask* m) : TEdit_field(m)
word TDate_field::class_id() const
{ return CLASS_DATE_FIELD; }
// Certified 100%
bool TDate_field::is_kind_of(word cid) const
{ return cid == CLASS_DATE_FIELD || TEdit_field::is_kind_of(cid); }
void TDate_field::create(WINDOW w)
{
// Elimina il flag R che si interpreta come salva in formato ANSI
@ -3083,6 +3087,10 @@ TReal_field::TReal_field(TMask* m) : TEdit_field(m)
word TReal_field::class_id() const
{ return CLASS_REAL_FIELD; }
// Certified 100%
bool TReal_field::is_kind_of(word cid) const
{ return cid == CLASS_REAL_FIELD || TEdit_field::is_kind_of(cid); }
void TReal_field::create(WINDOW w)
{
_ctl_data._flags.strip("AFM");

View File

@ -1016,6 +1016,9 @@ class TReal_field : public TEdit_field
protected: // TMask_field
// @cmember Ritorna l'identificatore della calsse
virtual word class_id() const;
virtual bool is_kind_of(word cid) const;
// @cmember Crea il controllo
virtual void create(WINDOW parent);
@ -1088,7 +1091,9 @@ protected: // TEditable_field
// @access Public Member
public:
// @cmember Legge un item del controllo dal file <p scanner>
void parse_head(TScanner& scanner);
virtual void parse_head(TScanner& scanner);
virtual bool is_kind_of(word cid) const;
// @cmember Costruttore
TDate_field(TMask* mask);

View File

@ -667,14 +667,14 @@ void TSpreadsheet::update(
if (!scroll)
{
xi_get_visible_rows(_obj, &first, &last);
scroll = items() < handle[first];
scroll = items() <= handle[first];
}
if (scroll)
xi_scroll(_obj, XI_SCROLL_FIRST);
else
// xi_scroll_rec(_obj, handle[first], NORMAL_COLOR, XI_ATR_ENABLED | XI_ATR_AUTOSELECT, 0);
xi_scroll(_obj, 0);
xi_scroll_rec(_obj, handle[first], NORMAL_COLOR, XI_ATR_ENABLED | XI_ATR_AUTOSELECT, 0);
// xi_scroll(_obj, 0);
_needs_update = -1; // Clear pending row update
}