From 4e3cc536f6683130c0d079749f7db16b0d0e4087 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 7 Dec 1995 11:14:10 +0000 Subject: [PATCH] Correzioni per ripresa del focus dopo il lancio una applicazione o la pressione di un bottone di una maschera in uno sheet git-svn-id: svn://10.65.10.50/trunk@2257 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/controls.cpp | 2 +- include/maskfld.cpp | 45 +++++++++-------- include/msksheet.cpp | 113 ++++++++++++++++++++++++------------------- include/msksheet.h | 6 +-- include/pagsca.h | 1 - include/partite.h | 1 + include/relation.cpp | 17 ++++--- include/sheet.h | 6 ++- include/xvtility.cpp | 2 +- 9 files changed, 107 insertions(+), 86 deletions(-) diff --git a/include/controls.cpp b/include/controls.cpp index 4489d69e3..51bf13f95 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -318,7 +318,7 @@ void TControl::update() const } void TControl::set_caption(const char* t) -{ +{ _caption = t; update(); } diff --git a/include/maskfld.cpp b/include/maskfld.cpp index 7e7509122..93f3ff03d 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -556,17 +556,22 @@ void TMask_field::reset() void TMask_field::set_prompt(const char* p) { if (_promptwin != NULL_WIN) - xvt_vobj_set_title(_promptwin, (char*) p); - - if (*p++ == '@') { - if (toupper(*p) == 'U') - xvt_set_font(_win, "", XVT_FS_UNDERLINE, CHARY-12); - if (toupper(*p) == 'B') - xvt_set_font(_win, "", XVT_FS_BOLD, CHARY-12); - } - else - xvt_set_font(_win, "", XVT_FS_NONE); + word style = 0; + for (const char* s = p; *s == '@'; s++) + { + s++; + switch(toupper(*s)) + { + case 'B': style |= XVT_FS_BOLD; break; + case 'U': style |= XVT_FS_UNDERLINE; break; + default : CHECKS(0, "Invalid prompt style ", s); break; + } + } + if (style) + xvt_set_font(_win, "", style, CHARY-12); + xvt_vobj_set_title(_promptwin, (char*)p); + } } @@ -656,7 +661,7 @@ HIDDEN const char* copy_value(TToken_string& msg, const TString& val) return val.sub(from, to); } -HIDDEN void run_app(const TMask& mask, TToken_string& msg) +HIDDEN void run_app(TMask& mask, TToken_string& msg) { TFilename a; @@ -679,6 +684,7 @@ HIDDEN void run_app(const TMask& mask, TToken_string& msg) } TExternal_app app(a); app.run(); + mask.set_focus(); } @@ -1618,7 +1624,8 @@ bool TBrowse::do_insert() TExternal_app a(app); a.run(); - + _fld->mask().set_focus(); + if (mail.check()) { TMessage* rcv = mail.next_s(MSG_AI); @@ -2178,11 +2185,11 @@ const char* TEdit_field::format(const char* d) const if (_flags.uppercase) fpark.upper(); - if (!_flags.pipeallowed) - { - for (int p = 0; fpark[p]; p++) - if (fpark[p] == '|') fpark[p] = '/'; - } + if (!_flags.pipeallowed) + { + for (int p = 0; fpark[p]; p++) + if (fpark[p] == '|') fpark[p] = '/'; + } } return fpark; @@ -3780,9 +3787,9 @@ void TZoom_field::create(WINDOW parent) int delta = 1; #endif - if (_browse || _sheet) delta *= 2; + if (_browse || _sheet) delta += 2; _buttonzoom = xvt_create_control(WC_PUSHBUTTON, _x+_width+delta, _y, - 2, 1, "Z", parent, default_flags(), PTR_LONG(this), DLG_F8); + 2, 1, "Z", parent, default_flags(), PTR_LONG(this), DLG_F8); } void TZoom_field::destroy() diff --git a/include/msksheet.cpp b/include/msksheet.cpp index ea4acf83a..1787fa5fe 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -851,21 +851,21 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev) if (xiev->v.xi_obj->type == XIT_ROW) { _check_enabled = FALSE; - if (_cell_dirty) off_cell_handler(); const int oldrec = _cur_rec; - set_pos(xiev->v.select.xi_obj->v.row, xiev->v.select.column); + set_pos(xiev->v.select.xi_obj->v.row, 1 /* xiev->v.select.column */); if (oldrec != _cur_rec) { _row_dirty = FALSE; on_idle(); // Forces update delayed by str2mask } - if (sheet_mask().id2pos(FIRST_FIELD-1) != -1) + const int button_pos = sheet_mask().id2pos(FIRST_FIELD-1); + if (button_pos >= 0) { - TMask_field& button = sheet_mask().field(FIRST_FIELD-1); + TMask_field& button = sheet_mask().fld(button_pos); if (button.active()) { str2mask(_cur_rec); @@ -878,6 +878,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev) } } _check_enabled = TRUE; + _owner->highlight(); } xiev->refused = TRUE; break; @@ -1181,6 +1182,40 @@ void TSpreadsheet::select(int rec) set_focus_cell(row, 1); } +void TSpreadsheet::on_idle() +{ + if (_needs_update >= 0) + { + if (_needs_update < items()) + update_rec(_needs_update); + _needs_update = -1; + } +} + +// @mfunc Cerca la colonna col +XI_OBJ* TSpreadsheet::find_column( + int col) const // @param Indice o identificatore colonna +{ + CHECKD(col >= 0, "Bad column ", col); + if (col < columns()) // Se e' un indice trasformalo in identificatore + col += FIRST_FIELD; + int num; + XI_OBJ** columns = xi_get_member_list(_list, &num); + for (int c = 1; c < num; c++) + { + if (columns[c]->cid == col) + break; + } + + if (c == num) + { + yesnofatal_box("Can't find column with id=%d", col); + c = 0; + } + + return columns[c]; +} + #else #include @@ -1201,7 +1236,6 @@ class TSpreadsheet : public TArray_sheet TBit_array _column_disabled; TArray _disabled; // Array di TBit_array - protected: virtual bool on_key(KEY key); KEY edit(int n, KEY tasto); @@ -1213,10 +1247,12 @@ public: TSpreadsheet(short x, short y, short dx, short dy, const char* maskname, int maskno, const char* head, WINDOW parent, TSheet_field * o); - TMask& sheet_mask() { return _mask; } + TMask& sheet_mask() const { return ((TSpreadsheet*)this)->_mask; } TMask& mask() const; - // Matteo + void swap_columns(const int fromid, const int toid) const; + void swap_rows( const int fromindex, const int toindex); + void set_getmask(SPREADSHEET_GETMASK n) { _getmask = n; } void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; } @@ -1245,7 +1281,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy, const char* head, WINDOW parent, TSheet_field* o) : TArray_sheet(x, y, dx, dy, maskname, head, 0, parent), _owner(o), - _mask(maskname, maskno), _notify(NULL), /* Matteo */ _getmask( NULL ) + _mask(maskname, maskno), _notify(NULL), _getmask( NULL ) { sheet_mask().set_sheet(o); } @@ -1267,11 +1303,11 @@ bool TSpreadsheet::on_key(KEY k) int n = (int)selected(); if (k != K_ENTER) { - if (k == K_INS) n = items(); else // Aggiunge alla fine + if (k == K_INS) n = (int)items(); else // Aggiunge alla fine if (k == 'A') n++; if (n < 0) n = 0; else - if (n > items()) n = items(); // Controlla range n + if (n > (int)items()) n = (int)items(); // Controlla range n if (notify(n, K_INS) == FALSE) // Chiede l'ok alla applicazione return FALSE; @@ -1365,15 +1401,6 @@ void TSpreadsheet::mask2str(int rec) #endif } -void TSpreadsheet::on_idle() -{ - if (_needs_update >= 0) - { - if (_needs_update < items()) - update_rec(_needs_update); - _needs_update = -1; - } -} // Certified 50% // @mfunc Permette di abilitare/disabilitare una singola cella @@ -1447,30 +1474,6 @@ void TSpreadsheet::enable_column( } #endif } - -// @mfunc Cerca la colonna col -XI_OBJ* TSpreadsheet::find_column( - int col) const // @param Indice o identificatore colonna -{ - CHECKD(col >= 0, "Bad column ", col); - if (col < columns()) // Se e' un indice trasformalo in identificatore - col += FIRST_FIELD; - int num; - XI_OBJ** columns = xi_get_member_list(_list, &num); - for (int c = 1; c < num; c++) - { - if (columns[c]->cid == col) - break; - } - - if (c == num) - { - yesnofatal_box("Can't find column with id=%d", col); - c = 0; - } - - return columns[c]; -} void TSpreadsheet::delete_column( const int col ) const { @@ -1527,8 +1530,10 @@ void TSpreadsheet::swap_columns(const int fromid, const int toid) const void TSpreadsheet::swap_rows( const int fromindex, const int toindex) { +#if XVT_OS == XVT_OS_WIN _str.swap(fromindex, toindex); _disabled.swap(fromindex, toindex); +#endif } void TSpreadsheet::set_column_width(const int col, const int width) const @@ -1657,7 +1662,7 @@ KEY TSpreadsheet::edit(int n, KEY tasto) #endif { KEY k; - const int olditems = items(); + const int olditems = (int)items(); str2mask(n); if( _getmask ) @@ -1807,7 +1812,7 @@ TString_array& TSheet_field::rows_array() const // Ritorna l'indice della prima riga vuota dello sheet int TSheet_field::first_empty() const { - const int max = _sheet->items(); + const int max = (int)_sheet->items(); for (int n = 0; n < max; n++) if (_sheet->row(n).empty_items()) break; @@ -1825,13 +1830,13 @@ TToken_string& TSheet_field::row( // o minore di 0 viene aggiunta una riga vuota in fondo allo spreadsheet // (viene chiamata la ) { - const int max = _sheet->items(); + const int max = (int)_sheet->items(); if (n < 0 || n >= max) { if (n < 0) n = first_empty(); if (n >= max) { - n = _sheet->add(new TToken_string(80)); + n = (int)_sheet->add(new TToken_string(80)); } } return _sheet->row(n); @@ -1849,7 +1854,7 @@ void TSheet_field::force_update( #if XVT_OS == XVT_OS_WIN _sheet->update(r); #else - _sheet->open(); + _sheet->open(); #endif } @@ -1860,7 +1865,7 @@ int TSheet_field::items() const int TSheet_field::selected() const { - return _sheet->selected(); + return (int)_sheet->selected(); } void TSheet_field::set_notify(SPREADSHEET_NOTIFY n) @@ -1884,8 +1889,11 @@ void TSheet_field::highlight() const int rows; xi_get_list_info(_sheet->_list, &rows); if (rows > 0) { - _sheet->set_focus_cell(_sheet->_cur_row, _sheet->_cur_col); - _sheet->str2mask(selected()); + if (_sheet->notify(_sheet->_cur_rec, K_TAB)) + { + _sheet->set_focus_cell(_sheet->_cur_row, _sheet->_cur_col); + _sheet->str2mask(selected()); + } } } #endif @@ -1995,6 +2003,7 @@ bool TSheet_field::on_key(KEY k) select(0); } +#if XVT_OS == XVT_OS_WIN if (k == K_ROWEDIT && items() > 0) { select(items()-1); @@ -2004,6 +2013,8 @@ bool TSheet_field::on_key(KEY k) _sheet->list_handler( &xie ); return TRUE; } +#endif + return TMask_field::on_key(k); } diff --git a/include/msksheet.h b/include/msksheet.h index 4a2dfd655..2bd7deaf3 100755 --- a/include/msksheet.h +++ b/include/msksheet.h @@ -7,10 +7,8 @@ #define K_ROWEDIT ( K_CTRL + 'I' ) -class TSheet_field; -class TSpreadsheet; - // @doc EXTERNAL +class TSheet_field; // @type SPREADSHEET_NOTIFY | Gestisce l'ingresso, l'uscita e la modifica da una riga dello sheet typedef bool (*SPREADSHEET_NOTIFY)(TSheet_field& s, int r, KEY k); @@ -24,6 +22,8 @@ class TSheet_field : public TMask_field { // @author:(INTERNAL) Guido + friend class TSpreadsheet; + // @access Private Member // @cmember Spreadsheet di apprtenenza dei campi diff --git a/include/pagsca.h b/include/pagsca.h index ac7ba196f..af0bd57aa 100755 --- a/include/pagsca.h +++ b/include/pagsca.h @@ -4,7 +4,6 @@ #define PAGSCA_NRIGP "NRIGP" #define PAGSCA_NUMPART "NUMPART" -#define PAGSCA_TIPOPAG "TIPOPAG" #define PAGSCA_IMPORTO "IMPORTO" #define PAGSCA_IMPORTOVAL "IMPORTOVAL" #define PAGSCA_RITENUTE "RITENUTE" diff --git a/include/partite.h b/include/partite.h index e7d239e6e..a5442e44c 100755 --- a/include/partite.h +++ b/include/partite.h @@ -10,6 +10,7 @@ #define PART_NRIGA "NRIGA" #define PART_TIPOMOV "TIPOMOV" +#define PART_TIPOPAG "TIPOPAG" #define PART_NREG "NREG" #define PART_NUMRIG "NUMRIG" #define PART_DATAREG "DATAREG" diff --git a/include/relation.cpp b/include/relation.cpp index cb49c800e..0a6f4dd18 100755 --- a/include/relation.cpp +++ b/include/relation.cpp @@ -1,4 +1,4 @@ -// $Id: relation.cpp,v 1.72 1995-12-01 16:58:28 angelo Exp $ +// $Id: relation.cpp,v 1.73 1995-12-07 11:13:59 guy Exp $ // relation.cpp // fv 12/8/93 // relation class for isam files @@ -1548,18 +1548,19 @@ const char* TFieldref::read(const TRectype& rec) const return buffer; } -const char* TFieldref::read(const TRelation* c) const +const char* TFieldref::read(const TRelation* r) const { - CHECK(c != NULL, "Can't read field from NULL relation"); - const char * s = read(c->lfile(_id).curr()); + CHECK(r != NULL, "Can't read field from NULL relation"); + const TRectype& rec = _id.empty() ? r->curr() : r->lfile(_id).curr(); + const char *s = read(rec); return s; } -void TFieldref::write(const char* val, TRelation* c) const +void TFieldref::write(const char* val, TRelation* r) const { - CHECK(c != NULL, "Can't write field on NULL relation"); - TRectype &curr = c->lfile(_id).curr(); - write(val, curr); + CHECK(r != NULL, "Can't write field on NULL relation"); + TRectype &rec = _id.empty() ? r->curr() : r->lfile(_id).curr(); + write(val, rec); } diff --git a/include/sheet.h b/include/sheet.h index 811a1c08a..b048b4c94 100755 --- a/include/sheet.h +++ b/include/sheet.h @@ -92,8 +92,6 @@ protected: virtual bool on_key(KEY); // @cmember Fa' l'update della finestra (vedi ) virtual void update(); - // @cmember Mostra la finestra (vedi ) - virtual void open(); // @cmember Setta il numero della prima riga dello sheet void set_first(long n); @@ -132,6 +130,10 @@ protected: public: // @cmember Costruttore TSheet(short x,short y,short dx,short dy,const char* title,const char* head,byte buttons = 0,long first = 0L,WINDOW parent = NULL_WIN); + + // @cmember Mostra la finestra (vedi ) + virtual void open(); + // @cmember Aggiunge un bottone nella finestra void add_button(short id, const char* caption, KEY key = K_ESC); diff --git a/include/xvtility.cpp b/include/xvtility.cpp index b59f68838..ecd93fa0f 100755 --- a/include/xvtility.cpp +++ b/include/xvtility.cpp @@ -911,7 +911,7 @@ WINDOW xvt_create_control( #else if (wt == WC_EDIT || wt == WC_LISTBUTTON) #endif - { + { HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW); SendMessage(hwnd, WM_SETFONT, NormalFont, FALSE); if (_bandiere & CTL_FLAG_MAC_MONACO9)