Correzioni guido (da commentare)

git-svn-id: svn://10.65.10.50/trunk@389 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-10-14 19:15:23 +00:00
parent 41cac87df5
commit 9b74e03674
9 changed files with 116 additions and 126 deletions

View File

@ -140,27 +140,13 @@ void TMask::handler(WINDOW win, EVENT* ep)
stop_run(K_ESC); break; stop_run(K_ESC); break;
case DLG_QUIT : case DLG_QUIT :
stop_run(K_FORCE_CLOSE); break; 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 : case DLG_NEWREC :
on_key(K_NEXT); break; if (test_focus_change()) stop_run(K_INS);
case DLG_PGUP : break;
on_key(K_PREV); break; case DLG_DELREC :
case DLG_FIRSTREC: if (test_focus_change()) stop_run(K_DEL);
stop_run(K_HOME); break; break;
case DLG_PREVREC :
stop_run(K_PREV); break;
case DLG_NEXTREC :
stop_run(K_NEXT); break;
case DLG_FINDREC :
stop_run(K_F9); break;
case DLG_LASTREC :
stop_run(K_END); break;
case DLG_SAVEREC :
stop_run(K_SAVE); break;
*/ */
case DLG_F9: case DLG_F9:
{ {
@ -204,7 +190,7 @@ TMask::TMask(const char* title, int pages, int cols, int rows, int xpos,
{ {
init_mask(mode); init_mask(mode);
for (_pages = 0; _pages < pages; _pages++) for (_pages = 0; _pages < pages; _pages++)
_pagewin[_pages] = create(xpos, ypos, cols, rows, title, WSF_CLOSE | WSF_SIZE, WD_MODAL); _pagewin[_pages] = create(xpos, ypos, cols, rows, title, WSF_CLOSE, WD_MODAL);
set_win(NULL_WIN); set_win(NULL_WIN);
add_buttons(); add_buttons();
} }
@ -321,12 +307,10 @@ void TMask::open()
_open = TRUE; _open = TRUE;
if (toolwin()) if (toolwin())
show_window(toolwin(), TRUE); show_window(toolwin(), TRUE);
set_front_window(fld(0).win()); // TBR
next_page(0); next_page(0);
} }
else else
{ {
set_front_window(fld(0).win()); // TBR
set_focus(); set_focus();
} }
} }
@ -749,6 +733,7 @@ bool TMask::on_key(KEY key)
"ed inizializzata mostruosamente in %ld millisecondi\n" "ed inizializzata mostruosamente in %ld millisecondi\n"
"Grazie per la comprensione", "Grazie per la comprensione",
fld(_focus).dlg(), (const char*)source_file(), clock1, clock2); fld(_focus).dlg(), (const char*)source_file(), clock1, clock2);
set_focus();
break; break;
default: default:
if (key > K_CTRL) if (key > K_CTRL)
@ -834,7 +819,7 @@ WINDOW TMask::read_page(TScanner& scanner, bool toolbar)
else else
{ {
w = create(r.left, r.top, r.right, r.bottom, w = create(r.left, r.top, r.right, r.bottom,
title, WSF_CLOSE | WSF_SIZE | WSF_INVISIBLE, WD_MODAL); title, WSF_CLOSE | WSF_INVISIBLE, WD_MODAL);
} }
while (scanner.popkey() != "EN") while (scanner.popkey() != "EN")

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.29 1994-10-14 17:55:57 alex Exp $ // $Id: maskfld.cpp,v 1.30 1994-10-14 19:15:06 guy Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -1382,16 +1382,20 @@ KEY TBrowse::run()
TFilename name("batb"); TFilename name("batb");
if (f.num() == LF_TABCOM) name << '%'; if (f.num() == LF_TABCOM) name << '%';
name << _cursor->file().name() << ".msk"; name << _cursor->file().name() << ".msk";
if (fexist(name)) if (fexist(name.lower()))
{ {
TScanner m(name.lower()); TScanner m(name);
while (m.line().left(2) != "PA"); // Find PAGE while (m.line().left(2) != "PA"); // Find PAGE
const int apicia = m.token().find('"')+1; const int apicia = m.token().find('"')+1;
const int apicic = m.token().find('"', apicia); const int apicic = m.token().find('"', apicia);
caption = m.token().sub(apicia, apicic); caption = m.token().sub(apicia, apicic);
} }
else else
caption = f.description(); {
caption = name.mid(4);
caption.cut(caption.find('.'));
caption.insert("Tabella ", 0);
}
} }
else else
caption = f.description(); caption = f.description();

View File

@ -27,6 +27,7 @@ class TSpreadsheet : public TWindow
TMask _mask; TMask _mask;
int _columns; int _columns;
bool _dirty; bool _dirty;
bool _firstfocus;
XI_OBJ *_list, *_itf; XI_OBJ *_list, *_itf;
@ -75,6 +76,7 @@ public:
TMask& mask(); TMask& mask();
int items() const { return _str.items(); } int items() const { return _str.items(); }
int selected() const { return _cur_row; }
int columns() const { return _columns; } int columns() const { return _columns; }
bool dirty() const { return _dirty; } bool dirty() const { return _dirty; }
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; } void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
@ -90,7 +92,6 @@ public:
void TSpreadsheet::init() void TSpreadsheet::init()
{ {
static bool first = TRUE; static bool first = TRUE;
if (!first) return; if (!first) return;
xvt_set_font(TASK_WIN, FF_FIXED, 0); xvt_set_font(TASK_WIN, FF_FIXED, 0);
@ -112,7 +113,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
const char* maskname, int maskno, const char* maskname, int maskno,
const char* head, WINDOW parent) const char* head, WINDOW parent)
: _mask(maskname, NO_MODE, maskno), _notify(NULL), _edit_field(NULL), _cur_row(0), _cur_col(0), : _mask(maskname, NO_MODE, maskno), _notify(NULL), _edit_field(NULL), _cur_row(0), _cur_col(0),
_row_dirty(FALSE), _check_enabled(TRUE) _row_dirty(FALSE), _check_enabled(TRUE), _firstfocus(TRUE)
{ {
const int NUMBER_WIDTH = 3; const int NUMBER_WIDTH = 3;
const int MAX_COL = 32; const int MAX_COL = 32;
@ -181,9 +182,9 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
NORMAL_COLOR, DISABLED_BACK_COLOR, // disabled NORMAL_COLOR, DISABLED_BACK_COLOR, // disabled
COLOR_RED, // active COLOR_RED, // active
LIST_CID); LIST_CID);
listdef->v.list->sizable_columns = TRUE;
listdef->v.list->movable_columns = TRUE;
listdef->v.list->scroll_bar = TRUE; listdef->v.list->scroll_bar = TRUE;
listdef->v.list->sizable_columns = FALSE;
listdef->v.list->movable_columns = FALSE;
listdef->v.list->scroll_bar_button = TRUE; listdef->v.list->scroll_bar_button = TRUE;
listdef->v.list->fixed_columns = 1; listdef->v.list->fixed_columns = 1;
listdef->v.list->width = rct.right-rct.left; listdef->v.list->width = rct.right-rct.left;
@ -204,7 +205,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL; long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL;
if (f->class_id() == CLASS_REAL_FIELD) flags |= XI_ATR_RJUST; if (f->class_id() == CLASS_REAL_FIELD) flags |= XI_ATR_RJUST;
if (f->active()) flags |= XI_ATR_ENABLED; if (f->active()) flags |= XI_ATR_ENABLED | XI_ATR_FOCUSBORDER | XI_ATR_AUTOSELECT;
else _column_disabled.set(i); else _column_disabled.set(i);
coldef = xi_add_column_def(listdef, cid, flags, cid, v_width[i], m_width[i], (char*)h); coldef = xi_add_column_def(listdef, cid, flags, cid, v_width[i], m_width[i], (char*)h);
@ -222,12 +223,12 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
CHECK(win, "Can't create a window for the spreadsheet"); CHECK(win, "Can't create a window for the spreadsheet");
set_win(win); // Set TWindow::_win set_win(win); // Set TWindow::_win
itfdef->v.itf->win = win; itfdef->v.itf->win = win; // Link interface to win
xi_create(NULL, itfdef); xi_create(NULL, itfdef); // Create the whole thing!
xi_tree_free(itfdef); xi_tree_free(itfdef); // Free definitions
_itf = xi_get_itf(win); _itf = xi_get_itf(win); // Store useful references for later use
_list = xi_get_obj(_itf, LIST_CID); _list = xi_get_obj(_itf, LIST_CID);
} }
@ -445,7 +446,7 @@ break;
*dst = '\0'; *dst = '\0';
} }
break; break;
case XIE_CHAR_CELL: case XIE_CHG_CELL:
if (!_row_dirty) if (!_row_dirty)
{ {
notify(_cur_row, K_SPACE); notify(_cur_row, K_SPACE);
@ -491,6 +492,12 @@ if (xiev->v.xi_obj->type == XIT_LIST)
} }
break; break;
case XIE_ON_LIST: 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); mask().set_focus_win(win(), FALSE);
break; break;
case XIE_OFF_LIST: case XIE_OFF_LIST:
@ -1082,6 +1089,11 @@ int TSheet_field::items() const
} }
int TSheet_field::selected() const
{
return _sheet->selected();
}
void TSheet_field::set_notify(SPREADSHEET_NOTIFY n) void TSheet_field::set_notify(SPREADSHEET_NOTIFY n)
{ {
_sheet->set_notify(n); _sheet->set_notify(n);

View File

@ -29,6 +29,7 @@ public:
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
int selected() const; // Number of current row
virtual void reset(); virtual void reset();
void destroy(int r = -1); // Destroy row void destroy(int r = -1); // Destroy row

View File

@ -1 +1 @@
#define VERSION 1.9 #define VERSION 1.10

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.15 1994-10-14 17:59:12 alex Exp $ // $Id: relapp.cpp,v 1.16 1994-10-14 19:15:17 guy Exp $
#include <mailbox.h> #include <mailbox.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
@ -216,11 +216,7 @@ void TRelation_application::enable_query()
TMask_field& c = _mask->fld(num); TMask_field& c = _mask->fld(num);
const bool has_query = c.has_query(); const bool has_query = c.has_query();
if (k == 1) if (k == 1)
{
// THIS should have been fixed
// if (!query && has_query) c.check(STARTING_CHECK);
c.enable(query); c.enable(query);
}
if (has_query) if (has_query)
((TEdit_field&)c).enable_check(query); ((TEdit_field&)c).enable_check(query);
} }
@ -253,26 +249,9 @@ void TRelation_application::set_toolbar(bool all)
} }
_mask->fld(pos).enable(enabdel); _mask->fld(pos).enable(enabdel);
} }
/*
const bool full = !file().empty() && _first != -1;
pos = _mask->id2pos(DLG_FIRSTREC);
if (pos >= 0) _mask->fld(pos).enable(full);
pos = _mask->id2pos(DLG_LASTREC);
if (pos >= 0) _mask->fld(pos).enable(full);
pos = _mask->id2pos(DLG_STOPREC);
if (pos >= 0) _mask->fld(pos).enable(full);
*/
} }
enable_query(); enable_query();
/*
const TRecnotype rpos = file().recno();
pos = _mask->id2pos(DLG_PREVREC);
if (pos >= 0) _mask->fld(pos).enable(mod && rpos != _first);
pos = _mask->id2pos(DLG_NEXTREC);
if (pos >= 0) _mask->fld(pos).enable(mod && rpos != _last);
*/
} }
@ -314,10 +293,13 @@ bool TRelation_application::autonum(TMask* m, bool rec)
{ {
TToken_string k(get_next_key()); TToken_string k(get_next_key());
if (!rec && !m->query_mode())
m->reset();
for (const char* n = k.get(0); n && *n; n = k.get()) for (const char* n = k.get(0); n && *n; n = k.get())
{ {
const short id = atoi(n); const short id = atoi(n);
if (id < 1) break; CHECKD (id > 0, "Identificatore di autonumerazione errato: ", id);
const char* val = k.get(); const char* val = k.get();
TMask_field& f = m->field(id); TMask_field& f = m->field(id);
if (rec || f.get().empty()) f.set(val); if (rec || f.get().empty()) f.set(val);
@ -350,7 +332,6 @@ void TRelation_application::query_mode(bool pre_ins)
if (pre_ins) if (pre_ins)
{ {
set_mode(NO_MODE); set_mode(NO_MODE);
autonum(_mask, FALSE);
init_query_insert_mode(*_mask); init_query_insert_mode(*_mask);
} }
else else
@ -362,6 +343,8 @@ void TRelation_application::query_mode(bool pre_ins)
void TRelation_application::insert_mode() void TRelation_application::insert_mode()
{
if (_mask->query_mode())
{ {
if (test_key(1, FALSE) == FALSE) if (test_key(1, FALSE) == FALSE)
{ {
@ -373,9 +356,7 @@ void TRelation_application::insert_mode()
} }
const bool changing = changing_mask(MODE_INS); const bool changing = changing_mask(MODE_INS);
TFilename workname; workname.temp("msk$$");
TFilename workname; workname.temp("rim$$");
if (changing) if (changing)
{ {
_mask->set_workfile(workname); _mask->set_workfile(workname);
@ -393,6 +374,15 @@ void TRelation_application::insert_mode()
delete _maskeys; delete _maskeys;
_maskeys = new TKey_array(_mask); _maskeys = new TKey_array(_mask);
} }
}
else
{
if (!autonum(_mask, FALSE))
{
query_insert_mode();
return;
}
}
set_mode(MODE_INS); set_mode(MODE_INS);
init_insert_mode(*_mask); init_insert_mode(*_mask);
@ -735,11 +725,8 @@ bool TRelation_application::main_loop()
} }
break; break;
case K_INS: case K_INS:
if (_mask->mode() == MODE_QUERY) if (_mask->query_mode() || _mask->save(TRUE))
insert_mode(); insert_mode();
else
if (save(TRUE))
query_mode(TRUE);
break; break;
case K_DEL: case K_DEL:
{ {

View File

@ -524,7 +524,7 @@ TString& TFixed_string::format(const char* fmt, ...)
va_start(pars, fmt); va_start(pars, fmt);
const int tot = vsprintf(_str, fmt, pars); const int tot = vsprintf(_str, fmt, pars);
va_end(pars); va_end(pars);
CHECK(tot >= 0 && tot < size(), "Ue'! Quanto scrivi?"); CHECK(tot >= 0 && tot < size(), "Ue'! Quanto scrivi con 'sta format?");
return *this; return *this;
} }
@ -658,7 +658,6 @@ const TFilename& TFilename::temp(const char* prefix)
// Certified 100% // Certified 100%
TToken_string::TToken_string(const char* s, char separator) TToken_string::TToken_string(const char* s, char separator)
: TString(s), _separator(separator) : TString(s), _separator(separator)
{ {
restart(); restart();
} }
@ -666,7 +665,6 @@ TToken_string::TToken_string(const char* s, char separator)
// Certified 100% // Certified 100%
TToken_string::TToken_string(int n, char separator) TToken_string::TToken_string(int n, char separator)
: TString(n), _separator(separator), _last(0) : TString(n), _separator(separator), _last(0)
{} {}
// Certified 100% // Certified 100%
@ -896,7 +894,6 @@ void TToken_string::destroy(int n)
restart(); restart();
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Paragraph string // Paragraph string
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -61,8 +61,11 @@ public:
CHECKD(i >= 0 && i <= _size, "Bad string subscript: ", i); CHECKD(i >= 0 && i <= _size, "Bad string subscript: ", i);
return _str[i]; return _str[i];
} }
char operator[](int i) const // TString[i] -> _str[i]
char operator[](int i) const { return _str[i]; } // TString[i] -> _str[i] {
CHECKD(i >= 0 && i <= _size, "Bad string subscript: ", i);
return _str[i];
}
int size() const { return _size; } int size() const { return _size; }
int len() const { return strlen(_str); } int len() const { return strlen(_str); }
@ -238,11 +241,11 @@ public:
const TString& operator =(const char* s) { set(s);restart();return *this; } const TString& operator =(const char* s) { set(s);restart();return *this; }
const TString& operator =(const TString& s) { set(s);restart();return *this; } const TString& operator =(const TString& s) { set(s);restart();return *this; }
void add(const char* s, int n = -1); // Aggiunge un token void add(const char* s, int n = -1); // Aggiunge una stringa
void add(char c, int pos = -1); // Aggiunge un char void add(char c, int pos = -1); // Aggiunge un char
void add(long n, int pos = -1); // Aggiunge un intero void add(long n, int pos = -1); // Aggiunge un intero
void add(int n, int pos = -1); // Aggiunge un intero void add(int n, int pos = -1); // Aggiunge un intero
void destroy(int pos); // Toglie il token pos void destroy(int pos); // Toglie la stringa pos
const char* get(); // Ritorna il prossimo token const char* get(); // Ritorna il prossimo token
const char* get(int n); // Ritorna un token (-1 = prossimo; -2 = ultimo; n = ennesimo) const char* get(int n); // Ritorna un token (-1 = prossimo; -2 = ultimo; n = ennesimo)
char get_char(int n = -1); // Ritorna un carattere char get_char(int n = -1); // Ritorna un carattere

View File

@ -1053,8 +1053,8 @@ void TViswin::handler (WINDOW win, EVENT * ep)
break; break;
case E_MOUSE_MOVE: case E_MOUSE_MOVE:
{ {
/*
if (!_selecting && !_iscross) // no buttons pressed if (!_selecting && !_iscross) // no buttons pressed
{ {
p = ep->v.mouse.where; p = ep->v.mouse.where;
if (in_text (p)) if (in_text (p))
@ -1064,6 +1064,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
check_link (&p); check_link (&p);
} }
} }
*/
if (_selecting || _iscross) if (_selecting || _iscross)
{ {
p = ep->v.mouse.where; p = ep->v.mouse.where;