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

@ -15,7 +15,8 @@ extern COLOR DISABLED_COLOR;
extern COLOR DISABLED_BACK_COLOR;
extern COLOR FOCUS_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_DKYELLOW = MAKE_COLOR(128,128, 0);

View File

@ -10,6 +10,19 @@
#include <urldefid.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
// Very deep hacking
typedef struct _stx_data
@ -161,8 +174,9 @@ void customize_colors()
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);
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_3D_LOOK, TRUE);
@ -525,7 +539,11 @@ void TControl::set_tab_cid(XI_OBJ* obj, short cid) const
obj->v.form->tab_cid = cid;
break;
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:
NFCHECK(0, "Can't set tab_cid to a static control: ", _obj->cid); break;
}
@ -557,7 +575,7 @@ XI_OBJ* TControl::find_operable(XI_OBJ* container, bool forward, bool normal) co
case XIT_FIELD:
if (normal && obj->cid > 0)
found = obj;
break;
break;
case XIT_CONTAINER:
case XIT_FORM:
case XIT_GROUP:
@ -758,7 +776,10 @@ const char* TControl::parse_caption(const char* cap, bool& bold, COLOR& color) c
{
int r = 0, g = 0, b = 0;
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++;
}
@ -990,14 +1011,16 @@ void TField_control::create(WINDOW win, short cid,
{
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);
frm_def->app_data = (long)this;
XI_RCT rct; coord2rct(win, left, top, width, height, rct);
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)
attrib |= XI_ATR_BORDER;
if (maxlen > width)
@ -1237,10 +1260,21 @@ TPushbutton_control::TPushbutton_control(WINDOW win, short cid,
short bmp_up, short bmp_dn)
: _bmp_up(bmp_up), _bmp_dn(bmp_dn)
{
if (bmp_up > 0)
text = "";
{
bool bold;
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);
_obj->v.btn->drawable = TRUE;
*_obj->v.btn->text = '\0';
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)
{
_obj->v.btn->drawable = TRUE;
_picture->add(_bmp_up = bmp_up);
if (bmp_dn > 0)
_picture->add(_bmp_dn = bmp_dn);
else
_bmp_dn = _bmp_up;
if (_obj->v.btn->text)
*_obj->v.btn->text = '\0';
}
else
{
_obj->v.btn->drawable = FALSE;
_bmp_up = _bmp_dn = 0;
}
}
@ -1267,6 +1297,8 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
void TPushbutton_control::update()
{
const long attrib = xi_get_attrib(_obj);
const WINDOW win = parent();
if (attrib & XI_ATR_VISIBLE)
{
const short bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up;
@ -1282,8 +1314,7 @@ void TPushbutton_control::update()
y += 2;
}
const WINDOW w = parent();
i.draw(w, x, y);
i.draw(win, x, y);
if (!(attrib & XI_ATR_ENABLED))
{
CPEN pen;
@ -1291,23 +1322,55 @@ void TPushbutton_control::update()
pen.pat = PAT_SOLID;
pen.style = P_SOLID;
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)
{
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();
xvt_dwin_draw_line(w, p);
xvt_dwin_draw_line(win, p);
}
for (int px = x + i.width(); px >= x; px -= 2)
{
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();
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; }
// @cmember Ritorna il prompt del controllo
const char* caption() const;
virtual const char* caption() const;
// @cmember Setta il prompt del controllo
virtual void set_caption(const char* c);
@ -167,10 +167,8 @@ public:
virtual ~TMultiline_control() {}
};
class TButton_control : public TControl
{
{
protected:
void create(WINDOW win, short cid,
short left, short top, short width, short height,
@ -195,12 +193,15 @@ public:
};
class TPushbutton_control : public TButton_control
{
{
TString _caption;
int _underscore;
short _bmp_up, _bmp_dn;
protected:
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* xiev);
virtual const char* caption() const { return _caption; }
public:
virtual void update();

View File

@ -624,7 +624,7 @@ void TForm_item::enable(
// @flag TRUE | Il campo viene abiliato
// @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;
show(on);

View File

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

View File

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

View File

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

View File

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

View File

@ -180,7 +180,7 @@ TSheet_control::TSheet_control(
l->rule_color = MASK_DARK_COLOR;
// Definizione della prima colonna (numero di riga)
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, "");
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++)
{
const int cid = FIRST_FIELD+i; // Column & Field ID
long attr = XI_ATR_VISIBLE | XI_ATR_ENABLED | XI_ATR_AUTOSCROLL | XI_ATR_READONLY;
if (_type[i] == 'C')
attr |= XI_ATR_SELECTABLE;
if (_type[i] == 'R')
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);
coldef->app_data = (long)this;
@ -611,7 +610,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
else
{
if (_cur_rec == rec)
_sheet->on_key(K_CTRL+'C');
_sheet->on_key(K_CTRL+'G');
}
const int c = _type[0] == 'C' ? 2 : 1;
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)
{
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);
_sheet = qf->sheet();
@ -716,11 +715,11 @@ TSheet::TSheet(short x, short y, short dx, short dy,
set_handler(DLG_USER, tutti_handler);
}
if (buttons & 0x1) add_button(DLG_LINK, "~Collega", K_CTRL+'C', BMP_LINK);
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 & 0x8) add_button(DLG_QUIT, "Fine", K_ESC);
else add_button(DLG_CANCEL, "Annulla", K_ESC);
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 & 0x4) add_button(DLG_DELREC, "Elimina", K_DEL, BMP_DELREC, BMP_DELRECDN);
if (buttons & 0x8) add_button(DLG_QUIT, "Fine", K_ESC);
else add_button(DLG_CANCEL, "Annulla", K_ESC);
}
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
_can_post = TRUE;
RCT r; f.get_rect(r);
xvt_dwin_invalidate_rect(f.parent(), &r);
}
return TRUE;
}
@ -1174,6 +1176,8 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
{
e->set_handler(browse_field_handler);
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 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");
// By Matt Pietrek