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:
parent
d1745dd3cd
commit
1d80e8a48c
@ -1009,9 +1009,10 @@ void TButton_control::create(WINDOW win, short cid,
|
|||||||
rct.right++;
|
rct.right++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned long attrib = flags2attr(flags);
|
|
||||||
if (wc == WC_CHECKBOX)
|
if (wc == WC_CHECKBOX)
|
||||||
rct.right += XI_FU_MULTIPLE / 2;
|
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);
|
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);
|
CHECKD(def, "Can't create the interface of TButton_control ", cid);
|
||||||
def->v.btn->fore_color = color;
|
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)
|
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_OBJ cell; XI_MAKE_CELL(&cell, _xi_lst, r, 0);
|
||||||
xi_set_focus(&cell);
|
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 next = _selected < _values.items() - 1 ? _selected + 1 : 0;
|
||||||
int first = -1;
|
int first = -1;
|
||||||
@ -1550,22 +1555,24 @@ void TDropDownList::select_by_initial(char c)
|
|||||||
first = i;
|
first = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (first == -1) return;
|
if (first == -1)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
for (i = next; i < _values.items(); i++)
|
for (i = next; i < _values.items(); i++)
|
||||||
if (toupper(*(_values.get(i))) == toupper(c))
|
if (toupper(*(_values.get(i))) == toupper(c))
|
||||||
{
|
|
||||||
select(i);
|
|
||||||
break;
|
break;
|
||||||
}
|
if (i == _values.items() && first >= 0)
|
||||||
if (i == _values.items() && first > -1)
|
i = first;
|
||||||
select(first);
|
|
||||||
|
return select(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDropDownList::select_by_ofs(int i)
|
bool TDropDownList::select_by_ofs(int i)
|
||||||
{
|
{
|
||||||
i += _selected;
|
i += _selected;
|
||||||
if (i >= 0 && i < _values.items())
|
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)
|
TDropDownList::TDropDownList(XI_OBJ* o, const char* codes, const char* values, int width)
|
||||||
|
@ -280,8 +280,6 @@ class TDropDownList : public TObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
const int selected() const { return _selected; }
|
const int selected() const { return _selected; }
|
||||||
void select_by_initial(char c);
|
|
||||||
void select_by_ofs(int n);
|
|
||||||
void open();
|
void open();
|
||||||
void close();
|
void close();
|
||||||
bool is_open() const { return _open; }
|
bool is_open() const { return _open; }
|
||||||
@ -291,9 +289,12 @@ public:
|
|||||||
int items() const { return _values.items(); }
|
int items() const { return _values.items(); }
|
||||||
long row2rec(int) const;
|
long row2rec(int) const;
|
||||||
int rec2row(long rec) const;
|
int rec2row(long rec) const;
|
||||||
void select(int i, bool force = FALSE);
|
|
||||||
void set_values(const char* c, const char* v);
|
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);
|
TDropDownList(XI_OBJ* o, const char* codes, const char* values, int wid);
|
||||||
virtual ~TDropDownList() {}
|
virtual ~TDropDownList() {}
|
||||||
};
|
};
|
||||||
@ -312,9 +313,9 @@ protected: // TTField_control
|
|||||||
public:
|
public:
|
||||||
void set_values(const char* c, const char* v);
|
void set_values(const char* c, const char* v);
|
||||||
int items() const { return _ddl->items(); }
|
int items() const { return _ddl->items(); }
|
||||||
void select(int i) { _ddl->select(i); }
|
bool select(int i) { return _ddl->select(i); }
|
||||||
void select_by_initial(char c) { _ddl->select_by_initial(c); }
|
bool select_by_initial(char c) { return _ddl->select_by_initial(c); }
|
||||||
void select_by_ofs(int i) { _ddl->select_by_ofs(i); }
|
bool select_by_ofs(int i) { return _ddl->select_by_ofs(i); }
|
||||||
int selected() const { return _ddl->selected(); }
|
int selected() const { return _ddl->selected(); }
|
||||||
|
|
||||||
TListbox_control(WINDOW win, short cid,
|
TListbox_control(WINDOW win, short cid,
|
||||||
|
@ -1079,11 +1079,20 @@ bool TButton_field::on_key(KEY key)
|
|||||||
{
|
{
|
||||||
bool ok = TRUE;
|
bool ok = TRUE;
|
||||||
if (key == K_SPACE)
|
if (key == K_SPACE)
|
||||||
|
{
|
||||||
|
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();
|
ok = on_hit();
|
||||||
if (ok && _exit_key > 0 && message(0) == NULL)
|
if (ok && _exit_key > 0 && !has_message())
|
||||||
mask().stop_run(_exit_key);
|
mask().stop_run(_exit_key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ok = TOperable_field::on_key(key);
|
ok = TOperable_field::on_key(key);
|
||||||
return ok;
|
return ok;
|
||||||
@ -1720,6 +1729,7 @@ void TBrowse::parse_input(TScanner& scanner)
|
|||||||
}
|
}
|
||||||
else // Field on the mask
|
else // Field on the mask
|
||||||
{
|
{
|
||||||
|
CHECKS(_inp_id.get_pos(s) < 0, "Duplicate input field ", s);
|
||||||
_inp_id.add(s);
|
_inp_id.add(s);
|
||||||
if (scanner.popkey() == "SE") _inp_id << '@'; // Special FILTERing field
|
if (scanner.popkey() == "SE") _inp_id << '@'; // Special FILTERing field
|
||||||
else scanner.push();
|
else scanner.push();
|
||||||
@ -1862,6 +1872,12 @@ const char* TBrowse::get_input_fields() const
|
|||||||
return _inp_id;
|
return _inp_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* TBrowse::get_input_field_names() const
|
||||||
|
{
|
||||||
|
return _inp_fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* TBrowse::get_output_fields() const
|
const char* TBrowse::get_output_fields() const
|
||||||
{
|
{
|
||||||
return _out_id;
|
return _out_id;
|
||||||
@ -3564,16 +3580,20 @@ const char* TList_field::raw2win(const char* data) const
|
|||||||
return value.get(pos);
|
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);
|
const bool changed = ((TListbox_control*)_ctl)->select_by_ofs(n);
|
||||||
|
if (changed)
|
||||||
_str = _codes.get(current());
|
_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);
|
const bool changed = ((TListbox_control*)_ctl)->select_by_initial(c);
|
||||||
|
if (changed)
|
||||||
_str = _codes.get(current());
|
_str = _codes.get(current());
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
@ -3588,7 +3608,6 @@ void TList_field::replace_items(
|
|||||||
{
|
{
|
||||||
_codes = codes;
|
_codes = codes;
|
||||||
_values = values;
|
_values = values;
|
||||||
|
|
||||||
if (_ctl)
|
if (_ctl)
|
||||||
add_list();
|
add_list();
|
||||||
}
|
}
|
||||||
@ -3633,7 +3652,7 @@ int TList_field::str2curr(const char* data)
|
|||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
if (items() && str.not_empty())
|
if (items() && str.not_empty())
|
||||||
yesnofatal_box("'%s' non e' un valore valido per il campo %s: %d",
|
NFCHECK("'%s' non e' un valore valido per il campo %s: %d",
|
||||||
data, prompt(), dlg());
|
data, prompt(), dlg());
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
@ -3656,7 +3675,7 @@ void TList_field::set(const char* data)
|
|||||||
|
|
||||||
void TList_field::set_window_data(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));
|
const int i = str2curr(win2raw(data));
|
||||||
current(i);
|
current(i);
|
||||||
}
|
}
|
||||||
|
@ -811,9 +811,12 @@ public:
|
|||||||
// solo da filtro
|
// solo da filtro
|
||||||
int input_fields();
|
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;
|
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
|
// @cmember Ritorna la lista completa dei campi di output
|
||||||
const char* get_output_fields() const;
|
const char* get_output_fields() const;
|
||||||
|
|
||||||
@ -1122,7 +1125,7 @@ class TList_field : public TEditable_field
|
|||||||
void add_list();
|
void add_list();
|
||||||
|
|
||||||
// @cmember seleziona all'offset dato dal corrente
|
// @cmember seleziona all'offset dato dal corrente
|
||||||
void select_by_ofs(int n);
|
bool select_by_ofs(int n);
|
||||||
|
|
||||||
// @access Protected Member
|
// @access Protected Member
|
||||||
protected:
|
protected:
|
||||||
@ -1204,13 +1207,13 @@ public:
|
|||||||
virtual bool is_kind_of(word cid) const;
|
virtual bool is_kind_of(word cid) const;
|
||||||
|
|
||||||
// @cmember Seleziona sulla base dell'iniziale
|
// @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)
|
// @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)
|
// @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
|
// @cmember Azzera il contenuto del campo
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
@ -102,38 +102,22 @@ void TIndwin::update_bar()
|
|||||||
_flags |= IND_FINISHED;
|
_flags |= IND_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Percentuale raggiunta finora
|
||||||
const double prc = (double)_status/_max;
|
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.left = CHARX; r.right -= CHARX;
|
||||||
r.top = (int)_bar;
|
r.top = (int)_bar;
|
||||||
r.bottom = r.top + 2*CHARY;
|
r.bottom = r.top + 2*CHARY;
|
||||||
|
|
||||||
RCT b = r;
|
RCT b = r;
|
||||||
|
// Rettangolo in rilievo
|
||||||
/*
|
b.right = b.left + int((r.right-r.left)*prc);
|
||||||
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);
|
|
||||||
xi_draw_3d_rect(w, &b, FALSE, 2, 0, 0, 0);
|
xi_draw_3d_rect(w, &b, FALSE, 2, 0, 0, 0);
|
||||||
|
// Rettangolo scavato
|
||||||
set_brush(COLOR_WHITE);
|
|
||||||
b.left = b.right; b.right = r.right;
|
b.left = b.right; b.right = r.right;
|
||||||
xi_draw_3d_rect(w, &b, TRUE, 2, 0, 0, 0);
|
xi_draw_3d_rect(w, &b, TRUE, 2, 0, 0, 0);
|
||||||
|
|
||||||
|
@ -1050,20 +1050,42 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
|
|||||||
if (n > 0)
|
if (n > 0)
|
||||||
add_tag_button(0, ca, _sel);
|
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;
|
short y = 0;
|
||||||
ca = f->browse()->get_input_fields();
|
for (const char* i = ids.get(0); i; i = ids.get())
|
||||||
for (const char* i = ca.get(0); i; i = ca.get())
|
|
||||||
{
|
{
|
||||||
if (*i != '"' && strchr(i, '@') == NULL)
|
if (*i != '"' && strchr(i, '@') == NULL)
|
||||||
{
|
{
|
||||||
const TMask_field& c = f->mask().field(f->atodlg(i));
|
const TMask_field& c = f->mask().field(f->atodlg(i));
|
||||||
if (c.is_editable() && c.active())
|
if (c.is_editable() && c.active())
|
||||||
{
|
{
|
||||||
TEditable_field* e = NULL;
|
int pos = ids.get_pos(c.dlg());
|
||||||
TString80 p = c.prompt();
|
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
|
// Toglie spazi e simboli iniziali dal prompt
|
||||||
for (int a = 0; p[a] && !isalnum(p[a]); a++);
|
for (int a = 0; p[a] && !isalnum(p[a]); a++);
|
||||||
p.ltrim(a); p.left_just(16);
|
p.ltrim(a);
|
||||||
|
}
|
||||||
|
p.left_just(16);
|
||||||
|
TEditable_field* e = NULL;
|
||||||
switch (c.class_id())
|
switch (c.class_id())
|
||||||
{
|
{
|
||||||
case CLASS_EDIT_FIELD:
|
case CLASS_EDIT_FIELD:
|
||||||
|
@ -1287,6 +1287,14 @@ int TToken_string::get_pos(const char* s)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Certified 80%
|
||||||
|
int TToken_string::get_pos(long n)
|
||||||
|
{
|
||||||
|
char s[16]; sprintf(s, "%ld", n);
|
||||||
|
return get_pos(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Certified 90%
|
// Certified 90%
|
||||||
bool TToken_string::empty_items() const
|
bool TToken_string::empty_items() const
|
||||||
|
@ -488,6 +488,8 @@ public:
|
|||||||
long get_long(int n = -1);
|
long get_long(int n = -1);
|
||||||
// @cmember Ritorna la posizione dell'item s
|
// @cmember Ritorna la posizione dell'item s
|
||||||
int get_pos(const char* 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
|
// @cmember Ritorna il numero di token presenti
|
||||||
int items() const;
|
int items() const;
|
||||||
// @cmember Controlla se tutti i token sono nulli
|
// @cmember Controlla se tutti i token sono nulli
|
||||||
|
Loading…
x
Reference in New Issue
Block a user