Velocizzati spreadsheet

MOdificata gestione chiave 1 della relapp


git-svn-id: svn://10.65.10.50/trunk@1333 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-05-09 13:33:34 +00:00
parent aa41da6683
commit 32761e46b5
16 changed files with 1831 additions and 1817 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
#ifndef APPNAME
#define APPNAME PRASSI
#define QAPPNAME "PRASSI"
#define LIBDIR f:\xvt.400\win_x86\ptk\lib
#define LIBDIR f:\xvt.45b\w16_x86\ptk\lib
#endif
#define NO_STD_EDIT_MENU

View File

@ -1781,13 +1781,6 @@ bool TRectype::get_bool(const char* fieldname) const
return *_isam_string == 'X';
}
#else
const char* TRectype::get(const char* fieldname) const
{
return get_str(fieldname);
}
#endif // FOXPRO
@ -2124,8 +2117,8 @@ long TRecfield::operator =(long l)
#ifndef FOXPRO
const real& TRecfield::operator =(const real& r)
{
strcpy(_isam_string, r.string());
__putfieldbuff( _len, _dec, _type, _isam_string, _p);
@ -2133,29 +2126,10 @@ const real& TRecfield::operator =(const real& r)
return r;
}
#else
const char* TRectype::get(const char* fieldname) const
{
RecDes* rd = rec_des();
if (CFieldType((char*) fieldname, rd) == _datefld)
{
const TRecfield f((TRectype&)*this, fieldname);
strcpy(_isam_string, (const char*) f);
}
else
if (CGetFieldBuff((char*) fieldname, rd, _rec, _isam_string) == -1)
UNKNOWN_FIELD(num(), fieldname);
return _isam_string;
}
#endif // FOXPRO
const TDate& TRecfield::operator =(const TDate& d)
{
strcpy(_isam_string, (const char*)d);
__putfieldbuff( _len, _dec, _type, _isam_string, _p);
@ -2166,7 +2140,6 @@ const TDate& TRecfield::operator =(const TDate& d)
const char* TRecfield::operator =(const char* s)
{
__putfieldbuff( _len, _dec, _type, s, _p);
_rec->setempty(FALSE);
@ -2175,7 +2148,6 @@ const char* TRecfield::operator =(const char* s)
void TRecfield::setptr(TRecnotype r)
{
if (_p == NULL) return;
@ -2194,7 +2166,6 @@ void TRecfield::setptr(TRecnotype r)
TRecfield::operator int() const
{
__getfieldbuff( _len, _type, _p, _isam_string);
return atoi(_isam_string);
@ -2202,7 +2173,6 @@ TRecfield::operator int() const
TRecfield::operator long() const
{
__getfieldbuff( _len, _type, _p, _isam_string);
return atol(_isam_string);
@ -2211,18 +2181,18 @@ TRecfield::operator long() const
#ifndef FOXPRO
TRecfield::operator const real() const
TRecfield::operator const real() const
{
__getfieldbuff( _len, _type, _p, _isam_string);
real r(_isam_string);
return r;
}
#endif // FOXPRO
TRecfield::operator TDate() const
{
static TDate d;
__getfieldbuff( _len, _type, _p, _isam_string);

View File

@ -96,8 +96,6 @@ public:
char get_char(const char* fieldname) const ;
bool get_bool(const char* fieldname) const ;
real get_real(const char* fieldname) const ;
#else
const char* get(const char* fieldname) const ;
#endif
TDate get_date(const char* fieldname) const ;
@ -278,8 +276,8 @@ public:
void put(const char* fieldname, const real& val)
{ curr().put(fieldname, val);}
#else
const char* get(const char* fieldname) const
{ return curr().get(fieldname);}
const char* get_str(const char* fieldname) const
{ return curr().get_str(fieldname);}
#endif
// @DES Put NON tipizzata

View File

@ -145,12 +145,12 @@ void TMask::handler(WINDOW win, EVENT* ep)
stop_run(K_AUTO_ENTER);
break;
case DLG_CANCEL :
if (test_focus_change(ep->v.ctl.ci.win))
stop_run(K_ESC);
// if (test_focus_change(ep->v.ctl.ci.win))
stop_run(K_ESC);
break;
case DLG_QUIT :
if (test_focus_change(ep->v.ctl.ci.win))
stop_run(K_FORCE_CLOSE);
// if (test_focus_change(ep->v.ctl.ci.win))
stop_run(K_FORCE_CLOSE);
break;
case DLG_F9:
{
@ -214,6 +214,9 @@ void TMask::read_mask(const char* name, int num, int max)
_sheetmask = num > 0;
long start_t = clock();
while (clock() == start_t) continue; // Attende scatto timer
start_t = clock();
if (!_sheetmask)
_total_time = _build_time = _init_time = 0;
@ -786,8 +789,8 @@ bool TMask::on_key(KEY key)
next_page(+1);
break;
case K_F12:
message_box("Lettura = %ld:\n"
"Creazione = %ld:\n"
message_box("Lettura = %ld\n"
"Creazione = %ld\n"
"Inizializzazione = %ld",
_total_time-_build_time, _build_time, _init_time);
break;
@ -799,15 +802,14 @@ bool TMask::on_key(KEY key)
next_page(1000 + key - K_F1);
else
{
const int last = fields();
for (int i = 0; i < last; i++)
for (int i = 0; i < fields(); i++)
{
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)
{
bool ok = b.dlg() != DLG_CANCEL && b.dlg() != DLG_QUIT && b.dlg() != DLG_F9;
bool ok = b.dlg() == DLG_CANCEL || b.dlg() == DLG_QUIT || b.dlg() == DLG_F9;
if (!ok) ok = test_focus_change(b.win());
if (ok)
f.on_key(K_SPACE);

View File

@ -730,8 +730,8 @@ bool TMask_field::do_message(int num)
bool TMask_field::test_focus_change()
{
bool ok = TRUE;
if (focusdirty()) on_key(K_TAB); // Comportamento normale
else if (is_edit() && in_key(1)) on_hit(); // Serve per eseguire gli handler autoprementi
if (focusdirty()) ok = on_key(K_TAB); // Comportamento normale
else if (is_edit() && in_key(1)) ok = on_hit(); // Serve per eseguire gli handler autoprementi
return ok;
}
@ -2123,9 +2123,12 @@ bool TEdit_field::on_key(KEY key)
const bool query = mask().query_mode();
// check consistency
if (_sheet) ok = query || _sheet->check(FINAL_CHECK);
if (_sheet)
ok = query || _sheet->check(FINAL_CHECK);
else
if (_browse &&
{
ok = query || !(check_type() == CHECK_REQUIRED && get().empty());
if (_browse && ok &&
check_enabled() &&
_validate_func != 21 && // 21 = NOT_EMPTY_CHECK_FIELD
(!query || forced()))
@ -2133,9 +2136,7 @@ bool TEdit_field::on_key(KEY key)
if (dirty()) ok = _browse->check(FINAL_CHECK); // Check consistency
else ok = _browse->empty_check();
}
else
ok = query || !(check_type() == CHECK_REQUIRED && get().empty());
}
if (!ok)
return default_error_box();
}

View File

@ -361,16 +361,17 @@ void TSpreadsheet::update_rec(int rec)
XI_OBJ row;
XI_MAKE_ROW(&row, _list, riga);
xi_cell_request(&row); // Update internal values
if (_update)
{
// xi_set_row_height(&row, CHARY+1); // Force row updating
XI_OBJ cell;
for (int c = 1; c < _columns; c++)
{
XI_MAKE_CELL(&cell, _list, riga, c);
xi_set_text(&cell, xi_get_text(&cell, NULL, -1));
}
}
/*
if (_update)
{
XI_OBJ cell;
for (int c = 1; c < _columns; c++)
{
XI_MAKE_CELL(&cell, _list, riga, c);
xi_set_text(&cell, xi_get_text(&cell, NULL, -1));
}
}
*/
}
}
@ -566,7 +567,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
char* dst = xiev->v.cell_request.s;
if (src && *src)
{
const int len = xiev->v.cell_request.len;
const int& len = xiev->v.cell_request.len;
strncpy(dst, src, len);
}
else
@ -574,10 +575,11 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
}
break;
case XIE_CHG_CELL:
if (_edit_field)
if (_edit_field && !_cell_dirty)
{
notify_change();
_edit_field->set_focusdirty(_cell_dirty = TRUE);
_cell_dirty = TRUE;
_edit_field->set_focusdirty();
}
break;
case XIE_BUTTON:
@ -643,7 +645,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
}
break;
case XIE_ON_LIST:
if (_firstfocus) // Trick to avoid the sheet to keep the focus forever ...
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;
@ -683,10 +685,13 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
ok = notify(_cur_rec, K_ENTER); // Notify edit
_update = TRUE; // Reenable update
}
if (!ok)
xiev->refused = TRUE;
else
if (ok)
{
xvt_statbar_refresh();
_edit_field = NULL; // Reset current field
}
else
xiev->refused = TRUE;
_check_enabled = TRUE;
}
@ -723,8 +728,6 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
else
mask2str(_cur_rec); // Update sheet row
}
if (!xiev->refused)
_edit_field = NULL; // Reset current field
_check_enabled = TRUE;
}
break;
@ -764,10 +767,8 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
_lastab = k;
break;
case K_UP:
_lastab = K_BTAB;
break;
case K_DOWN:
_lastab = K_TAB;
_lastab = _cur_col < 2 ? K_TAB : K_BTAB;
break;
case K_F1:
_check_enabled = FALSE; // Disable checks

View File

@ -1,4 +1,4 @@
// $Id: printapp.cpp,v 1.25 1995-05-09 09:12:14 villa Exp $
// $Id: printapp.cpp,v 1.26 1995-05-09 13:33:21 guy Exp $
#include <ctype.h>
#include <stdarg.h>
@ -846,9 +846,7 @@ void TPrint_application::print()
if (_cur->items () >= _wthr &&
(_force_progind || printer ().printtype () != screenvis))
_prind = new TProgind (_cur->items (),
(char *) (const char *) _wmess,
_wcancel, _wbar, 35);
_prind = new TProgind (_cur->items (), _wmess, _wcancel, _wbar, 35);
print_tree (_pr_tree);
_cur->freeze (FALSE);

View File

@ -873,3 +873,13 @@ const TImporto& TImporto::normalize()
return *this;
}
int TImporto::compare(const TSortable& s) const
{
const TImporto& i = (const TImporto&)s;
const real d = valore() - i.valore();
int res = d.sign();
if (res == 0)
res = sezione() != i.sezione();
return res;
}

View File

@ -25,6 +25,7 @@ class real : public TObject
// @END
protected:
virtual TObject* dup() const;
char* literals() const;
char* points(int decimals = 0) const;
@ -156,10 +157,13 @@ public:
};
class TImporto : public TObject
class TImporto : public TSortable
{
char _sezione;
real _valore;
protected:
virtual int compare(const TSortable& s) const;
public:
char sezione() const { return _sezione; }

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.53 1995-04-06 15:42:50 alex Exp $
// $Id: relapp.cpp,v 1.54 1995-05-09 13:33:26 guy Exp $
#include <mailbox.h>
#include <sheet.h>
#include <urldefid.h>
@ -22,7 +22,7 @@ HIDDEN bool can_change_firm()
HTASK ct = GetCurrentTask();
TaskFindHandle(&te, ct);
TaskFindHandle(&te, te.hTaskParent);
can = strcmp(te.szModule, "BA0") == 0;
can = stricmp(te.szModule, "BA0") == 0;
#else
can = TRUE;
#endif
@ -34,7 +34,6 @@ HIDDEN bool can_change_firm()
}
///////////////////////////////////////////////////////////
// Array delle chiavi della maschera di ricerca
///////////////////////////////////////////////////////////
@ -229,11 +228,10 @@ void TRelation_application::set_fixed()
void TRelation_application::enable_query()
{
const bool query = _mask->query_mode();
const bool noedit = !_mask->edit_mode();
const byte numkeys = _maskeys->items();
const bool query = _mask->query_mode();
const bool keyon = query || get_relation()->status() == _isreinsert;
for (byte k = 1; k <= numkeys; k++)
for (byte k = 1; k <= _maskeys->items(); k++)
{
const TChiave& chiave = _maskeys->key(k);
for (int i = 0; i < chiave.items(); i++)
@ -243,7 +241,7 @@ void TRelation_application::enable_query()
if (c.enabled_default())
{
if (k == 1)
c.enable(noedit);
c.enable(keyon);
if (c.has_query())
((TEdit_field&)c).enable_check(query);
}
@ -449,7 +447,7 @@ bool TRelation_application::modify_mode()
if (changing)
{
_mask->open_modal();
delete _maskeys; // May conflict! Keep this one
delete _maskeys;
_maskeys = new TKey_array(_mask);
}
@ -458,7 +456,6 @@ bool TRelation_application::modify_mode()
err = read(*_mask);
if (err != NOERR)
{
error_box("Errore di caricamento dati: %d", err);
query_mode();
return FALSE;
}
@ -488,12 +485,18 @@ bool TRelation_application::search_mode()
if (_mask->mode() != MODE_QUERY)
query_mode();
TMask_field* f = get_search_field();
if (f)
if (f->on_key(K_F9))
TMask_field* prima = get_search_field();
while (prima)
{
if (prima->on_key(K_F9))
{
if (find(1))
return modify_mode();
}
TMask_field* dopo = &_mask->fld(_mask->focus_field());
prima = (dopo == prima) ? NULL : dopo;
}
return FALSE;
}
@ -645,7 +648,10 @@ bool TRelation_application::save(bool check_dirty)
{
changed = autonum(_mask, TRUE);
if (!changed)
{
_mask->disable_starting_check();
enable_query(); // Abilita chiave 1 per rinumerazione manuale
}
}
else
changed = FALSE;

View File

@ -12,15 +12,19 @@ HIDDEN const char* strlwr (const char* str)
}
inline bool string_start(char c)
{ return c == '"' || c == '\'' || c == '{' || c == '\''; }
{ return c == '"' || c == '\'' || c == '{'; }
inline char match(char c)
{ return (c == '{') ? '}' : c; }
TScanner::TScanner(const char* filename)
: ifstream(strlwr(filename)), _token(128), _key(2), _pushed(FALSE), _line(0)
{
if (bad()) fatal_box("Impossibile aprire %s", filename);
: _pushed(FALSE), _line(0),
_token(128), _key(2), _buffer(1024*16)
{
setbuf((char*)(const char*)_buffer, _buffer.size());
open(filename);
if (bad())
fatal_box("Impossibile aprire %s", filename);
}
const TString& TScanner::pop()

View File

@ -17,7 +17,7 @@
class TScanner : private ifstream
{
// @DPRIV
TString _token, _key;
TString _token, _key, _buffer;
bool _pushed;
word _line;

View File

@ -64,7 +64,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
flags = WSF_VSCROLL;
}
if (dx == 0) // Calculates window width
if (dx == 0) // Compute window width
{
RCT r; xvt_vobj_get_client_rect(parent, &r);
dx = r.right/CHARX -6;
@ -72,7 +72,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
const int larg = width();
if (dx > larg) dx = larg;
}
if (dy == 0) dy = 20; // Calculates window height
if (dy == 0) dy = 20; // Compute window height
create(x, y, dx, dy, title, flags, wt, parent);
if (wt != W_PLAIN) // If normal sheet add buttons
@ -139,6 +139,10 @@ void TSheet::open()
{
// Abilita selezione se c'e' almeno un elemento
xvt_enable_control(_button[0], items() > 0 && _disabled.ones() < items());
if (_checkable)
xvt_enable_control(_button[1], items() > 0 && _check_enabled);
repos_buttons();
}
TScroll_window::open();
@ -200,8 +204,8 @@ void TSheet::handler(WINDOW win, EVENT* ep)
const short f = head_on() ? 1 : 0;
if (y >= f)
{
long vec = selected();
long nuo = first()+y-f;
const long vec = selected();
const long nuo = first()+y-f;
select(nuo);
if (ep->type == E_MOUSE_DBL)
dispatch_e_char(win, K_ENTER);
@ -746,7 +750,7 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
CTL_FLAG_DISABLED, 0L, DLG_EDIT);
}
if (s && s->items() > 2)
if (s && s->items() > 0)
{
int maxlen = 0;
SLIST lst = xvt_slist_create();
@ -764,8 +768,8 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
xvt_slist_destroy(lst);
TString16 id; id << f->dlg();
const int sel = s->get_pos(id) >> 1;
xvt_list_set_sel(listbox, sel, TRUE);
_sel = s->get_pos(id) >> 1;
xvt_list_set_sel(listbox, _sel, TRUE);
}
}
@ -864,7 +868,7 @@ void TBrowse_sheet::handler(WINDOW win, EVENT* ep)
if (ep->type == E_CONTROL && ep->v.ctl.id == DLG_FINDREC)
{
const int what = xvt_list_get_sel_index(ep->v.ctl.ci.win);
if (what >= 0)
if (what >= 0 && what != _sel)
stop_run(K_CTRL + what);
else
set_focus();

View File

@ -148,7 +148,8 @@ public:
class TBrowse_sheet : public TCursor_sheet
{
TEdit_field* const _field;
TEdit_field* const _field; // Linked edit field
int _sel; // Current listbox selection
protected:
virtual void handler(WINDOW win, EVENT* ep);

View File

@ -10,7 +10,6 @@
extern "C" { long nap(long period); }
#endif
// ERROR HOOK che intercetta errori XVT
// put breakpoint here
@ -117,7 +116,7 @@ bool allow_another_instance()
GlobalLock(GetModuleHandle((const char*)MAKELP(0,hInstance))));
if ( hModuleSel == 0 ) // Make sure we succeeded.
return 0;
return FALSE;
// Make pointers to the resident names table and the OFSTRUCT
LPSTR moduleName = (LPSTR)MAKELP( hModuleSel, *(WORD FAR *)MAKELP(hModuleSel, 0x26));
@ -147,7 +146,7 @@ bool allow_another_instance()
{
// Stop when we come to a directory separator or colon
if ( (*fileName=='\\') || (*fileName=='/') || (*fileName==':') )
return 0;
return FALSE;
if ( isupper(*fileName) )
{
@ -175,10 +174,6 @@ static BOOLEAN event_hook(HWND hwnd,
break;
case WM_CTLCOLOR:
{
#ifdef __CTL3D__
*ret = Ctl3dCtlColorEx(msg, wparam, lparam);
return FALSE; // Non fare altro
#else
const word type = HIWORD(lparam);
if (type == CTLCOLOR_LISTBOX || type == CTLCOLOR_EDIT ||
type == CTLCOLOR_MSGBOX)
@ -206,6 +201,14 @@ static BOOLEAN event_hook(HWND hwnd,
*ret = focus ? FocusBrush : NormalBrush;
return FALSE; // Non fare altro
}
#ifdef __CTL3D__
else
{
*ret = Ctl3dCtlColorEx(msg, wparam, lparam);
return TRUE;
}
#else
#endif
}
break;
@ -577,6 +580,7 @@ void customize_controls(bool on)
xvt_vobj_set_attr(NULL_WIN,ATTR_WIN_PM_DRAWABLE_TWIN, TRUE);
xvt_vobj_set_attr(NULL_WIN,ATTR_EVENT_HOOK, (long)event_hook);
xvt_vobj_set_attr(NULL_WIN,ATTR_WIN_CREATEWINDOW_HOOK, (long)createwindow_hook);
allow_another_instance();
HINSTANCE _hInstance = (HINSTANCE)xvt_vobj_get_attr(NULL_WIN, ATTR_WIN_INSTANCE);
@ -797,7 +801,7 @@ WINDOW xvt_create_control(WIN_TYPE wt,
if (wt == WC_GROUPBOX)
{
win = xvt_create_text(r.left, r.top, r.right, r.top+CHARY,
caption, parent, flags, app_data, id);
caption, parent, 0, app_data, id);
}
#endif
@ -860,7 +864,7 @@ void xvt_set_title(WINDOW win, const char* cap)
TControl* c = TControl::WINDOW2TControl(win);
c->set_caption(cap);
#else
xvt_vobj_set_title(win, cap);
xvt_vobj_set_title(win, (char*)cap);
#endif
}