From 0a93dba34dcb97238a2350130d43aab8ad32255b Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 16 Jan 1995 15:10:52 +0000 Subject: [PATCH] Corretto destinatario TMessage MOdificati sheet in modo da gestire meglio perdita e guadagno del focus Tolta isspace dalle TString e messa is_space git-svn-id: svn://10.65.10.50/trunk@869 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/applicat.cpp | 9 +- include/config.cpp | 2 +- include/isam.cpp | 1 - include/isam.h | 1 - include/mailbox.cpp | 11 +- include/mailbox.h | 6 +- include/mask.cpp | 18 +- include/maskfld.cpp | 13 +- include/maskfld.h | 6 +- include/msksheet.cpp | 661 ++++++++++++++++++++++--------------------- include/msksheet.h | 3 +- include/relapp.cpp | 11 +- include/relation.cpp | 10 +- include/strings.cpp | 20 +- 14 files changed, 398 insertions(+), 374 deletions(-) diff --git a/include/applicat.cpp b/include/applicat.cpp index 12db0c32f..7ef7f6cc3 100755 --- a/include/applicat.cpp +++ b/include/applicat.cpp @@ -130,9 +130,9 @@ void TBanner::handler(WINDOW win, EVENT* ep) r.left += 4; r.right -= 4; r.top += 4; r.bottom -= 4; - set_pen(COLOR_BLACK); win_draw_rect(win, &r); - offset_rect(&r, 1, 1); set_pen(COLOR_WHITE); win_draw_rect(win, &r); + offset_rect(&r, -1, -1); + set_pen(COLOR_BLACK); win_draw_rect(win, &r); win_draw_icon(win, CHARX<<1, CHARX<<1, ICON_RSRC); } @@ -650,10 +650,7 @@ void TApplication::set_cursor(bool w) else { _count--; -#ifdef DBG - if (_count < 0) - yesnofatal_box("end_wait without matching begin_wait"); -#endif + CHECK(_count >= 0, "end_wait without matching begin_wait"); if (_count == 0) ::set_cursor(ww, CURSOR_ARROW); } diff --git a/include/config.cpp b/include/config.cpp index 681acf5f9..cf26a9adc 100755 --- a/include/config.cpp +++ b/include/config.cpp @@ -122,7 +122,7 @@ TString& TConfig::get(const char* var, const char* section, int index, const cha { // ritorna valore di variabile nella sezione corrente o in // quella specificata - static TFixed_string s(__tmp_string, 256); + static TFixed_string s(&__tmp_string[256], 256); TString80 vvar(var); if (index != -1) vvar << '(' << index << ')'; _check_paragraph(section); diff --git a/include/isam.cpp b/include/isam.cpp index 76f34deb2..5aa9c8fc0 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -689,7 +689,6 @@ int TLocalisamfile::open(unsigned int mode) err = _open(); _was_open = TRUE; } - _isatab = FALSE; setstatus(err); return err; } diff --git a/include/isam.h b/include/isam.h index 5d93a9bd5..7d4eb6a4e 100755 --- a/include/isam.h +++ b/include/isam.h @@ -379,7 +379,6 @@ class TLocalisamfile : public TBaseisamfile { // @DPRIV bool _was_open; // Vero se il file e' stato aperto come Localisamfile - bool _isatab; // Vero se il file e' una tabella int _oldkey; // Old key if already open public: diff --git a/include/mailbox.cpp b/include/mailbox.cpp index a07158805..3ae6f1287 100755 --- a/include/mailbox.cpp +++ b/include/mailbox.cpp @@ -1,4 +1,4 @@ -// $Id: mailbox.cpp,v 1.10 1994-12-15 18:06:18 guy Exp $ +// $Id: mailbox.cpp,v 1.11 1995-01-16 15:10:23 guy Exp $ #include #include @@ -18,10 +18,11 @@ TMessage::TMessage(const char* to, const char* sub, const char* text, const char* from) -{ - _to = to; - if (to && *to && (_to.len() != 6 || _to.strip(" -") != to)) - _to = cmd2name(to); +{ + TString80 rec(to); + if (rec.not_empty() && (rec.len() != 6 || rec.strip(" -") != to)) + rec = cmd2name(to); + _to = rec; _subject = sub; _text = text; _from = (from == NULL || *from == '\0') ? main_app().name() : from; diff --git a/include/mailbox.h b/include/mailbox.h index a9512df34..aad65e462 100755 --- a/include/mailbox.h +++ b/include/mailbox.h @@ -1,4 +1,4 @@ -// $Id: mailbox.h,v 1.4 1994-10-24 15:06:27 guy Exp $ +// $Id: mailbox.h,v 1.5 1995-01-16 15:10:24 guy Exp $ /* si', trattasi di -*-c++-*- */ // Mailbox.h @@ -7,10 +7,6 @@ #ifndef __MAILBOX_H #define __MAILBOX_H -#ifndef __ARRAY_H -#include -#endif - #ifndef __STRINGS_H #include #endif diff --git a/include/mask.cpp b/include/mask.cpp index 35a3b0e9a..4b4e787e7 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -25,12 +25,12 @@ bool TMask::test_focus_change(WINDOW next) TMask_field& prev = fld(_focus); if (prev.win() != next) - { - if (prev.on_key(K_TAB) == FALSE) // Test if previous field agrees ... + { + ok = prev.test_focus_change(); + if (!ok) // Test if previous field agrees ... { set_focus(); prev.set_focusdirty(FALSE); - ok = FALSE; // ... sorry, it does not } } return ok; @@ -132,11 +132,17 @@ void TMask::handler(WINDOW win, EVENT* ep) switch(ep->v.ctl.id) { case DLG_OK: - if (test_focus_change()) stop_run(K_AUTO_ENTER); break; + if (test_focus_change(ep->v.ctl.ci.win)) + stop_run(K_AUTO_ENTER); + break; case DLG_CANCEL : - stop_run(K_ESC); break; + if (test_focus_change(ep->v.ctl.ci.win)) + stop_run(K_ESC); + break; case DLG_QUIT : - stop_run(K_FORCE_CLOSE); break; + if (test_focus_change(ep->v.ctl.ci.win)) + stop_run(K_FORCE_CLOSE); + break; case DLG_F9: { WINDOW w = ep->v.ctl.ci.win; diff --git a/include/maskfld.cpp b/include/maskfld.cpp index a1df562f4..f8bf89253 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -1,4 +1,4 @@ -// $Id: maskfld.cpp,v 1.67 1995-01-05 17:50:24 guy Exp $ +// $Id: maskfld.cpp,v 1.68 1995-01-16 15:10:31 guy Exp $ #include #include @@ -457,7 +457,7 @@ void TMask_field::set_prompt(const char* p) void TMask_field::set(const char* s) -{ +{ if (mask().is_running()) { set_window_data(s); @@ -722,6 +722,15 @@ bool TMask_field::do_message(int num) } +bool TMask_field::test_focus_change() +{ + bool ok = TRUE; + if (focusdirty()) + ok = on_key(K_TAB); + return ok; +} + + // Certified 90% bool TMask_field::on_hit() { diff --git a/include/maskfld.h b/include/maskfld.h index 1eae102c4..f36cd5fad 100755 --- a/include/maskfld.h +++ b/include/maskfld.h @@ -1,4 +1,4 @@ -/* $Id: maskfld.h,v 1.19 1994-12-30 10:11:11 villa Exp $ */ +/* $Id: maskfld.h,v 1.20 1995-01-16 15:10:36 guy Exp $ */ #ifndef __MASKFLD_H #define __MASKFLD_H @@ -121,6 +121,7 @@ public: bool focusdirty() const { return _flags.focusdirty; } void set_focusdirty(bool d = TRUE) { _flags.focusdirty = d; } void set_dirty(bool d = TRUE); + void set_justify(bool r) { _flags.rightjust = r; } virtual const char* class_name() const; virtual word class_id() const; @@ -159,9 +160,10 @@ public: bool is_edit() const; bool to_check(KEY k, bool checkrun = FALSE) const; - + virtual bool on_hit(); virtual bool on_key(KEY key); + virtual bool test_focus_change(); void set(const char* s); TString& get() const; diff --git a/include/msksheet.cpp b/include/msksheet.cpp index b23f02490..55e5451cd 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -96,6 +96,7 @@ public: void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork); } bool active() const { return _active; } + bool test_focus_change(); void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; } @@ -363,11 +364,19 @@ void TSpreadsheet::update_rec(int rec) void TSpreadsheet::set_focus_cell(int riga, int colonna) { - set_front_window(win()); // It seems necessary to make xi_set_focus work properly + set_front_window(win()); // It seems necessary const int r = rec2row(riga); - XI_OBJ cell; - XI_MAKE_CELL(&cell, _list, r, colonna); - xi_set_focus(&cell); + + for (; colonna < _columns; colonna++) + if (!cell_disabled(r, colonna-1)) + break; + + if (colonna < _columns) + { + XI_OBJ cell; + XI_MAKE_CELL(&cell, _list, r, colonna); + xi_set_focus(&cell); + } } @@ -428,10 +437,23 @@ void TSpreadsheet::notify_change() { notify(_cur_rec, K_SPACE); _row_dirty = TRUE; + set_dirty(); } } +bool TSpreadsheet::test_focus_change() +{ + bool ok = dirty() != 3; + if (ok && _row_dirty) + { + str2mask(selected()); + ok = sheet_mask().check_fields(); + } + return ok; +} + + void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev) { TSpreadsheet* es = (TSpreadsheet*)xi_get_app_data(itf); @@ -439,6 +461,7 @@ void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev) es->list_handler(xiev); } + // Certified 75% void TSpreadsheet::list_handler(XI_EVENT *xiev) { @@ -448,340 +471,332 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev) switch (xiev->type) { case XIE_GET_FIRST: - { - const long max = items(); - if (max > 0L) + if (items() > 0L) { - long n = max * (long)xiev->v.rec_request.percent / 100L; + long n = items() * (long)xiev->v.rec_request.percent / 100L; if (n < 0L) n = 0L; xiev->v.rec_request.data_rec = n; } else xiev->refused = TRUE; - } - break; - case XIE_GET_LAST: - xiev->v.rec_request.data_rec = items()-1; - break; - case XIE_GET_PREV: - case XIE_GET_NEXT: -{ - const long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ; - if (n < 0 || n >= items()) - xiev->refused = TRUE; - else - xiev->v.rec_request.data_rec = n; -} -break; - case XIE_CELL_REQUEST: -{ - const int rec = (int)xiev->v.cell_request.rec; - const char* src = NULL; - int nm; - XI_OBJ** obj = xi_get_member_list(xiev->v.cell_request.list, &nm); - const int num = xiev->v.cell_request.col_nbr; - const int cid = obj[num]->cid; - - if (cid >= FIRST_FIELD) + break; + case XIE_GET_LAST: + xiev->v.rec_request.data_rec = items()-1; + break; + case XIE_GET_PREV: + case XIE_GET_NEXT: { - if (rec < items()) - { - const int col = cid - FIRST_FIELD; - TMask_field* f = field(cid); - const int acqua = f->class_id(); + const long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ; + if (n < 0 || n >= items()) + xiev->refused = TRUE; + else + xiev->v.rec_request.data_rec = n; + } + break; + case XIE_CELL_REQUEST: + { + const int rec = (int)xiev->v.cell_request.rec; + const char* src = NULL; + int nm; + XI_OBJ** obj = xi_get_member_list(xiev->v.cell_request.list, &nm); + const int num = xiev->v.cell_request.col_nbr; + const int cid = obj[num]->cid; + + if (cid >= FIRST_FIELD) + { + if (rec < items()) + { + const int col = cid - FIRST_FIELD; + TMask_field* f = field(cid); + const int acqua = f->class_id(); + + if (acqua == CLASS_BUTTON_FIELD) + { + if (isdigit(_button[0])) + xiev->v.cell_request.icon_rid = atoi(_button); + else + src = _button; + } + else + { + src = row(rec).get(col); // Set value for cell + if (src && *src && f->is_edit()) + { + src = f->picture_data(src, FALSE); // Get formatted string + } + if (field(cid)->has_query()) + { + xiev->v.cell_request.button = + xiev->v.cell_request.button_on_focus = TRUE; + } + if (cell_disabled(rec, col)) + xiev->v.cell_request.back_color = DISABLED_BACK_COLOR; + } + } + } else src = format("%d", rec+1); + + const int len = xiev->v.cell_request.len; + char* dst = xiev->v.cell_request.s; + if (src) + strncpy(dst, src, len); + else + *dst = '\0'; + } + break; + case XIE_CHG_CELL: + notify_change(); + _cell_dirty = TRUE; + break; + case XIE_BUTTON: + if (xiev->v.xi_obj->type == XIT_CELL) + dispatch_e_char(win(), K_F9); + else + if (xiev->v.xi_obj->type == XIT_LIST) + insert(-1); + break; + case XIE_SELECT: + if (xiev->v.xi_obj->type == XIT_ROW) + { + _check_enabled = FALSE; - if (acqua == CLASS_BUTTON_FIELD) - { - if (isdigit(_button[0])) - xiev->v.cell_request.icon_rid = atoi(_button); - else - src = _button; + const int oldrec = _cur_rec; + set_pos(xiev->v.select.xi_obj->v.row, xiev->v.select.column); + if (oldrec != _cur_rec) + { + str2mask(_cur_rec); + _row_dirty = FALSE; + } + + update(_cur_rec); + + TMask_field* button = col2field(_cur_col); + notify_change(); + button->on_hit(); + mask2str(_cur_rec); + + _check_enabled = TRUE; + } + xiev->refused = TRUE; + break; + case XIE_DBL_CELL: + { + _check_enabled = FALSE; + + const int oldrec = _cur_rec; + set_pos(xiev->v.xi_obj->v.cell.row, xiev->v.xi_obj->v.cell.column); + + if (oldrec != _cur_rec || !_row_dirty) + { + _row_dirty = FALSE; + notify_change(); + } + const KEY k = edit(_cur_rec); + if (k == K_ENTER) + { + update_rec(_cur_rec); + _row_dirty = TRUE; + } + + if (!cell_disabled(_cur_rec, _cur_col-1)) + set_focus_cell(_cur_row, _cur_col); + _check_enabled = TRUE; + } + break; + case XIE_ON_LIST: + if (_firstfocus) // Trick to avoid the sheet to keep the focus forever ... + { // .. it costed me two day worth of hard work! + xiev->refused = TRUE; + _firstfocus = FALSE; + } + else + mask().set_focus_win(win(), FALSE); + break; + case XIE_OFF_LIST: + break; + case XIE_ON_ROW: + if (_check_enabled) + { + set_pos(xiev->v.xi_obj->v.row, _cur_col); + if (_cur_rec < items()) + { + str2mask(_cur_rec); + _row_dirty = FALSE; } else { - src = row(rec).get(col); // Set value for cell - if (src && *src && f->is_edit()) - { - src = f->picture_data(src, FALSE); // Get formatted string - } - if (field(cid)->has_query()) - { - xiev->v.cell_request.button = - xiev->v.cell_request.button_on_focus = TRUE; - } - if (cell_disabled(rec, col)) - xiev->v.cell_request.back_color = DISABLED_BACK_COLOR; - } - } - } else src = format("%d", rec+1); - - const int len = xiev->v.cell_request.len; - char* dst = xiev->v.cell_request.s; - if (src) - { - strncpy(dst, src, len); - // if (isspace(*dst)) { TFixed_string d(dst); d.ltrim(); } TBR - } - else - *dst = '\0'; -} -break; - case XIE_CHG_CELL: - notify_change(); - _cell_dirty = TRUE; - break; - case XIE_BUTTON: - if (xiev->v.xi_obj->type == XIT_CELL) - dispatch_e_char(win(), K_F9); - else - if (xiev->v.xi_obj->type == XIT_LIST) - insert(-1); - break; - case XIE_SELECT: - if (xiev->v.xi_obj->type == XIT_ROW) -{ - _check_enabled = FALSE; - - const int oldrec = _cur_rec; - set_pos(xiev->v.select.xi_obj->v.row, xiev->v.select.column); - if (oldrec != _cur_rec) - { - str2mask(_cur_rec); - _row_dirty = FALSE; - } - - update(_cur_rec); - - TMask_field* button = col2field(_cur_col); - notify_change(); - button->on_hit(); - mask2str(_cur_rec); - - _check_enabled = TRUE; -} -xiev->refused = TRUE; -break; - case XIE_DBL_CELL: -{ - _check_enabled = FALSE; - - const int oldrec = _cur_rec; - set_pos(xiev->v.xi_obj->v.cell.row, xiev->v.xi_obj->v.cell.column); - - if (oldrec != _cur_rec || !_row_dirty) - { - _row_dirty = FALSE; - notify_change(); - } - const KEY k = edit(_cur_rec); - if (k == K_ENTER) - { - update_rec(_cur_rec); - _row_dirty = TRUE; - } - - if (!cell_disabled(_cur_rec, _cur_col)) - set_focus_cell(_cur_row, _cur_col); - _check_enabled = TRUE; -} -break; - case XIE_ON_LIST: - if (_firstfocus) // Trick to avoid the sheet to keep the focus forever ... -{ // .. it costed me two day worth of hard work! - xiev->refused = TRUE; - _firstfocus = FALSE; -} -else -mask().set_focus_win(win(), FALSE); -break; - case XIE_OFF_LIST: - break; - case XIE_ON_ROW: - if (_check_enabled) -{ - set_pos(xiev->v.xi_obj->v.row, _cur_col); - if (_cur_rec < items()) - { - str2mask(_cur_rec); - _row_dirty = FALSE; - } - else - { - _cur_row = _cur_rec = 0; - xiev->refused = TRUE; - } -} -break; - case XIE_OFF_ROW: - if (_row_dirty && _check_enabled) -{ - _check_enabled = FALSE; // Avoid recursion! - str2mask(_cur_rec); // It shouldn't have to be necessary - bool ok = sheet_mask().check_fields(); - if (ok) - { - mask2str(_cur_rec); - ok = notify(_cur_rec, K_ENTER); // Notify edit - } - if (!ok) - { - xiev->refused = TRUE; - } - else - { - set_dirty(); - xvt_statbar_refresh(); - } - _check_enabled = TRUE; -} -break; - case XIE_ON_CELL: - if (_check_enabled) -{ - TMask_field* f = cell2field(xiev->v.xi_obj); - const int col = (f->dlg()-FIRST_FIELD) % 100; - if (cell_disabled(_cur_rec, col)) // If the cell is disabled ... - { - dispatch_e_char(win(), _lastab); // ... skip to the next one. - } - else - { - _edit_field = f; - _cur_col = xiev->v.xi_obj->v.cell.column; - _cell_dirty = FALSE; - } -} -break; - case XIE_OFF_CELL: - if (_edit_field && _check_enabled) -{ - _check_enabled = FALSE; - if (_cell_dirty) - { - TMask_field* c = _edit_field; // Save field, it could turn out to be NULL on error - const char* nuo = c->picture_data(xi_get_text(xiev->v.xi_obj, NULL, -1), TRUE); - c->set(nuo); // Set new mask value - c->set_dirty(); // Get it dirty! - if (c->on_key(c->is_edit() ? K_TAB : K_SPACE) == FALSE) // Test it - { - xiev->refused = *nuo != '\0'; - } - else - { - mask2str(_cur_rec); // Update sheet row - _edit_field = NULL; // Reset current field - } - } - _check_enabled = TRUE; -} -break; - case XIE_GET_PERCENT: -{ - const long rec = xiev->v.get_percent.record; - long n = items(); if (n < 1) n = 1; - xiev->v.get_percent.percent = int(rec * 100L / n); -} -break; - case XIE_CLEANUP: - break; - case XIE_XVT_EVENT: -{ - EVENT* ep = &xiev->v.xvte; - switch (ep->type) - { - case E_FOCUS: - if (_check_enabled && ep->v.active == FALSE) - { - const bool ok = (bool)xi_move_focus(_itf); - if (!ok) - { - set_dirty(3); + _cur_row = _cur_rec = 0; xiev->refused = TRUE; } } break; - case E_CHAR: - if (_edit_field) + case XIE_OFF_ROW: + if (_row_dirty && _check_enabled) { - const KEY k = e_char_to_key(ep); - switch(k) + _check_enabled = FALSE; // Avoid recursion! + str2mask(_cur_rec); // It shouldn't have to be necessary + bool ok = sheet_mask().check_fields(); + if (ok) + { + mask2str(_cur_rec); + ok = notify(_cur_rec, K_ENTER); // Notify edit + } + if (!ok) + xiev->refused = TRUE; + else + xvt_statbar_refresh(); + + _check_enabled = TRUE; + } + break; + case XIE_ON_CELL: + if (_check_enabled) + { + TMask_field* f = cell2field(xiev->v.xi_obj); + const int col = (f->dlg()-FIRST_FIELD) % 100; + if (cell_disabled(_cur_rec, col)) // If the cell is disabled ... + { + dispatch_e_char(win(), _lastab); // ... skip to the next one. + } + else + { + _edit_field = f; + _cur_col = xiev->v.xi_obj->v.cell.column; + _cell_dirty = FALSE; + } + } + break; + case XIE_OFF_CELL: + if (_edit_field && _check_enabled) + { + _check_enabled = FALSE; + if (_cell_dirty) { - case K_TAB: - case K_BTAB: - _lastab = k; - break; - case K_F1: - _check_enabled = FALSE; // Disable checks - _edit_field->on_key(K_F1); - set_focus_cell(_cur_row, _cur_col); - _check_enabled = TRUE; // Enable checks - break; - case K_F2: - case K_F3: - case K_F8: - case K_F9: - case K_F11: - if (_check_enabled && active()) + TMask_field* c = _edit_field; // Save field, it could turn out to be NULL on error + const char* nuo = c->picture_data(xi_get_text(xiev->v.xi_obj, NULL, -1), TRUE); + c->set(nuo); // Set new mask value + c->set_dirty(); // Get it dirty! + if (c->on_key(c->is_edit() ? K_TAB : K_SPACE) == FALSE) // Test it + { + xiev->refused = *nuo != '\0'; + } + else { + mask2str(_cur_rec); // Update sheet row + _edit_field = NULL; // Reset current field + } + } + _check_enabled = TRUE; + } + break; + case XIE_GET_PERCENT: + { + const long rec = xiev->v.get_percent.record; + long n = items(); if (n < 1) n = 1; + xiev->v.get_percent.percent = int(rec * 100L / n); + } + break; + case XIE_CLEANUP: + break; + case XIE_XVT_EVENT: + { + EVENT* ep = &xiev->v.xvte; + switch (ep->type) + { + case E_FOCUS: + if (_check_enabled && ep->v.active == FALSE) + { + const bool ok = (bool)xi_move_focus(_itf); + if (!ok) + { + set_dirty(3); + xiev->refused = TRUE; + } + } + break; + case E_CHAR: + if (_edit_field) + { + const KEY k = e_char_to_key(ep); + switch(k) + { + case K_TAB: + case K_BTAB: + _lastab = k; + break; + case K_F1: _check_enabled = FALSE; // Disable checks - notify_change(); - if (_edit_field->on_key(k)) - { - mask2str(_cur_rec); - } - else - { - if (k == K_F9) - { - _edit_field = &_mask.fld(_mask.focus_field()); - const short foca = _edit_field->dlg(); - const int col = (foca - FIRST_FIELD) % 100 +1; - if (col > 0 && col != _cur_col) - { - _cur_col = col; - dispatch_e_char(win(), K_F9); - } - } - } + _edit_field->on_key(K_F1); set_focus_cell(_cur_row, _cur_col); _check_enabled = TRUE; // Enable checks - } - break; - case K_PREV: - case K_NEXT: - if (xi_move_focus(_itf)) - dispatch_e_char(parent(), k); - break; - case K_ESC: - xi_set_focus(_itf); - dispatch_e_char(parent(), K_ESC); - 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; + break; + case K_F2: + case K_F3: + case K_F8: + case K_F9: + case K_F11: + if (_check_enabled && active()) + { + _check_enabled = FALSE; // Disable checks + notify_change(); + if (_edit_field->on_key(k)) + { + mask2str(_cur_rec); + } + else + { + if (k == K_F9) + { + _edit_field = &_mask.fld(_mask.focus_field()); + const short foca = _edit_field->dlg(); + const int col = (foca - FIRST_FIELD) % 100 +1; + if (col > 0 && col != _cur_col) + { + _cur_col = col; + dispatch_e_char(win(), K_F9); + } + } + } + set_focus_cell(_cur_row, _cur_col); + _check_enabled = TRUE; // Enable checks + } + break; + case K_PREV: + case K_NEXT: + case K_ESC: + if (xi_move_focus(_itf)) + dispatch_e_char(parent(), k); + break; + case K_ENTER: + case K_SHIFT+K_ENTER: + if (xi_move_focus(_itf)) + 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; + } } + break; + default: + break; } + } break; default: break; } } -break; -default: -break; -} -} void TSpreadsheet::activate(bool on) { @@ -855,6 +870,7 @@ public: void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; } void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork);} bool dirty() const { return _owner->dirty(); } + bool test_focus_change() { return TRUE; } void mask2str(int riga); void str2mask(int riga); @@ -1263,14 +1279,13 @@ void TSheet_field::set_notify(SPREADSHEET_NOTIFY n) void TSheet_field::highlight() const { + TMask_field::highlight(); #if XVT_OS == XVT_OS_WIN - if (_sheet->_firstfocus && items()) - { + if (items()) + { _sheet->_firstfocus = FALSE; _sheet->set_focus_cell(0, 1); } -#else - TMask_field::highlight(); #endif } @@ -1311,20 +1326,18 @@ bool TSheet_field::on_hit() return TRUE; } +bool TSheet_field::test_focus_change() +{ + return _sheet->test_focus_change(); +} + bool TSheet_field::on_key(KEY k) { - if (k == K_TAB || k == K_ENTER) - { - if (dirty() > TRUE) + if (k == K_ENTER) + { + if (!test_focus_change()) return FALSE; - if (k == K_ENTER && dirty()) - { - _sheet->str2mask(selected()); - const bool ok = sheet_mask().check_fields(); - if (!ok) return FALSE; - } } - return TMask_field::on_key(k); } diff --git a/include/msksheet.h b/include/msksheet.h index e7533445c..b6c6d679e 100755 --- a/include/msksheet.h +++ b/include/msksheet.h @@ -19,7 +19,8 @@ protected: virtual word class_id() const; virtual bool on_hit(); virtual bool on_key(KEY k); - + virtual bool test_focus_change(); + virtual void parse_head(TScanner& scanner); virtual bool parse_item(TScanner& scanner); virtual void create(WINDOW parent); diff --git a/include/relapp.cpp b/include/relapp.cpp index 39eb8b246..92352a3c5 100755 --- a/include/relapp.cpp +++ b/include/relapp.cpp @@ -1,4 +1,4 @@ -// $Id: relapp.cpp,v 1.44 1995-01-04 15:39:31 guy Exp $ +// $Id: relapp.cpp,v 1.45 1995-01-16 15:10:45 guy Exp $ #include #include #include @@ -623,6 +623,7 @@ bool TRelation_application::save(bool check_dirty) } was_dirty = FALSE; + begin_wait(); if (mode == MODE_INS) { bool changed = TRUE; @@ -648,6 +649,7 @@ bool TRelation_application::save(bool check_dirty) get_relation()->restore_status(); err = rewrite(*_mask); } + end_wait(); switch(err) { @@ -743,10 +745,6 @@ bool TRelation_application::main_loop() k = _mask->run(); - // Seleziona il cursore a clessidra se necessario - if (k != K_QUIT && k != K_F9) - begin_wait(); - switch (k) { case K_ESC: @@ -830,9 +828,6 @@ bool TRelation_application::main_loop() } break; } - - if (k != K_QUIT && k != K_F9) - end_wait(); } while (k != K_QUIT); if (_mask->is_open()) diff --git a/include/relation.cpp b/include/relation.cpp index 53d3adf26..f3757a228 100755 --- a/include/relation.cpp +++ b/include/relation.cpp @@ -1,4 +1,4 @@ -// $Id: relation.cpp,v 1.30 1995-01-09 16:51:18 guy Exp $ +// $Id: relation.cpp,v 1.31 1995-01-16 15:10:49 guy Exp $ // relation.cpp // fv 12/8/93 // relation class for isam files @@ -1104,9 +1104,11 @@ TRecnotype TCursor::readrec() FILE* _f = open_index(); - if ((fseek(_f, _pos * sizeof(TRecnotype), SEEK_SET) != 0) || - (fread(&nrec, sizeof(TRecnotype), 1, _f) != 1)) - fatal_box("Can't read record in file n. %d\n", file().filehnd()->ln); + if (fseek(_f, _pos * sizeof(TRecnotype), SEEK_SET) != 0) + fatal_box("Can't seek position %ld in cursor n. %d\n", _pos, file().filehnd()->ln); + + if (fread(&nrec, sizeof(TRecnotype), 1, _f) != 1) + fatal_box("Can't read position %ld in cursor n. %d\n", _pos, file().filehnd()->ln); fclose(_f); diff --git a/include/strings.cpp b/include/strings.cpp index 4e1f29b67..215bad992 100755 --- a/include/strings.cpp +++ b/include/strings.cpp @@ -22,7 +22,10 @@ HIDDEN const int MAXSTR = 301; HIDDEN char __spark[MAXSTR]; // Utility buffer -TFixed_string spark(__spark, MAXSTR); +TFixed_string spark(__spark, MAXSTR); + +inline bool is_space(char c) +{ return c >= K_TAB && c <= K_SPACE; } // Dinamically resizes a string // Certified 99% @@ -156,7 +159,7 @@ TString& TString::strip_spaces() for (int i = 0; _str[i]; i++) { char c = _str[i]; - if (isspace(c) && !instring) continue; + if (is_space(c) && !instring) continue; if (c == '"' || c == '\'') { if (instring == c) instring = '\0'; @@ -301,7 +304,7 @@ TString& TString::ltrim(int count) if (count >= len()) return cut(0); s = &_str[count]; } - else for (s = _str; *s && isspace(*s); s++); + else for (s = _str; *s && is_space(*s); s++); if (s != _str) strcpy(_str, s); return *this; @@ -318,7 +321,8 @@ TString& TString::rtrim(int count) else { char* good = _str-1; - for (char* s = _str; *s; s++) if (!isspace(*s)) good = s; + for (char* s = _str; *s; s++) + if (!is_space(*s)) good = s; *(good+1) = '\0'; } return *this; @@ -329,7 +333,7 @@ TString& TString::trim() char* last = _str; // Salta spazi iniziali - for (const char* s = _str; *s && isspace(*s); s++); + for (const char* s = _str; *s && is_space(*s); s++); // Copia stringa if (s > _str) @@ -337,7 +341,7 @@ TString& TString::trim() for(char* c = _str; *s; s++) { *c++ = *s; - if (!isspace(*s)) last = c; + if (!is_space(*s)) last = c; } // Elimina spazi finali *last = '\0'; @@ -896,7 +900,7 @@ int TToken_string::get_pos(const char* s) bool TToken_string::empty_items() const { for (const char* c = _str; *c; c++) - if (!isspace(*c) && *c != _separator) return FALSE; + if (!is_space(*c) && *c != _separator) return FALSE; return TRUE; } @@ -999,7 +1003,7 @@ void TParagraph_string::tokenize() for (int end = start+_width; end < len(); end = start+_width) { for (int i = end; i >= start; i--) - if (isspace(_str[i])) break; + if (is_space(_str[i])) break; if (i < start) {