controls.cpp Corretta dimensione dei listbox collegati alle celle
controls.h Aggiunta la funzione per calcolare la larghezza minima msksheet.cpp Corretta gestione listbox git-svn-id: svn://10.65.10.50/trunk@3310 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0446be8679
commit
0b5ea3bfd9
@ -1851,23 +1851,21 @@ bool TDropDownList::select(int i, bool force)
|
||||
|
||||
bool TDropDownList::select_by_initial(char c)
|
||||
{
|
||||
int next = _selected < _values.items() - 1 ? _selected + 1 : 0;
|
||||
int first = -1;
|
||||
for (int i = 0; i < _values.items(); i++)
|
||||
if (toupper(*(_values.get(i))) == toupper(c))
|
||||
{
|
||||
first = i;
|
||||
const int tot = _values.items();
|
||||
int i = _selected;
|
||||
c = toupper(c);
|
||||
while(TRUE)
|
||||
{
|
||||
i++;
|
||||
if (i >= tot)
|
||||
i = 0;
|
||||
if (i == _selected)
|
||||
break;
|
||||
const char p = toupper(*(_values.get(i)));
|
||||
if (p == c)
|
||||
break;
|
||||
}
|
||||
if (first == -1)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = next; i < _values.items(); i++)
|
||||
if (toupper(*(_values.get(i))) == toupper(c))
|
||||
break;
|
||||
if (i == _values.items() && first >= 0)
|
||||
i = first;
|
||||
|
||||
bool ok = FALSE;
|
||||
if (i != selected())
|
||||
{
|
||||
@ -1912,6 +1910,18 @@ void TDropDownList::set_values(const char* c, const char* v)
|
||||
{
|
||||
_codes = c;
|
||||
_values = v;
|
||||
}
|
||||
|
||||
int TDropDownList::calc_min_width()
|
||||
{
|
||||
int len = 1;
|
||||
for (const char* v = _values.get(0); v; v = _values.get())
|
||||
{
|
||||
const int l = strlen(v);
|
||||
if (l > len) len = l;
|
||||
}
|
||||
|
||||
return len * XI_FU_MULTIPLE;
|
||||
}
|
||||
|
||||
void TDropDownList::open()
|
||||
@ -1950,6 +1960,16 @@ void TDropDownList::open()
|
||||
}
|
||||
// Larghezza in form units dell'edit field
|
||||
len = len * XI_FU_MULTIPLE / _obj->itf->v.itf->fu_width - 2;
|
||||
|
||||
if (_obj->type == XIT_CELL)
|
||||
{
|
||||
const int m = calc_min_width();
|
||||
if (len < m)
|
||||
{
|
||||
len = m;
|
||||
r.right = r.left + m * _obj->itf->v.itf->fu_width / XI_FU_MULTIPLE;
|
||||
}
|
||||
}
|
||||
|
||||
XI_OBJ_DEF* coldef = xi_add_column_def(lstdef, _obj->cid+2000,
|
||||
XI_ATR_VISIBLE|XI_ATR_ENABLED|XI_ATR_READONLY|XI_ATR_SELECTABLE,
|
||||
|
@ -282,6 +282,7 @@ class TDropDownList : public TObject
|
||||
protected:
|
||||
static void ddl_str_eh (XI_OBJ* itf, XI_EVENT* xiev);
|
||||
void update_selection(XI_EVENT* xiev) const;
|
||||
int calc_min_width();
|
||||
|
||||
public:
|
||||
const int selected() const { return _selected; }
|
||||
|
@ -709,7 +709,7 @@ void TSpreadsheet::notify_change()
|
||||
_edit_field = cell2field(NULL); // Ricalcola correttamente il campo corrente
|
||||
|
||||
notify(_cur_rec, K_SPACE);
|
||||
_row_dirty = TRUE;
|
||||
_row_dirty = _cell_dirty = TRUE;
|
||||
set_dirty();
|
||||
}
|
||||
}
|
||||
@ -1153,7 +1153,9 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
beep();
|
||||
} else
|
||||
if (_edit_field->is_kind_of(CLASS_LIST_FIELD))
|
||||
{
|
||||
{
|
||||
notify_change(); // Aggiorna valore corrente listbox
|
||||
|
||||
TList_field& lst = ((TList_field&)*_edit_field);
|
||||
bool changed = FALSE;
|
||||
switch (k)
|
||||
@ -1173,6 +1175,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
{
|
||||
XI_OBJ cell; XI_MAKE_CELL(&cell, _obj, _cur_row, _cur_col);
|
||||
xi_set_text(&cell, (char*)(const char*)lst.get());
|
||||
_cell_dirty = TRUE;
|
||||
}
|
||||
refused = TRUE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user