form.cpp Aggiunti const a funzioni virtuali che una volta l'avevano
controls.cpp Corretto lo scrolling e le dimensioni dei listbox window.cpp Corretti colori trasparenti git-svn-id: svn://10.65.10.50/trunk@3143 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
edf327866e
commit
85a2d7afec
@ -22,6 +22,8 @@ typedef struct _stx_data
|
||||
|
||||
#endif
|
||||
|
||||
HIDDEN bool _button_blocked = FALSE;
|
||||
|
||||
short get_focus_id(WINDOW win)
|
||||
{
|
||||
XI_OBJ * itf = xi_get_itf(win);
|
||||
@ -416,12 +418,18 @@ HIDDEN void xi_event_handler(XI_OBJ* itf, XI_EVENT* xiev)
|
||||
ctl = (TControl*)xi_get_app_data(xiev->v.xi_obj->parent);
|
||||
break;
|
||||
case a_xvt:
|
||||
if (xiev->v.xvte.type == E_CHAR)
|
||||
switch (xiev->v.xvte.type)
|
||||
{
|
||||
XI_OBJ* fo = xi_get_focus(itf);
|
||||
if (fo != NULL && fo->type == XIT_CELL)
|
||||
ctl = (TControl*)xi_get_app_data(fo->parent);
|
||||
}
|
||||
case E_CHAR:
|
||||
{
|
||||
XI_OBJ* fo = xi_get_focus(itf);
|
||||
if (fo != NULL && fo->type == XIT_CELL)
|
||||
ctl = (TControl*)xi_get_app_data(fo->parent);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case a_xvt_post:
|
||||
if (notify_xvt)
|
||||
@ -429,6 +437,9 @@ HIDDEN void xi_event_handler(XI_OBJ* itf, XI_EVENT* xiev)
|
||||
TWindow* w = (TWindow*)xi_get_app_data(itf);
|
||||
CHECK(w, "Can't send XVT event to a null window");
|
||||
w->handler(w->win(), &xiev->v.xvte);
|
||||
|
||||
if (xiev->v.xvte.type == E_MOUSE_UP)
|
||||
_button_blocked = FALSE;
|
||||
}
|
||||
else
|
||||
notify_xvt = TRUE;
|
||||
@ -1020,9 +1031,12 @@ void TField_control::create(WINDOW win, short cid,
|
||||
CHECKD(_obj, "Can't create field ", cid);
|
||||
STX_DATA* stx = (STX_DATA*)_obj->v.field->stx;
|
||||
CHECKD(stx, "NULL stx for field ", cid);
|
||||
const int offset = _obj->v.field->btn_rct.left - stx->rct.right + 1;
|
||||
_obj->v.field->btn_rct.left -= offset ;
|
||||
_obj->v.field->btn_rct.right -= offset;
|
||||
|
||||
// Aggiusta il rettangolo del bottone in modo da allinearlo al testo
|
||||
RCT& br = _obj->v.field->btn_rct;
|
||||
const int offset = stx->rct.right - br.left - 1;
|
||||
br.left += offset;
|
||||
br.right += offset;
|
||||
|
||||
update_tab_cid();
|
||||
|
||||
@ -1563,6 +1577,13 @@ int TDropDownList::rec2row(long rec) const
|
||||
return r;
|
||||
}
|
||||
|
||||
void TDropDownList::update_selection(XI_EVENT* xiev) const
|
||||
{
|
||||
if (xiev->v.rec_request.data_rec == selected())
|
||||
xiev->v.rec_request.attrib |= XI_ATR_SELECTED;
|
||||
else
|
||||
xiev->v.rec_request.attrib &= ~XI_ATR_SELECTED;
|
||||
}
|
||||
|
||||
void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev)
|
||||
{
|
||||
@ -1584,46 +1605,69 @@ void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev)
|
||||
if (ddl->items() == 0)
|
||||
xiev->refused = TRUE;
|
||||
else
|
||||
{
|
||||
xiev->v.rec_request.data_rec = ddl->items() * xiev->v.rec_request.percent/100;
|
||||
ddl->update_selection(xiev);
|
||||
}
|
||||
break;
|
||||
case XIE_GET_LAST:
|
||||
xiev->v.rec_request.data_rec = ddl->items() - 1;
|
||||
ddl->update_selection(xiev);
|
||||
break;
|
||||
case XIE_GET_NEXT:
|
||||
if (xiev->v.rec_request.spec_rec >= ddl->items()-1)
|
||||
xiev->refused = TRUE;
|
||||
else
|
||||
{
|
||||
xiev->v.rec_request.data_rec = xiev->v.rec_request.spec_rec + 1;
|
||||
ddl->update_selection(xiev);
|
||||
}
|
||||
break;
|
||||
case XIE_GET_PREV:
|
||||
if (xiev->v.rec_request.spec_rec == 0)
|
||||
xiev->refused = TRUE;
|
||||
else
|
||||
{
|
||||
xiev->v.rec_request.data_rec = xiev->v.rec_request.spec_rec - 1;
|
||||
ddl->update_selection(xiev);
|
||||
}
|
||||
break;
|
||||
case XIE_GET_PERCENT:
|
||||
if (ddl->items() > 1)
|
||||
xiev->v.get_percent.percent = (int)((xiev->v.get_percent.record * 100l)/((long)ddl->items()-1l));
|
||||
xiev->v.get_percent.percent = int((xiev->v.get_percent.record * 100L)/(ddl->items()-1));
|
||||
break;
|
||||
case XIE_DBL_CELL:
|
||||
ddl->select((int)(ddl->row2rec(xiev->v.xi_obj->v.cell.row)));
|
||||
ddl->close();
|
||||
break;
|
||||
case XIE_ON_ROW:
|
||||
if (ddl->displayed())
|
||||
ddl->select((int)(ddl->row2rec(xiev->v.xi_obj->v.row)));
|
||||
break;
|
||||
case XIE_ON_ROW:
|
||||
/* Guy: Per ora ignora sto evento, prova con XIE_SELECT */
|
||||
break;
|
||||
case XIE_SELECT:
|
||||
if (xiev->v.xi_obj->type == XIT_ROW)
|
||||
{
|
||||
const long rec = ddl->row2rec(xiev->v.xi_obj->v.row);
|
||||
ddl->select((int)rec);
|
||||
}
|
||||
break;
|
||||
case XIE_XVT_EVENT:
|
||||
if ((xiev->v.xvte.type == E_FOCUS && xiev->v.xvte.v.active == FALSE) || xiev->v.xvte.type == E_MOUSE_UP)
|
||||
ddl->close();
|
||||
if ((xiev->v.xvte.type == E_FOCUS && xiev->v.xvte.v.active == FALSE) ||
|
||||
xiev->v.xvte.type == E_MOUSE_UP)
|
||||
{
|
||||
ddl->close();
|
||||
if (xiev->v.xvte.type == E_FOCUS)
|
||||
_button_blocked = TRUE;
|
||||
}
|
||||
else if (xiev->v.xvte.type == E_CHAR)
|
||||
{
|
||||
const KEY k = xiev->v.xvte.v.chr.ch;
|
||||
if (k == K_ENTER || k == K_ESC)
|
||||
ddl->close();
|
||||
else
|
||||
{
|
||||
if (k >= ' ' && k <= 'z')
|
||||
ddl->select_by_initial(k);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XIE_CHAR_CELL: // TBI: questa e' copiata da edit
|
||||
@ -1658,19 +1702,9 @@ bool TDropDownList::select(int i, bool force)
|
||||
else
|
||||
xi_set_text(_obj, (char*)_codes.get(i));
|
||||
|
||||
if (is_open())
|
||||
{
|
||||
int r = rec2row(i);
|
||||
if (r < 0)
|
||||
{
|
||||
xi_scroll_rec(_xi_lst, i, FOCUS_COLOR, XI_ATR_ENABLED, 0);
|
||||
r = rec2row(i);
|
||||
}
|
||||
CHECKD(r >= 0, "Can't select listbox item ", r);
|
||||
XI_OBJ cell; XI_MAKE_CELL(&cell, _xi_lst, r, 0);
|
||||
xi_set_focus(&cell);
|
||||
}
|
||||
|
||||
if (force && is_open())
|
||||
xi_scroll_rec(_xi_lst, i, NORMAL_COLOR, XI_ATR_ENABLED | XI_ATR_SELECTED, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1695,8 +1729,31 @@ bool TDropDownList::select_by_initial(char c)
|
||||
break;
|
||||
if (i == _values.items() && first >= 0)
|
||||
i = first;
|
||||
|
||||
bool ok = FALSE;
|
||||
if (i != selected())
|
||||
{
|
||||
if (is_open())
|
||||
{
|
||||
const int oldsel = selected();
|
||||
|
||||
return select(i);
|
||||
// Scrolla alla selezione corrente
|
||||
xi_scroll_rec(_xi_lst, i, NORMAL_COLOR, XI_ATR_SELECTED | XI_ATR_ENABLED, 0);
|
||||
|
||||
const int r = rec2row(oldsel);
|
||||
if (r >= 0)
|
||||
{
|
||||
XI_OBJ riga; XI_MAKE_ROW(&riga, _xi_lst, r);
|
||||
long attr = xi_get_attrib(&riga);
|
||||
attr &= ~XI_ATR_SELECTED;
|
||||
xi_set_attrib(&riga, attr);
|
||||
xi_dequeue();
|
||||
}
|
||||
|
||||
}
|
||||
ok = select(i);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TDropDownList::select_by_ofs(int i)
|
||||
@ -1707,9 +1764,9 @@ bool TDropDownList::select_by_ofs(int 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)
|
||||
: _obj(o), _codes(codes), _values(values),
|
||||
_open(FALSE), _xi_lst(NULL), _width(width),
|
||||
_open(FALSE), _xi_lst(NULL),
|
||||
_displayed(FALSE), _selected(0)
|
||||
{}
|
||||
|
||||
@ -1722,53 +1779,42 @@ void TDropDownList::set_values(const char* c, const char* v)
|
||||
void TDropDownList::open()
|
||||
{
|
||||
if (_open) return;
|
||||
|
||||
|
||||
XI_OBJ_DEF* itfdef = xi_create_itf_def(ITF_CID, (XI_EVENT_HANDLER)ddl_str_eh, NULL, "",
|
||||
(long)this);
|
||||
// qui si vedra' se e cosa modificare
|
||||
itfdef->v.itf->automatic_back_color = TRUE;
|
||||
// compute size of field with button
|
||||
|
||||
RCT r; xi_get_rect(_obj, &r);
|
||||
|
||||
XI_RCT xr = r;
|
||||
xi_pu_to_fu(_obj->itf, (PNT*)&xr, 2);
|
||||
|
||||
if (_width == 0) // usually in spreadsheet cells
|
||||
_width = (xr.right - xr.left)/XI_FU_MULTIPLE;
|
||||
|
||||
if ((xr.right - xr.left) < (_width * XI_FU_MULTIPLE))
|
||||
{
|
||||
xr.right = xr.left + (_width * XI_FU_MULTIPLE);
|
||||
r = xr;
|
||||
xi_fu_to_pu(_obj->itf, (PNT*)&r, 2);
|
||||
}
|
||||
|
||||
int hei = items() <= 1 ? 2*XI_FU_MULTIPLE + 1 : (min(6,items()) * XI_FU_MULTIPLE) + 1;
|
||||
|
||||
const int hei = items() <= 1 ? 2*XI_FU_MULTIPLE + 1 : (min(6,items()) * XI_FU_MULTIPLE) + 1;
|
||||
XI_OBJ_DEF* lstdef = xi_add_list_def(itfdef, _obj->cid+1000, 0, 0, hei,
|
||||
XI_ATR_ENABLED|XI_ATR_VISIBLE, NORMAL_COLOR, NORMAL_BACK_COLOR,
|
||||
DISABLED_COLOR, DISABLED_BACK_COLOR, FOCUS_COLOR, 0);
|
||||
XI_ATR_ENABLED|XI_ATR_VISIBLE,
|
||||
NORMAL_COLOR, NORMAL_BACK_COLOR,
|
||||
DISABLED_COLOR, DISABLED_BACK_COLOR,
|
||||
FOCUS_COLOR, 0);
|
||||
|
||||
lstdef->v.list->active_back_color = FOCUS_BACK_COLOR;
|
||||
lstdef->v.list->scroll_bar = items() > 6;
|
||||
lstdef->v.list->no_heading = TRUE;
|
||||
lstdef->v.list->no_horz_lines = TRUE;
|
||||
lstdef->v.list->no_vert_lines = TRUE;
|
||||
// lstdef->v.list->no_vert_lines = TRUE;
|
||||
lstdef->v.list->resize_with_window = TRUE;
|
||||
|
||||
/*
|
||||
int len;
|
||||
if (_in_cell)
|
||||
len = items() <= 6 ? r.right - r.left - 2 : (_width-1) * XI_FU_MULTIPLE;
|
||||
else
|
||||
len = items() <= 6 ? _obj->v.field->rct.right - _obj->v.field->rct.left - 2 :
|
||||
(_width-1) * XI_FU_MULTIPLE;
|
||||
*/
|
||||
int len = xr.right - xr.left - 2;
|
||||
if (items() > 6) len = (_width-1) * XI_FU_MULTIPLE;
|
||||
lstdef->v.list->single_select = TRUE;
|
||||
|
||||
// compute size in pixel of field (with button enclosed)
|
||||
RCT r; xi_get_rect(_obj, &r);
|
||||
|
||||
// Larghezza in pixel dell'edit field
|
||||
int len = r.right - r.left;
|
||||
if (lstdef->v.list->scroll_bar)
|
||||
{
|
||||
// Larghezza in pixel del bottone
|
||||
const int bw = int(_obj->itf->v.itf->fu_height * XI_FU_MULTIPLE / _obj->itf->v.itf->fu_width);
|
||||
len -= bw;
|
||||
}
|
||||
// Larghezza in form units dell'edit field
|
||||
len = len * XI_FU_MULTIPLE / _obj->itf->v.itf->fu_width - 2;
|
||||
|
||||
XI_OBJ_DEF* coldef = xi_add_column_def(lstdef, _obj->cid+2000,
|
||||
XI_ATR_VISIBLE|XI_ATR_ENABLED|XI_ATR_READONLY,
|
||||
XI_ATR_VISIBLE|XI_ATR_ENABLED|XI_ATR_READONLY|XI_ATR_SELECTABLE,
|
||||
0, len, 80, "");
|
||||
|
||||
RCT l; xi_get_def_rect(lstdef, &l);
|
||||
@ -1814,13 +1860,6 @@ void TDropDownList::open()
|
||||
xvt_vobj_raise(win);
|
||||
_displayed = TRUE;
|
||||
|
||||
/*
|
||||
xi_scroll_rec(_xi_lst, _selected, NORMAL_COLOR, XI_ATR_ENABLED, 0);
|
||||
const int row = rec2row(_selected);
|
||||
XI_OBJ cell;
|
||||
XI_MAKE_CELL(&cell, _xi_lst, row, 0);
|
||||
xi_set_focus(&cell);
|
||||
*/
|
||||
select(_selected, TRUE);
|
||||
|
||||
xi_dequeue();
|
||||
@ -1835,7 +1874,8 @@ bool TListbox_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
|
||||
{
|
||||
case XIE_DBL_FIELD:
|
||||
case XIE_BUTTON:
|
||||
_ddl->open();
|
||||
if (!_ddl->is_open() && !_button_blocked)
|
||||
_ddl->open();
|
||||
break;
|
||||
case XIE_CHAR_FIELD:
|
||||
{
|
||||
@ -1876,7 +1916,7 @@ TListbox_control::TListbox_control(WINDOW win, short cid,
|
||||
const char* codes, const char* values)
|
||||
{
|
||||
create(win, cid, left, top, width , 1, width, flags, text, TRUE);
|
||||
_ddl = new TDropDownList(_obj, codes, values, width);
|
||||
_ddl = new TDropDownList(_obj, codes, values);
|
||||
_ddl->select(0, TRUE);
|
||||
}
|
||||
|
||||
|
@ -273,13 +273,14 @@ class TDropDownList : public TObject
|
||||
TToken_string _values;
|
||||
|
||||
int _selected;
|
||||
int _width;
|
||||
bool _open;
|
||||
bool _displayed;
|
||||
bool _in_cell;
|
||||
|
||||
|
||||
protected:
|
||||
static void ddl_str_eh (XI_OBJ* itf, XI_EVENT* xiev);
|
||||
|
||||
void update_selection(XI_EVENT* xiev) const;
|
||||
|
||||
public:
|
||||
const int selected() const { return _selected; }
|
||||
void open();
|
||||
@ -297,7 +298,7 @@ public:
|
||||
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);
|
||||
virtual ~TDropDownList() {}
|
||||
};
|
||||
|
||||
|
@ -1634,7 +1634,7 @@ protected:
|
||||
virtual bool set(const char*);
|
||||
bool set(const TDate& d);
|
||||
virtual bool parse_item(TScanner& scanner);
|
||||
virtual void print_body(ostream& out);
|
||||
virtual void print_body(ostream& out) const;
|
||||
|
||||
virtual void print_on(TMask& m);
|
||||
virtual void read_from(const TMask& m);
|
||||
@ -1673,7 +1673,7 @@ bool TForm_date::read()
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TForm_date::print_body(ostream& out)
|
||||
void TForm_date::print_body(ostream& out) const
|
||||
{
|
||||
TForm_string::print_body(out);
|
||||
out << " FORMAT \"" << _format << "\"\n";
|
||||
@ -1781,7 +1781,7 @@ protected:
|
||||
virtual bool parse_item(TScanner& scanner);
|
||||
virtual void print_on(TMask& m);
|
||||
virtual void read_from(const TMask& m);
|
||||
virtual void print_body(ostream& out);
|
||||
virtual void print_body(ostream& out) const;
|
||||
virtual bool update();
|
||||
|
||||
public:
|
||||
@ -1856,7 +1856,7 @@ void TForm_list::read_from(const TMask& m)
|
||||
}
|
||||
}
|
||||
|
||||
void TForm_list::print_body(ostream& out)
|
||||
void TForm_list::print_body(ostream& out) const
|
||||
{
|
||||
TForm_string::print_body(out);
|
||||
|
||||
@ -2373,7 +2373,7 @@ void TPrint_section::repos_fields(const char* name, int size)
|
||||
{
|
||||
if (!ps.form().dirty()) ps.form().set_dirty();
|
||||
ps.set_dirty();
|
||||
if (yesno_box("E' stato cambiato il font o la dimensione del carattere.\nDevo aggiornare le coordinate dei campi?"))
|
||||
if (yesno_box("E' stato cambiato il font o la dimensione del carattere.\nSi desidera aggiornare le coordinate dei campi?"))
|
||||
{
|
||||
s_data prm;
|
||||
prm.size_1=ps.form().fontsize();
|
||||
|
@ -494,14 +494,16 @@ void TImage::convert_transparent_color()
|
||||
// @comm Legge nell'immagine i pixel uguali a quello in alto a sinistra e li setta
|
||||
// uguali allo sfondo delle maschere
|
||||
{
|
||||
const COLOR trans = xvt_image_get_pixel(_image, 0, 0);
|
||||
if (trans != MASK_BACK_COLOR && xvt_image_get_format(_image) == XVT_IMAGE_CL8)
|
||||
const COLOR trans = xvt_image_get_pixel(_image, 0, 0) & 0x00FFFFFF;
|
||||
if (trans != (MASK_BACK_COLOR & 0x00FFFFFF) &&
|
||||
xvt_image_get_format(_image) == XVT_IMAGE_CL8)
|
||||
{
|
||||
for (int index = 0; index < 256; index++)
|
||||
if (xvt_image_get_clut(_image, index) == trans)
|
||||
if (trans == (xvt_image_get_clut(_image, index) & 0x00FFFFFF))
|
||||
{
|
||||
xvt_image_set_clut(_image, index, MASK_BACK_COLOR);
|
||||
break;
|
||||
if (index < 256)
|
||||
xvt_image_set_clut(_image, index, MASK_BACK_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user