Corretta gestione listbox nelle celle e bottoni della toolbar

git-svn-id: svn://10.65.10.50/trunk@2947 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-05-31 15:07:00 +00:00
parent d1745dd3cd
commit 1d80e8a48c
8 changed files with 4095 additions and 4049 deletions

View File

@ -1009,9 +1009,10 @@ void TButton_control::create(WINDOW win, short cid,
rct.right++;
}
const unsigned long attrib = flags2attr(flags);
if (wc == WC_CHECKBOX)
rct.right += XI_FU_MULTIPLE / 2;
const unsigned long attrib = flags2attr(flags);
XI_OBJ_DEF* def = xi_add_button_def(NULL, cid, &rct, attrib, (char*)t, cid);
CHECKD(def, "Can't create the interface of TButton_control ", cid);
def->v.btn->fore_color = color;
@ -1510,7 +1511,7 @@ void TDropDownList::close()
}
}
void TDropDownList::select(int i, bool force)
bool TDropDownList::select(int i, bool force)
{
if (force || i != _selected)
{
@ -1537,10 +1538,14 @@ void TDropDownList::select(int i, bool force)
XI_OBJ cell; XI_MAKE_CELL(&cell, _xi_lst, r, 0);
xi_set_focus(&cell);
}
return TRUE;
}
return FALSE;
}
void TDropDownList::select_by_initial(char c)
bool TDropDownList::select_by_initial(char c)
{
int next = _selected < _values.items() - 1 ? _selected + 1 : 0;
int first = -1;
@ -1550,22 +1555,24 @@ void TDropDownList::select_by_initial(char c)
first = i;
break;
}
if (first == -1) return;
if (first == -1)
return FALSE;
for (i = next; i < _values.items(); i++)
if (toupper(*(_values.get(i))) == toupper(c))
{
select(i);
break;
}
if (i == _values.items() && first > -1)
select(first);
if (i == _values.items() && first >= 0)
i = first;
return select(i);
}
void TDropDownList::select_by_ofs(int i)
bool TDropDownList::select_by_ofs(int i)
{
i += _selected;
if (i >= 0 && i < _values.items())
select(i);
return select(i);
return FALSE;
}
TDropDownList::TDropDownList(XI_OBJ* o, const char* codes, const char* values, int width)

View File

@ -280,8 +280,6 @@ class TDropDownList : public TObject
public:
const int selected() const { return _selected; }
void select_by_initial(char c);
void select_by_ofs(int n);
void open();
void close();
bool is_open() const { return _open; }
@ -291,9 +289,12 @@ public:
int items() const { return _values.items(); }
long row2rec(int) const;
int rec2row(long rec) const;
void select(int i, bool force = FALSE);
void set_values(const char* c, const char* v);
bool select(int i, bool force = FALSE);
bool select_by_initial(char c);
bool select_by_ofs(int n);
TDropDownList(XI_OBJ* o, const char* codes, const char* values, int wid);
virtual ~TDropDownList() {}
};
@ -312,9 +313,9 @@ protected: // TTField_control
public:
void set_values(const char* c, const char* v);
int items() const { return _ddl->items(); }
void select(int i) { _ddl->select(i); }
void select_by_initial(char c) { _ddl->select_by_initial(c); }
void select_by_ofs(int i) { _ddl->select_by_ofs(i); }
bool select(int i) { return _ddl->select(i); }
bool select_by_initial(char c) { return _ddl->select_by_initial(c); }
bool select_by_ofs(int i) { return _ddl->select_by_ofs(i); }
int selected() const { return _ddl->selected(); }
TListbox_control(WINDOW win, short cid,

View File

@ -1080,9 +1080,18 @@ bool TButton_field::on_key(KEY key)
bool ok = TRUE;
if (key == K_SPACE)
{
ok = on_hit();
if (ok && _exit_key > 0 && message(0) == NULL)
mask().stop_run(_exit_key);
if (dlg() != DLG_CANCEL && dlg() != DLG_QUIT)
{
const TMask& m = mask();
if (parent() == m.toolwin())
ok = m.focus_field().on_key(K_TAB);
}
if (ok)
{
ok = on_hit();
if (ok && _exit_key > 0 && !has_message())
mask().stop_run(_exit_key);
}
}
else
ok = TOperable_field::on_key(key);
@ -1720,6 +1729,7 @@ void TBrowse::parse_input(TScanner& scanner)
}
else // Field on the mask
{
CHECKS(_inp_id.get_pos(s) < 0, "Duplicate input field ", s);
_inp_id.add(s);
if (scanner.popkey() == "SE") _inp_id << '@'; // Special FILTERing field
else scanner.push();
@ -1862,6 +1872,12 @@ const char* TBrowse::get_input_fields() const
return _inp_id;
}
const char* TBrowse::get_input_field_names() const
{
return _inp_fn;
}
const char* TBrowse::get_output_fields() const
{
return _out_id;
@ -3564,16 +3580,20 @@ const char* TList_field::raw2win(const char* data) const
return value.get(pos);
}
void TList_field::select_by_ofs(int n)
bool TList_field::select_by_ofs(int n)
{
((TListbox_control*)_ctl)->select_by_ofs(n);
_str = _codes.get(current());
const bool changed = ((TListbox_control*)_ctl)->select_by_ofs(n);
if (changed)
_str = _codes.get(current());
return changed;
}
void TList_field::select_by_initial(char c)
bool TList_field::select_by_initial(char c)
{
((TListbox_control*)_ctl)->select_by_initial(c);
_str = _codes.get(current());
const bool changed = ((TListbox_control*)_ctl)->select_by_initial(c);
if (changed)
_str = _codes.get(current());
return changed;
}
// @doc EXTERNAL
@ -3588,7 +3608,6 @@ void TList_field::replace_items(
{
_codes = codes;
_values = values;
if (_ctl)
add_list();
}
@ -3633,8 +3652,8 @@ int TList_field::str2curr(const char* data)
if (i < 0)
{
if (items() && str.not_empty())
yesnofatal_box("'%s' non e' un valore valido per il campo %s: %d",
data, prompt(), dlg());
NFCHECK("'%s' non e' un valore valido per il campo %s: %d",
data, prompt(), dlg());
i = 0;
}
return i;
@ -3656,7 +3675,7 @@ void TList_field::set(const char* data)
void TList_field::set_window_data(const char* data)
{
CHECK(0,"So' passato da 'sta stronza!!!");
NFCHECK(0,"So' passato da 'sta stronza!!!");
const int i = str2curr(win2raw(data));
current(i);
}

View File

@ -811,9 +811,12 @@ public:
// solo da filtro
int input_fields();
// @cmember Ritorna la lista completa dei campi di input
// @cmember Ritorna la lista completa degli identificatori dei campi di input
const char* get_input_fields() const;
// @cmember Ritorna la lista completa dei nomi dei campi di input
const char* get_input_field_names() const;
// @cmember Ritorna la lista completa dei campi di output
const char* get_output_fields() const;
@ -1122,7 +1125,7 @@ class TList_field : public TEditable_field
void add_list();
// @cmember seleziona all'offset dato dal corrente
void select_by_ofs(int n);
bool select_by_ofs(int n);
// @access Protected Member
protected:
@ -1204,13 +1207,13 @@ public:
virtual bool is_kind_of(word cid) const;
// @cmember Seleziona sulla base dell'iniziale
void select_by_initial(char c);
bool select_by_initial(char c);
// @cmember Seleziona il prossimo se possibile (no wrap)
void select_next() { select_by_ofs(1); }
bool select_next() { return select_by_ofs(1); }
// @cmember Seleziona il precedente se possibile (no wrap)
void select_prev() { select_by_ofs(-1); }
bool select_prev() { return select_by_ofs(-1); }
// @cmember Azzera il contenuto del campo
virtual void reset();

View File

@ -102,38 +102,22 @@ void TIndwin::update_bar()
_flags |= IND_FINISHED;
}
// Percentuale raggiunta finora
const double prc = (double)_status/_max;
RCT r; xvt_vobj_get_client_rect(win(), &r);
WINDOW w = win();
RCT r; xvt_vobj_get_client_rect(w, &r);
// Rettangolo contenente l'intera barra
r.left = CHARX; r.right -= CHARX;
r.top = (int)_bar;
r.bottom = r.top + 2*CHARY;
RCT b = r;
/*
set_pen(COLOR_BLACK);
const int width = r.right - r.left;
set_brush(COLOR_BLUE);
b.right = b.left + int(width*prc);
xvt_dwin_draw_rect(win(), &b);
set_brush(COLOR_WHITE);
b.left = b.right; b.right = r.right;
xvt_dwin_draw_rect(win(), &b);
set_mode(M_XOR);
xvt_dwin_set_fore_color(win(), COLOR_BLUE);
char n[8]; sprintf(n, "%d%%", int(100*prc));
xvt_dwin_draw_text(win(), r.left+width/2-CHARX, (r.bottom+r.top+CHARY)/2-3, n, -1);
set_mode(M_COPY);
*/
WINDOW w = win();
b.right = b.left + int(r.right*prc);
// Rettangolo in rilievo
b.right = b.left + int((r.right-r.left)*prc);
xi_draw_3d_rect(w, &b, FALSE, 2, 0, 0, 0);
set_brush(COLOR_WHITE);
// Rettangolo scavato
b.left = b.right; b.right = r.right;
xi_draw_3d_rect(w, &b, TRUE, 2, 0, 0, 0);

View File

@ -1050,20 +1050,42 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
if (n > 0)
add_tag_button(0, ca, _sel);
TToken_string tids = head;
TToken_string tfns = fields;
TToken_string ids = f->browse()->get_input_fields();
TToken_string fns = f->browse()->get_input_field_names();
short y = 0;
ca = f->browse()->get_input_fields();
for (const char* i = ca.get(0); i; i = ca.get())
for (const char* i = ids.get(0); i; i = ids.get())
{
if (*i != '"' && strchr(i, '@') == NULL)
{
const TMask_field& c = f->mask().field(f->atodlg(i));
if (c.is_editable() && c.active())
{
int pos = ids.get_pos(c.dlg());
CHECK(pos >= 0, "Invalid input field");
TString80 p = fns.get(pos);
pos = tfns.get_pos(p);
if (pos >= 0)
{
p = tids.get(pos);
pos = p.find('@');
if (pos >= 0)
p.cut(pos);
}
else
p.cut(0);
if (p.empty())
{
p = c.prompt();
// Toglie spazi e simboli iniziali dal prompt
for (int a = 0; p[a] && !isalnum(p[a]); a++);
p.ltrim(a);
}
p.left_just(16);
TEditable_field* e = NULL;
TString80 p = c.prompt();
// Toglie spazi e simboli iniziali dal prompt
for (int a = 0; p[a] && !isalnum(p[a]); a++);
p.ltrim(a); p.left_just(16);
switch (c.class_id())
{
case CLASS_EDIT_FIELD:

View File

@ -1287,6 +1287,14 @@ int TToken_string::get_pos(const char* s)
return -1;
}
// Certified 80%
int TToken_string::get_pos(long n)
{
char s[16]; sprintf(s, "%ld", n);
return get_pos(s);
}
// Certified 90%
bool TToken_string::empty_items() const

View File

@ -488,6 +488,8 @@ public:
long get_long(int n = -1);
// @cmember Ritorna la posizione dell'item s
int get_pos(const char* s);
// @cmember Ritorna la posizione dell'item s
int get_pos(long s);
// @cmember Ritorna il numero di token presenti
int items() const;
// @cmember Controlla se tutti i token sono nulli