Eliminata la possibilita' di passare da una ricerca all'altra nelle maschere
chiuse git-svn-id: svn://10.65.10.50/trunk@130 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
03532d4a93
commit
81ff8d9358
@ -25,18 +25,14 @@ class TPicture_array
|
||||
{
|
||||
enum { MAXPIC = 128 };
|
||||
PICTURE _picture[MAXPIC];
|
||||
HBITMAP _graybmp;
|
||||
HBRUSH _graybrush;
|
||||
|
||||
public:
|
||||
PICTURE getbmp(short id);
|
||||
PICTURE operator[](short id) { return _picture[id-BMP_OK]; }
|
||||
HBRUSH graybrush() const { return _graybrush; }
|
||||
|
||||
void reset();
|
||||
|
||||
TPicture_array();
|
||||
~TPicture_array() { reset(); } // Shouldn't do anything
|
||||
~TPicture_array() { reset(); }
|
||||
};
|
||||
|
||||
|
||||
@ -62,12 +58,6 @@ PICTURE TPicture_array::getbmp(short id)
|
||||
TPicture_array::TPicture_array()
|
||||
{
|
||||
memset(_picture, 0, sizeof(_picture));
|
||||
|
||||
const byte even = 1+4+16+64;
|
||||
const byte odd = 2+8+32+128;
|
||||
const byte grid[8] = { odd, even, odd, even, odd, even, odd, even };
|
||||
_graybmp = CreateBitmap(8, 8, 1, 1, grid);
|
||||
_graybrush = CreatePatternBrush(_graybmp);
|
||||
}
|
||||
|
||||
void TPicture_array::reset()
|
||||
@ -78,13 +68,6 @@ void TPicture_array::reset()
|
||||
picture_free(_picture[i]);
|
||||
_picture[i] = NULL;
|
||||
}
|
||||
|
||||
if (_graybrush)
|
||||
{
|
||||
DeleteObject(_graybrush);
|
||||
DeleteObject(_graybmp);
|
||||
_graybrush = _graybmp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -690,19 +673,6 @@ void TPush_button::update() const
|
||||
p.h = ex;
|
||||
win_draw_line(_hdc, p);
|
||||
}
|
||||
/*
|
||||
HWND hwnd = (HWND)get_value(_hdc, ATTR_NATIVE_WINDOW);
|
||||
HDC hdc = GetDC(hwnd);
|
||||
RECT r;
|
||||
r.left = _client.left+DEPTH+1;
|
||||
r.top = _client.top+DEPTH+1;
|
||||
r.right = _client.right-DEPTH-1;
|
||||
r.bottom = _client.bottom-DEPTH-1;
|
||||
HBRUSH oldBrush = SelectObject(hdc, cpb.graybrush());
|
||||
PatBlt(hdc, r.left, r.top, r.right-r.left, r.bottom-r.top, 0xFA0089); // Real magic number
|
||||
SelectObject(hdc, oldBrush);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
109
include/mask.cpp
109
include/mask.cpp
@ -10,7 +10,7 @@
|
||||
|
||||
#define NULL_PAGE 256
|
||||
|
||||
HIDDEN const char* MASK_EXT = "msk";
|
||||
HIDDEN const char* const MASK_EXT = "msk";
|
||||
|
||||
#ifdef DBG
|
||||
clock_t clock1, clock2, clock3;
|
||||
@ -22,6 +22,24 @@ clock_t clock1, clock2, clock3;
|
||||
|
||||
HIDDEN bool moving_focus = FALSE;
|
||||
|
||||
|
||||
bool TMask::test_focus_change(WINDOW next)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
|
||||
TMask_field& prev = fld(_focus);
|
||||
if (prev.win() != next)
|
||||
{
|
||||
if (prev.on_key(K_TAB) == FALSE) // Test if previous field agrees ...
|
||||
{
|
||||
set_focus();
|
||||
prev._focus_dirty = FALSE;
|
||||
ok = FALSE; // ... sorry, it does not
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TMask::control_handler(EVENT* ep)
|
||||
{
|
||||
const WINDOW win = ep->v.ctl.ci.win;
|
||||
@ -32,9 +50,12 @@ void TMask::control_handler(EVENT* ep)
|
||||
|
||||
if (type == WC_CHECKBOX)
|
||||
{
|
||||
xvt_check_box(win, !xvt_get_checked_state(win));
|
||||
set_focus_win(win, FALSE);
|
||||
f->on_key(K_SPACE);
|
||||
if (test_focus_change(win))
|
||||
{
|
||||
xvt_check_box(win, !xvt_get_checked_state(win));
|
||||
set_focus_win(win, FALSE);
|
||||
f->on_key(K_SPACE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -42,32 +63,42 @@ void TMask::control_handler(EVENT* ep)
|
||||
{
|
||||
if (moving_focus == FALSE)
|
||||
{
|
||||
((TRadio_field*)f)->check_radiobutton(win);
|
||||
set_focus_win(win, FALSE);
|
||||
f->on_key(K_SPACE);
|
||||
if (test_focus_change(win))
|
||||
{
|
||||
((TRadio_field*)f)->check_radiobutton(win);
|
||||
set_focus_win(win, FALSE);
|
||||
f->on_key(K_SPACE);
|
||||
}
|
||||
} else moving_focus = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == WC_PUSHBUTTON)
|
||||
{
|
||||
set_focus_win(win, FALSE);
|
||||
f->on_hit();
|
||||
if (test_focus_change(win))
|
||||
{
|
||||
set_focus_win(win, FALSE);
|
||||
f->on_hit();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (ep->v.ctl.ci.v.edit.focus_change)
|
||||
{
|
||||
if (ep->v.ctl.ci.v.edit.active)
|
||||
{
|
||||
TMask_field& old = fld(_focus);
|
||||
if (old.dlg() != f->dlg() && old.on_key(K_TAB) == FALSE)
|
||||
set_focus_win(old.win(), TRUE);
|
||||
else
|
||||
{
|
||||
{
|
||||
/*
|
||||
TMask_field& old = fld(_focus);
|
||||
if (old.dlg() != f->dlg() && old.on_key(K_TAB) == FALSE)
|
||||
set_focus_win(old.win(), TRUE);
|
||||
else
|
||||
{
|
||||
set_focus_win(win, FALSE);
|
||||
f->set_focusdirty(FALSE);
|
||||
}
|
||||
*/
|
||||
if (test_focus_change(win))
|
||||
set_focus_win(win, FALSE);
|
||||
f->set_focusdirty(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -97,13 +128,17 @@ void TMask::handler(WINDOW win, EVENT* ep)
|
||||
case E_CONTROL:
|
||||
switch(ep->v.ctl.id)
|
||||
{
|
||||
case DLG_OK :
|
||||
stop_run(K_AUTO_ENTER); break;
|
||||
case DLG_OK:
|
||||
if (test_focus_change()) stop_run(K_AUTO_ENTER); break;
|
||||
case DLG_BAR :
|
||||
case DLG_CANCEL :
|
||||
stop_run(K_ESC); break;
|
||||
case DLG_QUIT :
|
||||
stop_run(K_FORCE_CLOSE); break;
|
||||
case DLG_NEWREC :
|
||||
if (test_focus_change()) stop_run(K_INS); break;
|
||||
case DLG_DELREC :
|
||||
if (test_focus_change()) stop_run(K_DEL); break;
|
||||
/*
|
||||
case DLG_PGDN :
|
||||
on_key(K_NEXT); break;
|
||||
@ -119,18 +154,18 @@ void TMask::handler(WINDOW win, EVENT* ep)
|
||||
stop_run(K_F9); break;
|
||||
case DLG_LASTREC :
|
||||
stop_run(K_END); break;
|
||||
case DLG_NEWREC :
|
||||
stop_run(K_INS); break;
|
||||
case DLG_DELREC :
|
||||
stop_run(K_DEL); break;
|
||||
case DLG_SAVEREC :
|
||||
stop_run(K_SAVE); break;
|
||||
*/
|
||||
case DLG_F9:
|
||||
{
|
||||
// Attiva ricerca sul campo associato al bottone
|
||||
TMask_field* f = (TMask_field*)get_app_data(ep->v.ctl.ci.win);
|
||||
f->on_key(K_F9);
|
||||
case DLG_F9:
|
||||
{
|
||||
WINDOW w = ep->v.ctl.ci.win;
|
||||
if (test_focus_change(w))
|
||||
{
|
||||
// Attiva ricerca sul campo associato al bottone
|
||||
TMask_field* f = (TMask_field*)get_app_data(w);
|
||||
f->on_key(K_F9);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -575,14 +610,10 @@ void TMask::set_focus()
|
||||
// Move the focus to the next (+1) or previous(-1) valid control
|
||||
void TMask::move_focus_field(int d)
|
||||
{
|
||||
TMask_field& f = fld(_focus);
|
||||
|
||||
if (f.on_key(K_TAB) == FALSE) // Don't you agree to lose focus? ...
|
||||
{
|
||||
set_focus(); // ... Keep it
|
||||
if (!test_focus_change())
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
TMask_field& f = fld(_focus);
|
||||
if (f.class_id() == CLASS_RADIO_FIELD)
|
||||
{
|
||||
TRadio_field& radio = (TRadio_field&)f;
|
||||
@ -700,7 +731,7 @@ bool TMask::on_key(KEY key)
|
||||
TMask_field& f = fld(i);
|
||||
if (f.class_id() != CLASS_BUTTON_FIELD || !f.active()) continue;
|
||||
TButton_field& b = (TButton_field&)f;
|
||||
if (b.virtual_key() == key && fld(_focus).on_key(K_TAB) == TRUE)
|
||||
if (b.virtual_key() == key && test_focus_change())
|
||||
{
|
||||
f.on_key(K_SPACE);
|
||||
break;
|
||||
@ -804,7 +835,7 @@ int TMask::find_first_field(WINDOW w, int dir) const
|
||||
|
||||
bool TMask::check_current_page()
|
||||
{
|
||||
if (fld(_focus).on_key(K_TAB) == FALSE)
|
||||
if (!test_focus_change())
|
||||
return FALSE;
|
||||
|
||||
if (sheets() > 0)
|
||||
@ -898,9 +929,9 @@ bool TMask::get_bool(short fld_id) const
|
||||
void TMask::set(short fld_id, const char* s, bool hit)
|
||||
{
|
||||
TMask_field& f = field(fld_id);
|
||||
|
||||
f.set(s);
|
||||
if (hit && (f.active() || f.ghost())) f.on_key(K_TAB);
|
||||
if (hit && (f.active() || f.ghost()))
|
||||
f.on_key(K_TAB);
|
||||
}
|
||||
|
||||
void TMask::set(short fld_id, long n, bool hit)
|
||||
|
@ -74,6 +74,8 @@ protected:
|
||||
bool check_current_page(); // Check all the fields on the current page
|
||||
void next_page(int p); // Show next/previous page
|
||||
int curr_page() const { return _page; } // Current page number
|
||||
|
||||
bool test_focus_change(WINDOW w = NULL_WIN);
|
||||
void control_handler(EVENT* ep);
|
||||
void handler(WINDOW win, EVENT* ep);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: maskfld.cpp,v 1.10 1994-08-31 12:20:32 guy Exp $
|
||||
// $Id: maskfld.cpp,v 1.11 1994-09-01 16:30:53 guy Exp $
|
||||
#include <xvt.h>
|
||||
|
||||
#include <applicat.h>
|
||||
@ -638,16 +638,23 @@ bool TMask_field::on_key(KEY key)
|
||||
{
|
||||
switch(key-11000)
|
||||
{
|
||||
case 'E':enable_default(); break;
|
||||
case 'c':reset(); on_hit();
|
||||
case 'd':disable(); break;
|
||||
case 'e':enable(); break;
|
||||
case 'h':hide(); break;
|
||||
case 's':show(); break;
|
||||
case 'E':
|
||||
enable_default(); break;
|
||||
case 'c':
|
||||
reset(); on_hit();
|
||||
case 'd':
|
||||
disable(); break;
|
||||
case 'e':
|
||||
enable(); break;
|
||||
case 'h':
|
||||
hide(); break;
|
||||
case 's':
|
||||
show(); break;
|
||||
#ifdef DBG
|
||||
default :return yesnofatal_box("Invalid key sent to field %d: %d", dlg(), key);
|
||||
default :
|
||||
return yesnofatal_box("Invalid key sent to field %d: %d", dlg(), key);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1273,10 +1280,13 @@ bool TBrowse::do_insert()
|
||||
TToken_string& TBrowse::create_siblings(TToken_string& siblings)
|
||||
{
|
||||
const TMask& mask = field().mask();
|
||||
TBit_array key(4); // Elenco delle chiavi gia' utilizzate
|
||||
|
||||
siblings = ""; // Azzera la lista dei campi associati
|
||||
|
||||
if (!mask.is_running())
|
||||
return siblings; // Non saprei come fare
|
||||
|
||||
TBit_array key(4); // Elenco delle chiavi gia' utilizzate
|
||||
|
||||
// Scorre la lista dei campi di output
|
||||
int n = 0;
|
||||
for (const char* i = _out_id.get(0); i; i = _out_id.get(), n++)
|
||||
@ -2079,6 +2089,10 @@ void TButton_field::create(WINDOW parent)
|
||||
_prompt = "Annulla";
|
||||
_virtual_key = _exit_key = K_ESC;
|
||||
break;
|
||||
case DLG_DELREC:
|
||||
_virtual_key = 'E';
|
||||
_exit_key = K_DEL;
|
||||
break;
|
||||
case DLG_QUIT:
|
||||
if (_prompt.empty())
|
||||
_prompt = "Fine";
|
||||
|
@ -71,7 +71,9 @@ public:
|
||||
void enable_cell(int row, int column, bool on = TRUE);
|
||||
bool cell_disabled(int row, int column) const;
|
||||
|
||||
TMask& mask() { return _mask; }
|
||||
TMask& sheet_mask() { return _mask; }
|
||||
TMask& mask();
|
||||
|
||||
int items() const { return _str.items(); }
|
||||
int columns() const { return _columns; }
|
||||
bool dirty() const { return _dirty; }
|
||||
@ -154,7 +156,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
||||
}
|
||||
|
||||
RCT rct = resize_rect(x, y, dx, dy, WO_TE, parent);
|
||||
rct.right -= 20;
|
||||
rct.right -= 28;
|
||||
rct.bottom -= 8;
|
||||
|
||||
XI_OBJ_DEF* itfdef = xi_create_itf_def(ITF_CID,
|
||||
@ -166,8 +168,9 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
||||
XI_OBJ_DEF* listdef = xi_add_list_def(itfdef, LIST_CID,
|
||||
0, 0, rct.bottom-rct.top,
|
||||
XI_ATR_ENABLED | XI_ATR_VISIBLE,
|
||||
NORMAL_COLOR, NORMAL_BACK_COLOR,
|
||||
NORMAL_COLOR, DISABLED_BACK_COLOR, NORMAL_COLOR,
|
||||
NORMAL_COLOR, NORMAL_BACK_COLOR, // normal
|
||||
NORMAL_COLOR, DISABLED_BACK_COLOR, // disabled
|
||||
MAKE_COLOR(0, 127, 0), // active
|
||||
LIST_CID);
|
||||
listdef->v.list->scroll_bar = TRUE;
|
||||
listdef->v.list->sizable_columns = TRUE;
|
||||
@ -325,7 +328,7 @@ bool TSpreadsheet::destroy(int rec)
|
||||
enable_cell(_str.items(), -1); // Enable last line
|
||||
}
|
||||
|
||||
if (ok) update(-1);
|
||||
if (ok && mask().is_running()) update(-1);
|
||||
|
||||
return ok;
|
||||
}
|
||||
@ -465,6 +468,11 @@ if (xiev->v.xi_obj->type == XIT_LIST)
|
||||
_check_enabled = TRUE;
|
||||
}
|
||||
break;
|
||||
case XIE_ON_LIST:
|
||||
mask().set_focus_win(win(), FALSE);
|
||||
break;
|
||||
case XIE_OFF_LIST:
|
||||
break;
|
||||
case XIE_ON_ROW:
|
||||
if (_check_enabled)
|
||||
{
|
||||
@ -512,11 +520,6 @@ break;
|
||||
{
|
||||
_edit_field = f;
|
||||
_cur_col = xiev->v.xi_obj->v.cell.column;
|
||||
_check_enabled = FALSE;
|
||||
xi_set_focus(_itf);
|
||||
xi_set_color(xiev->v.xi_obj, XIC_BACK, FOCUS_BACK_COLOR);
|
||||
xi_set_focus(xiev->v.xi_obj);
|
||||
_check_enabled = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -552,8 +555,6 @@ break;
|
||||
}
|
||||
_check_enabled = TRUE;
|
||||
}
|
||||
if (!xiev->refused)
|
||||
xi_set_color(xiev->v.xi_obj, XIC_BACK, NORMAL_BACK_COLOR);
|
||||
}
|
||||
break;
|
||||
case XIE_GET_PERCENT:
|
||||
@ -617,20 +618,26 @@ break;
|
||||
if (ok) dispatch_e_char(parent(), k);
|
||||
}
|
||||
break;
|
||||
/*
|
||||
case K_PREV:
|
||||
xi_scroll(_list, XI_SCROLL_PGUP);
|
||||
break;
|
||||
case K_NEXT:
|
||||
xi_scroll(_list, XI_SCROLL_PGDOWN);
|
||||
break;
|
||||
case K_HOME:
|
||||
xi_scroll(_list, XI_SCROLL_FIRST);
|
||||
break;
|
||||
case K_END:
|
||||
xi_scroll(_list, XI_SCROLL_LAST);
|
||||
break;
|
||||
*/
|
||||
case K_ENTER:
|
||||
case K_CTRL+K_ENTER:
|
||||
{
|
||||
const bool ok = (bool)xi_move_focus(_itf);
|
||||
if (ok) dispatch_e_char(parent(), k == K_ENTER ? K_TAB : K_BTAB);
|
||||
}
|
||||
break;
|
||||
|
||||
case K_CTRL+K_PREV:
|
||||
xi_scroll(_list, XI_SCROLL_PGUP);
|
||||
break;
|
||||
case K_CTRL+K_NEXT:
|
||||
xi_scroll(_list, XI_SCROLL_PGDOWN);
|
||||
break;
|
||||
case K_CTRL+K_HOME:
|
||||
xi_scroll(_list, XI_SCROLL_FIRST);
|
||||
break;
|
||||
case K_CTRL+K_END:
|
||||
xi_scroll(_list, XI_SCROLL_LAST);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -689,7 +696,9 @@ public:
|
||||
|
||||
TArray& rows_array() const { return data(); }
|
||||
|
||||
TMask& mask() { return _mask; }
|
||||
TMask& sheet_mask() { return _mask; }
|
||||
TMask& mask();
|
||||
|
||||
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
|
||||
void set_dirty(bool spork = TRUE) { _dirty = spork;}
|
||||
bool dirty() const { return _dirty;}
|
||||
@ -756,6 +765,13 @@ bool TSpreadsheet::on_key(KEY k)
|
||||
|
||||
#endif
|
||||
|
||||
TMask& TSpreadsheet::mask()
|
||||
{
|
||||
TMask* m = (TMask*)get_app_data(parent());
|
||||
return *m;
|
||||
}
|
||||
|
||||
|
||||
TMask_field* TSpreadsheet::field(short id) const
|
||||
{
|
||||
const int pos = _mask.id2pos(id);
|
||||
@ -1025,7 +1041,7 @@ void TSheet_field::enable_cell(int row, int column, bool on)
|
||||
|
||||
TMask& TSheet_field::sheet_mask() const
|
||||
{
|
||||
return _sheet->mask();
|
||||
return _sheet->sheet_mask();
|
||||
}
|
||||
|
||||
bool TSheet_field::on_hit()
|
||||
@ -1043,8 +1059,8 @@ bool TSheet_field::on_key(KEY k)
|
||||
if (k == K_TAB)
|
||||
{
|
||||
const bool spork = _sheet->dirty();
|
||||
if (spork < FALSE || spork > TRUE)
|
||||
return error_box("Tabella inconsistente: correggere le celle errate");
|
||||
if (spork != FALSE && spork != TRUE)
|
||||
return FALSE;
|
||||
set_dirty(spork);
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,8 @@ public:
|
||||
HIDDEN TEvent_manager EM;
|
||||
|
||||
void TEvent_manager::push(WINDOW w, const EVENT& e)
|
||||
{
|
||||
{
|
||||
CHECK(w, "You shouldn't send events to NULL_WIN!");
|
||||
_w[_end] = w;
|
||||
_e[_end] = e;
|
||||
_end = (++_end) % MAX;
|
||||
@ -355,7 +356,7 @@ void do_events()
|
||||
|
||||
KEY e_char_to_key(const EVENT* ep)
|
||||
{
|
||||
CHECK(ep->type == E_CHAR, "Can't convert to key a Non-E_CHAR event");
|
||||
CHECK(ep->type == E_CHAR, "I can't convert a Non-E_CHAR event to a key");
|
||||
|
||||
KEY key = ep->v.chr.ch;
|
||||
if (key < K_INS || key > K_HELP)
|
||||
@ -381,7 +382,6 @@ void dispatch_e_char(WINDOW win, KEY key)
|
||||
|
||||
e.v.chr.ch = short(key);
|
||||
|
||||
// dispatch_event(win, &e);
|
||||
EM.push(win, e);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user