Modificata gestione focus negli sheet.

git-svn-id: svn://10.65.10.50/trunk@40 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-08-19 10:43:57 +00:00
parent 617fd7e074
commit 5479720988
6 changed files with 2322 additions and 2320 deletions

File diff suppressed because it is too large Load Diff

View File

@ -375,8 +375,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
case XIE_GET_PREV: case XIE_GET_PREV:
case XIE_GET_NEXT: case XIE_GET_NEXT:
{ {
const long n = xiev->v.rec_request.spec_rec + const long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ;
(xiev->type == XIE_GET_NEXT ? +1 : -1) ;
if (n < 0 || n >= items()) if (n < 0 || n >= items())
xiev->refused = TRUE; xiev->refused = TRUE;
else else
@ -481,7 +480,6 @@ break;
if (row_dirty && check_enabled) if (row_dirty && check_enabled)
{ {
check_enabled = FALSE; // Avoid recursion! check_enabled = FALSE; // Avoid recursion!
set_dirty();
str2mask(cur_row); // It shouldn't have to be necessary str2mask(cur_row); // It shouldn't have to be necessary
bool ok = _mask.check_fields(); bool ok = _mask.check_fields();
if (ok) if (ok)
@ -489,11 +487,15 @@ break;
mask2str(cur_row); mask2str(cur_row);
ok = notify(cur_row, K_ENTER); // Notify edit ok = notify(cur_row, K_ENTER); // Notify edit
} }
else if (!ok)
{ {
xiev->refused = TRUE; xiev->refused = TRUE;
set_dirty(2); // Set error status set_dirty(2); // Set error status
set_focus_cell(cur_row, cur_col); }
else
{
xvt_statbar_set("");
set_dirty();
} }
check_enabled = TRUE; check_enabled = TRUE;
} }
@ -511,16 +513,17 @@ break;
else else
{ {
xiev->refused = TRUE; // Refuse focus on disabled cells xiev->refused = TRUE; // Refuse focus on disabled cells
/*
const int r = xiev->v.xi_obj->v.cell.row; const int r = xiev->v.xi_obj->v.cell.row;
int c = xiev->v.xi_obj->v.cell.column; int c = xiev->v.xi_obj->v.cell.column;
c += cur_col > col ? -1 : +1; c += cur_col > col ? -1 : +1;
if (c < 0) c = _columns-1; else if (c < 1) c = _columns-1; else
if (c >= _columns) c = 0; if (c >= _columns) c = 1;
XI_OBJ cell; XI_OBJ cell;
XI_MAKE_CELL(&cell, _list, r, c); XI_MAKE_CELL(&cell, _list, r, c);
xi_set_focus(&cell); xi_move_focus(&cell);
*/
} }
} }
break; break;
@ -543,18 +546,17 @@ break;
if (c->on_key(K_TAB) == FALSE) // Test it if (c->on_key(K_TAB) == FALSE) // Test it
{ {
c->set(old); c->set(old);
XI_OBJ* itf = xi_get_itf(win()); xiev->refused = TRUE;
// xi_set_focus(xiev->v.xi_obj);
} }
else else
{ {
xiev->refused = TRUE;
mask2str(cur_row); // Update sheet row mask2str(cur_row); // Update sheet row
edit_field = NULL; // Reset current field edit_field = NULL; // Reset current field
xi_set_color(xiev->v.xi_obj, XIC_BACK, NORMAL_BACK_COLOR);
} }
check_enabled = TRUE; check_enabled = TRUE;
} }
if (!xiev->refused)
xi_set_color(xiev->v.xi_obj, XIC_BACK, NORMAL_BACK_COLOR);
} }
break; break;
case XIE_GET_PERCENT: case XIE_GET_PERCENT:
@ -843,9 +845,11 @@ void TSpreadsheet::str2mask(int riga)
TMask_field& f = _mask.fld(pos); TMask_field& f = _mask.fld(pos);
f.set(val); f.set(val);
f.enable(!cell_disabled(riga, id-FIRST_FIELD)); f.enable(!cell_disabled(riga, id-FIRST_FIELD));
if (f.active() || f.ghost()) if (f.active() || f.ghost())
{ {
if (f.has_check()) f.check(STARTING_CHECK); if (f.has_check()) f.check(STARTING_CHECK);
f.set_dirty(FALSE);
f.on_hit(); f.on_hit();
} }
f.set_dirty(FALSE); f.set_dirty(FALSE);
@ -989,18 +993,6 @@ void TSheet_field::force_update(int r)
} }
void TSheet_field::set_window_data(const char*)
{
_sheet->set_dirty(FALSE);
set_dirty(FALSE);
}
void TSheet_field::set_field_data(const char*)
{
set_dirty(_sheet->dirty());
}
int TSheet_field::items() const int TSheet_field::items() const
{ {
return (int)_sheet->items(); return (int)_sheet->items();
@ -1030,15 +1022,25 @@ TMask& TSheet_field::sheet_mask() const
return _sheet->mask(); return _sheet->mask();
} }
bool TSheet_field::on_hit()
{
if (!mask().is_running())
{
force_update();
_sheet->set_dirty(FALSE);
}
return TRUE;
}
bool TSheet_field::on_key(KEY k) bool TSheet_field::on_key(KEY k)
{ {
if (k == K_TAB) if (k == K_TAB)
{ {
const bool spork = _sheet->dirty(); const bool spork = _sheet->dirty();
if (spork < FALSE || spork > TRUE) if (spork < FALSE || spork > TRUE)
return error_box("Tabella inconsistente: correggere i valori errati prima di uscirne"); return error_box("Tabella inconsistente: correggere le celle errate");
set_dirty(spork); set_dirty(spork);
} }
return TMask_field::on_key(k); return TMask_field::on_key(k);
} }

View File

@ -1,47 +1,46 @@
#ifndef __MSKSHEET_H #ifndef __MSKSHEET_H
#define __MSKSHEET_H #define __MSKSHEET_H
#ifndef __MASK_H #ifndef __MASK_H
#include <mask.h> #include <mask.h>
#endif #endif
class TSpreadsheet; class TSpreadsheet;
typedef bool (*SPREADSHEET_NOTIFY)(int r, KEY k); typedef bool (*SPREADSHEET_NOTIFY)(int r, KEY k);
class TSheet_field : public TMask_field class TSheet_field : public TMask_field
{ {
TSpreadsheet* _sheet; TSpreadsheet* _sheet;
TToken_string _head; TToken_string _head;
protected: protected:
virtual word class_id() const; virtual word class_id() const;
virtual bool on_key(KEY k); virtual bool on_hit();
virtual bool on_key(KEY k);
virtual void parse_head(TScanner& scanner);
virtual bool parse_item(TScanner& scanner); virtual void parse_head(TScanner& scanner);
virtual void create(WINDOW parent); virtual bool parse_item(TScanner& scanner);
virtual void set_window_data(const char*); virtual void create(WINDOW parent);
virtual void set_field_data(const char*);
public:
public: TToken_string& row(int n); // Get/Create a new row
TToken_string& row(int n); // Get/Create a new row TArray& rows_array() const; // Get all rows
TArray& rows_array() const; // Get all rows int first_empty() const; // First empty row
int first_empty() const; // First empty row int items() const; // Number of rows
int items() const; // Number of rows
virtual void reset();
virtual void reset(); void force_update(int r = -1);// Update data/screen
void force_update(int r = -1);// Update data/screen
TMask& sheet_mask() const;
TMask& sheet_mask() const; void set_notify(SPREADSHEET_NOTIFY n);
void set_notify(SPREADSHEET_NOTIFY n); void enable_column(int col, bool on = TRUE);
void enable_column(int col, bool on = TRUE); void enable_cell(int row, int column, bool on = TRUE);
void enable_cell(int row, int column, bool on = TRUE); void disable_cell(int row, int column) { enable_cell(row, column, FALSE); }
void disable_cell(int row, int column) { enable_cell(row, column, FALSE); }
TSheet_field(TMask* m);
TSheet_field(TMask* m); virtual ~TSheet_field();
virtual ~TSheet_field(); };
};
#endif
#endif

View File

@ -1 +1 @@
#define VERSION 1.7 #define VERSION 1.8

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff