automask.* Supporto automask all'interno degli spreadsheet

default.url  Aggiunto bottone elabora
defmask.h    Aggiunto DLG_ELABORA
urldefid.h   Aggiunto BMP_ELABORA
dongle.cpp   Corretta procedura di connessione a chiave o server
expr.*       Corretti operatori di conversione a TString, real e bool
form.cpp     Modificata indentazione
isamrpc.cpp  Aggiunto riconoscimento stringa localhost
netsock.cpp  Aggiunto riconoscimento stringa localhost
relation.cpp Usato operatore as_string delle espresioni
strings.cpp  Migliorato assegnamento


git-svn-id: svn://10.65.10.50/trunk@6735 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-06-10 14:25:36 +00:00
parent a582971ad0
commit 7cfd681203
14 changed files with 92 additions and 48 deletions

View File

@ -23,26 +23,27 @@ bool TAutomask::error_box(const char* fmt, ...)
return FALSE;
}
bool TAutomask::universal_handler(TMask_field& f, KEY key)
TField_event TAutomask::key2event(TMask_field& f, KEY key) const
{
TAutomask& wm = (TAutomask&)f.mask();
TOperable_field& of = (TOperable_field&)f;
TField_event fe = fe_null;
long jolly = key;
switch (key)
{
case K_TAB:
if (wm.is_running() || wm.get_sheet() != NULL)
{
if (f.focusdirty() && f.is_edit())
fe = fe_modify;
const TMask& wm = f.mask();
if (wm.is_running() || wm.get_sheet() != NULL)
{
if (f.focusdirty() && f.is_edit())
fe = fe_modify;
}
else
fe = fe_init;
}
else
fe = fe_init;
break;
case K_SPACE:
if (!f.is_edit())
{
const TMask& wm = f.mask();
if (wm.is_running())
{
if (f.is_kind_of(CLASS_BUTTON_FIELD))
@ -65,9 +66,29 @@ bool TAutomask::universal_handler(TMask_field& f, KEY key)
fe = fe_null;
break;
}
return fe == fe_null ? TRUE : wm.on_field_event(of, fe, jolly);
return fe;
}
bool TAutomask::universal_handler(TMask_field& f, KEY key)
{
TOperable_field& of = (TOperable_field&)f;
TAutomask& am = (TAutomask&)of.mask();
TField_event fe = am.key2event(of, key);
return fe == fe_null ? TRUE : am.on_field_event(of, fe, 0);
}
bool TAutomask::insheet_universal_handler(TMask_field& f, KEY key)
{
TMask& m = f.mask();
TSheet_field& s = *m.get_sheet();
TAutomask& am = (TAutomask&)s.mask();
TOperable_field& of = (TOperable_field&)f;
TField_event fe = am.key2event(of, key);
return fe == fe_null ? TRUE : am.on_field_event(of, fe, m.number());
}
bool TAutomask::universal_notifier(TSheet_field& s, int row, KEY key)
{
TAutomask& wm = (TAutomask&)s.mask();
@ -111,11 +132,22 @@ void TAutomask::set_handlers()
{
f.set_handler(universal_handler);
if (f.is_sheet())
{
((TSheet_field&)f).set_notify(universal_notifier);
TMask& m = ((TSheet_field&)f).sheet_mask();
for (int j = m.fields()-1; j >= 0; j--)
{
TMask_field& g = m.fld(j);
if (g.is_operable())
g.set_handler(insheet_universal_handler);
}
}
}
}
}
TAutomask::TAutomask(const char* name, int num)
: TMask(name, num)
{

View File

@ -14,10 +14,12 @@ class TAutomask : public TMask
{
private:
static bool universal_handler(TMask_field& f, KEY k);
static bool insheet_universal_handler(TMask_field& f, KEY k);
static bool universal_notifier(TSheet_field& f, int row, KEY k);
protected:
void set_handlers();
TField_event key2event(TMask_field& f, KEY key) const;
public:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly) pure;

View File

@ -148,6 +148,7 @@ image BMP_LINK QRESDIR"link.bmp"
image BMP_PRINT QRESDIR"print.bmp"
image BMP_SETPRINT QRESDIR"setprint.bmp"
image BMP_RECALC QRESDIR"recalc.bmp"
image BMP_ELABORA QRESDIR"elabora.bmp"
image BMP_OLE QRESDIR"ole.bmp"
image BMP_LENTE QRESDIR"lente.bmp"
image BMP_FAX QRESDIR"fax.bmp"

View File

@ -28,7 +28,7 @@
#define DLG_PRINT 24 /* TAG del bottone Stampa */
#define DLG_SETPRINT 25 /* TAG del bottone Imposta Stampa */
#define DLG_RECALC 26 /* TAG del bottone Ricalcola */
#define DLG_ELAB 27 /* TAG del bottone <Elabora> */
#define DLG_ELABORA 27 /* TAG del bottone <Elabora> */
#define DLG_FAX 28 /* TAG del bottone <Fax> */
#define DLG_EMAIL 29 /* TAG del bottone <Posta> */
#define DLG_USER 100 /* TAG del primo controllo definito dall'utente */

View File

@ -460,7 +460,7 @@ bool TDongle::login(bool test_all_keys)
TDongleHardware hw = _hardware;
if (hw == _dongle_unknown)
{
if (can_try_server() == 3)
if (os_dongle_server_running())
{
hw = _dongle_network;
}

View File

@ -266,7 +266,6 @@ void TExpression::evaluate_user_func(int index, int nparms, TEval_stack& stack,
}
void TExpression::setvar(const char* varname, const real& val)
{
if (_var.getnum(varname) != val)
{
@ -277,7 +276,6 @@ void TExpression::setvar(const char* varname, const real& val)
void TExpression::setvar(int varnum, const real& val)
{
if (_var.getnum(varnum) != val)
{
@ -436,7 +434,7 @@ void TExpression::eval()
}
break;
case _match:
{
{
const TString & s2 = evalstack.pop_string();
const TString & s1 = evalstack.pop_string();
evalstack.push(real((s1.match(s2)) ? 1.0 : 0.0));
@ -582,8 +580,7 @@ void TExpression::eval()
break;
case _len:
{
TString s1(evalstack.pop_string());
TString& s1 = evalstack.pop_string();
evalstack.push(real(s1.len()));
}
break;

View File

@ -78,11 +78,11 @@ enum TCodesym {
// @doc INTERNAL
// @class TValue | Classe per la definizione dei valori che possono essere assunti
// dai termini di una espressione o il valore dell'espressione stessa
//
// @base public | TObject
class TValue : public TObject
// @class TValue | Classe per la definizione dei valori che possono essere assunti
// dai termini di una espressione o il valore dell'espressione stessa
//
// @base public | TObject
class TValue : public TObject
// @author:(INTERNAL) Sandro
{
@ -110,8 +110,8 @@ public:
const real& number() const
{ return _r; }
// @cmember Ritorna il valore come stringa
const char* string() const
{ return (const char*) _s;}
const TString& string() const
{ return _s;}
// @cmember Setta il valore passato come real
void set(const real& val)
{ _r = val; _s = val.string(); _t = _numexpr; }

View File

@ -758,7 +758,7 @@ bool TForm_item::do_message(int num)
TToken_string& messaggio = message(num);
if (messaggio.empty_items()) return FALSE;
TToken_string msg(16, ',');
TToken_string msg(80, ',');
for (const char* m = messaggio.get(0); m; m = messaggio.get())
{
msg = m;

View File

@ -222,7 +222,7 @@ bool rpc_UserLogin(const char* server, const char* user,
return FALSE;
}
const bool local = server == NULL || *server == '\0';
const bool local = server == NULL || *server == '\0' || stricmp(server, "localhost") == 0;
TString name(40);
if (local)
name = "locale";

View File

@ -517,7 +517,7 @@ TConnection* TSocketClient::OnQueryConnection(const char* service,
if (cur_socket == NULL)
{
TString strServer = server;
if (strServer.empty())
if (strServer.empty() || stricmp(strServer, "localhost") == 0)
strServer = "127.0.0.1";
cur_socket = new skstream(strServer, (skstream::service)atoi(service));
@ -540,7 +540,7 @@ BOOL TSocketClient::Execute(DWORD id, const char* cmd)
if (ok)
{
const int buflen = strlen(cmd)+1;
cur_socket->sync();
cur_socket->sync();
cur_socket->write(cmd, buflen);
cur_socket->flush();
ok = cur_socket->good();
@ -561,15 +561,15 @@ BOOL TSocketClient::Request(DWORD id, const char* cmd)
ok = Execute(id, cmd);
if (ok)
{
m_dwSize = 0;
cur_socket->read((char*)&m_dwSize, sizeof(m_dwSize));
ok = m_dwSize > 0;
if (ok)
{
m_pData = new BYTE[m_dwSize];
cur_socket->read(m_pData, (int)m_dwSize);
ok = cur_socket->good();
}
m_dwSize = 0;
cur_socket->read((char*)&m_dwSize, sizeof(m_dwSize));
ok = m_dwSize > 0;
if (ok)
{
m_pData = new BYTE[m_dwSize];
cur_socket->read(m_pData, (int)m_dwSize);
ok = cur_socket->good();
}
}
semaphore = FALSE;

View File

@ -228,7 +228,7 @@ const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to)
expr.setvar(k, to.get(name));
}
const char* val = expr;
const char* val = expr.as_string();
if (*val == '\0' && _altexprs.objptr(j))
{
@ -238,7 +238,7 @@ const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to)
name = altexpr.varname(k); name.upper();
altexpr.setvar(k, to.get(name));
}
val = altexpr;
val = altexpr.as_string();
}
return val;
@ -588,6 +588,8 @@ int TRelation::position_rels(
// <nl>Le altre funzioni sul record procedono normalmente
{
TString expr; // Stringa di lavoro per la valutazione delle espressioni
_errors = NOERR;
// workhorse: position files for each active relation
@ -609,7 +611,7 @@ int TRelation::position_rels(
// build record
for (int j = 0 ; j < rd._fields.items(); j++) // for each field
{
TString expr (rd.evaluate_expr(j, to));
expr = rd.evaluate_expr(j, to);
TFieldref& s = (TFieldref&) rd._fields[j];
if (from.is_sorted() && from.curr().type(s.name()) ==_alfafld)
expr.rpad(s.len(from.curr()),'~');

View File

@ -134,10 +134,18 @@ TString& TString::set(
// @rdesc Ritorna l'indirizzo della stringa inizializzata
{
if (s == NULL) s = "";
const int sz = *s ? strlen(s) : 15;
if (sz > size()) resize(sz, FALSE);
strcpy(_str, s);
if (s && *s)
{
const int sz = strlen(s);
if (sz > size()) resize(sz, FALSE);
strcpy(_str, s);
}
else
{
if (size() == 0)
resize(15, FALSE);
*_str = '\0';
}
return *this;
}

View File

@ -52,6 +52,7 @@
#define BMP_LINK 117
#define BMP_PRINT 118
#define BMP_RECALC 119
#define BMP_ELABORA 120
#define BMP_FIRSTREC 121
#define BMP_PREVREC 122
#define BMP_STOPREC 123

View File

@ -20,7 +20,8 @@ TVariable_field::TVariable_field(
if (expr && *expr)
{
_e = new TExpression(expr, type);
if (TFixed_string(expr).find('-') == -1) _put_string = new TToken_string(expr, '+');
if (TFixed_string(expr).find('-') < 0)
_put_string = new TToken_string(expr, '+');
}
}