controls.cpp Allungatto rettangolo campi text

maskfld.cpp     Aggiornato uso collega (ex-gestione)
sheet.cpp       Resi scrollabili campi piu' lunghi del video
sheet.h         Aggiunte bitmap alla add_button


git-svn-id: svn://10.65.10.50/trunk@2842 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-05-16 10:31:27 +00:00
parent 8e1cb4e72a
commit 31114112f2
4 changed files with 44 additions and 27 deletions

@ -806,7 +806,7 @@ TText_control::TText_control(WINDOW win, short cid,
width = t.len();
XI_RCT rct; coord2rct(win, left, top, width, height, rct);
rct.right += bold ? (width*XI_FU_MULTIPLE/4) : XI_FU_MULTIPLE/2;
rct.right += bold ? (width*XI_FU_MULTIPLE/4) : XI_FU_MULTIPLE;
const unsigned long attrib = flags2attr(flags);
XI_OBJ_DEF* def = xi_add_text_def(NULL, cid, &rct, attrib, (char*)(const char*)t);

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

@ -91,14 +91,15 @@ TSheet_control::TSheet_control(
{
const int NUMBER_WIDTH = 7;
short v_width[MAX_COL];
short m_width[MAX_COL];
int fixed_columns = 1; // Number of fixed columns
// Calcolo larghezza massima tabella
TToken_string header(head);
TToken_string new_header(256);
int i = 0, tot_width = NUMBER_WIDTH+1;
int f_width = tot_width<<1; // Stima larghezza colonne fisse
int i = 0;
int f_width = NUMBER_WIDTH; // Stima larghezza colonne fisse
int max_width = f_width; // Stima larghezza della colonna piu' grande
for (const char* h = header.get(); h; h = header.get(), i++)
@ -135,11 +136,12 @@ TSheet_control::TSheet_control(
testa.cut(at);
v = max(at, v);
}
v_width[i] = v+1; // v = width of column
if (v >= max_width) max_width = v+1;
tot_width += v_width[i];
v++;
m_width[i] = v; // v = memory width of column
if (v > 64) v = 64;
v_width[i] = v;
if (v_width[i] > max_width) max_width = v_width[i];
new_header.add(testa);
}
@ -159,7 +161,7 @@ TSheet_control::TSheet_control(
XI_OBJ_DEF* listdef = xi_add_list_def(NULL, cid,
rct.top, rct.left, rct.bottom-rct.top,
XI_ATR_ENABLED | XI_ATR_VISIBLE | XI_ATR_NAVIGATE,
XI_ATR_ENABLED | XI_ATR_VISIBLE,
NORMAL_COLOR, NORMAL_BACK_COLOR, // normal
DISABLED_COLOR, DISABLED_BACK_COLOR, // disabled
FOCUS_COLOR, // active
@ -175,7 +177,6 @@ TSheet_control::TSheet_control(
l->scroll_bar = TRUE;
l->scroll_bar_button = TRUE;
l->white_space_color = MASK_DARK_COLOR;
// l->row_focus_border = TRUE;
// Definizione della prima colonna (numero di riga)
const long attr = XI_ATR_VISIBLE | XI_ATR_RJUST | XI_ATR_SELECTABLE;
@ -190,13 +191,13 @@ 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;
long attr = XI_ATR_VISIBLE | XI_ATR_ENABLED | XI_ATR_AUTOSCROLL;
if (_type[i] == 'C')
attr |= XI_ATR_SELECTABLE;
if (_type[i] == 'R')
attr |= XI_ATR_RJUST;
coldef = xi_add_column_def(listdef, cid, attr, cid+1,
v_width[i] * XI_FU_MULTIPLE, v_width[i], (char*)h);
v_width[i] * XI_FU_MULTIPLE, m_width[i], (char*)h);
coldef->app_data = (long)this;
coldef->v.column->heading_platform = TRUE;
@ -505,11 +506,18 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
src = row(rec).get(col);
break;
}
if (rec == _cur_rec)
{
xiev->v.cell_request.color = FOCUS_COLOR;
xiev->v.cell_request.back_color = FOCUS_BACK_COLOR;
}
if (_disabled[rec])
{
xiev->v.cell_request.color = DISABLED_COLOR;
xiev->v.cell_request.back_color = DISABLED_BACK_COLOR;
}
else
if (rec == _cur_rec)
{
xiev->v.cell_request.color = FOCUS_COLOR;
xiev->v.cell_request.back_color = FOCUS_BACK_COLOR;
}
}
}
else
@ -576,7 +584,13 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
case K_LEND:
rec = items()-1;
break;
default:
case K_TAB:
case K_BTAB:
case K_LEFT:
case K_RIGHT:
break;
default:
refused = TRUE;
break;
}
if (rec >= 0)
@ -600,7 +614,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
{
toggle(rec);
XI_OBJ cell; XI_MAKE_CELL(&cell, _obj, row, col);
xi_cell_request(&cell);
// xi_cell_request(&cell);
}
else
{
@ -611,8 +625,8 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
XI_OBJ cell; XI_MAKE_CELL(&cell, _obj, row,1);
xi_set_focus(&cell);
}
make_current(rec);
}
make_current(rec);
}
refused = TRUE;
break;
@ -646,9 +660,9 @@ TSheet::TSheet(short x, short y, short dx, short dy,
set_handler(DLG_USER, tutti_handler);
}
if (buttons & 0x1) add_button(DLG_LINK, "~Gestione", K_CTRL+'G');
if (buttons & 0x2) add_button(DLG_NEWREC, "Nuovo", K_INS);
if (buttons & 0x4) add_button(DLG_DELREC, "Elimina", K_DEL);
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);
}
@ -665,11 +679,14 @@ TSheet_control& TSheet::sheet()
// @mfunc Aggiunge un bottone nella finestra
void TSheet::add_button(
short id, // @parm Identificatore del bottone da aggiungere
short id, // @parm Identificatore del bottone da aggiungere
const char* caption, // @parm Testo del bottone da aggiungere
KEY key) // @parm Combinazione di tasti corrispondente
KEY key, // @parm Combinazione di tasti corrispondente
short bmp_up, // @parm Bitmap normale
short bmp_dn) // @parm Bitmap premuta
{
TButton_field& butt = TMask::add_button(id, 0, caption, 0, -1, 11, 2, "");
TButton_field& butt = TMask::add_button(id, 0, caption, 0, -1, 11, 2,
"", bmp_up, bmp_dn);
butt.set_hot_key(key);
}

@ -52,7 +52,7 @@ public: // TWindow
public:
// @cmember Aggiunge un bottone nella finestra
void add_button(short id, const char* caption, KEY key);
void add_button(short id, const char* caption, KEY key, short bmp_up = 0, short bmp_dn = 0);
// @cmember Ritorna il numero di elementi di <p _page>
long items() const { return get_items(); }