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
This commit is contained in:
parent
4510dcba25
commit
0a93dba34d
@ -130,9 +130,9 @@ void TBanner::handler(WINDOW win, EVENT* ep)
|
|||||||
|
|
||||||
r.left += 4; r.right -= 4;
|
r.left += 4; r.right -= 4;
|
||||||
r.top += 4; r.bottom -= 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);
|
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);
|
win_draw_icon(win, CHARX<<1, CHARX<<1, ICON_RSRC);
|
||||||
}
|
}
|
||||||
@ -650,10 +650,7 @@ void TApplication::set_cursor(bool w)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_count--;
|
_count--;
|
||||||
#ifdef DBG
|
CHECK(_count >= 0, "end_wait without matching begin_wait");
|
||||||
if (_count < 0)
|
|
||||||
yesnofatal_box("end_wait without matching begin_wait");
|
|
||||||
#endif
|
|
||||||
if (_count == 0)
|
if (_count == 0)
|
||||||
::set_cursor(ww, CURSOR_ARROW);
|
::set_cursor(ww, CURSOR_ARROW);
|
||||||
}
|
}
|
||||||
|
@ -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
|
// ritorna valore di variabile nella sezione corrente o in
|
||||||
// quella specificata
|
// 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 << ')';
|
TString80 vvar(var); if (index != -1) vvar << '(' << index << ')';
|
||||||
|
|
||||||
_check_paragraph(section);
|
_check_paragraph(section);
|
||||||
|
@ -689,7 +689,6 @@ int TLocalisamfile::open(unsigned int mode)
|
|||||||
err = _open();
|
err = _open();
|
||||||
_was_open = TRUE;
|
_was_open = TRUE;
|
||||||
}
|
}
|
||||||
_isatab = FALSE;
|
|
||||||
setstatus(err);
|
setstatus(err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,6 @@ class TLocalisamfile : public TBaseisamfile
|
|||||||
{
|
{
|
||||||
// @DPRIV
|
// @DPRIV
|
||||||
bool _was_open; // Vero se il file e' stato aperto come Localisamfile
|
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
|
int _oldkey; // Old key if already open
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -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 <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fstream.h>
|
#include <fstream.h>
|
||||||
@ -18,10 +18,11 @@
|
|||||||
|
|
||||||
TMessage::TMessage(const char* to, const char* sub,
|
TMessage::TMessage(const char* to, const char* sub,
|
||||||
const char* text, const char* from)
|
const char* text, const char* from)
|
||||||
{
|
{
|
||||||
_to = to;
|
TString80 rec(to);
|
||||||
if (to && *to && (_to.len() != 6 || _to.strip(" -") != to))
|
if (rec.not_empty() && (rec.len() != 6 || rec.strip(" -") != to))
|
||||||
_to = cmd2name(to);
|
rec = cmd2name(to);
|
||||||
|
_to = rec;
|
||||||
_subject = sub;
|
_subject = sub;
|
||||||
_text = text;
|
_text = text;
|
||||||
_from = (from == NULL || *from == '\0') ? main_app().name() : from;
|
_from = (from == NULL || *from == '\0') ? main_app().name() : from;
|
||||||
|
@ -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++-*- */
|
/* si', trattasi di -*-c++-*- */
|
||||||
// Mailbox.h
|
// Mailbox.h
|
||||||
@ -7,10 +7,6 @@
|
|||||||
#ifndef __MAILBOX_H
|
#ifndef __MAILBOX_H
|
||||||
#define __MAILBOX_H
|
#define __MAILBOX_H
|
||||||
|
|
||||||
#ifndef __ARRAY_H
|
|
||||||
#include <array.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __STRINGS_H
|
#ifndef __STRINGS_H
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,12 +25,12 @@ bool TMask::test_focus_change(WINDOW next)
|
|||||||
|
|
||||||
TMask_field& prev = fld(_focus);
|
TMask_field& prev = fld(_focus);
|
||||||
if (prev.win() != next)
|
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();
|
set_focus();
|
||||||
prev.set_focusdirty(FALSE);
|
prev.set_focusdirty(FALSE);
|
||||||
ok = FALSE; // ... sorry, it does not
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
@ -132,11 +132,17 @@ void TMask::handler(WINDOW win, EVENT* ep)
|
|||||||
switch(ep->v.ctl.id)
|
switch(ep->v.ctl.id)
|
||||||
{
|
{
|
||||||
case DLG_OK:
|
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 :
|
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 :
|
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:
|
case DLG_F9:
|
||||||
{
|
{
|
||||||
WINDOW w = ep->v.ctl.ci.win;
|
WINDOW w = ep->v.ctl.ci.win;
|
||||||
|
@ -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 <xvt.h>
|
#include <xvt.h>
|
||||||
|
|
||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
@ -457,7 +457,7 @@ void TMask_field::set_prompt(const char* p)
|
|||||||
|
|
||||||
|
|
||||||
void TMask_field::set(const char* s)
|
void TMask_field::set(const char* s)
|
||||||
{
|
{
|
||||||
if (mask().is_running())
|
if (mask().is_running())
|
||||||
{
|
{
|
||||||
set_window_data(s);
|
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%
|
// Certified 90%
|
||||||
bool TMask_field::on_hit()
|
bool TMask_field::on_hit()
|
||||||
{
|
{
|
||||||
|
@ -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
|
#ifndef __MASKFLD_H
|
||||||
#define __MASKFLD_H
|
#define __MASKFLD_H
|
||||||
|
|
||||||
@ -121,6 +121,7 @@ public:
|
|||||||
bool focusdirty() const { return _flags.focusdirty; }
|
bool focusdirty() const { return _flags.focusdirty; }
|
||||||
void set_focusdirty(bool d = TRUE) { _flags.focusdirty = d; }
|
void set_focusdirty(bool d = TRUE) { _flags.focusdirty = d; }
|
||||||
void set_dirty(bool d = TRUE);
|
void set_dirty(bool d = TRUE);
|
||||||
|
void set_justify(bool r) { _flags.rightjust = r; }
|
||||||
|
|
||||||
virtual const char* class_name() const;
|
virtual const char* class_name() const;
|
||||||
virtual word class_id() const;
|
virtual word class_id() const;
|
||||||
@ -159,9 +160,10 @@ public:
|
|||||||
|
|
||||||
bool is_edit() const;
|
bool is_edit() const;
|
||||||
bool to_check(KEY k, bool checkrun = FALSE) const;
|
bool to_check(KEY k, bool checkrun = FALSE) const;
|
||||||
|
|
||||||
virtual bool on_hit();
|
virtual bool on_hit();
|
||||||
virtual bool on_key(KEY key);
|
virtual bool on_key(KEY key);
|
||||||
|
virtual bool test_focus_change();
|
||||||
|
|
||||||
void set(const char* s);
|
void set(const char* s);
|
||||||
TString& get() const;
|
TString& get() const;
|
||||||
|
@ -96,6 +96,7 @@ public:
|
|||||||
void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork); }
|
void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork); }
|
||||||
|
|
||||||
bool active() const { return _active; }
|
bool active() const { return _active; }
|
||||||
|
bool test_focus_change();
|
||||||
|
|
||||||
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
|
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)
|
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);
|
const int r = rec2row(riga);
|
||||||
XI_OBJ cell;
|
|
||||||
XI_MAKE_CELL(&cell, _list, r, colonna);
|
for (; colonna < _columns; colonna++)
|
||||||
xi_set_focus(&cell);
|
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);
|
notify(_cur_rec, K_SPACE);
|
||||||
_row_dirty = TRUE;
|
_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)
|
void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev)
|
||||||
{
|
{
|
||||||
TSpreadsheet* es = (TSpreadsheet*)xi_get_app_data(itf);
|
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);
|
es->list_handler(xiev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 75%
|
// Certified 75%
|
||||||
void TSpreadsheet::list_handler(XI_EVENT *xiev)
|
void TSpreadsheet::list_handler(XI_EVENT *xiev)
|
||||||
{
|
{
|
||||||
@ -448,340 +471,332 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
|
|||||||
switch (xiev->type)
|
switch (xiev->type)
|
||||||
{
|
{
|
||||||
case XIE_GET_FIRST:
|
case XIE_GET_FIRST:
|
||||||
{
|
if (items() > 0L)
|
||||||
const long max = items();
|
|
||||||
if (max > 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;
|
if (n < 0L) n = 0L;
|
||||||
xiev->v.rec_request.data_rec = n;
|
xiev->v.rec_request.data_rec = n;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
xiev->refused = TRUE;
|
xiev->refused = TRUE;
|
||||||
}
|
break;
|
||||||
break;
|
case XIE_GET_LAST:
|
||||||
case XIE_GET_LAST:
|
xiev->v.rec_request.data_rec = items()-1;
|
||||||
xiev->v.rec_request.data_rec = items()-1;
|
break;
|
||||||
break;
|
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 + (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 long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ;
|
||||||
{
|
if (n < 0 || n >= items())
|
||||||
const int col = cid - FIRST_FIELD;
|
xiev->refused = TRUE;
|
||||||
TMask_field* f = field(cid);
|
else
|
||||||
const int acqua = f->class_id();
|
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)
|
const int oldrec = _cur_rec;
|
||||||
{
|
set_pos(xiev->v.select.xi_obj->v.row, xiev->v.select.column);
|
||||||
if (isdigit(_button[0]))
|
if (oldrec != _cur_rec)
|
||||||
xiev->v.cell_request.icon_rid = atoi(_button);
|
{
|
||||||
else
|
str2mask(_cur_rec);
|
||||||
src = _button;
|
_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
|
else
|
||||||
{
|
{
|
||||||
src = row(rec).get(col); // Set value for cell
|
_cur_row = _cur_rec = 0;
|
||||||
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);
|
|
||||||
xiev->refused = TRUE;
|
xiev->refused = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case E_CHAR:
|
case XIE_OFF_ROW:
|
||||||
if (_edit_field)
|
if (_row_dirty && _check_enabled)
|
||||||
{
|
{
|
||||||
const KEY k = e_char_to_key(ep);
|
_check_enabled = FALSE; // Avoid recursion!
|
||||||
switch(k)
|
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:
|
TMask_field* c = _edit_field; // Save field, it could turn out to be NULL on error
|
||||||
case K_BTAB:
|
const char* nuo = c->picture_data(xi_get_text(xiev->v.xi_obj, NULL, -1), TRUE);
|
||||||
_lastab = k;
|
c->set(nuo); // Set new mask value
|
||||||
break;
|
c->set_dirty(); // Get it dirty!
|
||||||
case K_F1:
|
if (c->on_key(c->is_edit() ? K_TAB : K_SPACE) == FALSE) // Test it
|
||||||
_check_enabled = FALSE; // Disable checks
|
{
|
||||||
_edit_field->on_key(K_F1);
|
xiev->refused = *nuo != '\0';
|
||||||
set_focus_cell(_cur_row, _cur_col);
|
}
|
||||||
_check_enabled = TRUE; // Enable checks
|
else
|
||||||
break;
|
|
||||||
case K_F2:
|
|
||||||
case K_F3:
|
|
||||||
case K_F8:
|
|
||||||
case K_F9:
|
|
||||||
case K_F11:
|
|
||||||
if (_check_enabled && active())
|
|
||||||
{
|
{
|
||||||
|
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
|
_check_enabled = FALSE; // Disable checks
|
||||||
notify_change();
|
_edit_field->on_key(K_F1);
|
||||||
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);
|
set_focus_cell(_cur_row, _cur_col);
|
||||||
_check_enabled = TRUE; // Enable checks
|
_check_enabled = TRUE; // Enable checks
|
||||||
}
|
break;
|
||||||
break;
|
case K_F2:
|
||||||
case K_PREV:
|
case K_F3:
|
||||||
case K_NEXT:
|
case K_F8:
|
||||||
if (xi_move_focus(_itf))
|
case K_F9:
|
||||||
dispatch_e_char(parent(), k);
|
case K_F11:
|
||||||
break;
|
if (_check_enabled && active())
|
||||||
case K_ESC:
|
{
|
||||||
xi_set_focus(_itf);
|
_check_enabled = FALSE; // Disable checks
|
||||||
dispatch_e_char(parent(), K_ESC);
|
notify_change();
|
||||||
break;
|
if (_edit_field->on_key(k))
|
||||||
case K_CTRL+K_PREV:
|
{
|
||||||
xi_scroll(_list, XI_SCROLL_PGUP);
|
mask2str(_cur_rec);
|
||||||
break;
|
}
|
||||||
case K_CTRL+K_NEXT:
|
else
|
||||||
xi_scroll(_list, XI_SCROLL_PGDOWN);
|
{
|
||||||
break;
|
if (k == K_F9)
|
||||||
case K_CTRL+K_HOME:
|
{
|
||||||
xi_scroll(_list, XI_SCROLL_FIRST);
|
_edit_field = &_mask.fld(_mask.focus_field());
|
||||||
break;
|
const short foca = _edit_field->dlg();
|
||||||
case K_CTRL+K_END:
|
const int col = (foca - FIRST_FIELD) % 100 +1;
|
||||||
xi_scroll(_list, XI_SCROLL_LAST);
|
if (col > 0 && col != _cur_col)
|
||||||
break;
|
{
|
||||||
default:
|
_cur_col = col;
|
||||||
break;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TSpreadsheet::activate(bool on)
|
void TSpreadsheet::activate(bool on)
|
||||||
{
|
{
|
||||||
@ -855,6 +870,7 @@ public:
|
|||||||
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
|
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
|
||||||
void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork);}
|
void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork);}
|
||||||
bool dirty() const { return _owner->dirty(); }
|
bool dirty() const { return _owner->dirty(); }
|
||||||
|
bool test_focus_change() { return TRUE; }
|
||||||
|
|
||||||
void mask2str(int riga);
|
void mask2str(int riga);
|
||||||
void str2mask(int riga);
|
void str2mask(int riga);
|
||||||
@ -1263,14 +1279,13 @@ void TSheet_field::set_notify(SPREADSHEET_NOTIFY n)
|
|||||||
|
|
||||||
void TSheet_field::highlight() const
|
void TSheet_field::highlight() const
|
||||||
{
|
{
|
||||||
|
TMask_field::highlight();
|
||||||
#if XVT_OS == XVT_OS_WIN
|
#if XVT_OS == XVT_OS_WIN
|
||||||
if (_sheet->_firstfocus && items())
|
if (items())
|
||||||
{
|
{
|
||||||
_sheet->_firstfocus = FALSE;
|
_sheet->_firstfocus = FALSE;
|
||||||
_sheet->set_focus_cell(0, 1);
|
_sheet->set_focus_cell(0, 1);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
TMask_field::highlight();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1311,20 +1326,18 @@ bool TSheet_field::on_hit()
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TSheet_field::test_focus_change()
|
||||||
|
{
|
||||||
|
return _sheet->test_focus_change();
|
||||||
|
}
|
||||||
|
|
||||||
bool TSheet_field::on_key(KEY k)
|
bool TSheet_field::on_key(KEY k)
|
||||||
{
|
{
|
||||||
if (k == K_TAB || k == K_ENTER)
|
if (k == K_ENTER)
|
||||||
{
|
{
|
||||||
if (dirty() > TRUE)
|
if (!test_focus_change())
|
||||||
return FALSE;
|
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);
|
return TMask_field::on_key(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@ protected:
|
|||||||
virtual word class_id() const;
|
virtual word class_id() const;
|
||||||
virtual bool on_hit();
|
virtual bool on_hit();
|
||||||
virtual bool on_key(KEY k);
|
virtual bool on_key(KEY k);
|
||||||
|
virtual bool test_focus_change();
|
||||||
|
|
||||||
virtual void parse_head(TScanner& scanner);
|
virtual void parse_head(TScanner& scanner);
|
||||||
virtual bool parse_item(TScanner& scanner);
|
virtual bool parse_item(TScanner& scanner);
|
||||||
virtual void create(WINDOW parent);
|
virtual void create(WINDOW parent);
|
||||||
|
@ -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 <mailbox.h>
|
#include <mailbox.h>
|
||||||
#include <sheet.h>
|
#include <sheet.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
@ -623,6 +623,7 @@ bool TRelation_application::save(bool check_dirty)
|
|||||||
}
|
}
|
||||||
was_dirty = FALSE;
|
was_dirty = FALSE;
|
||||||
|
|
||||||
|
begin_wait();
|
||||||
if (mode == MODE_INS)
|
if (mode == MODE_INS)
|
||||||
{
|
{
|
||||||
bool changed = TRUE;
|
bool changed = TRUE;
|
||||||
@ -648,6 +649,7 @@ bool TRelation_application::save(bool check_dirty)
|
|||||||
get_relation()->restore_status();
|
get_relation()->restore_status();
|
||||||
err = rewrite(*_mask);
|
err = rewrite(*_mask);
|
||||||
}
|
}
|
||||||
|
end_wait();
|
||||||
|
|
||||||
switch(err)
|
switch(err)
|
||||||
{
|
{
|
||||||
@ -743,10 +745,6 @@ bool TRelation_application::main_loop()
|
|||||||
|
|
||||||
k = _mask->run();
|
k = _mask->run();
|
||||||
|
|
||||||
// Seleziona il cursore a clessidra se necessario
|
|
||||||
if (k != K_QUIT && k != K_F9)
|
|
||||||
begin_wait();
|
|
||||||
|
|
||||||
switch (k)
|
switch (k)
|
||||||
{
|
{
|
||||||
case K_ESC:
|
case K_ESC:
|
||||||
@ -830,9 +828,6 @@ bool TRelation_application::main_loop()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k != K_QUIT && k != K_F9)
|
|
||||||
end_wait();
|
|
||||||
} while (k != K_QUIT);
|
} while (k != K_QUIT);
|
||||||
|
|
||||||
if (_mask->is_open())
|
if (_mask->is_open())
|
||||||
|
@ -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
|
// relation.cpp
|
||||||
// fv 12/8/93
|
// fv 12/8/93
|
||||||
// relation class for isam files
|
// relation class for isam files
|
||||||
@ -1104,9 +1104,11 @@ TRecnotype TCursor::readrec()
|
|||||||
|
|
||||||
FILE* _f = open_index();
|
FILE* _f = open_index();
|
||||||
|
|
||||||
if ((fseek(_f, _pos * sizeof(TRecnotype), SEEK_SET) != 0) ||
|
if (fseek(_f, _pos * sizeof(TRecnotype), SEEK_SET) != 0)
|
||||||
(fread(&nrec, sizeof(TRecnotype), 1, _f) != 1))
|
fatal_box("Can't seek position %ld in cursor n. %d\n", _pos, file().filehnd()->ln);
|
||||||
fatal_box("Can't read record in file n. %d\n", 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);
|
fclose(_f);
|
||||||
|
|
||||||
|
@ -22,7 +22,10 @@
|
|||||||
|
|
||||||
HIDDEN const int MAXSTR = 301;
|
HIDDEN const int MAXSTR = 301;
|
||||||
HIDDEN char __spark[MAXSTR]; // Utility buffer
|
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
|
// Dinamically resizes a string
|
||||||
// Certified 99%
|
// Certified 99%
|
||||||
@ -156,7 +159,7 @@ TString& TString::strip_spaces()
|
|||||||
for (int i = 0; _str[i]; i++)
|
for (int i = 0; _str[i]; i++)
|
||||||
{
|
{
|
||||||
char c = _str[i];
|
char c = _str[i];
|
||||||
if (isspace(c) && !instring) continue;
|
if (is_space(c) && !instring) continue;
|
||||||
if (c == '"' || c == '\'')
|
if (c == '"' || c == '\'')
|
||||||
{
|
{
|
||||||
if (instring == c) instring = '\0';
|
if (instring == c) instring = '\0';
|
||||||
@ -301,7 +304,7 @@ TString& TString::ltrim(int count)
|
|||||||
if (count >= len()) return cut(0);
|
if (count >= len()) return cut(0);
|
||||||
s = &_str[count];
|
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);
|
if (s != _str) strcpy(_str, s);
|
||||||
return *this;
|
return *this;
|
||||||
@ -318,7 +321,8 @@ TString& TString::rtrim(int count)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char* good = _str-1;
|
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';
|
*(good+1) = '\0';
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@ -329,7 +333,7 @@ TString& TString::trim()
|
|||||||
char* last = _str;
|
char* last = _str;
|
||||||
|
|
||||||
// Salta spazi iniziali
|
// Salta spazi iniziali
|
||||||
for (const char* s = _str; *s && isspace(*s); s++);
|
for (const char* s = _str; *s && is_space(*s); s++);
|
||||||
|
|
||||||
// Copia stringa
|
// Copia stringa
|
||||||
if (s > _str)
|
if (s > _str)
|
||||||
@ -337,7 +341,7 @@ TString& TString::trim()
|
|||||||
for(char* c = _str; *s; s++)
|
for(char* c = _str; *s; s++)
|
||||||
{
|
{
|
||||||
*c++ = *s;
|
*c++ = *s;
|
||||||
if (!isspace(*s)) last = c;
|
if (!is_space(*s)) last = c;
|
||||||
}
|
}
|
||||||
// Elimina spazi finali
|
// Elimina spazi finali
|
||||||
*last = '\0';
|
*last = '\0';
|
||||||
@ -896,7 +900,7 @@ int TToken_string::get_pos(const char* s)
|
|||||||
bool TToken_string::empty_items() const
|
bool TToken_string::empty_items() const
|
||||||
{
|
{
|
||||||
for (const char* c = _str; *c; c++)
|
for (const char* c = _str; *c; c++)
|
||||||
if (!isspace(*c) && *c != _separator) return FALSE;
|
if (!is_space(*c) && *c != _separator) return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -999,7 +1003,7 @@ void TParagraph_string::tokenize()
|
|||||||
for (int end = start+_width; end < len(); end = start+_width)
|
for (int end = start+_width; end < len(); end = start+_width)
|
||||||
{
|
{
|
||||||
for (int i = end; i >= start; i--)
|
for (int i = end; i >= start; i--)
|
||||||
if (isspace(_str[i])) break;
|
if (is_space(_str[i])) break;
|
||||||
|
|
||||||
if (i < start)
|
if (i < start)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user