Patch level : 10.0 500

Files correlati     : ba0
Ricompilazione Demo : [ ]
Commento            :
Ripristinato comportamento error_box


git-svn-id: svn://10.65.10.50/trunk@19574 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2009-11-04 14:49:29 +00:00
parent 0bbbc30ede
commit 89d8a61d76
9 changed files with 397 additions and 80 deletions

View File

@ -4,59 +4,264 @@
#include <config.h>
#include <dongle.h>
#include <prefix.h>
#include <sheet.h>
#include <sqlset.h>
#include <toolfld.h>
#include <urldefid.h>
#include <utility.h>
///////////////////////////////////////////////////////////
// TAdavnced_property sheet
///////////////////////////////////////////////////////////
class TAdvanced_property_sheet : public TMask
{
TProp_field* _pf;
protected:
virtual long handler(WINDOW win, EVENT* e);
void esporta();
public:
void freeze(bool on) { _pf->freeze(on); }
void add_cat(const char* prompt);
void add_prop(const char* prompt, const char* value);
void add_prop(const char* prompt, long value);
void set_read_only(bool ro = true);
TAdvanced_property_sheet(const char* title = "", int width = 78, int height = 20);
};
long TAdvanced_property_sheet::handler(WINDOW win, EVENT* e)
{
if (_pf != NULL)
{
switch (e->type)
{
case E_SIZE:
if (win == _pf->win().parent())
_pf->win().maximize();
break;
case E_CONTROL:
switch(e->v.ctl.id)
{
case DLG_EXPORT: esporta(); return 0L;
default: break;
}
break;
default:
break;
}
}
return TMask::handler(win, e);
}
void TAdvanced_property_sheet::add_cat(const char* prompt)
{
_pf->set_property(prompt, (const char*)NULL, prompt);
}
void TAdvanced_property_sheet::add_prop(const char* prompt, const char* value)
{
_pf->set_property(prompt, value, prompt);
}
void TAdvanced_property_sheet::add_prop(const char* prompt, long value)
{
_pf->set_property(prompt, value, prompt);
}
static BOOLEAN export_cb(WINDOW pg, XVT_TREEVIEW_NODE node, void* jolly)
{
char name[_MAX_PATH];
if (xvt_prop_get_string(pg, node, name, sizeof(name)))
{
ostream& out = *(ostream*)jolly;
char value[_MAX_PATH];
if (xvt_prop_get_data(pg, node, value, sizeof(value)))
out << '\t' << name << '\t' << value << endl; // Property
else
out << name << endl; // Category
}
return TRUE;
}
void TAdvanced_property_sheet::esporta()
{
TString cap; get_caption(cap);
for (char* buf = cap.get_buffer(); *buf; buf++)
{
switch (*buf)
{
case '?':
case '(':
case ')':
case '/':
case '\\':
case '*': *buf = ' '; break;
default : break;
}
}
cap.strip_spaces();
if (cap.blank())
cap = "export";
TFilename name;
name.tempdir(); name.add(cap); name.ext("xls");
if (name.full()) // Dummy test
{
ofstream xls(name);
_pf->for_each_property(export_cb, &xls);
}
if (name.exist())
xvt_sys_goto_url(name, "open");
}
void TAdvanced_property_sheet::set_read_only(bool ro)
{
xvt_prop_set_read_only(_pf->win().win(), NULL, ro);
}
TAdvanced_property_sheet::TAdvanced_property_sheet(const char* title, int width, int height)
: TMask(title && *title ? title : TR("Proprieta'"), 1, width, height), _pf(NULL)
{
add_button_tool(DLG_CANCEL, TR("Ritorna"), TOOL_CANCEL);
add_button_tool(DLG_EXPORT, TR("Esporta"), TOOL_EXCEL);
add_button_tool(DLG_HELP, TR("Help"), TOOL_HELP);
_pf = new TProp_field(this);
_pf->create(DLG_USER, 0, 0, 0, 0, page_win(0));
}
///////////////////////////////////////////////////////////
// TBasic_property sheet
///////////////////////////////////////////////////////////
class TBasic_property_sheet : public TArray_sheet
{
protected:
virtual bool get_cell_colors(int row, int col, COLOR& fore, COLOR& back) const;
public:
void add_cat(const char* cat);
void add_prop(const char* prop, const char* val);
void add_prop(const char* prop, long val);
TBasic_property_sheet(const char* title, int width, int height);
};
bool TBasic_property_sheet::get_cell_colors(int r, int col, COLOR& fore, COLOR& back) const
{
const TToken_string& riga = ((TBasic_property_sheet*)this)->row(r);
const bool changed = riga.items() == 1;
if (changed)
{
fore = FOCUS_COLOR;
back = REQUIRED_BACK_COLOR;
return true;
}
return changed;
}
void TBasic_property_sheet::add_cat(const char* cat)
{
add(cat);
}
void TBasic_property_sheet::add_prop(const char* prop, const char* val)
{
TToken_string r;
r = prop;
r.add(val);
add(r);
}
void TBasic_property_sheet::add_prop(const char* prop, long val)
{
add_prop(prop, format("%ld", val));
}
TBasic_property_sheet::TBasic_property_sheet(const char* title, int width, int height)
: TArray_sheet(-1, -1, width, height, title, format("@%d|@%d", width/4-2, 3*width/4-2))
{ }
///////////////////////////////////////////////////////////
// TProperty sheet
///////////////////////////////////////////////////////////
void TProperty_sheet::add_cat(const char* cat)
{
if (_power)
((TAdvanced_property_sheet*)_ps)->add_cat(cat);
else
((TBasic_property_sheet*)_ps)->add_cat(cat);
}
void TProperty_sheet::add_prop(const char* prop, const char* val)
{
if (_power)
((TAdvanced_property_sheet*)_ps)->add_prop(prop, val);
else
((TBasic_property_sheet*)_ps)->add_prop(prop, val);
}
void TProperty_sheet::add_prop(const char* prop, long val)
{
if (_power)
((TAdvanced_property_sheet*)_ps)->add_prop(prop, val);
else
((TBasic_property_sheet*)_ps)->add_prop(prop, val);
}
void TProperty_sheet::freeze(bool f)
{
if (_power)
((TAdvanced_property_sheet*)_ps)->freeze(f);
}
void TProperty_sheet::set_read_only(bool ro)
{
if (_power)
((TAdvanced_property_sheet*)_ps)->set_read_only(ro);
}
KEY TProperty_sheet::run()
{ return _ps->run(); }
TProperty_sheet::TProperty_sheet(const char* title, int width, int height)
{
_power = is_power_reseller();
if (_power)
_ps = new TAdvanced_property_sheet(title, width, height);
else
_ps = new TBasic_property_sheet(title, width, height);
}
TProperty_sheet::~TProperty_sheet()
{
delete _ps;
}
///////////////////////////////////////////////////////////
// Finestra informazioni
///////////////////////////////////////////////////////////
class TInfo_mask : public TArray_sheet
class TInfo_mask : public TProperty_sheet
{
protected:
virtual bool get_cell_colors(int row, int col, COLOR& fore, COLOR& back) const;
public:
void add_row(const char* prompt, const char* value, int err = 0);
void add_row(const char* prompt, unsigned long value, int err = 0);
TInfo_mask();
};
bool TInfo_mask::get_cell_colors(int r, int c, COLOR& fore, COLOR& back) const
{
const int err = ((TArray_sheet*)this)->row(r).get_int(2);
if (err > 0)
{
fore = err == 1 ? NORMAL_COLOR : FOCUS_COLOR;
back = err == 1 ? REQUIRED_BACK_COLOR : FOCUS_BACK_COLOR;
}
return TArray_sheet::get_cell_colors(r, c, fore, back);
}
void TInfo_mask::add_row(const char* prompt, const char* value, int err)
TInfo_mask::TInfo_mask() : TProperty_sheet(TR("Informazioni"))
{
TToken_string* r = new TToken_string;
r->add(prompt);
r->add(value);
r->add(err);
add(r);
}
freeze(true);
void TInfo_mask::add_row(const char* prompt, unsigned long value, int err)
{
TString16 str; str.format("%lu", value);
add_row(prompt, str);
}
TInfo_mask::TInfo_mask()
: TArray_sheet(-1, -1, 78, 20, TR("Informazioni"), "@18|@58")
{
const word ser_no = dongle().number();
int year = 2091, release = 10, tag = 0, patch = 1;
TString80 versione = "2091.10.00 Patch 0001";
TString80 versione = "2091.10.00";
if (main_app().get_version_info(year, release, tag, patch))
versione.format("%d.%02d.%02d Patch %04d", year, release, tag, patch);
versione.format("%d.%02d.%02d Patch %d", year, release, tag, patch);
TString80 stros, strwx, strcpu;
xvt_sys_get_version(stros.get_buffer(), strwx.get_buffer(), stros.size());
@ -76,7 +281,7 @@ TInfo_mask::TInfo_mask()
{
case _dongle_hardlock: prot = "Hardlock"; break;
case _dongle_eutron : prot = "Eutron"; break;
case _dongle_network : prot = campoini.get("Dongle", "Server"); break;
case _dongle_network : prot = ini_get_string(CONFIG_INSTALL, "Main", "Dongle", "Server"); break;
default : prot = TR("Nessuna"); break;
}
@ -111,48 +316,69 @@ TInfo_mask::TInfo_mask()
strsql = rs.driver_version();
}
add_row(TR("Versione"), versione);
add_row(TR("Protezione"), prot);
add_row(TR("N. di serie"), ser_no, ser_no < 0);
add_row(TR("Assistenza"), dongle().year_assist());
add_row(TR("Installazione"), tipo);
add_row(TR("Sistema Operativo"), stros);
add_row(TR("Utente"), user());
add_row(TR("Computer"), strcpu);
const TString study = firm2dir(-1);
add_row(TR("Studio"), study, study.find(' ') > 0 || study.len() > 30);
add_row(TR("Ditta"), campoini.get("Firm", "Main"));
add_cat(TR("Programma"));
add_prop(TR("Versione"), versione);
add_prop(TR("Protezione"), prot);
add_prop(TR("N. di serie"), ser_no);
if (ser_no > 0)
add_prop(TR("Assistenza"), dongle().year_assist());
add_prop(TR("Installazione"), tipo);
add_prop(TR("Utente"), user());
add_prop(TR("Linea di Comando"), arg);
add_cat(TR("Area dati"));
TFilename study = firm2dir(-1);
add_prop(TR("Studio"), study);
const long codditta = campoini.get_long("Firm", "Main");
add_prop(TR("Ditta"), codditta);
if (prefix_valid())
{
const TFirm& f = prefix().firm();
add_row(TR("Ragione Sociale"), f.ragione_sociale());
add_row(TR("Valuta"), f.codice_valuta());
add_prop(TR("Ragione Sociale"), f.ragione_sociale());
add_prop(TR("Valuta"), f.codice_valuta());
}
else
{
add_row(TR("Ragione Sociale"), campoini.get("Company"));
add_prop(TR("Ragione Sociale"), campoini.get("Company"));
}
add_row(TR("Programma"), arg);
add_row(TR("Config locale"), campoini.name(), campoini.name().find(' ') >= 0);
add_row(TR("Config utente"), userini.name(), userini.name().find(' ') >= 0);
add_row(TR("File temporanei"), temp, temp.find(' ') >= 0);
add_cat(TR("Dati Stazione"));
add_prop(TR("Sistema Operativo"), stros);
add_prop(TR("Utente"), user());
add_prop(TR("Computer"), strcpu);
const long mbfree = xvt_fsys_get_disk_free_space(study, 'M');
TString16 strmb; strmb.format("%ld Mb", mbfree);
add_row(TR("Spazio su disco"), strmb, mbfree < 512);
add_prop(TR("Spazio su disco"), strmb);
add_prop(TR("File temporanei"), temp);
TString printer;
printer = userini.get("Name", "Printer");
if (printer.blank())
printer = TR("Nessuna");
add_row(TR("Stampante"), printer, printer.len() >= 32);
add_prop(TR("Stampante"), printer);
add_cat(TR("Configurazioni"));
add_prop(TR("Config locale"), campoini.name());
add_prop(TR("Config studio"), study.add("studio.ini"));
if (codditta > 0)
{
study = firm2dir(codditta);
add_prop(TR("Config ditta"), study.add("ditta.ini"));
}
add_prop(TR("Config utente"), userini.name());
study = firm2dir(-1); study.add("config"); study.add(strcpu); study.ext("ini");
add_prop(TR("Config stazione"), study),
add_cat(TR("Librerie di supporto"));
xvt_print_pdf_version(printer.get_buffer(), printer.size());
add_row(TR("Libreria DB"), strdb);
add_row(TR("Libreria GUI"), strwx);
add_row(TR("Libreria PDF"), printer);
add_row(TR("Libreria SQL"), strsql);
add_prop(TR("Libreria DB"), strdb);
add_prop(TR("Libreria GUI"), strwx);
add_prop(TR("Libreria PDF"), printer);
add_prop(TR("Libreria SQL"), strsql);
set_read_only();
freeze(false);
}
// About box: risposta alla opzione Informazioni del menu File

View File

@ -1,6 +1,33 @@
#ifndef __ABOUT_H
#define __ABOUT_H
#ifndef __MASK_H
#include <mask.h>
#endif
#ifndef __TREECTRL_H
#include <treectrl.h>
#endif
class TProperty_sheet : public TObject
{
bool _power;
TWindow* _ps;
protected:
void freeze(bool f);
public:
void add_cat(const char* prompt);
void add_prop(const char* prompt, const char* value);
void add_prop(const char* prompt, long value);
void set_read_only(bool ro = true);
KEY run();
TProperty_sheet(const char* title = "", int width = 78, int height = 20);
virtual ~TProperty_sheet();
};
void about();
#endif

View File

@ -529,13 +529,20 @@ void TApplication::run(
if (mod == NULL || *mod == '\0')
return;
XVT_CONFIG cfg;
XVT_CONFIG cfg; memset(&cfg, 0, sizeof(cfg));
cfg.menu_bar_ID = TASK_MENUBAR;
cfg.about_box_ID = 0;
cfg.base_appl_name = base.name();
cfg.appl_name = title;
cfg.taskwin_title = dongle().product();
int year, major, minor, patch;
if (TApplication::get_version_info(year, major, minor, patch))
{
TString16 ver; ver.format("%d %d.%d/%d", year, major, minor, patch);
xvt_vobj_set_attr(NULL_WIN, ATTR_APPL_VERSION_STRING, (long)(const char*)ver);
}
set_xvt_hooks();
_running = TRUE;

View File

@ -1852,7 +1852,6 @@ void TMask::on_idle()
{
TOperable_field& s = (TOperable_field&)fld(_focus);
s.on_idle();
if (_msg_field > 0)
{
TMask_field& f = field(_msg_field);
@ -1863,14 +1862,15 @@ void TMask::on_idle()
}
if (_error_severity > 0)
{
set_focus();
switch(_error_severity)
{
case 2: warning_box(_error_message); break;
case 3: error_box(_error_message); break;
default: message_box(_error_message); break;
}
const int es = _error_severity; // Memorizzo per azzerare subito
_error_severity = 0;
set_focus();
switch(es)
{
case 2: xvt_dm_popup_warning(_error_message); break;
case 3: xvt_dm_popup_error (_error_message); break;
default: xvt_dm_popup_message(_error_message); break;
}
}
if (_test_fld >= 0)
{

View File

@ -1,3 +1,4 @@
#include <about.h>
#include <automask.h>
#include <colors.h>
#include <controls.h>
@ -737,11 +738,13 @@ void TGroup_field::create(WINDOW parent)
///////////////////////////////////////////////////////////
TOperable_field::TOperable_field(TMask* m)
: TMask_field(m), _message(NULL), _handler(NULL)
: TMask_field(m), _message(NULL), _handler(NULL), _help(NULL)
{ }
TOperable_field::~TOperable_field()
{
if (_help)
delete _help;
if (_message)
delete _message;
}
@ -764,7 +767,7 @@ bool TOperable_field::parse_item(TScanner& scanner)
{
if (scanner.key() == "HE") // HELP
{
scanner.string(); // Ignored from this version
_help = new TString(scanner.string());
return true;
}
@ -802,13 +805,59 @@ bool TOperable_field::on_key(
{
case K_F11:
if (handler(key))
{
TString msg;
msg << TR("Identificatore: ") << dlg() << '\n'
<< TR("Maschera: ") << mask().source_file() << '\n';
{
TProperty_sheet p(prompt(), 60, 10);
p.add_cat(TR("Sorgente"));
TFilename fn = mask().source_file(); fn.lower();
p.add_prop(TR("Maschera"), fn);
p.add_prop(TR("Personalizzata"), fn.find("custom") > 0 ? "Si" : "No");
if (mask().get_sheet() != NULL)
p.add_prop(TR("Spreadsheet"), mask().get_sheet()->dlg());
p.add_cat(TR("Informazioni"));
TString16 id; id << dlg();
// p.add_prop(TR("Tipo"), class_name()); // Per ora ritorna sempre "Field"!
p.add_prop(TR("Identificatore"), id);
p.add_prop(TR("Lunghezza"), long(size()));
if (_help != NULL)
p.add_prop(TR("Help"), *_help);
p.add_prop(TR("Obbligatorio"), required() ? TR("Si") : TR("No"));
p.add_cat(TR("Database"));
id.cut(0);
if (field() != NULL)
msg << TR("Campo: ") << *field();
message_box(msg);
{
const TIsam_handle f0 = atoi(field()->id());
if (f0 <= 0)
{
if (main_app().class_id() == CLASS_RELATION_APPLICATION)
{
TRelation_application& ra = (TRelation_application&)main_app();
id = ra.get_relation()->file(0).name();
}
}
else
id << f0;
TString80 str; str << *field();
p.add_prop(TR("Campo"), str);
}
else
{
// p.add_prop(TR("Campo"), TR("Nessuno")); ???
if (class_id() == CLASS_EDIT_FIELD || is_kind_of(CLASS_EDIT_FIELD))
{
const TEdit_field& ef = (TEdit_field&)*this;
const TBrowse* b = ef.browse();
if (b != NULL && b->cursor() != NULL)
id = b->cursor()->file(0).name();
}
}
if (id.full())
{
p.add_prop(TR("Tabella"), id);
p.add_prop(TR("Descrizione"), prefix().description(id));
}
p.run();
}
break;
case K_CTRL + K_TAB:

View File

@ -474,6 +474,7 @@ class TOperable_field : public TMask_field
{
// @cmember Comandi da eseguire in caso di modifica del campo
TString_array* _message;
TString* _help;
// @cmember Handler del controllo
CONTROL_HANDLER _handler;

View File

@ -1757,8 +1757,8 @@ bool TRelation_application::parse_command_line()
return _lnflag != 0;
}
// il valore di ritorno indica se attivare l'"automagia" (spedizione dei tasti e
// precaricamento della maschera)
// il valore di ritorno indica se attivare l'"automagia":
// spedizione dei tasti e precaricamento della maschera
bool TRelation_application::load_transaction()
{
bool retv = FALSE;

View File

@ -1028,6 +1028,11 @@ COLOR TProp_field::get_color_property(const char* name) const
return col;
}
bool TProp_field::for_each_property(PROP_CALLBACK pcb, void* jolly)
{
return xvt_prop_for_each(win().win(), pcb, jolly) != 0;
}
static TString_array _items;
bool TProp_field::parse_item(TScanner& scanner)

View File

@ -143,7 +143,9 @@ public:
const TString& get_property(const char* name) const;
COLOR get_color_property(const char* name) const;
long get_long_property(const char* name) const;;
long get_long_property(const char* name) const;
bool for_each_property(PROP_CALLBACK pcb, void* jolly);
TProp_field(TMask* m);
};