Corretta gestione listbox

git-svn-id: svn://10.65.10.50/trunk@2796 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-05-13 07:31:27 +00:00
parent d15ddcf5f5
commit 74f2ab4b13
8 changed files with 3346 additions and 3315 deletions

View File

@ -1664,6 +1664,9 @@ void TListbox_control::set_values(const char* val)
{
_values = val;
_ddl->set_values(val);
if (selected() >= _values.items())
_ddl->select(0, TRUE);
else
_ddl->select(selected(), TRUE);
}

View File

@ -3326,7 +3326,8 @@ void TReal_field::exchange(bool show_value, const real& nuo)
// List_field
///////////////////////////////////////////////////////////
TList_field::TList_field(TMask* m) : TEditable_field(m)
TList_field::TList_field(TMask* m)
: TEditable_field(m), _size(0)
{ }
word TList_field::class_id() const
@ -3337,7 +3338,11 @@ void TList_field::read_item(TScanner& scanner)
{
TToken_string ts(scanner.string());
_codes.add(ts.get());
_values.add(ts.get());
const char* v = ts.get();
_values.add(v);
CHECKS(strlen(v) <= (word)_ctl_data._width, "List item is too long:", v);
ts = "";
while (scanner.popkey() == "ME")
@ -3348,7 +3353,7 @@ void TList_field::read_item(TScanner& scanner)
void TList_field::parse_head(TScanner& scanner)
{
_ctl_data._size = _size = scanner.integer();
_ctl_data._size = scanner.integer();
_ctl_data._width = scanner.integer();
if (_ctl_data._width == 0)
_ctl_data._width = _ctl_data._size;
@ -3451,25 +3456,38 @@ void TList_field::add_list()
const char* TList_field::win2raw(const char* data) const
{
if (*data == '\0') return data;
// fool the compiler to keep const
TToken_string& codes = ((TList_field*)this)->_codes;
TToken_string& value = ((TList_field*)this)->_values;
int pos = value.get_pos(data);
_ctl_data._park = data; // data puo' venire da una TToken_string::get
int pos = value.get_pos(_ctl_data._park);
if (pos < 0 && _ctl_data._park.blank())
{
_ctl_data._park = value.get(0);
if (_ctl_data._park.blank())
pos = 0;
}
CHECKS(pos >= 0, "Unknown listbox value:", data);
return codes.get(pos);
}
const char* TList_field::raw2win(const char* data) const
{
if (*data == '\0') return data;
// fool the compiler to keep const
TToken_string& codes = ((TList_field*)this)->_codes;
TToken_string& value = ((TList_field*)this)->_values;
int pos = codes.get_pos(data);
CHECKS(pos >= 0, "Unknown listbox code:", data);
_ctl_data._park = data; // data puo' venire da una TToken_string::get
int pos = codes.get_pos(_ctl_data._park);
if (pos < 0 && _ctl_data._park.blank())
{
_ctl_data._park = codes.get(0);
if (_ctl_data._park.blank())
pos = 0;
}
CHECKS(pos >= 0, "Unknown listbox code:", (const char*)_ctl_data._park);
return value.get(pos);
}
@ -3508,6 +3526,8 @@ void TList_field::create(WINDOW parent)
const int len = create_prompt(parent, 0, 0);
_ctl_data._x += len;
_size = _ctl_data._width;
_ctl = new TListbox_control(parent, _ctl_data._dlg,
_ctl_data._x, _ctl_data._y,
_ctl_data._width,
@ -3761,7 +3781,7 @@ bool TZoom_field::on_key( KEY key )
get_window_data();
break;
case K_F9:
if (has_query())
if (browse() != NULL)
break;
case K_F8:
{

View File

@ -217,7 +217,7 @@ public:
virtual bool has_check() const
{ return FALSE;}
// @cmember Controlla se il campo ha una richiesta
virtual bool has_query() const
virtual bool has_query_button() const
{ return FALSE;}
// @cmember Ritorna il campo corrispondente su record
virtual const TFieldref* field() const
@ -929,7 +929,7 @@ public:
// @cmember Controlla se il campo ha un check
virtual bool has_check() const;
// @cmember Controlla se il campo ha una ricerca
virtual bool has_query() const
virtual bool has_query_button() const
{ return _browse != NULL;}
// @cmember Ritorna TRUE se il campo e' di tipo edit
@ -1157,6 +1157,10 @@ public:
// @cmember Ritorna la dimensione del buffer associato al campo
virtual word size() const { return _size; }
// @cmember Esegue la ricerca. Torna il tasto che ha terminato la ricerca
virtual bool has_query_button() const
{ return TRUE; }
// @cmember Conversione da formato visuale a valore
virtual const char* win2raw(const char* data) const;

View File

@ -277,11 +277,11 @@ TSpreadsheet::TSpreadsheet(
f_width += v+1;
}
testa.cut(at);
v = max(at, v+(f->has_query() ? 1 : 0));
v = max(at, v+(f->has_query_button() ? 1 : 0));
}
else
{
v = max(testa.len(), m+(f->has_query() ? 1 : 0));
v = max(testa.len(), m+(f->has_query_button() ? 1 : 0));
}
if (v > 69)
v = 69;
@ -788,7 +788,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
if (cell_disabled(rec, col))
xiev->v.cell_request.back_color = DISABLED_BACK_COLOR;
else
if (e->has_query() || e->is_kind_of(CLASS_LIST_FIELD))
if (e->has_query_button())
{
xiev->v.cell_request.button = TRUE;
xiev->v.cell_request.button_on_focus = TRUE;

View File

@ -153,8 +153,12 @@ void TRelation_application::enable_query()
{
if (c.in_key(1))
c.enable(keyon);
if (c.has_query())
((TEdit_field&)c).enable_check(query);
if (c.is_edit())
{
TEdit_field& e = (TEdit_field&)c;
if (e.browse() != NULL)
e.enable_check(query);
}
}
}