maskfld.cpp Aggiiustata gestione del tasto gestione

msksheet.cpp   Reso parametrico autoselect
controls.h     Aggiunto prompt con sottolineatura ai bottoni
form.cpp       Corretto commento
xvtility.cpp   Spostati in controls i colori
sheet.cpp      Corretto sort numeber delle colonnne


git-svn-id: svn://10.65.10.50/trunk@3229 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-07-24 08:43:02 +00:00
parent adc7237f77
commit 479c93ab42
10 changed files with 117 additions and 57 deletions

View File

@ -16,6 +16,7 @@ extern COLOR DISABLED_BACK_COLOR;
extern COLOR FOCUS_COLOR; extern COLOR FOCUS_COLOR;
extern COLOR FOCUS_BACK_COLOR; extern COLOR FOCUS_BACK_COLOR;
extern BOOLEAN CAMPI_SCAVATI; extern BOOLEAN CAMPI_SCAVATI;
extern BOOLEAN AUTOSELECT;
const COLOR COLOR_DKCYAN = MAKE_COLOR(0,128,128); const COLOR COLOR_DKCYAN = MAKE_COLOR(0,128,128);
const COLOR COLOR_DKYELLOW = MAKE_COLOR(128,128, 0); const COLOR COLOR_DKYELLOW = MAKE_COLOR(128,128, 0);

View File

@ -10,6 +10,19 @@
#include <urldefid.h> #include <urldefid.h>
#include <window.h> #include <window.h>
COLOR MASK_BACK_COLOR = COLOR_DKCYAN;
COLOR MASK_LIGHT_COLOR = COLOR_CYAN;
COLOR MASK_DARK_COLOR = COLOR_GRAY;
COLOR TOOL_BACK_COLOR = COLOR_GRAY;
COLOR NORMAL_COLOR = COLOR_BLACK;
COLOR NORMAL_BACK_COLOR = COLOR_LTGRAY;
COLOR DISABLED_COLOR = COLOR_GRAY;
COLOR DISABLED_BACK_COLOR = MASK_BACK_COLOR;
COLOR FOCUS_COLOR = NORMAL_COLOR;
COLOR FOCUS_BACK_COLOR = COLOR_CYAN;
BOOLEAN CAMPI_SCAVATI = FALSE;
BOOLEAN AUTOSELECT = FALSE;
#ifndef STX_DATA #ifndef STX_DATA
// Very deep hacking // Very deep hacking
typedef struct _stx_data typedef struct _stx_data
@ -161,7 +174,8 @@ void customize_colors()
FOCUS_COLOR = colors.get_color("Focus", NULL, -1, FOCUS_COLOR); FOCUS_COLOR = colors.get_color("Focus", NULL, -1, FOCUS_COLOR);
FOCUS_BACK_COLOR = colors.get_color("FocusBack", NULL, -1, FOCUS_BACK_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); TOOL_BACK_COLOR = colors.get_color("ToolBack", NULL, -1, MASK_DARK_COLOR);
CAMPI_SCAVATI = colors.get_bool("Campi3D", NULL, -1, FALSE); CAMPI_SCAVATI = colors.get_bool("Campi3D", NULL, -1, (bool)CAMPI_SCAVATI);
AUTOSELECT = colors.get_bool("AutoSelect", NULL, -1, (bool)AUTOSELECT);
xi_set_pref(XI_PREF_NATIVE_CTRLS, FALSE); xi_set_pref(XI_PREF_NATIVE_CTRLS, FALSE);
xi_set_pref(XI_PREF_3D_LOOK, TRUE); xi_set_pref(XI_PREF_3D_LOOK, TRUE);
@ -525,7 +539,11 @@ void TControl::set_tab_cid(XI_OBJ* obj, short cid) const
obj->v.form->tab_cid = cid; obj->v.form->tab_cid = cid;
break; break;
case XIT_LIST: case XIT_LIST:
obj->v.list->tab_cid = cid; break; obj->v.list->tab_cid = cid;
break;
case XIT_COLUMN:
obj->parent->v.list->tab_cid = cid;
break;
default: default:
NFCHECK(0, "Can't set tab_cid to a static control: ", _obj->cid); break; NFCHECK(0, "Can't set tab_cid to a static control: ", _obj->cid); break;
} }
@ -758,7 +776,10 @@ const char* TControl::parse_caption(const char* cap, bool& bold, COLOR& color) c
{ {
int r = 0, g = 0, b = 0; int r = 0, g = 0, b = 0;
sscanf(t, "%d,%d,%d", &r, &g, &b); sscanf(t, "%d,%d,%d", &r, &g, &b);
color = MAKE_COLOR(r, g, b); if (r == 0 && g == 0 && b == 0)
color = COLOR_BLACK;
else
color = MAKE_COLOR(r, g, b);
} }
while (*t && *t != ']') t++; while (*t && *t != ']') t++;
} }
@ -990,14 +1011,16 @@ void TField_control::create(WINDOW win, short cid,
{ {
in_create = TRUE; in_create = TRUE;
const short fcid = cid > 0 ? cid + 1000 : cid - 1000; const short fcid = cid > 0 ? cid + 2000 : cid - 2000;
XI_OBJ_DEF* frm_def = xi_add_form_def(NULL, fcid, fcid); XI_OBJ_DEF* frm_def = xi_add_form_def(NULL, fcid, fcid);
frm_def->app_data = (long)this; frm_def->app_data = (long)this;
XI_RCT rct; coord2rct(win, left, top, width, height, rct); XI_RCT rct; coord2rct(win, left, top, width, height, rct);
rct.right += XI_FU_MULTIPLE/4; rct.right += XI_FU_MULTIPLE/4;
unsigned long attrib = flags2attr(flags) | XI_ATR_AUTOSELECT; unsigned long attrib = flags2attr(flags);
if (AUTOSELECT)
attrib |= XI_ATR_AUTOSELECT;
if (!CAMPI_SCAVATI) if (!CAMPI_SCAVATI)
attrib |= XI_ATR_BORDER; attrib |= XI_ATR_BORDER;
if (maxlen > width) if (maxlen > width)
@ -1238,9 +1261,20 @@ TPushbutton_control::TPushbutton_control(WINDOW win, short cid,
: _bmp_up(bmp_up), _bmp_dn(bmp_dn) : _bmp_up(bmp_up), _bmp_dn(bmp_dn)
{ {
if (bmp_up > 0) bool bold;
text = ""; COLOR color;
_caption = parse_caption(text, bold, color);
_underscore = _caption.find('~');
if (_underscore < 0)
_underscore = _caption.find('&');
if (_underscore >= 0)
_caption.strip("~&");
create(win, cid, left, top, width, height, flags, text, WC_PUSHBUTTON, NULL); create(win, cid, left, top, width, height, flags, text, WC_PUSHBUTTON, NULL);
_obj->v.btn->drawable = TRUE;
*_obj->v.btn->text = '\0';
set_bmp(bmp_up, bmp_dn); set_bmp(bmp_up, bmp_dn);
} }
@ -1248,18 +1282,14 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
{ {
if (bmp_up > 0) if (bmp_up > 0)
{ {
_obj->v.btn->drawable = TRUE;
_picture->add(_bmp_up = bmp_up); _picture->add(_bmp_up = bmp_up);
if (bmp_dn > 0) if (bmp_dn > 0)
_picture->add(_bmp_dn = bmp_dn); _picture->add(_bmp_dn = bmp_dn);
else else
_bmp_dn = _bmp_up; _bmp_dn = _bmp_up;
if (_obj->v.btn->text)
*_obj->v.btn->text = '\0';
} }
else else
{ {
_obj->v.btn->drawable = FALSE;
_bmp_up = _bmp_dn = 0; _bmp_up = _bmp_dn = 0;
} }
} }
@ -1267,6 +1297,8 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
void TPushbutton_control::update() void TPushbutton_control::update()
{ {
const long attrib = xi_get_attrib(_obj); const long attrib = xi_get_attrib(_obj);
const WINDOW win = parent();
if (attrib & XI_ATR_VISIBLE) if (attrib & XI_ATR_VISIBLE)
{ {
const short bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up; const short bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up;
@ -1282,8 +1314,7 @@ void TPushbutton_control::update()
y += 2; y += 2;
} }
const WINDOW w = parent(); i.draw(win, x, y);
i.draw(w, x, y);
if (!(attrib & XI_ATR_ENABLED)) if (!(attrib & XI_ATR_ENABLED))
{ {
CPEN pen; CPEN pen;
@ -1291,23 +1322,55 @@ void TPushbutton_control::update()
pen.pat = PAT_SOLID; pen.pat = PAT_SOLID;
pen.style = P_SOLID; pen.style = P_SOLID;
pen.color = MASK_BACK_COLOR; pen.color = MASK_BACK_COLOR;
xvt_dwin_set_cpen(w, &pen); xvt_dwin_set_cpen(win, &pen);
for (int py = y + i.height(); py >= y; py -= 2) for (int py = y + i.height(); py >= y; py -= 2)
{ {
PNT p; p.v = py; p.h = x; PNT p; p.v = py; p.h = x;
xvt_dwin_draw_set_pos(w, p); xvt_dwin_draw_set_pos(win, p);
p.h += i.width(); p.h += i.width();
xvt_dwin_draw_line(w, p); xvt_dwin_draw_line(win, p);
} }
for (int px = x + i.width(); px >= x; px -= 2) for (int px = x + i.width(); px >= x; px -= 2)
{ {
PNT p; p.v = y; p.h = px; PNT p; p.v = y; p.h = px;
xvt_dwin_draw_set_pos(w, p); xvt_dwin_draw_set_pos(win, p);
p.v += i.height(); p.v += i.height();
xvt_dwin_draw_line(w, p); xvt_dwin_draw_line(win, p);
} }
} }
} }
else
{
RCT& r = _obj->v.btn->rct;
int ascent, descent;
xvt_dwin_get_font_metrics(win, NULL, &ascent, &descent);
const int w = xvt_dwin_get_text_width(win, (char*)(const char*)_caption, -1);
int x = r.left + (r.right - r.left - w) / 2;
int y = r.top + (r.bottom - r.top + ascent - descent) / 2;
if (_obj->v.btn->down)
{
x += 2;
y += 2;
}
DRAW_CTOOLS ct;
xvt_dwin_get_draw_ctools(win, &ct);
ct.opaque_text = FALSE;
ct.fore_color = _obj->v.btn->fore_color;
xvt_dwin_set_draw_ctools(win, &ct);
xvt_dwin_draw_text(win, x, y, (char*)(const char*)_caption, -1);
if (_underscore >= 0)
{
TString cap = _caption;
cap[_underscore] = '_';
xvt_dwin_draw_text(win, x, y, (char*)(const char*)cap, _underscore+1);
}
}
} }
} }

View File

@ -80,7 +80,7 @@ public:
XI_OBJ_TYPE type() const { return _obj->type; } XI_OBJ_TYPE type() const { return _obj->type; }
// @cmember Ritorna il prompt del controllo // @cmember Ritorna il prompt del controllo
const char* caption() const; virtual const char* caption() const;
// @cmember Setta il prompt del controllo // @cmember Setta il prompt del controllo
virtual void set_caption(const char* c); virtual void set_caption(const char* c);
@ -167,8 +167,6 @@ public:
virtual ~TMultiline_control() {} virtual ~TMultiline_control() {}
}; };
class TButton_control : public TControl class TButton_control : public TControl
{ {
protected: protected:
@ -196,10 +194,13 @@ public:
class TPushbutton_control : public TButton_control class TPushbutton_control : public TButton_control
{ {
TString _caption;
int _underscore;
short _bmp_up, _bmp_dn; short _bmp_up, _bmp_dn;
protected: protected:
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* xiev); virtual bool event_handler(XI_OBJ* itf, XI_EVENT* xiev);
virtual const char* caption() const { return _caption; }
public: public:
virtual void update(); virtual void update();

View File

@ -624,7 +624,7 @@ void TForm_item::enable(
// @flag TRUE | Il campo viene abiliato // @flag TRUE | Il campo viene abiliato
// @flag FALSE | Il campo viene disabiliato // @flag FALSE | Il campo viene disabiliato
// @comm Viene automaticamente setta se il campo diventi visibile o nascosto (chaiam <mf TForm_item::show>) // @comm Viene automaticamente setta se il campo diventi visibile o nascosto (chiama <mf TForm_item::show>)
{ {
_flag.enabled = on; _flag.enabled = on;
show(on); show(on);

View File

@ -331,7 +331,6 @@ public:
void set_last_page(bool lp) void set_last_page(bool lp)
{ _lastpage = lp; } { _lastpage = lp; }
// @cmember Setta il modo di sfondo (fincatura) // @cmember Setta il modo di sfondo (fincatura)
void set_mode(bkg_mode b); void set_mode(bkg_mode b);
// @cmember Ritorna il modo di sfondo (fincatura) // @cmember Ritorna il modo di sfondo (fincatura)

View File

@ -16,7 +16,7 @@
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
#define DLG_PAGETAGS 32000 #define DLG_PAGETAGS 31000
HIDDEN const char* const MASK_EXT = "msk"; HIDDEN const char* const MASK_EXT = "msk";

View File

@ -2234,7 +2234,7 @@ KEY TBrowse::run()
switch (k) switch (k)
{ {
case K_CTRL+'C': case K_CTRL+'G':
if (_insert[0] == 'G') if (_insert[0] == 'G')
{ {
field().set(format("%ld", selected+1)); field().set(format("%ld", selected+1));

View File

@ -359,8 +359,11 @@ TSpreadsheet::TSpreadsheet(
const TOperable_field* f = field(cid); // Field on mask const TOperable_field* f = field(cid); // Field on mask
const int acqua = f->class_id(); const int acqua = f->class_id();
long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL | long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL | XI_ATR_FOCUSBORDER;
XI_ATR_FOCUSBORDER | XI_ATR_AUTOSELECT;
if (AUTOSELECT)
flags |= XI_ATR_AUTOSELECT;
switch (acqua) switch (acqua)
{ {
case CLASS_EDIT_FIELD: case CLASS_EDIT_FIELD:
@ -1240,7 +1243,8 @@ void TSpreadsheet::activate(bool on)
if (on) if (on)
{ {
att &= ~XI_ATR_READONLY; att &= ~XI_ATR_READONLY;
att |= XI_ATR_AUTOSELECT; if (AUTOSELECT)
att |= XI_ATR_AUTOSELECT;
} }
else else
{ {

View File

@ -180,7 +180,7 @@ TSheet_control::TSheet_control(
l->rule_color = MASK_DARK_COLOR; l->rule_color = MASK_DARK_COLOR;
// Definizione della prima colonna (numero di riga) // Definizione della prima colonna (numero di riga)
const long attr = XI_ATR_VISIBLE | XI_ATR_RJUST | XI_ATR_SELECTABLE; const long attr = XI_ATR_VISIBLE | XI_ATR_RJUST | XI_ATR_SELECTABLE;
XI_OBJ_DEF* coldef = xi_add_column_def(listdef, FIRST_FIELD+1000-1, attr, FIRST_FIELD+1000, XI_OBJ_DEF* coldef = xi_add_column_def(listdef, FIRST_FIELD+1000-1, attr, 0,
NUMBER_WIDTH * XI_FU_MULTIPLE, NUMBER_WIDTH, ""); NUMBER_WIDTH * XI_FU_MULTIPLE, NUMBER_WIDTH, "");
coldef->app_data = (long)this; coldef->app_data = (long)this;
@ -190,13 +190,12 @@ TSheet_control::TSheet_control(
for (h = new_header.get(0), i = 0; h; h = new_header.get(), i++) for (h = new_header.get(0), i = 0; h; h = new_header.get(), i++)
{ {
const int cid = FIRST_FIELD+i; // Column & Field ID
long attr = XI_ATR_VISIBLE | XI_ATR_ENABLED | XI_ATR_AUTOSCROLL | XI_ATR_READONLY; long attr = XI_ATR_VISIBLE | XI_ATR_ENABLED | XI_ATR_AUTOSCROLL | XI_ATR_READONLY;
if (_type[i] == 'C') if (_type[i] == 'C')
attr |= XI_ATR_SELECTABLE; attr |= XI_ATR_SELECTABLE;
if (_type[i] == 'R') if (_type[i] == 'R')
attr |= XI_ATR_RJUST; attr |= XI_ATR_RJUST;
coldef = xi_add_column_def(listdef, cid+1000, attr, cid+1001, coldef = xi_add_column_def(listdef, FIRST_FIELD+i+1000, attr, i+1,
v_width[i] * XI_FU_MULTIPLE, m_width[i], (char*)h); v_width[i] * XI_FU_MULTIPLE, m_width[i], (char*)h);
coldef->app_data = (long)this; coldef->app_data = (long)this;
@ -611,7 +610,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
else else
{ {
if (_cur_rec == rec) if (_cur_rec == rec)
_sheet->on_key(K_CTRL+'C'); _sheet->on_key(K_CTRL+'G');
} }
const int c = _type[0] == 'C' ? 2 : 1; const int c = _type[0] == 'C' ? 2 : 1;
XI_OBJ cell; XI_MAKE_CELL(&cell, _obj, row, c); XI_OBJ cell; XI_MAKE_CELL(&cell, _obj, row, c);
@ -705,7 +704,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
_parked(-1), _sheet(NULL), _select_row(-1) _parked(-1), _sheet(NULL), _select_row(-1)
{ {
TQuery_field* qf = new TQuery_field(this); TQuery_field* qf = new TQuery_field(this);
qf->construct(883, head, 1, sht_y, -3, win(), "", -1); qf->construct(30883, head, 1, sht_y, -3, win(), "", -1);
fields_array().add(qf); fields_array().add(qf);
_sheet = qf->sheet(); _sheet = qf->sheet();
@ -716,11 +715,11 @@ TSheet::TSheet(short x, short y, short dx, short dy,
set_handler(DLG_USER, tutti_handler); set_handler(DLG_USER, tutti_handler);
} }
if (buttons & 0x1) add_button(DLG_LINK, "~Collega", K_CTRL+'C', BMP_LINK); if (buttons & 0x1) add_button(DLG_LINK, "~Gestione", K_CTRL+'G');
if (buttons & 0x2) add_button(DLG_NEWREC, "~Nuovo", K_INS, BMP_NEWREC, BMP_NEWRECDN); if (buttons & 0x2) add_button(DLG_NEWREC, "~Nuovo", K_INS, BMP_NEWREC, BMP_NEWRECDN);
if (buttons & 0x4) add_button(DLG_DELREC, "Elimina", K_DEL, BMP_DELREC, BMP_DELRECDN); if (buttons & 0x4) add_button(DLG_DELREC, "Elimina", K_DEL, BMP_DELREC, BMP_DELRECDN);
if (buttons & 0x8) add_button(DLG_QUIT, "Fine", K_ESC); if (buttons & 0x8) add_button(DLG_QUIT, "Fine", K_ESC);
else add_button(DLG_CANCEL, "Annulla", K_ESC); else add_button(DLG_CANCEL, "Annulla", K_ESC);
} }
TSheet::~TSheet() TSheet::~TSheet()
@ -1075,6 +1074,9 @@ bool TBrowse_sheet::browse_field_handler(TMask_field& f, KEY k)
{ {
_cur_browse->select(rec); // Non mettere post_select _cur_browse->select(rec); // Non mettere post_select
_can_post = TRUE; _can_post = TRUE;
RCT r; f.get_rect(r);
xvt_dwin_invalidate_rect(f.parent(), &r);
} }
return TRUE; return TRUE;
} }
@ -1174,6 +1176,8 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
{ {
e->set_handler(browse_field_handler); e->set_handler(browse_field_handler);
e->set(c.get()); e->set(c.get());
if (e->dlg() == f->dlg())
first_focus(e->dlg());
} }
} }
} }

View File

@ -51,18 +51,6 @@ short ROWY = GetSystemMetrics(SM_CYSCREEN) / 25;
short CHARY = 14; short CHARY = 14;
short BASEY = 12; short BASEY = 12;
COLOR MASK_BACK_COLOR = COLOR_DKCYAN;
COLOR MASK_LIGHT_COLOR = COLOR_CYAN;
COLOR MASK_DARK_COLOR = COLOR_GRAY;
COLOR TOOL_BACK_COLOR = COLOR_GRAY;
COLOR NORMAL_COLOR = COLOR_BLACK;
COLOR NORMAL_BACK_COLOR = COLOR_LTGRAY;
COLOR DISABLED_COLOR = COLOR_GRAY;
COLOR DISABLED_BACK_COLOR = MASK_BACK_COLOR;
COLOR FOCUS_COLOR = NORMAL_COLOR;
COLOR FOCUS_BACK_COLOR = COLOR_CYAN;
BOOLEAN CAMPI_SCAVATI = FALSE;
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP"); const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
// By Matt Pietrek // By Matt Pietrek