Corretta gestione orecchie e campi di edit sugli sheet
git-svn-id: svn://10.65.10.50/trunk@3120 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
20d3b6a42b
commit
077266f0b0
@ -28,9 +28,10 @@ short get_focus_id(WINDOW win)
|
||||
XI_OBJ * obj = xi_get_focus(itf);
|
||||
|
||||
if (obj == NULL || obj->type == XIT_ITF)
|
||||
return -1;
|
||||
if (obj->type == XIT_CELL || (obj->type == XIT_BTN && obj->v.btn->type == XIBT_RADIOBTN))
|
||||
return -1;
|
||||
if (obj->type == XIT_CELL || (obj->type == XIT_BTN && obj->parent != obj->itf))
|
||||
obj = obj->parent;
|
||||
|
||||
return obj->cid;
|
||||
}
|
||||
|
||||
@ -61,7 +62,7 @@ KEY TControl::xiev_to_key(const XI_EVENT* xiev)
|
||||
class TPicture_array : public TArray
|
||||
{
|
||||
public:
|
||||
TImage& add(short id, bool convert = FALSE);
|
||||
TImage& add(short id);
|
||||
|
||||
const TImage& image(short id) const { return (const TImage&)operator[](id); }
|
||||
bool exist(short id) const { return objptr(id) != NULL; }
|
||||
@ -70,20 +71,19 @@ public:
|
||||
virtual ~TPicture_array() {}
|
||||
};
|
||||
|
||||
TImage& TPicture_array::add(short id, bool convert)
|
||||
TImage& TPicture_array::add(short id)
|
||||
{
|
||||
TImage* i = (TImage*)objptr(id);
|
||||
|
||||
if (i == NULL)
|
||||
{
|
||||
i = new TImage(id);
|
||||
i->convert_transparent_color();
|
||||
TArray::add(i, id);
|
||||
if (convert)
|
||||
i->convert_transparent_color();
|
||||
}
|
||||
|
||||
return *i;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utility functions
|
||||
@ -137,9 +137,29 @@ XVT_FNTID xvt_default_font(bool bold)
|
||||
static byte event_map[XIE_POST_NAVIGATION+1];
|
||||
enum event_action { a_ignore, a_xvt, a_xvt_post, a_obj, a_child, a_update, a_select, a_post, a_debug };
|
||||
|
||||
void init_controls()
|
||||
{
|
||||
xi_set_font_id(xvt_default_font());
|
||||
|
||||
// @func Permette di cambiare i colori attivi del programma
|
||||
void customize_colors()
|
||||
|
||||
// @comm Legge dal file di configurazione i colori scelti dall'utente e
|
||||
// ne setta le variabili in modo da poter personalizzare i colori
|
||||
//
|
||||
// @xref <c TConfig>
|
||||
|
||||
{
|
||||
TConfig colors(CONFIG_USER, "Colors");
|
||||
|
||||
MASK_BACK_COLOR = colors.get_color("MaskBack", NULL, -1, MASK_BACK_COLOR);
|
||||
MASK_LIGHT_COLOR = colors.get_color("MaskLight", NULL, -1, MASK_LIGHT_COLOR);
|
||||
MASK_DARK_COLOR = colors.get_color("MaskDark", NULL, -1, MASK_DARK_COLOR);
|
||||
NORMAL_COLOR = colors.get_color("Normal", NULL, -1, NORMAL_COLOR);
|
||||
NORMAL_BACK_COLOR = colors.get_color("NormalBack", NULL, -1, NORMAL_BACK_COLOR);
|
||||
DISABLED_COLOR = colors.get_color("Disabled", NULL, -1, DISABLED_COLOR);
|
||||
DISABLED_BACK_COLOR = colors.get_color("DisabledBack", NULL, -1, DISABLED_BACK_COLOR);
|
||||
FOCUS_COLOR = colors.get_color("Focus", NULL, -1, FOCUS_COLOR);
|
||||
FOCUS_BACK_COLOR = colors.get_color("FocusBack", NULL, -1, FOCUS_BACK_COLOR);
|
||||
TOOL_BACK_COLOR = colors.get_color("ToolBack", NULL, -1, MASK_DARK_COLOR);
|
||||
CAMPI_SCAVATI = colors.get_bool("Campi3D", NULL, -1, FALSE);
|
||||
|
||||
xi_set_pref(XI_PREF_NATIVE_CTRLS, FALSE);
|
||||
xi_set_pref(XI_PREF_3D_LOOK, TRUE);
|
||||
@ -148,8 +168,15 @@ void init_controls()
|
||||
xi_set_pref(XI_PREF_COLOR_CTRL, MASK_BACK_COLOR);
|
||||
xi_set_pref(XI_PREF_COLOR_DARK, MASK_DARK_COLOR);
|
||||
xi_set_pref(XI_PREF_COLOR_DISABLED, DISABLED_COLOR);
|
||||
|
||||
if (_picture)
|
||||
_picture->destroy();
|
||||
}
|
||||
|
||||
void init_controls()
|
||||
{
|
||||
xi_set_font_id(xvt_default_font());
|
||||
|
||||
// xi_set_pref(XI_PREF_AUTOSEL_ON_MOUSE, TRUE); // Da' problemi nelle ricerche
|
||||
xi_set_pref(XI_PREF_CARET_WIDTH, 2);
|
||||
|
||||
xi_init();
|
||||
@ -227,6 +254,8 @@ void free_controls()
|
||||
|
||||
HIDDEN void xi_event_handler(XI_OBJ *itf, XI_EVENT *xiev);
|
||||
|
||||
#define MASK_RECT_ID -883
|
||||
|
||||
WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
|
||||
const char* caption, TWindow* msk, bool tag)
|
||||
{
|
||||
@ -308,7 +337,7 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
|
||||
XI_RCT rct; xi_get_xi_rct(itf, &rct);
|
||||
rct.top += Y_FU_MULTIPLE; // Lascia lo spazio per i Bottoni di cambio pagina
|
||||
|
||||
def = xi_add_rect_def(NULL, DLG_PAGETAGS, &rct, XI_ATR_VISIBLE, 0, 0);
|
||||
def = xi_add_rect_def(NULL, MASK_RECT_ID, &rct, XI_ATR_VISIBLE, 0, 0);
|
||||
XI_OBJ* obj = xi_create(itf, def);
|
||||
CHECK(obj, "Can't create page rectangle");
|
||||
|
||||
@ -593,7 +622,7 @@ void TControl::coord2rct(WINDOW win, short x, short y, short dx, short dy, XI_RC
|
||||
{
|
||||
int num;
|
||||
XI_OBJ** child = xi_get_member_list(itf, &num);
|
||||
if (num > 0 && child[0]->cid == DLG_PAGETAGS)
|
||||
if (num > 0 && child[0]->cid == MASK_RECT_ID)
|
||||
y++;
|
||||
}
|
||||
|
||||
@ -1206,9 +1235,9 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
|
||||
if (bmp_up > 0)
|
||||
{
|
||||
_obj->v.btn->drawable = TRUE;
|
||||
_picture->add(_bmp_up = bmp_up, TRUE);
|
||||
_picture->add(_bmp_up = bmp_up);
|
||||
if (bmp_dn > 0)
|
||||
_picture->add(_bmp_dn = bmp_dn, TRUE);
|
||||
_picture->add(_bmp_dn = bmp_dn);
|
||||
else
|
||||
_bmp_dn = _bmp_up;
|
||||
if (_obj->v.btn->text)
|
||||
|
@ -10,7 +10,6 @@
|
||||
#define DLG_PGDN 5 /* TAG del bottone <PgDn> */
|
||||
#define DLG_PGUP 6 /* TAG del bottone <PgUp> */
|
||||
#define DLG_PAGE 7 /* TAG del bottone <PgUp/PgDn> */
|
||||
#define DLG_PAGETAGS 8 /* TAG del bottone <Pg n> */
|
||||
#define DLG_QUIT 9 /* TAG del bottone <Uscita> */
|
||||
#define DLG_F9 10 /* TAG del bottone <Ricerca> */
|
||||
#define DLG_FIRSTREC 11 /* TAG del bottone <Primo> */
|
||||
|
@ -16,10 +16,42 @@
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
|
||||
#define NULL_PAGE 256
|
||||
#define DLG_PAGETAGS 32000
|
||||
|
||||
HIDDEN const char* const MASK_EXT = "msk";
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// PAGE BUTTONS
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TPage_field : public TRadio_field
|
||||
{
|
||||
byte _def;
|
||||
|
||||
protected:
|
||||
virtual void current(int) { } // Evita il reset
|
||||
virtual int current() const { return _def; }
|
||||
|
||||
public:
|
||||
void create(WINDOW parent);
|
||||
void set_default(byte d) { _def = d; }
|
||||
void show_button(int i, bool on);
|
||||
|
||||
TPage_field(TMask* m) : TRadio_field(m) { }
|
||||
virtual ~TPage_field() { }
|
||||
};
|
||||
|
||||
void TPage_field::create(WINDOW parent)
|
||||
{
|
||||
_ctl = new TTagbutton_control(parent, _ctl_data._dlg, 0, 0, 80, 1, "", _values, _def);
|
||||
}
|
||||
|
||||
void TPage_field::show_button(int i, bool on)
|
||||
{
|
||||
TTagbutton_control* tag = (TTagbutton_control*)_ctl;
|
||||
tag->show_button(i, on);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TMask methods
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -128,9 +160,14 @@ void TMask::read_mask(
|
||||
}
|
||||
|
||||
void TMask::add_tag_button(byte pag, TToken_string& tags, byte sel)
|
||||
{
|
||||
TTagbutton_control* tb = new TTagbutton_control(_pagewin[pag], 32000, 0, 0, 80, 1, "", tags, sel);
|
||||
_pagetag.add(tb, pag);
|
||||
{
|
||||
TPage_field* pf = new TPage_field(this);
|
||||
pf->_ctl_data._dlg = DLG_PAGETAGS + 100 * pag;
|
||||
pf->replace_items("1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16", tags);
|
||||
pf->set_default(sel);
|
||||
pf->create(_pagewin[pag]);
|
||||
|
||||
_field.add(pf);
|
||||
}
|
||||
|
||||
void TMask::add_tag_buttons(TToken_string& tags)
|
||||
@ -249,7 +286,7 @@ TOperable_field& TMask::focus_field() const
|
||||
((TMask *)this)->_focus = id2pos(focus);
|
||||
TMask_field & f = fld(_focus);
|
||||
|
||||
CHECK(f.is_kind_of(CLASS_OPERABLE_FIELD), "Can't set focus to non operable_field");
|
||||
CHECK(f.is_kind_of(CLASS_OPERABLE_FIELD), "A non operable_field has the focus");
|
||||
return (TOperable_field&)f;
|
||||
}
|
||||
|
||||
@ -331,9 +368,9 @@ void TMask::enable_page(
|
||||
{
|
||||
_enabled.set(i, on);
|
||||
for (byte b = 0; b < _pages; b++)
|
||||
{
|
||||
TTagbutton_control& tag = (TTagbutton_control&)_pagetag[b];
|
||||
tag.show_button(i, on);
|
||||
{
|
||||
TPage_field& pf = (TPage_field&)field(DLG_PAGETAGS + 100 * b);
|
||||
pf.show_button(i, on);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1661,9 +1698,14 @@ void TMask::set_caption(const char* c)
|
||||
{
|
||||
const char* cap = captions.get();
|
||||
if (cap == NULL) cap = captions.get(0);
|
||||
xvt_vobj_set_title(_pagewin[p], (char*)cap);
|
||||
TTagbutton_control* tag = (TTagbutton_control*)_pagetag.objptr(p);
|
||||
if (tag) tag->set_caption(c);
|
||||
xvt_vobj_set_title(_pagewin[p], (char*)cap);
|
||||
|
||||
const int pos = id2pos(DLG_PAGETAGS + 100 * p);
|
||||
if (pos >= 0)
|
||||
{
|
||||
TPage_field& tag = (TPage_field&)fld(pos);
|
||||
tag.set_prompt(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,9 +96,6 @@ class TMask : public TWindow
|
||||
// @cmember:(INTERNAL) Tempo di inizializzazione della maschera
|
||||
long _init_time;
|
||||
|
||||
// @cmember:(INTERNAL) numeri pagina
|
||||
TArray _pagetag;
|
||||
|
||||
// @cmember:(INTERNAL) identificatore del campo da testare per l'autopremimento
|
||||
short _test_fld;
|
||||
// @cmember:(INTERNAL) posizione del campo che per ultimo ha testato l'autopremimento
|
||||
|
@ -1391,7 +1391,7 @@ void TEditable_field::set(const char* data)
|
||||
_str = reformat(data);
|
||||
const TString& val = raw2win(_str);
|
||||
set_window_data(val);
|
||||
if (mask().is_running())
|
||||
// if (mask().is_running()) // Guy: Secondo me perde tempo solamente!
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
@ -3691,15 +3691,21 @@ void TList_field::set_window_data(const char* data)
|
||||
}
|
||||
|
||||
void TList_field::current(int n)
|
||||
{
|
||||
((TListbox_control*)_ctl)->select(n);
|
||||
{
|
||||
if (_ctl)
|
||||
((TListbox_control*)_ctl)->select(n);
|
||||
_str = _codes.get(n);
|
||||
_str.trim();
|
||||
}
|
||||
|
||||
int TList_field::current() const
|
||||
{
|
||||
return ((TListbox_control*)_ctl)->selected();
|
||||
{
|
||||
int c;
|
||||
if (_ctl)
|
||||
c = ((TListbox_control*)_ctl)->selected();
|
||||
else
|
||||
c = ((TList_field*)this)->_codes.get_pos(_str); // Fool the compiler for const sake
|
||||
return c;
|
||||
}
|
||||
|
||||
TString& TList_field::get_window_data()
|
||||
@ -3784,14 +3790,19 @@ void TRadio_field::create(WINDOW parent)
|
||||
|
||||
int TRadio_field::current() const
|
||||
{
|
||||
const int c = ((TRadiobutton_control*)_ctl)->get_checked();
|
||||
int c;
|
||||
if (_ctl)
|
||||
c = ((TRadiobutton_control*)_ctl)->get_checked();
|
||||
else
|
||||
c = TList_field::current();
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void TRadio_field::current(int n)
|
||||
{
|
||||
((TRadiobutton_control*)_ctl)->check_button(n);
|
||||
if (_ctl)
|
||||
((TRadiobutton_control*)_ctl)->check_button(n);
|
||||
_str = _codes.get(n);
|
||||
_str.trim();
|
||||
}
|
||||
|
@ -461,7 +461,13 @@ TOperable_field* TSpreadsheet::col2field(int pos) const
|
||||
|
||||
// Retrieves the corresponding field of the mask from a spredsheet cell
|
||||
TOperable_field* TSpreadsheet::cell2field(const XI_OBJ* cell) const
|
||||
{
|
||||
{
|
||||
XI_OBJ cella;
|
||||
if (cell == NULL)
|
||||
{
|
||||
XI_MAKE_CELL(&cella, _obj, _cur_row, _cur_col);
|
||||
cell = &cella;
|
||||
}
|
||||
return col2field(cell->v.cell.column);
|
||||
}
|
||||
|
||||
@ -687,8 +693,9 @@ void TSpreadsheet::notify_change()
|
||||
{
|
||||
if (!_row_dirty)
|
||||
{
|
||||
/* Guy! */
|
||||
str2mask(_cur_rec);
|
||||
str2mask(_cur_rec);
|
||||
_edit_field = cell2field(NULL); // Ricalcola correttamente il campo corrente
|
||||
|
||||
notify(_cur_rec, K_SPACE);
|
||||
_row_dirty = TRUE;
|
||||
set_dirty();
|
||||
@ -1014,12 +1021,6 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
const KEY k = xiev_to_key(xiev);
|
||||
switch(k)
|
||||
{
|
||||
case K_F1:
|
||||
_check_enabled = FALSE; // Disable checks
|
||||
_edit_field->on_key(k);
|
||||
set_focus_cell(_cur_row, _cur_col);
|
||||
_check_enabled = TRUE; // Enable checks
|
||||
break;
|
||||
case K_F8:
|
||||
case K_F9:
|
||||
if (_edit_field != NULL)
|
||||
|
2314
include/xvtility.cpp
2314
include/xvtility.cpp
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user