Patch level : 10.0 109

Files correlati     :
Ricompilazione Demo : [ ]
Commento           :

Riportata la versione 3.2 1208


git-svn-id: svn://10.65.10.50/trunk@17101 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2008-08-27 09:33:08 +00:00
parent 4f9ea774d6
commit 870a1baae0
11 changed files with 146 additions and 30 deletions

View File

@ -21,3 +21,28 @@
: INCR ( a1 -- )
1 SWAP +!
;
: STRCONTAINS ( s1 s2 -- b1 )
STRFIND 0 >=
;
: STRLEFT ( s1 n1 -- s2 )
0 SWAP STRMID
;
: STRRIGHT ( s1 n1 -- s2 )
OVER STRLEN SWAP - -1 STRMID
;
: STRSTARTSWITH ( s1 s2 -- b1 )
DUP STRLEN ROT SWAP STRLEFT =
;
: STRENDSWITH ( s1 s2 -- b1 )
DUP STRLEN ROT SWAP STRRIGHT =
;
: STRBEFORE ( s1 s2 -- s3 )
OVER SWAP STRFIND STRLEFT
;

View File

@ -32,7 +32,7 @@ enum AVM_opcode
avm_or, avm_over,
avm_perform, avm_pick, avm_plus_loop, avm_plus_store, avm_push,
avm_repeat, avm_rdrop, avm_rpeek, avm_rpush, avm_roll, avm_rot, avm_round,
avm_strlen, avm_strmid, avm_strtok_fetch, avm_strtok_add,
avm_strfind, avm_strlen, avm_strmid, avm_strtok_fetch, avm_strtok_add,
avm_store, avm_sp, avm_sub, avm_swap,
avm_then, avm_trunc,
avm_until, avm_usrword,
@ -59,7 +59,7 @@ const char* AVM_TOKENS[avm_zzz+1] =
"OR", "OVER",
"PERFORM", "PICK", "+LOOP", "+!", "$PUSH$",
"REPEAT", "R>", "R@", ">R", "ROLL", "ROT", "ROUND",
"STRLEN", "STRMID", "STRTOK@", "STRTOK+",
"STRFIND", "STRLEN", "STRMID", "STRTOK@", "STRTOK+",
"!", "SP", "-", "SWAP",
"THEN", "TRUNC",
"UNTIL", "$USR$",
@ -943,7 +943,7 @@ void TAVM::execute(const TAVM_op& op)
{
const TString name = _stack.pop().as_string();
do_fetch(name);
_stack.roll(1);
_stack.roll(1); // Swap (serve per concatenare le stringhe in maniera corretta)
do_add();
do_store(name);
}
@ -981,6 +981,13 @@ void TAVM::execute(const TAVM_op& op)
_stack.push(tok);
}
break;
case avm_strfind:
{
const TString& lit = _stack.pop().as_string();
const TString& big = _stack.pop().as_string();
_stack.push(big.find(lit)); break;
}
break;
case avm_strtok_add:
{
const TString& tok = _stack.pop().as_string();

View File

@ -738,7 +738,7 @@ TConfig::TConfig(int which_config, const char* paragraph)
}
case CONFIG_USER:
{
TString16 u = user();
TString80 u = user();
if (u.blank())
u = ::dongle().administrator();
u.lower();

View File

@ -1272,13 +1272,18 @@ TText_control::TText_control(WINDOW win, short cid,
RCT rct; coord2rct(win, left, top, width, height, rct);
rct.right += bold ? (width*XI_FU_MULTIPLE/4) : XI_FU_MULTIPLE;
if (big)
{
rct.right += (rct.right - rct.left);
rct.bottom += (rct.bottom - rct.top);
}
const unsigned long attrib = flags2attr(flags);
XI_OBJ_DEF* def = xi_add_text_def(NULL, cid, (XinRect *) &rct, attrib, (char*)(const char*)t);
CHECKS(def, "Can't create the definition of TText_control:", text);
def->v.text->fore_color = color;
if (bold)
def->v.text->font_id = xvt_default_font(true);
if (bold || big)
def->v.text->font_id = xvt_default_font(bold, big);
_obj = xi_create(get_interface(win), def);
CHECKS(_obj, "Can't create TText_control ", text);
@ -1391,12 +1396,34 @@ void TField_control::create(WINDOW win, short cid,
{
CHECK(!in_create, "Nested control creation");
in_create = true;
bool big = false;
bool bold = false;
const short fcid = cid > 0 ? cid + 2000 : cid - 2000;
XI_OBJ_DEF* frm_def = xi_add_form_def(NULL, fcid, fcid);
frm_def->app_data = (long)this;
RCT rct; coord2rct(win, left, top, width, height, rct);
rct.right += XI_FU_MULTIPLE/4;
for (const char* s = flags; *s; s++)
{
if (toupper(*s) == '{')
big = true;
else
if (toupper(*s) == '}')
bold = true;
}
RCT rct; coord2rct(win, left, top, width, height, rct);
rct.right += bold ? (width*XI_FU_MULTIPLE/4) : XI_FU_MULTIPLE/4;
if (big)
{
rct.right += (rct.right - rct.left);
const int dy = (rct.bottom - rct.top) / 2;
rct.bottom += dy;
}
unsigned long attrib = flags2attr(flags) | XI_ATR_EDITMENU;
if (AUTOSELECT)
@ -1418,27 +1445,37 @@ void TField_control::create(WINDOW win, short cid,
def->app_data = (long)this;
XI_FIELD_DEF* f = def->v.field;
if (big || bold)
f->font_id = xvt_default_font(bold, big);
f->well = CAMPI_SCAVATI;
f->active_back_color = FOCUS_BACK_COLOR;
if (height == 1)
{
f->auto_tab = true;
if (button)
{
f->button = true;
f->pixel_button_distance = 1;
}
}
else // E' un multiline, quindi setto il rettangolo
if (big)
{
f->xi_rct.top = rct.top;
f->xi_rct.bottom = rct.bottom;
f->xi_rct.right = rct.right;
f->xi_rct.left = rct.left;
f->cr_ok = true;
f->var_len_text = true;
}
}
else
if (height == 1)
{
f->auto_tab = true;
if (button)
{
f->button = true;
f->pixel_button_distance = 1;
}
}
else // E' un multiline, quindi setto il rettangolo
{
f->xi_rct.top = rct.top;
f->xi_rct.bottom = rct.bottom;
f->xi_rct.right = rct.right;
f->xi_rct.left = rct.left;
f->cr_ok = true;
f->var_len_text = true;
}
XI_OBJ* itf = get_interface(win);
XI_OBJ* form = xi_create(itf, frm_def);

View File

@ -4143,8 +4143,10 @@ void TRecfield::set(int from, int to)
if (nf == FIELDERR)
{
NFCHECK("File n. %d unknown field %s", _rec->num(), (const char*)_name);
_p = _rec->string();
if (_rec->exist(_name))
_subfield = _name;
else
NFCHECK("File n. %d unknown field %s", _rec->num(), _name); _p = _rec->string();
_len = 0;
_dec = 0;
_type = _alfafld;
@ -4192,6 +4194,8 @@ TRecfield::TRecfield(TRectype& rec, const char* name, int from, int to)
void TRecfield::put_subfield(const char* s)
{
if (strcmp(_name, _subfield) == 0)
return;
const TString& str = _rec->get(_name);
int p = str.find(_subfield);
@ -4300,6 +4304,11 @@ void TRecfield::setptr(TRecnotype r)
void TRecfield::get_subfield(TString& s) const
{
const TString& str = _rec->get(_name);
if (strcmp(_name, _subfield) == 0)
s =, str;
else
{
int p = str.find(_subfield);
if (p == 0 || (p > 0 && str[p - 1] < ' '))
@ -4405,7 +4414,7 @@ TRecfield::operator TDate() const
TRecfield::operator const char*() const
{
TString& tmp = get_tmp_string(_len);
TString& tmp = get_tmp_string(max(_len, 50));
if (_subfield == NULL)
{

View File

@ -967,7 +967,8 @@ bool TMask::on_key(
if (f.is_kind_of(CLASS_SHEET_FIELD))
{
TSheet_field& s = (TSheet_field&)f;
const int newrow = s.append() ? -1 : 0;
const int newrow = s.append() ? -1 : ( _focus == fire ? s.selected() + 1: 0);
notify_focus_field(s.dlg());
s.insert(newrow, true, true);
}

View File

@ -2287,7 +2287,21 @@ int TBrowse::do_input(
else
if (_filter[i] == '#')
{
work << '"' << field(atoi(&_filter[++i])).get() << '"';
if (_filter[++i] == '-')
{
TString val;
TSheet_field* sheet = field().mask().get_sheet();
if (sheet != NULL)
{
const short id = atoi(&_filter[++i]);
val = sheet->mask().field(id).get();
}
work << '"' << val << '"';
}
else
work << '"' << field(atoi(&_filter[i])).get() << '"';
while (isspace(_filter[i])) i++;
while (isdigit(_filter[i])) i++;
i--;
@ -3480,6 +3494,11 @@ void TEdit_field::create(WINDOW parent)
if (_browse) // Decide se attivare o meno il bottone di ricerca
_ctl_data._flags << 'B';
if (_ctl_data._prompt.find("@g") >= 0 || _ctl_data._prompt.find("@G") >= 0)
_ctl_data._flags << '{';
if (_ctl_data._prompt.find("@b") >= 0 || _ctl_data._prompt.find("@B") >= 0)
_ctl_data._flags << '}';
_ctl = new TField_control(parent, _ctl_data._dlg,
_ctl_data._x, _ctl_data._y,

View File

@ -643,10 +643,10 @@ protected:
word create_prompt(WINDOW parent, word width, word heigth);
virtual const char* reformat(const char* data) const;
virtual TString& get_window_data() pure;
virtual void set_window_data(const char* data) pure;
public: // TMask_field
virtual TString& get_window_data() pure;
// @cmember Ritorna il prompt del campo
virtual const char* prompt() const;

View File

@ -142,6 +142,8 @@ class TSpreadsheet : public TControl
int _columns;
// @cmember:(INTERNAL) Indica se e' attivo lo spreadsheet
bool _active;
// @cmember:(INTERNAL) Indica se e' attivo l'auto append
bool _auto_append;
// @cmember:(INTERNAL) Funzione per la gestione di una riga dello sheet (vedi <t SPREADSHEET_NOTIFY>)
SPREADSHEET_NOTIFY _notify;
@ -277,6 +279,8 @@ public:
void show_column(int col, bool on = TRUE);
// @cmember Permette di eliminare una colonna dallo spreadsheet
void delete_column(const int col) const;
// @cmember Permette di attivare/ disattivare l'auto append
void set_auto_append(bool on) { _auto_append = on;}
bool exist_column(const int col) const { return find_column(col) != NULL; }
// @cmember Sposta la colonna dalla posizione <p fromindex> alla posizione
// <p toindex>
@ -376,6 +380,7 @@ int TSpreadsheet::ROW_NUMBER_WIDTH = 3;
KEY TSpreadsheet::barcode_newline() const
{
static KEY _barcode_newline = 0xFFFF;
if (_barcode_newline == 0xFFFF)
{
TConfig ini(CONFIG_INSTALL, "Main");
@ -403,7 +408,7 @@ TSpreadsheet::TSpreadsheet(
_edit_field(NULL), _cur_row(0), _cur_rec(0), _cur_col(1),
_row_dirty(FALSE), _cell_dirty(FALSE), _check_enabled(TRUE),
_needs_update(-1), _selection_posted(-1), _save_columns_order(FALSE),
_f9_target(NULL)
_f9_target(NULL), _auto_append(false)
{
int m_width[MAX_COL], v_width[MAX_COL];
int fixed_cols = 0; // Number of fixed columns
@ -1743,7 +1748,11 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
if (xiev->v.xvte.type == E_CHAR)
{
const KEY k = e_char_to_key(&xiev->v.xvte);
switch (k)
if (_auto_append && k == K_DOWN && _cur_row == items() - 1 && test_focus_change())
owner().mask().send_key(K_CTRL + '+', 0);
switch (k)
{
case K_ROWEDIT:
xiev->type = XIE_DBL_CELL;
@ -2702,6 +2711,12 @@ void TSheet_field::enable(bool on)
s->activate(on);
}
void TSheet_field::set_auto_append(bool on)
{
TSpreadsheet* s = (TSpreadsheet*)_ctl;
s->set_auto_append(on);
}
bool TSheet_field::enabled() const
{
// return items() > 0;

View File

@ -255,6 +255,9 @@ public:
// @cmember Setta il member <p _append> con il valore di <p on>
void set_append(bool on = true)
{ _append = on;}
// @cmember Permette di attivare/ disattivare l'auto append
void set_auto_append(bool on = true);
// @cmember Ritorna il valore del membro <p _append>
bool append() const
{ return _append;}

View File

@ -254,7 +254,7 @@ bool TRecordset::save_as_text(const char* path)
out << unesc(val); // Evitiamo doppi separatori di campo e record
else
{
if (var.type() == _realfld)
if (var.type() == _realfld || (cols == 0 && is_numeric(val)))
num_reformat(val);
out << val;
}