Patch level : 10.0

Files correlati     : ba0 ba1
Ricompilazione Demo : [ ]
Commento            :
Corretta gestione menu e barre in programmi manutenzione


git-svn-id: svn://10.65.10.50/trunk@16743 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-06-13 08:41:37 +00:00
parent 1cf7fdd905
commit c6b1ca245f
11 changed files with 216 additions and 150 deletions

View File

@ -490,13 +490,14 @@ TColor_mask::TColor_mask()
set(215, ADVANCED_GRAPHICS ? "X" : ""); set(215, ADVANCED_GRAPHICS ? "X" : "");
set(216, color.get_int("TreeView")); set(216, color.get_int("TreeView"));
_preview = new TPreview_panel(1, 5, 33, 7, this); _preview = new TPreview_panel(1, 5, 33, 8, this);
_icons = new TPreview_icons(1, 10, -2, -2, this); _icons = new TPreview_icons(1, 10, -2, -2, this);
const int sz = color.get_int("ToolSize"); const int sz = color.get_int("ToolSize");
set(217, (sz-16)/8); set(217, (sz-16)/8);
set(218, EASY_RIDER ? "X" : ""); set(218, EASY_RIDER ? "X" : "");
set(219, TOOL_TEXT ? "X" : "");
} }
KEY TColor_mask::run() KEY TColor_mask::run()
@ -519,6 +520,7 @@ void TColor_mask::save_colors()
const int sz = get_int(217); const int sz = get_int(217);
colors.set("ToolSize", 16+sz*8); colors.set("ToolSize", 16+sz*8);
colors.set("EasyRider", get_bool(218) ? "X" : ""); colors.set("EasyRider", get_bool(218) ? "X" : "");
colors.set("ToolText", get_bool(219) ? "X" : "");
} }
COLOR TColor_mask::get_color_entry(const char* name) const COLOR TColor_mask::get_color_entry(const char* name) const
@ -576,22 +578,19 @@ COLOR TColor_mask::cid2color(short cid) const
COLOR TColor_mask::cid2syscolor(short cid, const XVT_COLOR_COMPONENT* cc) const COLOR TColor_mask::cid2syscolor(short cid, const XVT_COLOR_COMPONENT* cc) const
{ {
int entry[] = { XVT_COLOR_TROUGH, XVT_COLOR_BLEND, XVT_COLOR_BORDER, int entry[] = { XVT_COLOR_BACKGROUND /*XVT_COLOR_TROUGH*/, XVT_COLOR_BLEND, XVT_COLOR_BORDER,
XVT_COLOR_FOREGROUND, XVT_COLOR_BACKGROUND, XVT_COLOR_BACKGROUND, XVT_COLOR_FOREGROUND, XVT_COLOR_BACKGROUND, XVT_COLOR_BACKGROUND,
XVT_COLOR_HIGHLIGHT, XVT_COLOR_SELECT, XVT_COLOR_HIGHLIGHT, XVT_COLOR_SELECT,
XVT_COLOR_BLEND, XVT_COLOR_BORDER, XVT_COLOR_BLEND, XVT_COLOR_BORDER,
XVT_COLOR_BACKGROUND, XVT_COLOR_BLEND, XVT_COLOR_BORDER }; XVT_COLOR_BACKGROUND, XVT_COLOR_BLEND, XVT_COLOR_BORDER };
const unsigned int component = entry[cid-101]; const unsigned int component = entry[cid-101];
for (int i = 0; cc[i].type != XVT_COLOR_NULL; i++) for (int i = 0; cc[i].type != XVT_COLOR_NULL; i++) if (cc[i].type == component)
{ {
if (cc[i].type == component) switch (cid)
{ {
switch (cid) case 105: return COLOR_WHITE;
{ case 106: return blend_colors(cid2syscolor(105, cc), cid2syscolor(108, cc), 0.60);
case 105: return COLOR_WHITE; default : return cc[i].color;
case 106: return blend_colors(cid2syscolor(105, cc), cid2syscolor(108, cc), 0.60);
default : return cc[i].color;
}
} }
} }
return COLOR_BLACK; return COLOR_BLACK;

View File

@ -195,9 +195,7 @@ bool TMenuitem::create(const char* t)
} }
int TMenuitem::icon() const int TMenuitem::icon() const
{ { return _icon; }
return _icon;
}
bool TMenuitem::enabled() const bool TMenuitem::enabled() const
{ {

View File

@ -1216,15 +1216,15 @@ bool TExplorer_mask::on_key(KEY k)
TExplorer_mask::TExplorer_mask(TMenu& menu) : _tree(menu) TExplorer_mask::TExplorer_mask(TMenu& menu) : _tree(menu)
{ {
add_button_tool(DLG_SHRINK, TR("Menu Principale"), TOOL_FIRSTREC); add_button_tool(DLG_SHRINK, TR("Menu Iniziale"), TOOL_FIRSTREC);
add_button_tool(DLG_FINDREC, TR("Ricerca"), TOOL_LENTE); add_button_tool(DLG_FINDREC, TR("Ricerca"), TOOL_LENTE);
add_button_tool(TOOL_CONFIG, TR("Opzioni"), TOOL_CONFIG); add_button_tool(TOOL_CONFIG, TR("Opzioni"), TOOL_CONFIG);
add_button_tool(DLG_SETPRINT, TR(""), TOOL_SETPRINT); add_button_tool(DLG_SETPRINT, TR("Imposta"), TOOL_SETPRINT);
add_button_tool(TOOL_PREF, TR("Preferiti"), TOOL_PREF); add_button_tool(TOOL_PREF, TR("Preferiti"), TOOL_PREF);
add_button_tool(TOOL_ADDPREF, TR("Aggiungi ai Preferiti"), TOOL_ADDPREF); add_button_tool(TOOL_ADDPREF, TR("Aggiungi"), TOOL_ADDPREF);
add_button_tool(DLG_INFO, TR("Info"), TOOL_INFO); add_button_tool(DLG_INFO, TR("Info"), TOOL_INFO);
add_button_tool(DLG_HELP, TR("Help"), TOOL_HELP); add_button_tool(DLG_HELP, TR("Help"), TOOL_HELP);
add_button_tool(DLG_QUIT, TR(""), TOOL_QUIT); add_button_tool(DLG_QUIT, TR(""), TOOL_QUIT);
WINDOW panel = page_win(0); WINDOW panel = page_win(0);

View File

@ -37,8 +37,9 @@ protected:
public: public:
WINDOW notebook() const { return _ctrl; } WINDOW notebook() const { return _ctrl; }
WINDOW page_win(short pg);
short add_page(const TString& caption); short add_page(const TString& caption);
void set_page_caption(short page, const TString& caption); void set_page_caption(short page, const TString& caption, int icon);
bool remove_page(WINDOW page); bool remove_page(WINDOW page);
TBook_window(int x, int y, int dx, int dy, WINDOW parent, TWindowed_field* owner); TBook_window(int x, int y, int dx, int dy, WINDOW parent, TWindowed_field* owner);
@ -97,7 +98,7 @@ void TBook_window::update()
{ {
clear(COLOR_WHITE); clear(COLOR_WHITE);
RCT rctw; xvt_vobj_get_client_rect(win(), &rctw); RCT rctw; xvt_vobj_get_client_rect(win(), &rctw);
if (rctw.right >= 32) if (rctw.right >= 64 && rctw.bottom >= 64)
{ {
if (_logo.ok()) if (_logo.ok())
{ {
@ -156,6 +157,14 @@ void TBook_window::handler(WINDOW win, EVENT* ep)
TControl_host_window::handler(win, ep); TControl_host_window::handler(win, ep);
} }
WINDOW TBook_window::page_win(short pg)
{
WINDOW win = NULL_WIN;
if (_ctrl != NULL_WIN)
win = xvt_notebk_get_page(_ctrl, pg);
return win;
}
short TBook_window::add_page(const TString& caption) short TBook_window::add_page(const TString& caption)
{ {
if (_ctrl == NULL_WIN) if (_ctrl == NULL_WIN)
@ -163,7 +172,7 @@ short TBook_window::add_page(const TString& caption)
WIN_DEF wd; memset(&wd, 0, sizeof(wd)); WIN_DEF wd; memset(&wd, 0, sizeof(wd));
wd.wtype = WC_NOTEBK; wd.wtype = WC_NOTEBK;
wd.v.ctl.ctrl_id = DLG_MAIN; wd.v.ctl.ctrl_id = DLG_MAIN;
wd.v.ctl.flags = CTL_FLAG_RIGHT_JUST; wd.v.ctl.flags = CTL_FLAG_CENTER_JUST; // i.e. bottom!
xvt_vobj_get_client_rect(win(), &wd.rct); xvt_vobj_get_client_rect(win(), &wd.rct);
_ctrl = xvt_ctl_create_def(&wd, win(), 0L); _ctrl = xvt_ctl_create_def(&wd, win(), 0L);
} }
@ -188,10 +197,14 @@ short TBook_window::add_page(const TString& caption)
return pg; return pg;
} }
void TBook_window::set_page_caption(short page, const TString& caption) void TBook_window::set_page_caption(short page, const TString& caption, int icon)
{ {
xvt_notebk_set_tab_title(_ctrl, page, caption); // Titolo dell'orecchio if (_ctrl != NULL_WIN && page >= 0)
xvt_notebk_set_page_title(_ctrl, page, caption); // Titolo della finestra {
xvt_notebk_set_tab_title(_ctrl, page, caption); // Titolo dell'orecchio
xvt_notebk_set_tab_icon(_ctrl, page, icon); // Icona dell'orecchio
xvt_notebk_set_page_title(_ctrl, page, caption); // Titolo della finestra
}
} }
bool TBook_window::remove_page(WINDOW page) bool TBook_window::remove_page(WINDOW page)
@ -258,7 +271,8 @@ public:
virtual void create(short dlg, int x, int y, int dx, int dy, WINDOW parent); virtual void create(short dlg, int x, int y, int dx, int dy, WINDOW parent);
short add_page(const TString& caption); short add_page(const TString& caption);
void set_page_caption(short page, const TString& caption); void set_page_caption(short page, const TString& caption, int icon);
WINDOW page_win(short page);
void remove_all_pages(); void remove_all_pages();
TBook_field(TMask* m) : TWindowed_field(m) {} TBook_field(TMask* m) : TWindowed_field(m) {}
}; };
@ -269,10 +283,16 @@ short TBook_field::add_page(const TString& caption)
return bw.add_page(caption); return bw.add_page(caption);
} }
void TBook_field::set_page_caption(short page, const TString& caption) void TBook_field::set_page_caption(short page, const TString& caption, int icon)
{ {
TBook_window& bw = (TBook_window&)win(); TBook_window& bw = (TBook_window&)win();
bw.set_page_caption(page, caption); bw.set_page_caption(page, caption, icon);
}
WINDOW TBook_field::page_win(short page)
{
TBook_window& bw = (TBook_window&)win();
return bw.page_win(page);
} }
void TBook_field::remove_all_pages() void TBook_field::remove_all_pages()
@ -302,10 +322,10 @@ short TOutlook_mask::add_page(const TString& caption)
return bf.add_page(caption); return bf.add_page(caption);
} }
void TOutlook_mask::set_page_caption(short page, const TString& caption) void TOutlook_mask::set_page_caption(short page, const TString& caption, int icon)
{ {
TBook_field& bf = (TBook_field&)field(DLG_MAIN); TBook_field& bf = (TBook_field&)field(DLG_MAIN);
bf.set_page_caption(page, caption); bf.set_page_caption(page, caption, icon);
} }
bool TOutlook_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) bool TOutlook_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
@ -325,11 +345,11 @@ bool TOutlook_mask::on_field_event(TOperable_field& o, TField_event e, long joll
} }
else else
{ {
TBook_field& bf = (TBook_field&)field(DLG_MAIN);
// ba1 e ba2 sono programmi di manutenzione da eseguire in modo esclusivo // ba1 e ba2 sono programmi di manutenzione da eseguire in modo esclusivo
const bool manu = mi.run_modal(); const bool manu = mi.run_modal();
if (manu) if (manu)
{ {
TBook_field& bf = (TBook_field&)field(DLG_MAIN);
bf.remove_all_pages(); // Chiude tutti i programmi in corso bf.remove_all_pages(); // Chiude tutti i programmi in corso
mi.perform(); // Esegui in sincrono e a tutto schermo mi.perform(); // Esegui in sincrono e a tutto schermo
if (installing()) // when ba1 -6 if (installing()) // when ba1 -6
@ -342,8 +362,24 @@ bool TOutlook_mask::on_field_event(TOperable_field& o, TField_event e, long joll
if (pg >= 0) if (pg >= 0)
{ {
mi.perform(); // Esegui in asincrono in pagina nuova mi.perform(); // Esegui in asincrono in pagina nuova
xvt_sys_sleep(1000);
set_page_caption(pg, mi.caption()); for (int i = 0; i < 10; i++)
{
xvt_sys_sleep(500);
if (xvt_win_get_children_count(bf.page_win(pg)) != 0)
break;
}
int ico = mi.icon();
if (ico <= 0 || ico == ICON_RSRC)
{
const int area = get_int(DLG_LOOK);
if (area >= 0 && area < 16)
ico = _icon[area];
else
ico = ICON_RSRC;
set_page_caption(pg, mi.caption(), ico);
}
} }
} }
} }
@ -379,7 +415,7 @@ TOutlook_mask::TOutlook_mask(TMenu& menu) : _tree(menu)
menu.set_mask_mode(3); // Outlook mode menu.set_mask_mode(3); // Outlook mode
const int w = 28; const int w = 24;
const int h = rows() / 2; const int h = rows() / 2;
TTree_field& trifola = add_tree(DLG_TREE, 0, 0, 0, w, h); TTree_field& trifola = add_tree(DLG_TREE, 0, 0, 0, w, h);
@ -394,12 +430,14 @@ TOutlook_mask::TOutlook_mask(TMenu& menu) : _tree(menu)
add_field(cf); add_field(cf);
TString caption; TString caption;
int i = 0;
for (bool ok = _tree.goto_root(); ok; ok = _tree.goto_rbrother()) for (bool ok = _tree.goto_root(); ok; ok = _tree.goto_rbrother())
{ {
_tree.get_description(caption); _tree.get_description(caption);
const TMenuitem& mi = _tree.curr_item(); const TMenuitem& mi = _tree.curr_item();
const int ico = mi.enabled() ? mi.icon() : 10203; const int ico = mi.enabled() ? mi.icon() : 10203;
of->add_item(ico, caption, 0); of->add_item(ico, caption, 0);
_icon[i++] = ico; // Memorizza icona per orecchie
} }
xvt_pane_add(panel, dlg2win(DLG_TREE), "Menu", 1, 0); // Left upper pane xvt_pane_add(panel, dlg2win(DLG_TREE), "Menu", 1, 0); // Left upper pane

View File

@ -16,11 +16,12 @@
class TOutlook_mask : public TSpidey_mask class TOutlook_mask : public TSpidey_mask
{ {
TMenu_tree _tree; TMenu_tree _tree;
int _icon[16];
protected: protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
short add_page(const TString& caption); short add_page(const TString& caption);
void set_page_caption(short page, const TString& caption); void set_page_caption(short page, const TString& caption, int icon);
public: public:
TOutlook_mask(TMenu& menu); TOutlook_mask(TMenu& menu);

View File

@ -1,4 +1,4 @@
PAGE "Colori" -1 -1 54 17 PAGE "Colori" -1 -1 54 19
GROUPBOX DLG_NULL 16 5 GROUPBOX DLG_NULL 16 5
BEGIN BEGIN
@ -92,17 +92,17 @@ END
GROUPBOX DLG_NULL 32 3 GROUPBOX DLG_NULL 32 3
BEGIN BEGIN
PROMPT 1 12 "@bTemi predefiniti" PROMPT 1 14 "@bTemi predefiniti"
END END
BUTTON 211 12 BUTTON 211 12
BEGIN BEGIN
PROMPT 2 13 "Campo" PROMPT 2 15 "Campo"
END END
BUTTON 212 12 BUTTON 212 12
BEGIN BEGIN
PROMPT 18 13 "Sistema" PROMPT 18 15 "Sistema"
END END
BUTTON DLG_USER 12 2 BUTTON DLG_USER 12 2
@ -144,6 +144,11 @@ BEGIN
PROMPT 1 4 "Griglie a lettura facilitata" PROMPT 1 4 "Griglie a lettura facilitata"
END END
BOOLEAN 219
BEGIN
PROMPT 1 5 "Visualizza il testo negli strumenti della barra"
END
RADIOBUTTON 216 1 16 RADIOBUTTON 216 1 16
BEGIN BEGIN
PROMPT 32 0 "Tipo di Menu" PROMPT 32 0 "Tipo di Menu"

View File

@ -913,9 +913,9 @@ void TManutenzione_app::update_dir()
n.ext("cdx"); remove(n); n.ext("cdx"); remove(n);
n.ext("fpt"); remove(n); n.ext("fpt"); remove(n);
TString s(_MAX_PATH); TString msg(_MAX_PATH);
s.format(FR("File n. %d - %s : eliminato file non utilizzato"), i, (const char *)d.filename()); msg.format(FR("File n. %d - %s : eliminato file non utilizzato"), i, (const char *)d.filename());
write_log(s); write_log(msg);
} }
} }
if (i > 2 && is_firm == old_is_firm) if (i > 2 && is_firm == old_is_firm)
@ -950,9 +950,9 @@ void TManutenzione_app::update_dir()
{ {
if (!recover(b, err)) if (!recover(b, err))
{ {
TString s(_MAX_PATH); TString msg(_MAX_PATH);
s.format(TR("File n. %d - %s : errore n.ro %d"), i, (const char *)d.filename(), err); msg.format(TR("File n. %d - %s : errore n.ro %d"), i, (const char *)d.filename(), err);
write_log(s); write_log(msg);
} }
} }
} }
@ -1189,10 +1189,10 @@ void TManutenzione_app::convert_dir()
if (to_create && has_module(module, CHK_DONGLE)) if (to_create && has_module(module, CHK_DONGLE))
{ {
TDir df; df.get(i); TDir df; df.get(i);
const TFilename s(df.filename()); const TFilename fname(df.filename());
//crea il nuovo file in base al tracciato record nuovo! //crea il nuovo file in base al tracciato record nuovo!
if (!s.exist() && ds.len() > 0) if (!fname.exist() && ds.len() > 0)
{ {
set_autoload_new_files(false); set_autoload_new_files(false);
f.build(0L,rs); f.build(0L,rs);

View File

@ -11,7 +11,7 @@
TMask* TRec_sheet::_mask = NULL; TMask* TRec_sheet::_mask = NULL;
void TDir_sheet::add () void TDir_sheet::add()
{ {
_dir->get(LF_DIR, _lock, _nordir, _sysdirop); _dir->get(LF_DIR, _lock, _nordir, _sysdirop);
const int nitems = (int)_dir->eod() + 1; const int nitems = (int)_dir->eod() + 1;
@ -30,7 +30,7 @@ void TDir_sheet::add ()
TDir_sheet::TDir_sheet(const char* title, bool superprassi, const char* colonne) TDir_sheet::TDir_sheet(const char* title, bool superprassi, const char* colonne)
: TSheet(0, 0, 0, 0, title, colonne, superprassi ? 0xC : 0x8) : TSheet(0, 0, 0, 0, title, colonne, superprassi ? 0xC : 0x8)
{ {
add_button(DLG_PRINT, TR("Stampa Tracciati"), K_F3, BMP_PRINT); add_button(DLG_PRINT, TR("Tracciati"), K_F3, BMP_PRINT);
add_button(-1, "", 0, 1); // Separatore add_button(-1, "", 0, 1); // Separatore
if (superprassi) if (superprassi)
@ -42,7 +42,7 @@ TDir_sheet::TDir_sheet(const char* title, bool superprassi, const char* colonne)
add_button(-1, "", 0, 1); // Separatore add_button(-1, "", 0, 1); // Separatore
} }
add_button(DLG_INFO, TR("Informazioni"), K_F2, BMP_INFO); add_button(DLG_INFO, TR("Info"), K_F2, BMP_INFO);
add_button(DLG_HELP, TR("Help"), K_F1, BMP_HELP); add_button(DLG_HELP, TR("Help"), K_F1, BMP_HELP);
xvt_toolbar_set_last_tool(toolbar(), DLG_QUIT); xvt_toolbar_set_last_tool(toolbar(), DLG_QUIT);
@ -73,7 +73,7 @@ void TDir_sheet::get_row(long n, TToken_string& l)
TRec_sheet::TRec_sheet(int logicnum, const char * tab) TRec_sheet::TRec_sheet(int logicnum, const char * tab)
: _descr(NULL), _tab(tab) : _descr(NULL), _tab(tab)
{ {
_external = FALSE; _external = FALSE;
_dir = new TDir; _dir = new TDir;
@ -107,8 +107,7 @@ TRec_sheet::TRec_sheet(int logicnum, const char * tab)
} }
TRec_sheet::TRec_sheet(TExternisamfile* file) TRec_sheet::TRec_sheet(TExternisamfile* file)
: _descr(NULL), _tab("") : _descr(NULL), _tab("")
{ {
_external = TRUE; _external = TRUE;
_dir = new TDir; _dir = new TDir;
@ -173,7 +172,6 @@ HIDDEN bool len_handler(TMask_field& f, KEY key)
return TRUE; return TRUE;
} }
bool TRec_sheet::fld_notify(TSheet_field& f, int r, KEY k) bool TRec_sheet::fld_notify(TSheet_field& f, int r, KEY k)
{ {
if (k == K_CTRL + K_INS) if (k == K_CTRL + K_INS)
@ -244,9 +242,7 @@ void TRec_sheet::save()
out << *_dir; out << *_dir;
} }
void TRec_sheet::edit() void TRec_sheet::edit()
{ {
bool import_dirty = FALSE; bool import_dirty = FALSE;
TSheet_field& f1 = (TSheet_field&) _mask->field(F_FIELDS); TSheet_field& f1 = (TSheet_field&) _mask->field(F_FIELDS);
@ -395,9 +391,7 @@ void TRec_sheet::edit()
fcopy(_descfname,"des.xxx"); // salva il vecchio file di descrizioni fcopy(_descfname,"des.xxx"); // salva il vecchio file di descrizioni
f1.destroy(-1); f1.destroy(-1);
int i; for (int i = 0; i < nfields; i++)
for (i = 0; i < nfields; i++)
{ {
f1.row(i) = _rec->fielddef(i); f1.row(i) = _rec->fielddef(i);
if (_descr) if (_descr)
@ -425,7 +419,8 @@ void TRec_sheet::edit()
} }
nkeys = _rec->keys(); nkeys = _rec->keys();
f2.reset(); f2.reset();
for (i = 0; i < nkeys; i++) f2.row(i) = _rec->keydef(i); for (int i = 0; i < nkeys; i++)
f2.row(i) = _rec->keydef(i);
f2.disable_cell(0, 1); f2.disable_cell(0, 1);
} }
} }

View File

@ -57,7 +57,7 @@ static int fill_fields(int logicnum, TString_array& flds, bool keys_only = false
return flds.items(); return flds.items();
} }
bool TEdit_file::browse_cursor(TCursor& cursor, const TFilename& name) bool TEdit_file::browse_cursor(TCursor& cursor, const TFilename& fname)
{ {
TRectype& curr = cursor.curr(); TRectype& curr = cursor.curr();
TRectype svrec(cursor.curr()); TRectype svrec(cursor.curr());
@ -94,7 +94,7 @@ bool TEdit_file::browse_cursor(TCursor& cursor, const TFilename& name)
const bool superprassi = user() == ::dongle().administrator(); const bool superprassi = user() == ::dongle().administrator();
TCursor_sheet sheet(&cursor, trac, name, head, superprassi ? 6 : 0); TCursor_sheet sheet(&cursor, trac, fname, head, superprassi ? 6 : 0);
KEY ch; KEY ch;
while ((ch = sheet.run()) != K_ESC) while ((ch = sheet.run()) != K_ESC)
{ {
@ -290,10 +290,10 @@ void TEdit_file::edit_record(TRectype& rec)
{ {
const TRectype svrec(rec); // Salva record originale const TRectype svrec(rec); // Salva record originale
const TString svkey = svrec.key(1); const TString svkey = svrec.key(1);
FOR_EACH_ARRAY_ROW(flds, i, row) FOR_EACH_ARRAY_ROW(flds, j, frow)
{ {
const char* cp = row->get(0); const char* cp = frow->get(0);
rec.put(cp, m.get(100+i)); rec.put(cp, m.get(100+j));
} }
if (svkey != rec.key(1)) if (svkey != rec.key(1))
{ {

View File

@ -37,6 +37,13 @@ TProfiler_mask::TProfiler_mask() : TMask(TR("Test"), 1, 60, 12)
class TTest_application : public TSkeleton_application class TTest_application : public TSkeleton_application
{ {
TProgind* _pi;
clock_t start_timer() const;
clock_t start_progind(const long items, const char* prompt);
clock_t stop_progind();
protected: protected:
bool test1(TLog_report& log); bool test1(TLog_report& log);
bool test2(TLog_report& log); bool test2(TLog_report& log);
@ -44,10 +51,12 @@ protected:
bool test4(TLog_report& log); bool test4(TLog_report& log);
bool test5(TLog_report& log); bool test5(TLog_report& log);
clock_t start_timer() const;
public: public:
bool test(int n, TLog_report& log); bool test(int n, TLog_report& log);
virtual void main_loop(); virtual void main_loop();
TTest_application() : _pi(NULL) { }
}; };
clock_t TTest_application::start_timer() const clock_t TTest_application::start_timer() const
@ -58,35 +67,52 @@ clock_t TTest_application::start_timer() const
return t; return t;
} }
clock_t TTest_application::start_progind(const long items, const char* prompt)
{
CHECK(_pi == NULL, "Double progress indicator");
_pi = new TProgind(items, prompt, true, true);
return start_timer();
}
clock_t TTest_application::stop_progind()
{
clock_t t = clock();
if (_pi != NULL)
{
delete _pi;
_pi = NULL;
}
return t;
}
bool TTest_application::test1(TLog_report& log) bool TTest_application::test1(TLog_report& log)
{ {
bool ok = true; bool ok = true;
TLocalisamfile tab(LF_COMUNI); TLocalisamfile tab(LF_COMUNI);
clock_t start;
TRecnotype r = 0; TRecnotype r = 0;
TString80 msg; TString80 msg;
{
const int times = 10; const int times = 10;
TProgind p(times, TR("Lettura file comuni"), TRUE, TRUE); const clock_t start = start_progind(times, TR("Lettura file comuni"));
start = start_timer(); for (int i = 0; i < times; i++)
for (int i = 0; i < times; i++) {
{ for (tab.first(); tab.good(); tab.next())
for (tab.first(); tab.good(); tab.next()) r++;
r++;
msg.format("%ld records %ld msec", r, clock() - start); msg.format("%ld records %ld msec", r, clock() - start);
p.set_text(msg); _pi->set_text(msg);
if (!p.addstatus(1)) if (!_pi->addstatus(1))
{ {
log.log(1, TR("Interrotto dall'utente")); log.log(1, TR("Interrotto dall'utente"));
ok = false; ok = false;
break; break;
}
} }
} }
const clock_t t = clock() - start;
const clock_t t = stop_progind() - start;
msg.format("Lettura file comuni - " msg.format("Lettura file comuni - "
"%ld records in %ld msec - %lg records per sec", r, t, 1000.0*r/t); "%ld records in %ld msec - %lg records per sec", r, t, 1000.0*r/t);
log.log(0, msg); log.log(0, msg);
@ -216,27 +242,27 @@ bool TTest_application::test5(TLog_report& log)
{ {
bool ok = true; bool ok = true;
TString msg; TString msg;
TRecnotype n = 100; TRecnotype n = 200;
if (n > 0) if (n > 0)
{ {
TTable tab("CZZ"); TTable tab("CZZ");
msg.format("Creazione di %ld records", n); msg.format("Creazione di %ld records", n);
TProgind p(n, msg, true, true); const clock_t start = start_progind(n, msg);
clock_t start = start_timer(); int i;
for (int i = 1; i <= n; i++) for (i = 0; i < n; i++)
{ {
if ((i % 10) == 0 && !p.setstatus(i)) tab.put("CODTAB", i+1);
tab.write();
if (!_pi->addstatus(1))
{ {
log.log(1, TR("Interrotto dall'utente")); log.log(1, TR("Interrotto dall'utente"));
ok = false; ok = false;
break; break;
} }
tab.put("CODTAB", i);
tab.write();
} }
const clock_t t = clock() - start; const clock_t t = stop_progind() - start;
msg.format("Scritti %ld records in %ld msec - %lg records per sec", n, t, 1000.0*n/t); msg.format("Scritti %ld records in %ld msec - %lg records per sec", i, t, 1000.0*i/t);
log.log(0, msg); log.log(0, msg);
} }
@ -248,20 +274,18 @@ bool TTest_application::test5(TLog_report& log)
cur.freeze(); cur.freeze();
msg.format("Cancellazione %ld records", n); msg.format("Cancellazione %ld records", n);
TProgind p(n, msg, true, true); const clock_t start = start_progind(n, msg);
clock_t start = start_timer();
for (cur = 0; cur.pos() < n; ++cur) for (cur = 0; cur.pos() < n; ++cur)
{ {
const int i = cur.pos()+1; cur.file().remove();
if ((i % 10) == 0 && !p.setstatus(i)) if (!_pi->addstatus(1))
{ {
log.log(1, TR("Interrotto dall'utente")); log.log(1, TR("Interrotto dall'utente"));
ok = false; ok = false;
break; break;
} }
cur.file().remove();
} }
const clock_t t = clock() - start; const clock_t t = stop_progind() - start;
msg.format("Cancellati %ld records in %ld msec - %lg records per sec", n, t, 1000.0*n/t); msg.format("Cancellati %ld records in %ld msec - %lg records per sec", n, t, 1000.0*n/t);
log.log(0, msg); log.log(0, msg);
} }

View File

@ -315,51 +315,57 @@ void TMenu::import(const char* filename, TString& first)
if (first.empty()) if (first.empty())
first = line; first = line;
sub = &get_submenu(line); sub = &get_submenu(line);
} else }
if (line.starts_with("Caption", true)) else
{ {
CHECK(sub, "Invalid menu file"); if (sub != NULL)
const int equal = line.find('='); {
CHECK(equal > 0, "Invalid menu Caption"); if (line.starts_with("Caption", true))
line.ltrim(equal+1); {
line.strip("\""); CHECK(sub, "Invalid menu file");
*sub = line; const int equal = line.find('=');
} else CHECK(equal > 0, "Invalid menu Caption");
if (line.starts_with("Module", true)) line.ltrim(equal+1);
{ line.strip("\"");
CHECK(sub, "Invalid menu file"); *sub = line;
const int equal = line.find('='); } else
CHECK(equal > 0, "Invalid menu Module"); if (line.starts_with("Module", true))
const word mod = atoi(line.mid(equal+1)); {
sub->set_module(mod); CHECK(sub, "Invalid menu file");
} else const int equal = line.find('=');
if (line.starts_with("Item", true)) CHECK(equal > 0, "Invalid menu Module");
{ const word mod = atoi(line.mid(equal+1));
CHECK(sub, "Invalid menu file"); sub->set_module(mod);
const int equal = line.find('='); } else
CHECK(equal > 0, "Invalid menu Item"); if (line.starts_with("Item", true))
line.ltrim(equal+1); {
line.trim(); CHECK(sub, "Invalid menu file");
const int bracket = line.rfind('<'); const int equal = line.find('=');
if (bracket > 0) CHECK(equal > 0, "Invalid menu Item");
{ line.ltrim(equal+1);
const int endbracket = line.find('>', bracket); line.trim();
TFilename name = line.sub(bracket+1, endbracket); const int bracket = line.rfind('<');
if (name.custom_path()) if (bracket > 0)
{ {
bool proceed = true; const int endbracket = line.find('>', bracket);
if (line.find('E', endbracket+1) > 0) TFilename name = line.sub(bracket+1, endbracket);
proceed = dongle().active(EEAUT); if (name.custom_path())
if (proceed) {
{ bool proceed = true;
import(name, name); if (line.find('E', endbracket+1) > 0)
TMenu_item& child = sub->add_child(line); proceed = dongle().active(EEAUT);
child.cmd() = name; if (proceed)
} {
} import(name, name);
} TMenu_item& child = sub->add_child(line);
else child.cmd() = name;
sub->add_child(line); }
}
}
else
sub->add_child(line);
}
}
} }
} }
} }
@ -738,7 +744,7 @@ void TSet_users::put_in_record(const TMask& m)
TString_array& arr = *(TString_array*)obj; TString_array& arr = *(TString_array*)obj;
prg = key; prg = key;
prg << m.sfield(F_PROPERTIES).separator(); prg << m.sfield(F_PROPERTIES).separator();
FOR_EACH_ARRAY_ROW(arr, r, row) FOR_EACH_ARRAY_ROW(arr, i, row)
{ {
row->insert(prg, 0); row->insert(prg, 0);
prop_field.add(*row); prop_field.add(*row);