1994-11-10 14:17:03 +00:00
|
|
|
#include <applicat.h>
|
|
|
|
#include <colors.h>
|
1994-12-07 11:10:57 +00:00
|
|
|
#include <mask.h>
|
1995-04-20 14:35:14 +00:00
|
|
|
#include <printer.h>
|
1994-11-10 14:17:03 +00:00
|
|
|
#include <relation.h>
|
|
|
|
#include <sheet.h>
|
|
|
|
#include <urldefid.h>
|
|
|
|
#include <utility.h>
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TSheet
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
TSheet::TSheet(short x, short y, short dx, short dy,
|
|
|
|
const char* title, const char* head, byte buttons,
|
|
|
|
long first, WINDOW parent)
|
|
|
|
: _curr(first), _last_update(-1), _checkable(FALSE),
|
|
|
|
_check_enabled(TRUE), _buttonmask(buttons)
|
|
|
|
{
|
|
|
|
const char* g;
|
|
|
|
|
|
|
|
TToken_string new_head(512);
|
|
|
|
TToken_string h(head);
|
|
|
|
TString item(80);
|
|
|
|
|
|
|
|
for(_columns = 0; (g = h.get()) != NULL; _columns++)
|
|
|
|
{
|
1995-07-19 09:57:25 +00:00
|
|
|
CHECK(_columns < MAX_COL, "Too many columns in sheet ");
|
1994-11-10 14:17:03 +00:00
|
|
|
item = g;
|
|
|
|
|
|
|
|
const int et = item.find('@');
|
|
|
|
if (et >= 0)
|
|
|
|
{
|
|
|
|
const char t = item.right(1)[0];
|
|
|
|
_type[_columns] = isalpha(t) ? toupper(t) : '\0';
|
|
|
|
const int l = atoi(item.mid(et+1));
|
|
|
|
item.cut(et);
|
|
|
|
if (_columns == 0 && et == 0 && l <= 1)
|
|
|
|
_checkable = _size[0] = 1;
|
|
|
|
else
|
|
|
|
_size[_columns] = l > 0 ? l : item.len();
|
1994-12-02 13:30:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_size[_columns] = item.len();
|
|
|
|
_type[_columns] = '\0';
|
|
|
|
}
|
1995-03-22 09:07:04 +00:00
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
item.trim();
|
|
|
|
new_head.add(item);
|
|
|
|
}
|
|
|
|
set_row(new_head, -1);
|
|
|
|
|
|
|
|
for (int i = 0; i < MAX_BUT; i++) _button[i] = NULL_WIN;
|
|
|
|
|
|
|
|
if (parent == NULL_WIN) parent = TASK_WIN;
|
|
|
|
|
|
|
|
long flags = WSF_CLOSE | WSF_SIZE | WSF_VSCROLL | WSF_HSCROLL ;
|
|
|
|
WIN_TYPE wt = W_DOC;
|
|
|
|
|
|
|
|
if (parent != TASK_WIN)
|
|
|
|
{
|
|
|
|
wt = W_PLAIN;
|
|
|
|
flags = WSF_VSCROLL;
|
|
|
|
}
|
|
|
|
|
1995-05-09 13:33:34 +00:00
|
|
|
if (dx == 0) // Compute window width
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
RCT r; xvt_vobj_get_client_rect(parent, &r);
|
1994-11-10 14:17:03 +00:00
|
|
|
dx = r.right/CHARX -6;
|
|
|
|
|
|
|
|
const int larg = width();
|
|
|
|
if (dx > larg) dx = larg;
|
|
|
|
}
|
1995-05-09 13:33:34 +00:00
|
|
|
if (dy == 0) dy = 20; // Compute window height
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
create(x, y, dx, dy, title, flags, wt, parent);
|
1995-07-19 09:57:25 +00:00
|
|
|
if (wt != W_PLAIN) // If normal sheet add buttons
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
_visible_rows = rows()- head_on() - 3;
|
|
|
|
|
1995-05-16 09:35:12 +00:00
|
|
|
add_button(DLG_SELECT, "Selezione", K_ENTER);
|
1995-01-05 17:50:40 +00:00
|
|
|
if (_checkable) add_button(DLG_USER, "Tutti");
|
1995-05-16 09:35:12 +00:00
|
|
|
if (buttons & 0x1) add_button(DLG_LINK, "Gestione", K_INS);
|
|
|
|
if (buttons & 0x2) add_button(DLG_NEWREC, "~Nuovo", K_CTRL+'N');
|
|
|
|
if (buttons & 0x4) add_button(DLG_DELREC, "Elimina", K_DEL);
|
|
|
|
if (buttons & 0x8) add_button(DLG_QUIT, "Fine", K_ESC);
|
|
|
|
else add_button(DLG_CANCEL, "Annulla", K_ESC);
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @mfunc Aggiunge un bottone nella finestra
|
|
|
|
void TSheet::add_button(
|
|
|
|
short id, // @parm Identificatore del bottone da aggiungere
|
|
|
|
const char* caption, // @parm Testo del bottone da aggiungere
|
|
|
|
KEY key) // @parm Combinazione di tasti corrispondente
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
const int BUT_HEIGHT = 2;
|
|
|
|
#else
|
|
|
|
const int BUT_HEIGHT = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
WINDOW b = xvt_create_control(WC_PUSHBUTTON, 0, 0, 11, BUT_HEIGHT, caption, win(), 0, 0, id);
|
|
|
|
for (int i = 0; i < MAX_BUT; i++)
|
|
|
|
if (_button[i] == NULL_WIN)
|
|
|
|
{
|
|
|
|
_button[i] = b;
|
|
|
|
_key[i] = key;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSheet::repos_buttons() const
|
|
|
|
{
|
|
|
|
for (int buttons = 0; _button[buttons] != NULL_WIN; buttons++)
|
|
|
|
if (buttons == MAX_BUT-1) { buttons++; break; }
|
|
|
|
if (buttons == 0) return;
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
RCT wr; xvt_vobj_get_client_rect(win(), &wr);
|
|
|
|
RCT br; xvt_vobj_get_client_rect(_button[0], &br);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
int space = (wr.right - buttons * br.right) / (buttons+1);
|
|
|
|
if (space < 0) space = 0;
|
|
|
|
|
|
|
|
int x = space;
|
|
|
|
const int y = wr.bottom - br.bottom-4;
|
|
|
|
for (int b = 0; b < buttons; b++, x += br.right+space)
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
RCT r; xvt_rect_set(&r, x, y, x+br.right, y+br.bottom);
|
|
|
|
xvt_vobj_move(_button[b], &r);
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSheet::open()
|
|
|
|
{
|
|
|
|
set_scroll_max(width(), items());
|
|
|
|
_last_update = -1;
|
|
|
|
|
|
|
|
if (!is_visible(_curr)) set_first(_curr);
|
|
|
|
|
|
|
|
if (buttons_on())
|
|
|
|
{
|
|
|
|
// Abilita selezione se c'e' almeno un elemento
|
1995-02-13 17:21:25 +00:00
|
|
|
xvt_enable_control(_button[0], items() > 0 && _disabled.ones() < items());
|
1995-05-09 13:33:34 +00:00
|
|
|
|
|
|
|
if (_checkable)
|
|
|
|
xvt_enable_control(_button[1], items() > 0 && _check_enabled);
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
repos_buttons();
|
|
|
|
}
|
|
|
|
TScroll_window::open();
|
|
|
|
force_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TSheet::set_first(long n)
|
|
|
|
{
|
|
|
|
update_thumb(-1, n);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
void TSheet::set_row(const TToken_string& r, byte i)
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
if (i > 64) i = 0; else i++;
|
1994-12-27 14:59:25 +00:00
|
|
|
_page.add(r, i);
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @mfunc Crea la pagina
|
|
|
|
void TSheet::build_page(
|
|
|
|
long from) // @parm Numero della prima riga da visualizzare
|
|
|
|
|
|
|
|
// @comm Carica le righe visibili
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
const long f = (from < 0) ? first() : from;
|
|
|
|
|
|
|
|
if (_last_update != f)
|
|
|
|
{
|
|
|
|
int r = visible_rows();
|
|
|
|
if (f+r > items())
|
|
|
|
r = int(items()-f);
|
|
|
|
if (r > 0)
|
|
|
|
page_build(f, r);
|
|
|
|
_last_update = f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
short TSheet::reserved_rows() const
|
|
|
|
{
|
|
|
|
return buttons_on() ? 3 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TSheet::handler(WINDOW win, EVENT* ep)
|
|
|
|
{
|
|
|
|
switch(ep->type)
|
|
|
|
{
|
|
|
|
case E_FOCUS:
|
|
|
|
invert_row(selected());
|
|
|
|
break;
|
|
|
|
case E_MOUSE_DOWN:
|
|
|
|
if (ep->v.mouse.button)
|
|
|
|
{
|
|
|
|
dispatch_e_char(win, K_ESC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case E_MOUSE_DBL:
|
|
|
|
{
|
|
|
|
const short y = ep->v.mouse.where.v / CHARY;
|
|
|
|
const short f = head_on() ? 1 : 0;
|
|
|
|
if (y >= f)
|
|
|
|
{
|
1995-05-09 13:33:34 +00:00
|
|
|
const long vec = selected();
|
|
|
|
const long nuo = first()+y-f;
|
1994-11-10 14:17:03 +00:00
|
|
|
select(nuo);
|
|
|
|
if (ep->type == E_MOUSE_DBL)
|
|
|
|
dispatch_e_char(win, K_ENTER);
|
1995-07-03 07:49:30 +00:00
|
|
|
else if (vec == nuo)
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
1996-01-25 17:21:42 +00:00
|
|
|
// dispatch_e_char(win, K_SPACE); // Cosi' lo interpreta come spazio nel campo di edit!!!
|
|
|
|
TSheet::on_key(K_SPACE); // Mette l'eventuale segno di check
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dispatch_e_char(win, y ? K_UP : K_PREV);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_CONTROL:
|
|
|
|
switch(ep->v.ctl.id)
|
|
|
|
{
|
1995-05-16 09:35:12 +00:00
|
|
|
/*
|
|
|
|
case DLG_OK :
|
|
|
|
case DLG_SELECT:
|
|
|
|
dispatch_e_char(win, K_ENTER); break;
|
|
|
|
case DLG_CANCEL:
|
|
|
|
case DLG_QUIT :
|
|
|
|
dispatch_e_char(win, K_ESC); break;
|
|
|
|
case DLG_NEWREC:
|
|
|
|
dispatch_e_char(win, K_CTRL+'N'); break;
|
|
|
|
case DLG_LINK:
|
|
|
|
dispatch_e_char(win, K_INS); break;
|
|
|
|
case DLG_DELREC:
|
|
|
|
dispatch_e_char(win, K_DEL); break;
|
|
|
|
*/
|
1995-01-05 17:50:40 +00:00
|
|
|
case DLG_USER:
|
|
|
|
dispatch_e_char(win, one_checked() ? K_F2 : K_F3); break;
|
1994-11-10 14:17:03 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
const WINDOW b = ep->v.ctl.ci.win;
|
|
|
|
for (int i = 0; i < MAX_BUT; i++)
|
|
|
|
if (_button[i] == b)
|
|
|
|
{
|
1995-06-01 16:14:49 +00:00
|
|
|
// stop_run(_key[i]);
|
|
|
|
on_key(_key[i]);
|
|
|
|
return;
|
1994-11-10 14:17:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_SIZE:
|
|
|
|
{
|
|
|
|
_last_update = -1;
|
|
|
|
_visible_rows = ep->v.size.height/CHARY - (head_on() ? 1 : 0);
|
|
|
|
if (buttons_on())
|
|
|
|
{
|
|
|
|
_visible_rows -= reserved_rows();
|
|
|
|
repos_buttons();
|
|
|
|
}
|
|
|
|
force_update();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TScroll_window::handler(win, ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @func ???!!!???
|
1994-11-10 14:17:03 +00:00
|
|
|
PNT TSheet::log2dev(long x, long y) const
|
|
|
|
{
|
|
|
|
if (autoscrolling()) x -= origin().x;
|
|
|
|
return TWindow::log2dev(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TSheet::on_key(KEY key)
|
|
|
|
{
|
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case K_ENTER:
|
1995-02-13 17:21:25 +00:00
|
|
|
if (items() == 0) key = K_ESC;
|
|
|
|
if (selected() < 0 || _disabled[selected()])
|
1994-12-27 14:59:25 +00:00
|
|
|
break;
|
1994-11-10 14:17:03 +00:00
|
|
|
case K_ESC:
|
|
|
|
stop_run(key);
|
|
|
|
case K_DEL:
|
|
|
|
if ((_buttonmask & 0x4) && items())
|
|
|
|
stop_run(key);
|
|
|
|
break;
|
|
|
|
case K_INS:
|
1995-05-16 09:35:12 +00:00
|
|
|
if (_buttonmask & 0x1)
|
|
|
|
stop_run(key);
|
|
|
|
break;
|
|
|
|
case K_CTRL+'N':
|
|
|
|
if (_buttonmask & 0x2)
|
|
|
|
stop_run(key);
|
1994-11-10 14:17:03 +00:00
|
|
|
break;
|
|
|
|
case K_LHOME:
|
|
|
|
select(0);
|
|
|
|
return TRUE;
|
|
|
|
case K_LEND:
|
|
|
|
select(items()-1);
|
|
|
|
return TRUE;
|
|
|
|
case K_PREV:
|
|
|
|
select(selected()-visible_rows());
|
|
|
|
return TRUE;
|
|
|
|
case K_UP:
|
|
|
|
select(selected()-1);
|
|
|
|
return TRUE;
|
|
|
|
case K_NEXT:
|
|
|
|
select(selected()+visible_rows());
|
|
|
|
return TRUE;
|
|
|
|
case K_DOWN:
|
|
|
|
select(selected()+1);
|
|
|
|
return TRUE;
|
|
|
|
case K_CTRL+'P':
|
|
|
|
print();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
for (int i = 0; i < MAX_BUT; i++)
|
|
|
|
if (_key[i] == key)
|
|
|
|
{
|
1995-06-01 16:14:49 +00:00
|
|
|
if (key != K_ENTER || !_disabled[selected()])
|
|
|
|
stop_run(key);
|
1994-11-10 14:17:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_checkable && _check_enabled && items() > 0)
|
|
|
|
{
|
|
|
|
switch(key)
|
|
|
|
{
|
1994-12-02 13:30:45 +00:00
|
|
|
case K_SPACE:
|
1995-01-24 08:52:49 +00:00
|
|
|
check(selected(), !checked(selected()));
|
1994-12-02 13:30:45 +00:00
|
|
|
break;
|
|
|
|
case K_F2:
|
|
|
|
uncheck(-1);
|
|
|
|
break;
|
|
|
|
case K_F3:
|
|
|
|
check(-1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
return TScroll_window::on_key(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @mfunc Abilita/disabilita una riga
|
|
|
|
void TSheet::enable(
|
|
|
|
long n, // @parm Numero della riga da abilitare/diabilitare (default -1)
|
|
|
|
bool on) // @parm Operazione da svolgere sulla riga
|
|
|
|
//
|
|
|
|
// @flag TRUE | Abilita la riga <p n>-esima (default)
|
|
|
|
// @flag FALSE | Disabilita la riga <p n>-esima
|
|
|
|
|
|
|
|
// @comm Se <p n> e' minore di 0 allora vengono abilitate/disabilitate tutte le righe
|
1994-12-27 14:59:25 +00:00
|
|
|
{
|
|
|
|
if (n >= 0)
|
|
|
|
_disabled.set(n, !on);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (on)
|
|
|
|
_disabled.reset();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_disabled.set(items());
|
|
|
|
_disabled.set();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @mfunc Seleziona una riga facendola diventare corrente
|
|
|
|
void TSheet::select(
|
|
|
|
long n) // @parm Riga da selezionare (default -1)
|
1994-12-27 14:59:25 +00:00
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @comm Se <p n> assume un valore minore di 1 viene selezionata la prima riga.
|
|
|
|
// <nl>Nela caso si cerci di selezionare una riga maggiore di quelle presenti viene selezionata
|
|
|
|
// l'ultima.
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
if (n < 0) n = 0; else
|
|
|
|
if (n >= items()) n = items()-1;
|
|
|
|
|
|
|
|
invert_row(_curr);
|
|
|
|
_curr = n;
|
|
|
|
|
|
|
|
if (is_visible(_curr))
|
|
|
|
invert_row(_curr);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const long s = (_curr < first()) ? _curr : _curr-visible_rows()+1;
|
|
|
|
set_first(s);
|
|
|
|
force_update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @mfunc Permette di attivare/disattivare una riga
|
|
|
|
void TSheet::check(
|
|
|
|
long n, // @parm Numero della riga da attivare/disattivare
|
|
|
|
bool on) // @parm Operazione da effettuare sulla riga:
|
|
|
|
//
|
|
|
|
// @flag TRUE | Attiva la riga <p n>.esima (default)
|
|
|
|
// @flag FALSE | Disttiva la riga <p n>.esima
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
1995-01-24 08:52:49 +00:00
|
|
|
long s = selected();
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
if (n < 0)
|
|
|
|
{
|
|
|
|
if (on)
|
|
|
|
{
|
|
|
|
_checked.set(items()-1); // Force the size of Bit_array
|
|
|
|
_checked.set();
|
1995-01-24 08:52:49 +00:00
|
|
|
|
|
|
|
if (on && _disabled.first_one() >= 0)
|
|
|
|
{
|
|
|
|
for (long i = 0; i < items(); i++)
|
|
|
|
if (_disabled[i]) _checked.reset(i);
|
|
|
|
else s = i;
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
_checked.reset();
|
|
|
|
}
|
1995-01-24 08:52:49 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!_disabled[n])
|
|
|
|
_checked.set(n, on);
|
|
|
|
}
|
|
|
|
|
|
|
|
force_update();
|
|
|
|
select(s);
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Converte il numero di riga assoluto nell'indice dell'array _page
|
|
|
|
int TSheet::row_to_page(long n) const
|
|
|
|
{
|
|
|
|
long i = (n < 0) ? 0L : n-first()+1;
|
1995-10-31 11:37:59 +00:00
|
|
|
#ifdef DBG
|
1994-11-10 14:17:03 +00:00
|
|
|
if (i < 0 || i > visible_rows())
|
|
|
|
{
|
1995-10-31 11:37:59 +00:00
|
|
|
yesnofatal_box("Line out of screen: %ld", n);
|
|
|
|
i = 1;
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
1995-10-31 11:37:59 +00:00
|
|
|
#endif
|
1994-11-10 14:17:03 +00:00
|
|
|
return (int)i;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Converte il numero di riga assoluto nella coordinata y sulla finestra
|
|
|
|
int TSheet::row_to_win(long n) const
|
|
|
|
{
|
|
|
|
int y = row_to_page(n);
|
|
|
|
|
|
|
|
if (y < 1) y = 0; else
|
|
|
|
if (!head_on()) y--;
|
|
|
|
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Calcola la larghezza totale dello sheet virtuale
|
|
|
|
int TSheet::width() const
|
|
|
|
{
|
|
|
|
int width = 0;
|
|
|
|
for (int c = 0; c < _columns; c++)
|
|
|
|
width += _size[c]+(c > 0);
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSheet::invert_row(long n)
|
|
|
|
{
|
|
|
|
if (win() != NULL_WIN && is_visible(n))
|
|
|
|
{
|
|
|
|
const short y = row_to_win(n);
|
|
|
|
autoscroll(FALSE);
|
|
|
|
invert_bar(0,y,columns(),y+1);
|
|
|
|
autoscroll(TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @mfunc Forza il ridisegno di una riga.
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna se e' riuscito a fare il ridisegno (cioe' se la riga era visibile)
|
|
|
|
bool TSheet::update_row(
|
|
|
|
long n) // @parm Numero della riga da ridisegnare
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
const int i = row_to_page(n);
|
|
|
|
if (i >= _page.items()) return FALSE;
|
1995-03-22 09:07:04 +00:00
|
|
|
TToken_string& t = _page.row(i);
|
1994-11-10 14:17:03 +00:00
|
|
|
t.restart();
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
const bool chk = n >= 0 && _checked[n] && !_disabled[n];
|
1994-12-29 14:51:43 +00:00
|
|
|
bool changed = FALSE;
|
|
|
|
|
|
|
|
if (chk)
|
|
|
|
{
|
1995-04-10 15:28:03 +00:00
|
|
|
set_color(FOCUS_COLOR, NORMAL_BACK_COLOR);
|
1995-03-22 09:07:04 +00:00
|
|
|
changed = TRUE;
|
1994-12-29 14:51:43 +00:00
|
|
|
}
|
|
|
|
else if (_disabled[n])
|
|
|
|
{
|
1995-01-03 14:19:41 +00:00
|
|
|
set_color(DISABLED_COLOR, NORMAL_BACK_COLOR);
|
1994-12-29 14:51:43 +00:00
|
|
|
changed = TRUE;
|
|
|
|
}
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
if (n < 0)
|
1995-04-11 08:36:14 +00:00
|
|
|
set_font("", XVT_FS_NONE, 0);
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
|
|
int minx = (int)origin().x;
|
|
|
|
int maxx = minx + columns();
|
|
|
|
minx -= 80;
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
const int y = row_to_win(n);
|
|
|
|
const char* s;
|
|
|
|
|
|
|
|
for (int j = 0; x < maxx && (s = t.get()) != NULL; x += _size[j++]+1) if (x > minx)
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
int x1 = x;
|
|
|
|
if (n >= 0)
|
|
|
|
{
|
|
|
|
if (_checkable && j == 0)
|
1994-12-29 14:51:43 +00:00
|
|
|
{
|
|
|
|
s = chk ? "X" : " ";
|
1994-12-28 11:01:33 +00:00
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
switch (_type[j])
|
|
|
|
{
|
|
|
|
case 'R':
|
|
|
|
x1 += _size[j]-strlen(s); // Allinea a destra
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
s = itor(atoi(s)); // Numeri romani
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1995-03-22 09:07:04 +00:00
|
|
|
{
|
1994-11-10 14:17:03 +00:00
|
|
|
x1 += (_size[j]-strlen(s)) >> 1; // Centra le testate
|
1995-03-22 09:07:04 +00:00
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
stringat(x1, y, s);
|
|
|
|
}
|
1994-12-29 14:51:43 +00:00
|
|
|
if (changed)
|
1995-01-03 14:19:41 +00:00
|
|
|
set_color(NORMAL_COLOR, NORMAL_BACK_COLOR);
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
|
|
if (n < 0)
|
|
|
|
set_font("", XVT_FS_NONE, 0);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @mfunc Ritorna il contenuto di una riga
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna la <c TToken_string> con tutti gli elemnti della riga
|
|
|
|
TToken_string& TSheet::row(
|
|
|
|
long n) // @parm Riga di cui ritorna il contenuto (default -1)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @comm Se viene passato un numero di riga minore di 1 viene ritornato il contenuto della riga
|
|
|
|
// selezionata.
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
if (n < 0) n = selected();
|
1995-12-01 11:49:11 +00:00
|
|
|
|
|
|
|
int idx = 1;
|
|
|
|
// if (!is_visible(n) || _last_update < 0)
|
|
|
|
if (_last_update < 0 || n < _last_update || n >= _last_update + _page.items() -1)
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
1995-12-01 11:49:11 +00:00
|
|
|
// if (_last_update < 0)
|
|
|
|
// set_scroll_max(width(), items());
|
1995-10-31 11:37:59 +00:00
|
|
|
build_page(n);
|
1995-12-01 11:49:11 +00:00
|
|
|
// set_first(n);
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
1995-12-01 11:49:11 +00:00
|
|
|
else
|
|
|
|
idx = int(n - _last_update) + 1;
|
|
|
|
// const int idx = row_to_page(n);
|
1994-11-10 14:17:03 +00:00
|
|
|
return (TToken_string&)_page[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TSheet::update()
|
|
|
|
{
|
|
|
|
if (_last_update < 0)
|
|
|
|
{
|
1995-01-03 14:19:41 +00:00
|
|
|
set_color(NORMAL_COLOR, NORMAL_BACK_COLOR);
|
|
|
|
set_pen(NORMAL_COLOR);
|
|
|
|
set_brush(NORMAL_BACK_COLOR);
|
1995-04-11 08:36:14 +00:00
|
|
|
set_font("", XVT_FS_NONE, 0);
|
1994-11-10 14:17:03 +00:00
|
|
|
_visible_rows = rows() - reserved_rows() - head_on();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (head_on())
|
|
|
|
{
|
|
|
|
const int height = visible_rows()+1;
|
|
|
|
const int width = columns()+1;
|
|
|
|
short x = -1;
|
|
|
|
for (int c = 0; c < _columns; c++)
|
|
|
|
{
|
|
|
|
x += _size[c] + 1;
|
|
|
|
line(x,0,x,height);
|
|
|
|
}
|
|
|
|
autoscroll(FALSE);
|
|
|
|
set_brush(MASK_BACK_COLOR);
|
|
|
|
bar(0,0,width,1);
|
|
|
|
if (buttons_on())
|
|
|
|
bar(0, height, width, height+reserved_rows()+1);
|
|
|
|
autoscroll(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
build_page();
|
|
|
|
if (head_on()) update_row(-1);
|
|
|
|
|
|
|
|
long last = first() + visible_rows();
|
|
|
|
if (last > items()) last = items();
|
|
|
|
for (long n = first(); n < last; n++) update_row(n);
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
if (xvt_scr_get_focus_vobj() == win())
|
1994-11-10 14:17:03 +00:00
|
|
|
invert_row(selected());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSheet::print()
|
|
|
|
{
|
1995-04-20 14:35:14 +00:00
|
|
|
TPrinter& pr = printer();
|
1994-11-10 14:17:03 +00:00
|
|
|
TPrintrow row;
|
|
|
|
bool ok = pr.open();
|
1995-01-03 15:06:43 +00:00
|
|
|
|
|
|
|
main_app().begin_wait();
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
int step = visible_rows();
|
|
|
|
for (long n = 0L; ok && n < items(); n += step)
|
|
|
|
{
|
|
|
|
set_first(n);
|
|
|
|
build_page();
|
|
|
|
|
|
|
|
if ((n+step) > items()) step = int(items()-n);
|
|
|
|
for (int i = 1; ok && i <= step; i++)
|
|
|
|
{
|
|
|
|
const char* s;
|
|
|
|
|
|
|
|
TToken_string& t = (TToken_string&)_page[i];
|
|
|
|
t.restart();
|
|
|
|
|
|
|
|
row.reset();
|
|
|
|
for (int j = 0, x = 0; (s = t.get()) != NULL; x += _size[j++]+1)
|
|
|
|
row.put(s, x);
|
|
|
|
|
|
|
|
ok = pr.print(row);
|
|
|
|
}
|
|
|
|
}
|
1995-01-03 15:06:43 +00:00
|
|
|
|
|
|
|
main_app().end_wait();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
pr.formfeed();
|
|
|
|
pr.close();
|
|
|
|
}
|
|
|
|
set_focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TArray_sheet
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
TArray_sheet::TArray_sheet(short x, short y, short dx, short dy,
|
|
|
|
const char* caption, const char* head, byte buttons, WINDOW parent)
|
|
|
|
: TSheet(x, y, dx, dy, caption, head, buttons, 0L, parent)
|
1995-02-13 17:21:25 +00:00
|
|
|
{
|
|
|
|
select(0);
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
// Certified 90%
|
1994-12-29 14:51:43 +00:00
|
|
|
bool TArray_sheet::destroy(int i)
|
|
|
|
{
|
|
|
|
uncheck(-1);
|
|
|
|
enable(-1);
|
|
|
|
return _data.destroy(i, TRUE);
|
|
|
|
}
|
1995-03-22 09:07:04 +00:00
|
|
|
// Certified 100%
|
1995-10-24 18:19:10 +00:00
|
|
|
// @mfunc Copia le righe nella pagina da visualizzare
|
|
|
|
void TArray_sheet::page_build(
|
|
|
|
long first, // @parm Prima riga da visualizzare
|
|
|
|
byte num) // @parm Numero di righe da vsiualizzare
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
for (byte i = 0; i < num; i++)
|
|
|
|
set_row(data(first+i), i);
|
|
|
|
}
|
|
|
|
|
1995-10-24 18:19:10 +00:00
|
|
|
// @mfunc Aggiunge un elemento allo sheet
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna il numero di elemnti presenti nello sheet
|
|
|
|
long TArray_sheet::add(
|
|
|
|
const TToken_string& s) // @parm Oggetto da aggiungere
|
|
|
|
// @parm const TToken_string | *s | Oggetto da aggiungere passato per indirizzo
|
|
|
|
|
|
|
|
// @syntax add(const TToken_string& s)
|
|
|
|
// @syntax add(const TToken_string* s)
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
const long n = _data.add(s, -1);
|
|
|
|
set_scroll_max(-1, n);
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
long TArray_sheet::add(TToken_string* s)
|
|
|
|
{
|
1994-12-27 14:59:25 +00:00
|
|
|
const long n = _data.add(s);
|
1994-11-10 14:17:03 +00:00
|
|
|
set_scroll_max(-1, n);
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
long TArray_sheet::insert(const TToken_string& s, long n)
|
|
|
|
{
|
|
|
|
_data.insert(s, (int)n);
|
|
|
|
set_scroll_max(-1, items());
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TCursor_sheet
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
TCursor_sheet::TCursor_sheet(TCursor* cursor, const char* fields,
|
|
|
|
const char* title, const char* head, byte buttons)
|
|
|
|
: TSheet(-1,-1, 0, 0, title,head,buttons,cursor->pos()),
|
|
|
|
_cursor(cursor), _records(cursor->items())
|
|
|
|
{
|
|
|
|
TToken_string fldlst(fields);
|
1995-03-22 09:07:04 +00:00
|
|
|
int campo = 0;
|
|
|
|
for (const char* t = fldlst.get(0); t; t = fldlst.get(), campo++)
|
1994-11-10 14:17:03 +00:00
|
|
|
if (*t > ' ' && *t != '"')
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
const TFieldref fr(t, 0);
|
1994-11-10 14:17:03 +00:00
|
|
|
TRecfield* rf = new TRecfield(_cursor->curr(fr.file()),
|
|
|
|
fr.name(), fr.from(), fr.to() - 1);
|
1995-03-22 09:07:04 +00:00
|
|
|
_fields.add(rf, campo);
|
|
|
|
|
|
|
|
const TFieldtypes tipo = rf->type();
|
|
|
|
if (tipo == _intfld || tipo == _longfld || tipo == _realfld)
|
|
|
|
{
|
|
|
|
byte& c = column_flag(campo);
|
|
|
|
if (c == '\0') c = 'R'; // Allinea a destra tutti i campi numerici
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KEY TCursor_sheet::run()
|
|
|
|
{
|
|
|
|
_records = _cursor->items();
|
|
|
|
_cursor->freeze(TRUE);
|
|
|
|
const KEY k = TSheet::run();
|
|
|
|
_cursor->freeze(FALSE);
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TCursor_sheet::page_build(long first, byte rows)
|
|
|
|
{
|
|
|
|
TToken_string l(256);
|
|
|
|
|
|
|
|
*_cursor = (TRecnotype)first;
|
1995-03-22 09:07:04 +00:00
|
|
|
for (int r = 0; r < rows; r++, ++(*_cursor))
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
l.cut(0);
|
|
|
|
const int last = _fields.last();
|
|
|
|
for (int i = 0; i <= last; i++)
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
const TRecfield* rf = (TRecfield*)_fields.objptr(i);
|
|
|
|
const char* s = rf ? (const char*)*rf : "";
|
1994-11-10 14:17:03 +00:00
|
|
|
l.add(s);
|
|
|
|
}
|
|
|
|
set_row(l, r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TBrowse_sheet
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
|
|
|
|
const char* title, const char* head, byte buttons,
|
|
|
|
TEdit_field* f, TToken_string* s)
|
|
|
|
: TCursor_sheet(cursor, fields, title, head, buttons), _field(f)
|
|
|
|
|
|
|
|
{
|
1995-01-02 09:33:00 +00:00
|
|
|
if (field().browse()->inputs() == 1 && cursor->items() > 0)
|
|
|
|
{
|
|
|
|
#if XVT_OS == XVT_OS_SCOUNIX
|
|
|
|
const int s = f->size()+2;
|
|
|
|
#else
|
|
|
|
const int s = f->size()+1;
|
1994-11-10 14:17:03 +00:00
|
|
|
#endif
|
1995-01-02 09:33:00 +00:00
|
|
|
xvt_create_control(WC_EDIT, 1, -3, s, 1, f->get(), win(),
|
1995-01-05 17:50:40 +00:00
|
|
|
CTL_FLAG_DISABLED, 0L, DLG_EDIT);
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
|
1995-05-09 13:33:34 +00:00
|
|
|
if (s && s->items() > 0)
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
int maxlen = 0;
|
1995-03-22 09:07:04 +00:00
|
|
|
SLIST lst = xvt_slist_create();
|
1994-11-10 14:17:03 +00:00
|
|
|
for (const char* item = s->get(0); item; item = s->get())
|
|
|
|
{
|
|
|
|
item = s->get();
|
|
|
|
const int len = strlen(item);
|
|
|
|
if (len > maxlen) maxlen = len;
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_slist_add_at_elt(lst, (SLIST_ELT)NULL, (char*)item, 0L);
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WINDOW listbox = xvt_create_control(WC_LISTBUTTON, f->size()+3, -3, maxlen+3, 3,
|
1995-01-05 17:50:40 +00:00
|
|
|
"", win(), 0, 0L, DLG_FINDREC);
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_list_add(listbox, -1, (char*)lst);
|
|
|
|
xvt_slist_destroy(lst);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
TString16 id; id << f->dlg();
|
1995-05-09 13:33:34 +00:00
|
|
|
_sel = s->get_pos(id) >> 1;
|
|
|
|
xvt_list_set_sel(listbox, _sel, TRUE);
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
short TBrowse_sheet::reserved_rows() const
|
|
|
|
{
|
|
|
|
return TSheet::reserved_rows() + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TBrowse_sheet::repos_buttons() const
|
|
|
|
{
|
|
|
|
TSheet::repos_buttons(); // Repos toolbar
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
RCT wr; xvt_vobj_get_client_rect(win(), &wr); // Get window size
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
int left = CHARX; // left coord of next control to draw
|
|
|
|
|
1995-01-10 17:54:08 +00:00
|
|
|
for (int i = 0; i < 2; i++)
|
1995-01-05 17:50:40 +00:00
|
|
|
{
|
|
|
|
const short id = i ? DLG_EDIT : DLG_FINDREC;
|
1995-03-22 09:07:04 +00:00
|
|
|
const WINDOW w = xvt_win_get_ctl(win(), id);
|
1994-11-10 14:17:03 +00:00
|
|
|
if (w != NULL_WIN)
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
RCT r; xvt_vobj_get_client_rect(w, &r);
|
1994-11-10 14:17:03 +00:00
|
|
|
r.left = left;
|
|
|
|
r.top = wr.bottom - 4*CHARY + 4;
|
|
|
|
r.right += r.left;
|
|
|
|
r.bottom += r.top;
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_vobj_move(w, &r);
|
1994-11-10 14:17:03 +00:00
|
|
|
left = r.right+CHARX; // Increase left coord
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TBrowse_sheet::on_key(KEY k)
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
const WINDOW ctl = xvt_win_get_ctl(win(), DLG_EDIT);
|
1994-12-27 14:59:25 +00:00
|
|
|
const bool alnum = k >= ' ' && k < K_UP;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
if (ctl != NULL_WIN && (alnum || k == K_BACKSPACE || k == K_DEL))
|
|
|
|
{
|
|
|
|
const long oldsel = selected();
|
|
|
|
const bool corre = field().mask().is_running();
|
|
|
|
const WINDOW fldwin = field().win();
|
|
|
|
|
|
|
|
TString80 old(corre ? field().get_window_data() : field().get_field_data());
|
|
|
|
TString80 val(old.ltrim());
|
|
|
|
|
|
|
|
if (alnum)
|
|
|
|
{
|
|
|
|
if (val.len() >= field().size())
|
|
|
|
val.cut(0);
|
|
|
|
if (field()._flags.uppercase && isalpha(k))
|
|
|
|
k = toupper(k);
|
|
|
|
val << char(k);
|
|
|
|
}
|
|
|
|
else val.rtrim(1);
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
if (corre) xvt_vobj_set_title(fldwin, (char*)(const char*)val);
|
1994-11-10 14:17:03 +00:00
|
|
|
else field().set_field_data(val);
|
|
|
|
|
|
|
|
((TBrowse*)field().browse())->do_input(FALSE);
|
1995-11-27 08:39:18 +00:00
|
|
|
cursor()->read();
|
|
|
|
if (cursor()->file().bad())
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
beep();
|
|
|
|
val = old;
|
1995-03-22 09:07:04 +00:00
|
|
|
if (corre) xvt_vobj_set_title(fldwin, (char*)(const char*)val);
|
1994-11-10 14:17:03 +00:00
|
|
|
else field().set_field_data(val);
|
1995-11-27 08:39:18 +00:00
|
|
|
*cursor() = oldsel;
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
else
|
1995-11-27 08:39:18 +00:00
|
|
|
select(cursor()->pos());
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
if (ctl != NULL_WIN)
|
|
|
|
{
|
|
|
|
val = corre ? field().get_window_data() : field().get_field_data();
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_vobj_set_title(ctl, (char*)(const char*)val);
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
field().set("");
|
1995-03-22 09:07:04 +00:00
|
|
|
if (ctl != NULL_WIN) xvt_vobj_set_title(ctl, "");
|
1994-11-10 14:17:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TSheet::on_key(k);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TBrowse_sheet::handler(WINDOW win, EVENT* ep)
|
|
|
|
{
|
1995-01-05 17:50:40 +00:00
|
|
|
if (ep->type == E_CONTROL && ep->v.ctl.id == DLG_FINDREC)
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
const int what = xvt_list_get_sel_index(ep->v.ctl.ci.win);
|
1995-05-09 13:33:34 +00:00
|
|
|
if (what >= 0 && what != _sel)
|
1994-11-10 14:17:03 +00:00
|
|
|
stop_run(K_CTRL + what);
|
1995-03-22 09:07:04 +00:00
|
|
|
else
|
|
|
|
set_focus();
|
1994-11-10 14:17:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
TCursor_sheet::handler(win, ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KEY TBrowse_sheet::run()
|
|
|
|
{
|
|
|
|
const bool spork = field().dirty(); // Store field status
|
|
|
|
const TString80 old(field().get());
|
|
|
|
|
|
|
|
const KEY key = TCursor_sheet::run();
|
|
|
|
|
1995-05-16 09:35:12 +00:00
|
|
|
if (key != K_ENTER)
|
1994-11-10 14:17:03 +00:00
|
|
|
{
|
|
|
|
field().set(old); // Restore field status
|
|
|
|
field().set_dirty(spork);
|
|
|
|
}
|
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|