From db28017ec8d2723fbf876e4de97dc70eee926960 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Tue, 7 Sep 2021 11:37:46 +0200 Subject: [PATCH] Patch level : 12.0 nopatch Files correlati : xvaga.dll Commento : Cambiati NULL in nullptr Aggiunte funzioni per mostrare e nascondere finestre. Interno: Fare la patch insieme alle modifiche per le stampanti fare un gio generico --- src/include/transaction.cpp | 810 ++++++++++++++++++++++++++++++++++++ src/include/transaction.h | 191 +++++++++ src/xvaga/xvaga.cpp | 18 + src/xvaga/xvt.h | 2 + src/xvaga/xvtart.cpp | 5 + src/xvaga/xvtctl.cpp | 561 ++++++++++++++----------- src/xvaga/xvtmail.cpp | 31 +- 7 files changed, 1370 insertions(+), 248 deletions(-) create mode 100644 src/include/transaction.cpp create mode 100644 src/include/transaction.h diff --git a/src/include/transaction.cpp b/src/include/transaction.cpp new file mode 100644 index 000000000..89a4b565e --- /dev/null +++ b/src/include/transaction.cpp @@ -0,0 +1,810 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const char* TTransaction::build_rowkey(const char * table, int row) const +{ + TString& tmp = get_tmp_string(); + + tmp << table; + if (row > 0) + tmp << format(",%03d", row); + return tmp; +} + +const char * TTransaction::get_rowkey_logicnum(const TString & var) const +{ + const int pos = var.find(","); + + if (pos > 0) + return var.left(pos); + return var; +} + +int TTransaction::get_rowkey_row(const TString & var) const +{ + const int pos = var.find(","); + + if (pos > 0) + return atoi(var.mid(pos + 1)); + return 0; +} + +const char* TTransaction::build_varkey(const char* var, int index) const +{ + if (index >= 0) + { + TString& tmp = get_tmp_string(); + tmp << var << '(' << index << ')'; + return tmp; + } + return var; +} + +int TTransaction::get_varkey_index(const TString & var) const +{ + const int pos = var.find(","); + + if (pos > 0) + return atoi(var.mid(pos + 1)); + return -1; +} + +const char * TTransaction::get_varkey_name(const TString & var) const +{ + const int pos = var.find(","); + + if (pos > 0) + return var.left(pos); + return var; +} + +TTransaction & TTransaction::copy(const TTransaction & t) +{ + _head = t._head; + _rows = t._rows; + _file = t._file; + _type = t._type; + _executer = t._executer; + return *this; +} + +// @doc EXTERNAL + +// @mfunc Controlla se esite una variabile +// +// @rdesc Ritorna i seguenti valori: +// +// @flag true | Se la variabile esiste +// @flag false | Se la variabile non esiste +bool TTransaction::exist( + const char* var, // @parm Nome della variabile + int index, // @parm Indice dell'elemento dell'array (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) // @parm riga + + // @comm Se

e' = 0 viene costruito il nome dell'elemento + // dell'array da cercare, diversamente viene cercata la variabile + // normale passata in

. +{ + const char* key = build_varkey(var, index); + + + if (!table || *table == '\0') + return _head.is_key(key); + else + { + const char* rowkey = build_rowkey(table, row); + TAssoc_array * row_data = (TAssoc_array *)_rows.objptr(rowkey); + + if (row_data != nullptr) + return row_data->is_key(key); + } + return false; +} + +// @doc EXTERNAL + +// @mfunc Elimina una variabile +// +// @rdesc Ritorna i seguenti valori: +// +// @flag TRUE | Se la variabile esiteva +// @flag FALSE | Se la variabile non esiteva +bool TTransaction::remove( + const char* var, // @parm Nome della variabile + int index, // @parm Indice dell'elemento dell'array (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) // @parm riga + +// @comm Se

e' = 0 viene costruito il nome dell'elemento +// dell'array da cercare, diversamente viene cercata la variabile +// normale passata in

. +{ + const char* key = build_varkey(var, index); + bool ok = false; + + if (!table || *table == '\0') + ok = _head.remove(key); + else + { + const char* rowkey = build_rowkey(table, row); + TAssoc_array * row_data = (TAssoc_array *)_rows.objptr(rowkey); + + if (row_data != nullptr) + ok = row_data->remove(key); + } + return ok; +} + +// @doc EXTERNAL + +// @mfunc Elimina una serie di variabili dal paragrafo corrente +// +// @rdesc Ritorna i seguenti valori: +// +// @flag TRUE | Se la variabile esiteva +// @flag FALSE | Se la variabile non esiteva +bool TTransaction::remove_array( + const char* var, // @parm Nome della variabile + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) // @parm riga + +// @comm Viene cancellata l'aray di variabili passata in

. +{ + bool ok = false; + TString_array arr; + TString80 s = var; s << '('; + + if (!table || *table == '\0') + { + _head.get_keys(arr); + FOR_EACH_ARRAY_ROW(arr, r, str) + { + if (str->starts_with(s)) + { + + ok = remove(*str, r, nullptr); + } + } + } + else + { + const char* rowkey = build_rowkey(table, row); + TAssoc_array * row_data = (TAssoc_array *)_rows.objptr(rowkey); + + if (row_data != nullptr) + { + row_data->get_keys(arr); + FOR_EACH_ARRAY_ROW(arr, r, str) + { + if (str->starts_with(s)) + ok = remove(*str, r, table); + } + } + } + return ok; +} + + +void TTransaction::remove_all() +{ + _head.destroy(); + _rows.destroy(); +} + +// @doc EXTERNAL + +// @mfunc Ritorna il valore della variabile nella sezione corrente o in +// quella specificata +// +// @rdesc Ritorna la stringa contenuta nella variabile, se questa esiste, altrimenti +// il valore di default che dovrebbe assumere determinato dal parametro +//

+const TString& TTransaction::get( + const char* var, // @parm Variabile della quale ritornare il valore + int index, // @parm Eventuale indice della variabile (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) const // @parm riga + + // @comm Passando

= 0 viene appeso al nome della variabile per + // implementare un array. + // @xref + // +{ + const char* key = build_varkey(var, index); + const TString* val = nullptr; + + if (!table || *table == '\0') + val = (TString*)_head.objptr(key); + else + { + const char* rowkey = build_rowkey(table, row); + TAssoc_array * row_data = (TAssoc_array *)_rows.objptr(rowkey); + + if (row_data != nullptr) + val = (TString*) row_data->objptr(key); + } + if (val == nullptr) // Se non la trova inserisci il default + val = &EMPTY_STRING; + return *val; +} + +// @doc EXTERNAL + +// @mfunc Ritorna il valore della variabile nella sezione corrente o in +// quella specificata +// +// @rdesc Ritorna i seguenti valori +// +// @flag TRUE | Se la varabile e' settata con X +// @flag FALSE | Se la varabile nen e' settata con X +// @flag

| Se la varabile non esiste +bool TTransaction::get_bool( + const char* var, // @parm Variabile della quale ritornare il valore + int index, // @parm Eventuale indice della variabile (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) const // @parm riga + + // @comm Viene chiamata la funzione . + // Passando

= 0 viene appeso al nome variabile per + // implementare un array. + // Il paragrafo passato in

diventa quello attivo. + // + // @xref + // +{ + bool yes = false; + TString& s = (TString &) get(var, index, table, row); + + if (s.full()) + { + s.upper(); + yes = s == "X" || s == "Y" || s == "1" || s == "ON" || s == "YES" || s == "OK" || s == "TRUE"; + } + return yes; +} + +// @doc EXTERNAL + +// @mfunc Ritorna il valore del colore settato nella variabile nella +// sezione corrente o in quella specificata +COLOR TTransaction::get_color( + const char* var, // @parm Variabile della quale ritornare il valore + int index, // @parm Eventuale indice della variabile (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) const // @parm riga + + // @comm Passando

= 0 viene appeso al nome variabile per + // implementare un array. + // Il paragrafo passato in

diventa quello attivo. + // + // @xref + // +{ + TToken_string s(get(var, index, table, row), ','); + COLOR col = COLOR_BLACK; + + if (s.full()) + { + if (s.find(',') > 0) + { + const byte r = (byte)s.get_int(); + const byte g = (byte)s.get_int(); + const byte b = (byte)s.get_int(); + + col = RGB2COLOR(r, g, b); + } + else + { + col = atol(s); + if (col == 0L) + col = COLOR_BLACK; + } + } + return col; +} + +// @doc EXTERNAL + +// @mfunc Setta la variabile nella sezione corrente o specificata +// +// @rdesc Ritorna i seguenti valori: +// +// @flag TRUE | Se la variabile era gia' esistente +// @flag FALSE | Se la variabile non era gia' esistente +bool TTransaction::set( + const char* var, // @parm Nome della variabile da settare + const char* value, // @parm Stringa da assegnare alla variabile + int index, // @parm Eventuale indice della variabile (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) // @parm riga + +{ + // @syntax set(const char* var, const char* value, const char* section, bool force, int index); + // @syntax set(const char* var, long value, const char* section, bool force, int index); + // + // @comm Se

== TRUE crea il paragrafo e la variabile se non esistono; + // altrimenti da' errore. + // Passando

= 0 viene appeso al nome variabile per + // implementare un array. + // Il paragrafo passato in

diventa quello attivo. + + const char* key = build_varkey(var, index); + TString* val = nullptr; + bool itwas = false; + + if (!table || *table == '\0') + { + val = (TString*)_head.objptr(key); + itwas = val != nullptr; + if (itwas) + { + const TFixed_string str(value); + + // Se la variabile esisteva ed aveva un valore diverso ... + if (*val != str && !(str.blank() && val->empty())) + { + *val = str; // ... allora la sostituisco ... + val->trim(); + } + } + else + { + // Se la variabile non esisteva allora la aggiungo e metto a dirty. + val = new TString(value); + val->trim(); + itwas = _head.add(key, val, true); + } + } + else + { + const char* rowkey = build_rowkey(table, row); + TAssoc_array * row_data = (TAssoc_array *)_rows.objptr(rowkey); + + if (_executer.blank()) + _executer = table; + if (row_data == nullptr) + _rows.add(rowkey, row_data = new TAssoc_array, true); + if (row_data != nullptr) + { + val = (TString*)row_data->objptr(key); + itwas = val != nullptr; + if (itwas) + { + const TFixed_string str(value); + + // Se la variabile esisteva ed aveva un valore diverso ... + if (*val != str && !(str.blank() && val->empty())) + { + *val = str; // ... allora la sostituisco ... + val->trim(); + } + } + else + { + // Se la variabile non esisteva allora la aggiungo e metto a dirty. + val = new TString(value); + val->trim(); + itwas = row_data->add(key, val, true); + } + } + } + return itwas; +} + +bool TTransaction::set( + const char* var, // @parm Nome della variabile da settare + long value, // @parm Stringa da assegnare alla variabile + int index, // @parm Eventuale indice della variabile (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) // @parm riga +{ + TString16 t; + + t << value; + return set(var, t, index, table, row); +} + +bool TTransaction::set( + const char* var, // @parm Nome della variabile da settare + real value, // @parm Stringa da assegnare alla variabile + int index, // @parm Eventuale indice della variabile (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) // @parm riga +{ + TString40 t; + + t << value; + return set(var, t, index, table, row); +} + +bool TTransaction::set( + const char* var, // @parm Nome della variabile da settare + int value, // @parm Stringa da assegnare alla variabile + int index, // @parm Eventuale indice della variabile (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) // @parm riga +{ + TString16 t; + + t << value; + return set(var, t, index, table, row); +} + +bool TTransaction::set( + const char* var, // @parm Nome della variabile da settare + bool value, // @parm Stringa da assegnare alla variabile + int index, // @parm Eventuale indice della variabile (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) // @parm riga +{ + TString16 t; + + t << value ? "X" : " "; + return set(var, t, index, table, row); +} + +bool TTransaction::set( + const char* var, // @parm Nome della variabile da settare + COLOR col, // @parm Colore da assegnare alla variabile + int index, // @parm Eventuale indice della variabile (default -1) + const char * table, // @parm testata(TRANSACTION_HEADER) o tabella/file + int row) // @parm riga +{ + TString16 t; + + t.format("%d,%d,%d", XVT_COLOR_GET_RED(col), XVT_COLOR_GET_GREEN(col), XVT_COLOR_GET_BLUE(col)); + return set(var, t, index, table, row); +} + +bool TTransaction::read_ini() +{ + remove_all(); + if (_file.exist()) + { + TConfig cnf(_file, "Transaction"); + TString_array paragraphs; + + cnf.list_paragraphs(paragraphs); + FOR_EACH_ARRAY_ROW(paragraphs, r, para) + { + TAssoc_array & vars = cnf.list_variables(*para); + TString table; + int row = 0; + + if (*para != "Transaction") + { + table = get_rowkey_logicnum(*para); + row = get_rowkey_row(*para); + } + FOR_EACH_ASSOC_OBJECT(vars, obj, k, itm) + { + const TString key(k); + int index = get_varkey_index(key); + TString name = get_varkey_name(key); + + set(name, cnf.get(name, *para, index), index, table, row); + } + } + return true; + } + return false; +} + +bool TTransaction::read_xml() +{ + remove_all(); + if (_file.exist()) + { + TXmlItem xml; + + xml.Load(_file); + + TXmlItem * child = xml.GetChild(0); + + if (child->GetTag() == "Transaction") + { + const int nrows = child->GetChildren(); + TString_array vars; + + child->ListAttrs(vars); + FOR_EACH_ARRAY_ROW(vars, r, str) + { + int index = get_varkey_index(*str); + TString name = get_varkey_name(*str); + + set(name, child->GetAttr(*str), index, nullptr); + } + for(int n = 0; n < nrows; n++) + { + TXmlItem * child_row = child->GetChild(n); + const TString row_name = child_row->GetTag(); + TString logicnum = get_rowkey_logicnum(row_name); + const int row = get_rowkey_row(row_name); + + child_row->ListAttrs(vars); + FOR_EACH_ARRAY_ROW(vars, r1, str) + { + int index = get_varkey_index(*str); + TString name = get_varkey_name(*str); + + set(name, child_row->GetAttr(*str), index, logicnum, row); + } + } + } + return true; + } + return false; +} + +void TTransaction::write_ini_row_para(TConfig & cnf, const TString & rowkey, bool exec) +{ + TString_array arr; + TAssoc_array & row = *((TAssoc_array *)_rows.objptr(rowkey)); + + cnf.set_paragraph(rowkey); + row.get_keys(arr); + + FOR_EACH_ARRAY_ROW(arr, r1, str) + { + int index = get_varkey_index(*str); + const TString name = get_varkey_name(*str); + + cnf.set(name, *((TString *)row.objptr(*str)), nullptr, true, index); + } +} + +bool TTransaction::write_ini() +{ + bool ok = _head.items() > 0 && _rows.items(); + + if (ok) + { + TString_array arr; + TConfig cnf(_file, "Transaction"); + TString_array row_arr; + + _head.get_keys(arr); + cnf.set("Version", "2.0"); + FOR_EACH_ARRAY_ROW(arr, r, str) + { + int index = get_varkey_index(*str); + const TString name = get_varkey_name(*str); + + cnf.set(name, *((TString *)_head.objptr(*str)), nullptr, true, index); + } + _rows.get_keys(row_arr); + write_ini_row_para(cnf, _executer); + row_arr.sort(); + FOR_EACH_ARRAY_ROW(row_arr, r1, rowkey) + write_ini_row_para(cnf, *rowkey, false); + } + else + _file.fremove(); + return ok; +} + +void TTransaction::write_xml_row_para(TXmlItem & xml, const TString & rowkey, bool exec) +{ + TString_array arr; + TAssoc_array & row = *((TAssoc_array *)_rows.objptr(rowkey)); + TXmlItem & child = xml.AddChild(rowkey); + + row.get_keys(arr); + + FOR_EACH_ARRAY_ROW(arr, r1, str) + { + TXmlItem & child_row = xml.AddChild(rowkey); + + row.get_keys(arr); + FOR_EACH_ARRAY_ROW(arr, r1, str) + child.AddEnclosedText(*str, *((TString *)row.objptr(*str))); + } +} + +bool TTransaction::write_xml() +{ + bool ok = _head.items() > 0 && _rows.items(); + + if (ok) + { + TString_array arr; + TXmlItem xml; + TString_array row_arr; + + TXmlItem & child = xml.AddChild("Transaction"); + _head.get_keys(arr); + child.AddEnclosedText("Version", "2.0"); + FOR_EACH_ARRAY_ROW(arr, r, str) + child.AddEnclosedText(*str, *((TString *)_head.objptr(*str))); + _rows.get_keys(row_arr); + row_arr.sort(); + write_xml_row_para(xml, _executer); + FOR_EACH_ARRAY_ROW(row_arr, r1, rowkey) + write_xml_row_para(xml, *rowkey, false); + xml.Save(_file); + } + else + _file.fremove(); + return ok; +} + +const char * TTransaction::record_header() const +{ + TString &str = get_tmp_string(2569); + int logicnum = atoi(_executer); + + if (logicnum == 0) + logicnum = table2logic(_executer); + TToken_string keyfields(prefix().get_keyexpr(logicnum), '+'); + + str = "Record "; + FOR_EACH_STR_TOKEN(keyfields, fld) + if (fld.full()) + str << fld << " = " << get(fld, -1, _executer) << " "; + return str; +} + +bool TTransaction::get_errors(TString_array & errors) const +{ + TString error = get("ErrorMsg", 0, nullptr); + + errors.destroy(); + for (int i = 0; error.full(); error = get("ErrorMsg", ++i, nullptr)) + errors.add(error); + return errors.items() > 0; +} + +bool TTransaction::get_warnings(TString_array & warnings) const +{ + TString warning = get("WarningMsg", 0, nullptr); + + warnings.destroy(); + for (int i = 0; warning.full(); warning = get("WarningMsg", i++, nullptr)) + warnings.add(warning); + return warnings.items() > 0; +} + +bool TTransaction::read() +{ + if (_type == ini_transaction) + return read_ini(); + else + return read_xml(); +} + +bool TTransaction::write() +{ + if (_type == ini_transaction) + return write_ini(); + else + return write_xml(); +} + +bool file2app(TString & file ,TString& app) +{ + TString16 appname; appname << "Edit_" << file; + app = ini_get_string(CONFIG_INSTALL, "ba7", appname); + if (app.empty()) + { + if (isdigit(file[0])) + { + const int filenum = atoi(file); + if (filenum >= LF_USER && filenum < prefix().items()) + { + TLocalisamfile isf(filenum); + isf.get_relapp(app); + } + } + else + { + const int len = file.len(); + if (len == 3 || (len == 4 && file[0] == '%')) + { + TTable table(file); + + table.get_relapp(app); + } + else + if (len >= 4 && file[0] == '&') + { + TModule_table tabmod(file); + + tabmod.get_relapp(app); + } + } + } + + return app.full(); +} + +void execute_transactions(TArray & transactions, TLog_report & log) +{ + if (transactions.items() > 0) + { + TBit_array processed; + const int first = transactions.first(); + const int last = transactions.last(); + + while (true) + { + int i = first; + TTransaction t = (TTransaction &)transactions[i]; + TString table = t.executer(); + int logicnum = atoi(table); + + while (processed[i]) + i++; + if (i > last) + break; + if (table.full()) + { + TFilename path = t.name().path(); + + while (i >= 0) + { + if (t.executer() == table && path == t.name().path()) + { + t.write(); + processed.set(i); + } + i = transactions.succ(i); + while (processed[i]) + i++; + if (i > last) + break; + t = (TTransaction &)transactions[i]; + } + TString app; + + if (file2app(table, app)) + { + TFilename filemask(path); + TString_array files; + + filemask << "*" << "." << t.ext(); + app << " -i" << filemask << " -u" << user(); + TExternal_app cmd(app); + + cmd.run(); + list_files(filemask, files); + FOR_EACH_ARRAY_ROW(files, r, str) + { + TTransaction t(*str); + TString_array msgs; + + log.log(0, t.record_header()); + t.get_warnings(msgs); + FOR_EACH_ARRAY_ROW(msgs, nm, msg) + log.log(1, *msg); + if (t.result_ok()) + log.log(0, "Eseguita"); + else + { + t.get_errors(msgs); + FOR_EACH_ARRAY_ROW(msgs, nm, msg) + log.log(2, *msg); + } + } + remove_files(filemask, false); + } + else + { + TString msg(TR("Esecutore sconosciuto per le transazioni sul file ")); + + msg << (logicnum == 0) ? t.executer() : prefix().description(logicnum); + log.log(2, msg); + } + } + } + } +} diff --git a/src/include/transaction.h b/src/include/transaction.h new file mode 100644 index 000000000..fed1977b8 --- /dev/null +++ b/src/include/transaction.h @@ -0,0 +1,191 @@ +#ifndef __TRANSACTION_H +#define __TRANSACTION_H + +#ifndef __ASSOC_H +#include +#endif + +#ifndef __COLORS_H +#include +#endif + +#ifndef __REAL_H +#include +#endif + +#ifndef __REPUTILS_H +#include +#endif + +#define TRANSACTION_RUN "RUN" // Run application (eventually sets firm) +#define TRANSACTION_INSERT "INSERT" // Create a new record and fill it +#define TRANSACTION_MODIFY "MODIFY" // Load and modify an existing record +#define TRANSACTION_DELETE "DELETE" // Delete an existing record +#define TRANSACTION_LINK "LINK" // Load an existing record and interactively edit it + +#define TRANSACTION_HEADER 0 + +typedef enum {ini_transaction, xml_transaction} transaction_type; +typedef enum { transaction_mode_interactive = 'I', transaction_mode_automatic = 'A', transaction_mode_remain = 'R'} transaction_mode; + +// @doc EXTERNAL + +// @class TTransaction | Classe per la gestione dei file di configurazione in formato +// Windows +// +// @base public | TObject +class TTransaction : public TObject + + // @author:(INTERNAL) Bonazzi + + + // @access:(INTERNAL) Private Member +{ + // @cmember:(INTERNAL) Contenuto della testata + TAssoc_array _head; + // @cmember:(INTERNAL) Contenuto delle righe + TAssoc_array _rows; + // @cmember:(INTERNAL) Nome del file + TFilename _file; + // @cmember:(INTERNAL) tipo transazione + transaction_type _type; + TString _executer; + + // @access Protected Member +protected: + // @cmember legge da in file ini + bool TTransaction::read_ini(); + // @cmember legge da un xml + bool TTransaction::read_xml(); + // @cmember scrivono un file ini + void write_ini_row_para(TConfig & cnf, const TString & para, bool exec = true); + bool TTransaction::write_ini(); + // @cmember scrivono un xml + void write_xml_row_para(TXmlItem & xml, const TString & rowkey, bool exec = true); + bool TTransaction::write_xml(); + // @cmember costruisce il nome di una variabile + const char* build_rowkey(const char * file, int row = 0) const; + // @cmember ritorna il file di una riga + const char * TTransaction::get_rowkey_logicnum(const TString & var) const; + // @cmember ritorna il numero di riga di una riga + int TTransaction::get_rowkey_row(const TString & var) const; + // @cmember costruisce il nome di una variabile + const char* build_varkey(const char* var, int index) const; + // @cmember ritorna l'indice di una variabile + int get_varkey_index(const TString & var) const; + // @cmember ritorna il nome di una variabile + const char * get_varkey_name(const TString & var) const; + // @cmember Duplica una transazione. + virtual TObject* dup() const { return new TTransaction(*this); } + // @cmember Copia da una transazione. + virtual TTransaction & copy(const TTransaction & t); + // @access Public Memeber +public: + + // @cmember Ritornano il valore della variabile nella testata o nella righa specificata + virtual const TString& get(const char* var, int index = -1, const char * table = nullptr, int row = 0) const; + long get_long(const char* var, int index = -1, const char * table = nullptr, int row = 0) const { return atol(get(var, index, table, row)); } + real get_real(const char* var, int index = -1, const char * table = nullptr, int row = 0) const { return (real)get(var, index, table, row); } + int get_int(const char* var, int index = -1, const char * table = nullptr, int row = 0) const { return atoi(get(var, index, table, row)); } + bool get_bool(const char* var, int index = -1, const char * table = nullptr, int row = 0) const; + COLOR get_color(const char* var, int index = -1, const char * table = nullptr, int row = 0) const; + + const TString& get(const char* var, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) const + { return get(var, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + long get_long(const char* var, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) const + { return get_long(var, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + real get_real(const char* var, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) const + { return get_real(var, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + int get_int(const char* var, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) const + { return get_int(var, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + bool get_bool(const char* var, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) const + { return get_int(var, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + COLOR get_color(const char* var, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) const + { return get_int(var, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + + + // @cmember Setta la variabile nella nella testata o nella righa specificata + virtual bool set(const char* var, const char* value, int index = -1, const char * table = nullptr, int row = 0); + bool set(const char* var, long value, int index = -1, const char * table = nullptr, int row = 0); + bool set(const char* var, real value, int index = -1, const char * table = nullptr, int row = 0); + bool set(const char* var, int value, int index = -1, const char * table = nullptr, int row = 0); + bool set(const char* var, bool value, int index = -1, const char * table = nullptr, int row = 0); + bool set(const char* var, COLOR col, int index = -1, const char * table = nullptr, int row = 0); + + bool set(const char* var, const char* value, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) + { return set(var, value, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + bool set(const char* var, long value, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) + { return set(var, value, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + bool set(const char* var, real value, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) + { return set(var, value, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + bool set(const char* var, int value, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) + { return set(var, value, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + bool set(const char* var, bool value, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) + { return set(var, value, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + bool set(const char* var, COLOR col, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) + { return set(var, col, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + // @cmember Controlla se esite una variabile nella nella testata o nella righa specificata + + bool exist(const char* var, int index = -1, const char * table = nullptr, int row = 0); + bool exist(const char* var, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) + { return exist(var, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + + // @cmember Elimina una variabile nella nella testata o nella righa specificata + bool remove(const char* var, int index = -1, const char * table = nullptr, int row = 0); + bool remove(const char* var, int index = -1, int logic = TRANSACTION_HEADER, int row = 0) + { return remove(var, index, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + + // @cmember Elimina una array di variabili nella nella testata o nella righa specificata + bool remove_array(const char* var, const char * table = nullptr, int row = 0); + bool remove_array(const char* var, int logic = TRANSACTION_HEADER, int row = 0) + { return remove_array(var, (logic != TRANSACTION_HEADER) ? format("%d", logic) : "", row); } + + // @cmember Elimina tutte le variabili + void remove_all(); + // @cmember nouva transazione + void new_transaction(const char* file) { set_name(file); remove_all(); } + + // @cmember Ritorna il nome del file di configurazione + const TFilename& name() const { return _file; } + void set_name(const char * name) { _file = name; _file.ext(_type == ini_transaction ? "ini" : "xml"); } + const TString & executer() const { return _executer; } + const char * record_header() const; + const TString & get_action() const { return (const char *)get("Action", -1, nullptr); } + char get_mode() const { get("Mode", -1, TRANSACTION_HEADER)[0]; } + int get_stop_on_error() const { return get_bool("StopOnError", -1, nullptr) ? 1 : 0; } + const TString & get_caller() const { get("From", -1, nullptr); } + long get_firm() const { get_long("Firm", -1, nullptr); } + bool result_ok() const { return get("Result", -1, nullptr) == "OK"; } + bool result_error() const { return !ok(); } + bool get_errors(TString_array & errors) const; + bool get_warnings(TString_array & warnings) const; + + void set_executer(int logicnum) { _executer = format("%d", logicnum); } + void set_executer(const char * table) { _executer = table; } + bool set_action(TString & action) { return set("Action", action.upper(), -1, nullptr); } + bool set_action(const char * action) { TString a(action); return set("Action", a.upper(), -1, nullptr); } + bool set_mode(transaction_mode mode) { TString val; val << (char) mode; return set("Mode", val, -1, nullptr); } + bool set_stop_on_error(bool val) { return set("StopOnError", val ? 1 : 0, -1, nullptr); } + bool set_caller(const TString & caller) { return set("From", caller, -1, nullptr); } + bool set_firm(int firm) { return set("Firm", firm, -1, nullptr); } + const char * ext() const { return _type == ini_transaction ? "ini" : "xml"; } + + bool read(); + bool write(); + + TTransaction & operator= (const TTransaction & t) { return copy(t); } + + // @cmember Costruttore di copia + TTransaction(const TTransaction & t) { copy(t); } + // @cmember Costruttore + TTransaction(const char* file, const char* table, transaction_type type = ini_transaction) : _type(type), _executer(table) { set_name(file); if (_file.exist()) read(); } + TTransaction(const char* file, int logicnum = 0, transaction_type type = ini_transaction) : _type(type), _executer(logicnum > 0 ? format("%d", logicnum) : "") { set_name(file); if (_file.exist()) read(); + } + + // @ cmember Distruttore. Riscrive il file con le modifiche se necessrio, + virtual ~TTransaction() {} +}; + +void execute_transactions(TArray & transactions, TLog_report & log); + +#endif diff --git a/src/xvaga/xvaga.cpp b/src/xvaga/xvaga.cpp index eb308bb86..6e15803ea 100755 --- a/src/xvaga/xvaga.cpp +++ b/src/xvaga/xvaga.cpp @@ -4365,6 +4365,24 @@ void xvt_vobj_minimize(WINDOW win) SORRY_BOX(); } +void xvt_vobj_hide(WINDOW win) +{ + wxFrame* pMain = wxDynamicCast((wxObject*)win, wxFrame); + if (pMain != NULL) + pMain->Hide(); + else + SORRY_BOX(); +} + +void xvt_vobj_show(WINDOW win) +{ + wxFrame* pMain = wxDynamicCast((wxObject*)win, wxFrame); + if (pMain != NULL) + pMain->Show(); + else + SORRY_BOX(); +} + void xvt_vobj_move(WINDOW win, const RCT* rctp) { CAST_WIN(win, w); diff --git a/src/xvaga/xvt.h b/src/xvaga/xvt.h index df04a8436..288d91009 100755 --- a/src/xvaga/xvt.h +++ b/src/xvaga/xvt.h @@ -467,6 +467,8 @@ XVTDLL BOOLEAN xvt_vobj_is_focusable(WINDOW win); XVTDLL BOOLEAN xvt_vobj_is_valid(WINDOW win); XVTDLL void xvt_vobj_maximize(WINDOW win); // Added by XVAGA XVTDLL void xvt_vobj_minimize(WINDOW win); // Added by XVAGA +XVTDLL void xvt_vobj_hide(WINDOW win); // Added by XVAGA +XVTDLL void xvt_vobj_show(WINDOW win); // Added by XVAGA XVTDLL void xvt_vobj_move(WINDOW win, const RCT* rctp); XVTDLL void xvt_vobj_raise(WINDOW win); XVTDLL void xvt_vobj_set_attr(WINDOW win, long data, long value); diff --git a/src/xvaga/xvtart.cpp b/src/xvaga/xvtart.cpp index 39186eca2..b186e7887 100755 --- a/src/xvaga/xvtart.cpp +++ b/src/xvaga/xvtart.cpp @@ -2,7 +2,12 @@ #include "xvt.h" #include "xvtart.h" + +#ifdef __WXMSW__ #include "oswin32.h" +#else +#include "oslinux.h" +#endif #include #include diff --git a/src/xvaga/xvtctl.cpp b/src/xvaga/xvtctl.cpp index e4d79fa45..cbd8d5852 100755 --- a/src/xvaga/xvtctl.cpp +++ b/src/xvaga/xvtctl.cpp @@ -6,6 +6,7 @@ #include "treelistctrl.h" #include +#include #include #include #include @@ -20,7 +21,7 @@ static wxBitmap Image2Bitmap(XVT_IMAGE image, int maxx, int maxy, BOOLEAN trans) { - if (image == NULL || !((wxImage*)image)->IsOk()) + if (image == nullptr || !((wxImage*)image)->IsOk()) return wxNullBitmap; wxImage img = *(wxImage*)image; @@ -80,9 +81,9 @@ void Image2Colors(const wxImage& img, wxColour& mean, wxColour& dark, wxColour& static wxAuiDockArt* FindArtist(wxWindow* pWindow) { - wxAuiDockArt* pArtist = NULL; + wxAuiDockArt* pArtist = nullptr; const wxAuiManager* pManager = wxAuiManager::GetManager(pWindow); - if (pManager != NULL) + if (pManager != nullptr) pArtist = pManager->GetArtProvider(); return pArtist; } @@ -125,7 +126,7 @@ public: int ChangeSelection(size_t tab_no); // wxNotebook had it! void SetTabImage(size_t tab_no, XVT_IMAGE img); - short AddTab(wxWindow* pPage, const wxString text, XVT_IMAGE img = NULL, short idx = -1); + short AddTab(wxWindow* pPage, const wxString text, XVT_IMAGE img = nullptr, short idx = -1); TwxNoteBook(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style); ~TwxNoteBook(); }; @@ -298,7 +299,7 @@ public: WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data) { - wxASSERT(win_def_p != NULL); + wxASSERT(win_def_p != nullptr); const wxRect rct = RCT2Rect(&win_def_p->rct); wxWindow* pParent = wxStaticCast((wxObject*)parent_win, wxWindow); const wxWindowID id = win_def_p->v.ctl.ctrl_id; @@ -333,7 +334,7 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data) break; case WC_PUSHBUTTON: /* bottone normale */ { - wxButton* pb = NULL; + wxButton* pb = nullptr; if (win_def_p->text && *win_def_p->text) // Bottone normale con label pb = new wxButton(pParent, id, win_def_p->text, rct.GetPosition(), rct.GetSize()); else @@ -429,12 +430,12 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data) if (flags & CTL_FLAG_DISABLED) w.Disable(); XVT_FNTID font_id = win_def_p->v.ctl.font_id; - const bool bDestroyFont = font_id == NULL; + const bool bDestroyFont = font_id == nullptr; if (bDestroyFont) font_id = xvt_dwin_get_font(parent_win); - if (font_id != NULL) + if (font_id != nullptr) { - const wxFont& font = wxStaticCast(font_id, TFontId)->Font(NULL, win); + const wxFont& font = wxStaticCast(font_id, TFontId)->Font(nullptr, win); w.SetFont(font); if (bDestroyFont) xvt_font_destroy(font_id); @@ -451,7 +452,7 @@ void xvt_ctl_check_radio_button(WINDOW win, WINDOW* wins, int NbrWindows) for (int i = 0; i < NbrWindows; i++) { wxRadioButton* rb = wxDynamicCast((wxObject*)wins[i], wxRadioButton); - if (rb != NULL) + if (rb != nullptr) rb->SetValue(win == wins[i]); } } @@ -459,7 +460,7 @@ void xvt_ctl_check_radio_button(WINDOW win, WINDOW* wins, int NbrWindows) void xvt_ctl_set_checked(WINDOW win, BOOLEAN bCheck) { wxCheckBox* cb = wxDynamicCast((wxObject*)win, wxCheckBox); - if (cb != NULL) + if (cb != nullptr) cb->SetValue(bCheck != 0); } @@ -467,7 +468,7 @@ void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR { // Non posso usare wxControl in quanto certi controlli derivano da wxWindow wxWindow* w = wxDynamicCast((wxObject*)win, wxWindow); - if (w != NULL && colors != NULL) + if (w != nullptr && colors != nullptr) { if (action == XVT_COLOR_ACTION_SET) { @@ -488,12 +489,12 @@ void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR case XVT_COLOR_HIGHLIGHT: { TwxPopUp* tpu = wxDynamicCast(w, TwxPopUp); - if (tpu != NULL) + if (tpu != nullptr) tpu->SetSelectForeColor(rgb); else { TwxMetroBar* tmb = wxDynamicCast(w, TwxMetroBar); - if (tmb != NULL) + if (tmb != nullptr) tmb->SetSelectForeColor(rgb); } } @@ -501,7 +502,7 @@ void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR case XVT_COLOR_SELECT: { TwxPopUp* tpu = wxDynamicCast(w, TwxPopUp); - if (tpu != NULL) + if (tpu != nullptr) tpu->SetSelectBackColor(rgb); } break; @@ -512,7 +513,7 @@ void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR case XVT_COLOR_BORDER: { TwxMetroBar* tmb = wxDynamicCast(w, TwxMetroBar); - if (tmb != NULL) + if (tmb != nullptr) tmb->SetBorderColor(rgb); } break; @@ -534,13 +535,13 @@ void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down) { - if (win != NULL_WIN && up != NULL) + if (win != NULL_WIN && up != nullptr) { wxBitmapButton* pb = wxDynamicCast((wxObject*)win, wxBitmapButton); - if (pb != NULL) + if (pb != nullptr) { int mx, my; pb->GetSize(&mx, &my); - wxBitmap bmpUp = Image2Bitmap(up, mx, my, TRUE); + wxBitmap bmpUp = Image2Bitmap(up, mx, my, true); if (bmpUp.Ok()) { pb->SetBitmapLabel(bmpUp); @@ -548,9 +549,9 @@ void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down) wxBitmap bmpGay(imgGay); pb->SetBitmapDisabled(bmpGay); } - if (down != NULL) + if (down != nullptr) { - wxBitmap bmpDown = Image2Bitmap(down, mx, my, TRUE); + wxBitmap bmpDown = Image2Bitmap(down, mx, my, true); if (bmpDown.Ok()) pb->SetBitmapSelected(bmpDown); } @@ -569,7 +570,7 @@ void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down) static wxAuiManager* FindPaneManager(WINDOW win) { - wxAuiManager* pManager = NULL; + wxAuiManager* pManager = nullptr; if (win != NULL_WIN) { wxWindow* pwin = wxStaticCast((wxObject*)win, wxWindow); @@ -581,25 +582,25 @@ static wxAuiManager* FindPaneManager(WINDOW win) static wxAuiPaneInfo* LockPane(WINDOW win) { wxAuiManager* pManager = FindPaneManager(win); - if (pManager != NULL) + if (pManager != nullptr) { wxAuiPaneInfo& pane = pManager->GetPane((wxWindow*)win); if (pane.IsOk()) return &pane; } - return NULL; + return nullptr; } static void UnlockPane(WINDOW win) { wxAuiManager* pManager = FindPaneManager(win); - if (pManager != NULL) + if (pManager != nullptr) pManager->Update(); } BOOLEAN xvt_pane_add(WINDOW win, WINDOW pane, const char* name, int dock, int flags) { - BOOLEAN done = FALSE; + BOOLEAN done = false; if (win != NULL_WIN && pane != NULL_WIN && name && *name) { TwxWindow* owner = wxStaticCast((wxObject*)win, TwxWindow); @@ -612,31 +613,31 @@ BOOLEAN xvt_pane_add(WINDOW win, WINDOW pane, const char* name, int dock, int fl BOOLEAN xvt_pane_set_title(WINDOW win, const char* title) { wxAuiPaneInfo* pane = LockPane(win); - if (pane != NULL) + if (pane != nullptr) { pane->Caption(title); UnlockPane(win); } - return pane != NULL; + return pane != nullptr; } XVTDLL BOOLEAN xvt_pane_change_flags(WINDOW win, int set, int rst) { wxAuiPaneInfo* pane = LockPane(win); - if (pane != NULL && (set || rst)) + if (pane != nullptr && (set || rst)) { if (set) pane->SetFlag(set, true); if (rst) pane->SetFlag(rst, false); UnlockPane(win); } - return pane != NULL; + return pane != nullptr; } XVTDLL BOOLEAN xvt_pane_detach(WINDOW win) { - BOOLEAN ok = FALSE; + BOOLEAN ok = false; wxAuiManager* pManager = FindPaneManager(win); - if (pManager != NULL) + if (pManager != nullptr) { ok = pManager->DetachPane((wxWindow*)win); pManager->Update(); @@ -646,11 +647,11 @@ XVTDLL BOOLEAN xvt_pane_detach(WINDOW win) XVTDLL BOOLEAN xvt_pane_manager_load_perspective(WINDOW win, const char* perspective) { - BOOLEAN ok = FALSE; + BOOLEAN ok = false; if (perspective && *perspective) { wxAuiManager* pManager = FindPaneManager(win); - if (pManager != NULL) + if (pManager != nullptr) { const wxString str = perspective; ok = pManager->LoadPerspective(str, true); @@ -663,11 +664,11 @@ XVTDLL int xvt_pane_manager_save_perspective(WINDOW win, char* perspective, int { int nSize = 0; wxAuiManager* pManager = FindPaneManager(win); - if (pManager != NULL) + if (pManager != nullptr) { const wxString str = pManager->SavePerspective(); nSize = str.Len()+1; - if (perspective != NULL && max_size > 0) + if (perspective != nullptr && max_size > 0) wxStrncpy(perspective, str, max_size); } return nSize; @@ -675,9 +676,9 @@ XVTDLL int xvt_pane_manager_save_perspective(WINDOW win, char* perspective, int XVTDLL BOOLEAN xvt_pane_set_size_range(WINDOW win, int min_size, int best_size, int max_size) { - BOOLEAN ok = FALSE; + BOOLEAN ok = false; wxAuiPaneInfo* pane = LockPane(win); - if (pane != NULL) + if (pane != nullptr) { if (min_size > 0 || max_size > 0) { @@ -779,7 +780,7 @@ IMPLEMENT_DYNAMIC_CLASS(TwxNoteBook, wxAuiNotebook) #define CAST_NOTEBOOK(win, nb) TwxNoteBook& nb = *wxStaticCast((wxObject*)win, TwxNoteBook); inline bool VALID_NOTEBOOK(WINDOW notebk, short page_no) -{ return page_no >= 0 && wxDynamicCast((wxObject*)notebk, TwxNoteBook)!=NULL; } +{ return page_no >= 0 && wxDynamicCast((wxObject*)notebk, TwxNoteBook)!=nullptr; } BEGIN_EVENT_TABLE(TwxNoteBook, wxAuiNotebook) EVT_AUINOTEBOOK_PAGE_CHANGING(wxID_ANY, TwxNoteBook::OnPageChanging) @@ -793,7 +794,7 @@ bool TwxNoteBook::SetBackgroundColour(const wxColour& col) if (ok) // Se cambio lo sfondo del tab control devo notificarlo all'art provider { TwxAuiDefaultTabArt* pArtist = (TwxAuiDefaultTabArt*)GetArtProvider(); - if (pArtist != NULL) + if (pArtist != nullptr) pArtist->SetBackgroundColour(col); } return ok; @@ -805,7 +806,7 @@ bool TwxNoteBook::SetForegroundColour(const wxColour& col) if (ok) // Se cambio il colore del testo del tab control devo notificarlo all'art provider { TwxAuiDefaultTabArt* pArtist = (TwxAuiDefaultTabArt*)GetArtProvider(); - if (pArtist != NULL) + if (pArtist != nullptr) pArtist->SetForegroundColour(col); } return ok; @@ -819,7 +820,7 @@ void TwxNoteBook::OnChar(wxKeyEvent& evt) if (kc >= WXK_F1 && kc <= WXK_F24 || kc == WXK_ESCAPE || kc == WXK_RETURN) { TwxWindow* gp = wxDynamicCast(GetGrandParent(), TwxWindow); - if (gp != NULL) + if (gp != nullptr) gp->ProcessEvent(evt); else evt.Skip(); @@ -878,12 +879,12 @@ void TwxNoteBook::OnPageChanged(wxAuiNotebookEvent& evt) short TwxNoteBook::AddTab(wxWindow* pPage, const wxString text, XVT_IMAGE xvt_img, short idx) { - wxBitmap bmp = Image2Bitmap(xvt_img, BOOK_ICO_SIZE, BOOK_ICO_SIZE, TRUE); + wxBitmap bmp = Image2Bitmap(xvt_img, BOOK_ICO_SIZE, BOOK_ICO_SIZE, true); if (idx < 0 || idx >= (int)GetPageCount()) { AddPage(pPage, text, false, bmp); - idx = GetPageCount()-1; + idx = ((short)GetPageCount())-1; } else InsertPage(idx, pPage, text, false, bmp); @@ -893,7 +894,7 @@ short TwxNoteBook::AddTab(wxWindow* pPage, const wxString text, XVT_IMAGE xvt_im void TwxNoteBook::SetTabImage(size_t idx, XVT_IMAGE img) { - wxBitmap bmp = Image2Bitmap(img, BOOK_ICO_SIZE, BOOK_ICO_SIZE, TRUE); + wxBitmap bmp = Image2Bitmap(img, BOOK_ICO_SIZE, BOOK_ICO_SIZE, true); SetPageBitmap(idx, bmp); } @@ -943,7 +944,7 @@ TwxNoteBook::TwxNoteBook(wxWindow *parent, wxWindowID id, _nice_windows.Put((WINDOW)this, this); // Serve per poter fare la xvt_vobj_destroy wxAuiTabCtrl* atc = GetActiveTabCtrl(); - if (atc != NULL) + if (atc != nullptr) #if wxCHECK_VERSION(2,9,0) atc->GetEventHandler().Bind(wxEVT_CHAR, (functor)&TwxNoteBook::OnChar); #else @@ -988,10 +989,11 @@ WINDOW xvt_notebk_get_page(WINDOW notebk, short tab_no) short xvt_notebk_get_num_tabs(WINDOW notebk) { short pg = 0; + if (notebk != NULL_WIN) { CAST_NOTEBOOK(notebk, nb); - pg = nb.GetPageCount(); + pg = (short) nb.GetPageCount(); } return pg; } @@ -1021,7 +1023,7 @@ void xvt_notebk_set_front_page(WINDOW notebk, short tab_no) { CAST_NOTEBOOK(notebk, nb); wxWindow* w = nb.GetPage(tab_no); - if (w != NULL) + if (w != nullptr) { nb.ChangeSelection(tab_no); // Non genera evento di cambio pagina! if (!w->IsShown()) // A volte succede che la prima pagina sia nascosta! @@ -1084,9 +1086,10 @@ void xvt_notebk_set_tab_title(WINDOW notebk, short tab_no, const char* title) if (VALID_NOTEBOOK(notebk, tab_no)) { CAST_NOTEBOOK(notebk, nb); - const short pc = nb.GetPageCount(); + const short pc = (short) nb.GetPageCount(); + if (tab_no >= pc) - nb.AddTab(nb.GetPage(pc-1), title, NULL, pc); + nb.AddTab(nb.GetPage(pc-1), title, nullptr, pc); else nb.SetPageText(tab_no, title); } @@ -1121,9 +1124,9 @@ void TwxTreeCtrl::OnExpanding(wxTreeEvent& evt) e.v.ctl.ci.type = WC_TREE; e.v.ctl.ci.win = WINDOW(this); e.v.ctl.ci.v.treeview.node = id.m_pItem; - e.v.ctl.ci.v.treeview.expanded = TRUE; + e.v.ctl.ci.v.treeview.expanded = true; if (GetChildrenCount(id) == 0) // Trucco perfido ... - e.v.ctl.ci.v.treeview.collapsed = TRUE; // ... stato indeterminato = EXPANDING + e.v.ctl.ci.v.treeview.collapsed = true; // ... stato indeterminato = EXPANDING TwxWindow* win = wxStaticCast(GetParent(), TwxWindow); win->DoXvtEvent(e); if (GetChildrenCount(id) == 0) // Allora e' proprio vero ... @@ -1141,7 +1144,7 @@ void TwxTreeCtrl::OnCollapsed(wxTreeEvent& evt) e.v.ctl.ci.type = WC_TREE; e.v.ctl.ci.win = WINDOW(this); e.v.ctl.ci.v.treeview.node = evt.GetItem().m_pItem; - e.v.ctl.ci.v.treeview.collapsed = TRUE; + e.v.ctl.ci.v.treeview.collapsed = true; TwxWindow* win = wxStaticCast(GetParent(), TwxWindow); win->DoXvtEvent(e); Resume(); @@ -1159,9 +1162,9 @@ void TwxTreeCtrl::OnClick(wxTreeEvent& evt, bool bDouble) e.v.ctl.ci.win = WINDOW(this); e.v.ctl.ci.v.treeview.node = evt.GetItem().m_pItem; if (bDouble) - e.v.ctl.ci.v.treeview.dbl_click = TRUE; + e.v.ctl.ci.v.treeview.dbl_click = true; else - e.v.ctl.ci.v.treeview.sgl_click = TRUE; + e.v.ctl.ci.v.treeview.sgl_click = true; TwxWindow* win = wxStaticCast(GetParent(), TwxWindow); win->DoXvtEvent(e); Resume(); @@ -1205,7 +1208,7 @@ void TwxTreeCtrl::OnActivated(wxTreeEvent& evt) void TwxTreeCtrl::OnRightDown(wxMouseEvent& evt) { TwxWindow* pParent = wxDynamicCast(GetParent(), TwxWindow); - if (pParent != NULL) + if (pParent != nullptr) { XVT_EVENT e(E_MOUSE_DOWN); e.v.mouse.button = 1; @@ -1220,14 +1223,14 @@ void TwxTreeCtrl::OnRightDown(wxMouseEvent& evt) int TwxTreeCtrl::img2int(XVT_IMAGE xvt_img) { int i = -1; - if (xvt_img != NULL) + if (xvt_img != nullptr) { i = m_img[xvt_img] - 1; // Ho memorizzato indice+1 if (i < 0) // Immagine sconosciuta { const wxImage& img = *(wxImage*)xvt_img; wxImageList* il = GetImageList(); - if (il == NULL) // Lista non ancora creata + if (il == nullptr) // Lista non ancora creata { il = new wxImageList; il->Create(img.GetWidth(), img.GetHeight(), true, 3); @@ -1356,7 +1359,7 @@ XVT_TREEVIEW_NODE xvt_treeview_add_child_node(WINDOW win, XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image, const char* string, XVT_TREEVIEW_CALLBACK WXUNUSED(callback), const char* data) { - XVT_TREEVIEW_NODE node = NULL; + XVT_TREEVIEW_NODE node = nullptr; if (win != NULL_WIN) { CAST_TREEVIEW(win, tv); @@ -1381,7 +1384,7 @@ XVT_TREEVIEW_NODE xvt_treeview_add_child_node(WINDOW win, XVT_TREEVIEW_NODE xvt_treeview_get_child_node(WINDOW win, XVT_TREEVIEW_NODE parent_node, int position) { - XVT_TREEVIEW_NODE child_node = NULL; + XVT_TREEVIEW_NODE child_node = nullptr; if (win != NULL_WIN && position >= 0) { CAST_TREEVIEW(win, tv); @@ -1404,13 +1407,13 @@ XVT_TREEVIEW_NODE xvt_treeview_get_child_node(WINDOW win, XVT_TREEVIEW_NODE pare const char* xvt_treeview_get_node_data(WINDOW win, XVT_TREEVIEW_NODE node) { - const char* data = NULL; - if (win != NULL_WIN && node != NULL) + const char* data = nullptr; + if (win != NULL_WIN && node != nullptr) { CAST_TREEVIEW(win, tv); const wxTreeItemId id(node); TwxTreeItemData* pData = (TwxTreeItemData*)tv.GetItemData(id); - if (pData != NULL) + if (pData != nullptr) data = (const char*)pData->m_strData; } return data; @@ -1418,7 +1421,7 @@ const char* xvt_treeview_get_node_data(WINDOW win, XVT_TREEVIEW_NODE node) void xvt_treeview_destroy_node(WINDOW win, XVT_TREEVIEW_NODE node) { - if (win != NULL_WIN && node != NULL) + if (win != NULL_WIN && node != nullptr) { CAST_TREEVIEW(win, tv); wxTreeItemId id(node); @@ -1428,19 +1431,19 @@ void xvt_treeview_destroy_node(WINDOW win, XVT_TREEVIEW_NODE node) BOOLEAN xvt_treeview_enable_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN on) { - BOOLEAN ok = (win != NULL_WIN) && (node != NULL); + BOOLEAN ok = (win != NULL_WIN) && (node != nullptr); if (ok) { CAST_TREEVIEW(win, tv); wxTreeItemId id(node); - tv.Enable(id, on != FALSE); + tv.Enable(id, on != false); } return ok; } BOOLEAN xvt_treeview_expand_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN recurse) { - BOOLEAN ok = (win != NULL_WIN) && (node != NULL); + BOOLEAN ok = (win != NULL_WIN) && (node != nullptr); if (ok) { CAST_TREEVIEW(win, tv); @@ -1457,7 +1460,7 @@ BOOLEAN xvt_treeview_expand_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN rec XVT_TREEVIEW_NODE xvt_treeview_get_root_node(WINDOW win) { - XVT_TREEVIEW_NODE pRoot = NULL; + XVT_TREEVIEW_NODE pRoot = nullptr; if (win != NULL_WIN) { CAST_TREEVIEW(win, tv); @@ -1476,7 +1479,7 @@ XVT_TREEVIEW_NODE xvt_treeview_get_selected_node(WINDOW win) SLIST xvt_treeview_get_selected_list(WINDOW win) { - SLIST list = NULL; + SLIST list = nullptr; CAST_TREEVIEW(win, tv); wxArrayTreeItemIds selections; const size_t nSel = tv.GetSelections(selections); @@ -1487,10 +1490,10 @@ SLIST xvt_treeview_get_selected_list(WINDOW win) { const wxTreeItemId& id = selections[i]; const TwxTreeItemData* pData = (const TwxTreeItemData*)tv.GetItemData(id); - if (pData != NULL) - xvt_slist_add_at_elt(list, NULL, pData->m_strData, (long)id.m_pItem); + if (pData != nullptr) + xvt_slist_add_at_elt(list, nullptr, pData->m_strData, (long)id.m_pItem); else - xvt_slist_add_at_elt(list, NULL, "", (long)id.m_pItem); + xvt_slist_add_at_elt(list, nullptr, "", (long)id.m_pItem); } } return list; @@ -1499,7 +1502,7 @@ SLIST xvt_treeview_get_selected_list(WINDOW win) BOOLEAN xvt_treeview_remove_child_node(WINDOW win, XVT_TREEVIEW_NODE node) { - BOOLEAN ok = (win != NULL_WIN) && (node != NULL); + BOOLEAN ok = (win != NULL_WIN) && (node != nullptr); if (ok) { CAST_TREEVIEW(win, tv); @@ -1518,7 +1521,7 @@ BOOLEAN xvt_treeview_remove_child_node(WINDOW win, XVT_TREEVIEW_NODE node) BOOLEAN xvt_treeview_remove_node_children(WINDOW win, XVT_TREEVIEW_NODE node) { - BOOLEAN ok = FALSE; + BOOLEAN ok = false; if (win != NULL_WIN) { CAST_TREEVIEW(win, tv); @@ -1528,7 +1531,7 @@ BOOLEAN xvt_treeview_remove_node_children(WINDOW win, XVT_TREEVIEW_NODE node) id = tv.GetRootItem(); tv.DeleteChildren(id); tv.Resume(); - ok = TRUE; + ok = true; } return ok; } @@ -1541,7 +1544,7 @@ void xvt_treeview_resume(WINDOW win) void xvt_treeview_select_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN sel) { - if (win != NULL_WIN && node != NULL) + if (win != NULL_WIN && node != nullptr) { CAST_TREEVIEW(win, tv); const wxTreeItemId id(node); @@ -1560,7 +1563,7 @@ void xvt_treeview_select_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN sel) void xvt_treeview_set_node_images(WINDOW win, XVT_TREEVIEW_NODE node, XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image) { - if (win != NULL_WIN && node != NULL) + if (win != NULL_WIN && node != nullptr) { CAST_TREEVIEW(win, tv); const wxTreeItemId id(node); @@ -1570,17 +1573,17 @@ void xvt_treeview_set_node_images(WINDOW win, XVT_TREEVIEW_NODE node, XVT_IMAGE void xvt_treeview_set_node_bold(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN bold) { - if (win != NULL_WIN && node != NULL) + if (win != NULL_WIN && node != nullptr) { CAST_TREEVIEW(win, tv); const wxTreeItemId id(node); - tv.SetItemBold(id, bold != FALSE); + tv.SetItemBold(id, bold != false); } } void xvt_treeview_set_node_string(WINDOW win, XVT_TREEVIEW_NODE node, const char* text) { - if (win != NULL_WIN && node != NULL) + if (win != NULL_WIN && node != nullptr) { CAST_TREEVIEW(win, tv); const wxTreeItemId id(node); @@ -1600,7 +1603,7 @@ static XVT_TREEVIEW_NODE FindTreeNodeString(wxTreeCtrl& tv, const wxTreeItemId& if (parent.IsOk()) { TwxTreeItemData* pData = (TwxTreeItemData*)tv.GetItemData(parent); - if (pData != NULL && pData->m_strData == text) + if (pData != nullptr && pData->m_strData == text) return parent.m_pItem; wxTreeItemIdValue cookie; @@ -1608,21 +1611,21 @@ static XVT_TREEVIEW_NODE FindTreeNodeString(wxTreeCtrl& tv, const wxTreeItemId& id = tv.GetNextChild(parent, cookie)) { XVT_TREEVIEW_NODE node = FindTreeNodeString(tv, id, text); - if (node != NULL) + if (node != nullptr) return node; } } - return NULL; + return nullptr; } XVT_TREEVIEW_NODE xvt_treeview_find_node_string(WINDOW win, const char* text) { - XVT_TREEVIEW_NODE node = NULL; + XVT_TREEVIEW_NODE node = nullptr; if (win != NULL_WIN && text && *text) { CAST_TREEVIEW(win, tv); node = FindTreeNodeString(tv, tv.GetSelection(), text); - if (node == NULL) + if (node == nullptr) node = FindTreeNodeString(tv, tv.GetRootItem(), text); } return node; @@ -1805,7 +1808,7 @@ void TwxOutlookBar::OnMouseLeave(wxMouseEvent& WXUNUSED(e)) void TwxOutlookBar::OnSelected(wxCommandEvent& evt) { TwxWindow* win = wxDynamicCast(GetParent(), TwxWindow); - if (win != NULL) + if (win != nullptr) { XVT_EVENT e(E_CONTROL); e.v.ctl.id = evt.GetId(); @@ -1845,7 +1848,7 @@ TwxOutlookBar::~TwxOutlookBar() BOOLEAN xvt_list_add(WINDOW win, int index, const char* text) { wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox); - BOOLEAN ok = lb != NULL; + BOOLEAN ok = lb != nullptr; if (ok) { const wxString str = text; @@ -1863,12 +1866,12 @@ int xvt_list_add_item(WINDOW win, short icon, const char* text, int flags) if (win != NULL_WIN) { TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar); - if (olb != NULL) + if (olb != nullptr) n = olb->Add(icon, text, flags); else { TwxMetroBar* mb = wxDynamicCast((wxObject*)win, TwxMetroBar); - if (mb != NULL) + if (mb != nullptr) n = mb->Add(icon, text, flags); } } @@ -1881,17 +1884,17 @@ BOOLEAN xvt_list_clear(WINDOW win) if (ok) { wxVListBox* olb = wxDynamicCast((wxObject*)win, wxVListBox); - if (olb != NULL) + if (olb != nullptr) olb->Clear(); else { wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox); - if (lb != NULL) + if (lb != nullptr) lb->Clear(); else { TwxMetroBar* mb = wxDynamicCast((wxObject*)win, TwxMetroBar); - if (mb != NULL) + if (mb != nullptr) mb->Clear(); } } @@ -1905,17 +1908,17 @@ int xvt_list_get_sel_index(WINDOW win) if (win != NULL_WIN) { wxVListBox* olb = wxDynamicCast((wxObject*)win, wxVListBox); - if (olb != NULL) + if (olb != nullptr) sel = olb->GetSelection(); else { wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox); - if (lb != NULL) + if (lb != nullptr) sel = lb->GetSelection(); else { TwxMetroBar* mb = wxDynamicCast((wxObject*)win, TwxMetroBar); - if (mb != NULL) + if (mb != nullptr) sel = mb->GetSelection(); } } @@ -1929,7 +1932,7 @@ BOOLEAN xvt_list_set_sel(WINDOW win, int index, BOOLEAN select) if (ok) { wxVListBox* olb = wxDynamicCast((wxObject*)win, wxVListBox); - if (olb != NULL) + if (olb != nullptr) { if (select) olb->SetSelection(index); @@ -1937,12 +1940,12 @@ BOOLEAN xvt_list_set_sel(WINDOW win, int index, BOOLEAN select) else { wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox); - if (lb != NULL) + if (lb != nullptr) lb->SetSelection(index, select != 0); else { TwxMetroBar* mb = wxDynamicCast((wxObject*)win, TwxMetroBar); - if (mb != NULL) + if (mb != nullptr) mb->SetSelection(index, select!=0); } } @@ -1956,17 +1959,17 @@ int xvt_list_count(WINDOW win) if (win != NULL_WIN) { wxVListBox* olb = wxDynamicCast((wxObject*)win, wxVListBox); - if (olb != NULL) + if (olb != nullptr) n = olb->GetItemCount(); else { wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox); - if (lb != NULL) + if (lb != nullptr) n = lb->GetCount(); else { TwxMetroBar* mb = wxDynamicCast((wxObject*)win, TwxMetroBar); - if (mb != NULL) + if (mb != nullptr) mb->GetItemCount(); } @@ -2159,7 +2162,7 @@ void TwxMetroBar::OnMouseDown(wxMouseEvent& e) if (m_nCurr >= 0 && m_nCurr < m_nItems ) { TwxWindow* win = wxDynamicCast(GetParent(), TwxWindow); - if (win != NULL) + if (win != nullptr) { XVT_EVENT e(E_CONTROL); e.v.ctl.id = GetId(); @@ -2271,7 +2274,7 @@ void TwxPopUp::OnKillFocus(wxFocusEvent& WXUNUSED(e)) void TwxPopUp::NotifySelection() { TwxWindow* win = wxDynamicCast(GetParent(), TwxWindow); - if (win != NULL) + if (win != nullptr) { XVT_EVENT e(E_CONTROL); e.v.ctl.id = GetId(); @@ -2350,7 +2353,7 @@ MENU_TAG xvt_list_popup(WINDOW parent_win, const RCT* ownrct, const MENU_ITEM* m { int sel = -1; int items = 0; - if (parent_win != NULL_WIN && ownrct != NULL && menu != NULL) + if (parent_win != NULL_WIN && ownrct != nullptr && menu != nullptr) { wxWindow* parent = wxStaticCast((wxObject*)parent_win, wxWindow); int width = ownrct->right - ownrct->left; @@ -2400,7 +2403,7 @@ MENU_TAG xvt_list_popup(WINDOW parent_win, const RCT* ownrct, const MENU_ITEM* m WINDOW win = xvt_ctl_create_def(&wd, parent_win, 0); TwxPopUp* lb = wxDynamicCast((wxObject*)win, TwxPopUp); - if (lb != NULL) + if (lb != nullptr) { for (int i = 0; menu[i].tag != 0; i++) { @@ -2447,12 +2450,41 @@ MENU_TAG xvt_list_popup(WINDOW parent_win, const RCT* ownrct, const MENU_ITEM* m #define TwxToolBarBase wxToolBar #endif +class wxToolObject : public wxObject +{ + wxToolBarToolBase * _tool; + +public: + wxToolBarToolBase * tool() const { return _tool; } + + wxToolObject(wxToolBarToolBase * tool) : _tool(tool) {} +}; + +class wxToolData : public wxObject +{ + short _pos; + int _ico; + +public: + short pos() const { return _pos; } + int ico() const { return _ico; } + + void set_pos(short pos) { _pos = pos; } + + wxToolData(int ico, short pos = -1) : _pos(pos), _ico(ico) {} +}; + +WX_DECLARE_OBJARRAY(wxToolObject, wxToolArray); +#include +WX_DEFINE_OBJARRAY(wxToolArray); + class TwxToolBar : public TwxToolBarBase { DECLARE_DYNAMIC_CLASS(TwxToolBar) wxBitmap m_texture; bool m_bMetroStyle; - + wxToolArray _hidden_tool; + protected: DECLARE_EVENT_TABLE() void OnTool(wxCommandEvent& evt); @@ -2460,13 +2492,15 @@ protected: virtual bool SetBackgroundColour(const wxColour& colour); virtual bool SetForegroundColour(const wxColour& colour); - TwxToolBar() : TwxToolBarBase(NULL, wxID_ANY) { wxASSERT(false); } + TwxToolBar() : TwxToolBarBase(nullptr, wxID_ANY) { wxASSERT(false); } public: void ShowTool(int id, bool on); void SetBackgroundTexture(XVT_IMAGE img); void SetMetroStyle(bool ms); + wxToolArray & hidden() { return _hidden_tool; } + TwxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style); }; @@ -2534,7 +2568,7 @@ bool TwxToolBar::SetBackgroundColour(const wxColour& colour) if (ok) // Se cambio lo sfondo della toolbar devo aggiornare anche quello del gripper { wxAuiDockArt* pArtist = FindArtist(this); - if (pArtist != NULL) + if (pArtist != nullptr) pArtist->SetColor(wxAUI_DOCKART_GRIPPER_COLOUR, colour); } return ok; @@ -2546,7 +2580,7 @@ bool TwxToolBar::SetForegroundColour(const wxColour& colour) if (ok) // Se cambio lo sfondo della toolbar devo aggiornare anche quello del gripper { wxAuiDockArt* pArtist = FindArtist(this); - if (pArtist != NULL) + if (pArtist != nullptr) pArtist->SetColor(wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR, colour); } return ok; @@ -2554,7 +2588,7 @@ bool TwxToolBar::SetForegroundColour(const wxColour& colour) void TwxToolBar::SetBackgroundTexture(XVT_IMAGE xvt_img) { - if (xvt_img != NULL) + if (xvt_img != nullptr) { const wxImage& img = *(wxImage*)xvt_img; wxColour mean, dark, light; @@ -2584,9 +2618,9 @@ static TwxToolBar* Win2Bar(WINDOW win) BOOLEAN xvt_toolbar_add_control(WINDOW win, int cid, TOOL_TYPE type, const char *title, int ico, int WXUNUSED(cust_width), int idx) { - BOOLEAN ok = FALSE; + BOOLEAN ok = false; TwxToolBar* ptb = Win2Bar(win); - if (ptb != NULL) + if (ptb != nullptr) { TwxToolBar& tb = *ptb; switch (type) @@ -2597,55 +2631,62 @@ BOOLEAN xvt_toolbar_add_control(WINDOW win, int cid, TOOL_TYPE type, const char ok = idx < 0; #else if (idx < 0) - ok = tb.AddSeparator() != NULL; + ok = tb.AddSeparator() != nullptr; else - ok = tb.InsertSeparator(idx) != NULL; + ok = tb.InsertSeparator(idx) != nullptr; #endif break; default: + { + const wxBitmap bmp = xvtart_GetToolResource(ico, tb.GetToolBitmapSize().y); + wxString cap, tip; + wxChar acc = 0; + for (const char* t = title; *t; t++) { - const wxBitmap bmp = xvtart_GetToolResource(ico, tb.GetToolBitmapSize().y); - wxString cap, tip; - wxChar acc = 0; - for (const char* t = title; *t; t++) + if (*t == '~' || *t == '&') { - if (*t == '~' || *t == '&') - { - cap << '&'; - acc = toupper(*(t+1)); - } - else - { - cap << *t; - tip << *t; - } - } - if (acc > '\0') - { - if (acc >= 'A' && acc <= 'Z') - tip << "\n(Alt+" << acc << ")"; + cap << '&'; + acc = toupper(*(t + 1)); } else { - switch (ico) // Gestione bottoni speciali - { - case 102: tip << "\n(Esc)"; break; - case 114: tip << "\n(Alt+F4)"; break; - case 162: tip << "\n(F2)"; break; - case 163: tip << "\n(F1)"; break; - default: break; - } + cap << *t; + tip << *t; } + } + if (acc > '\0') + { + if (acc >= 'A' && acc <= 'Z') + tip << "\n(Alt+" << acc << ")"; + } + else + { + switch (ico) // Gestione bottoni speciali + { + case 102: tip << "\n(Esc)"; break; + case 114: tip << "\n(Alt+F4)"; break; + case 162: tip << "\n(F2)"; break; + case 163: tip << "\n(F1)"; break; + default: break; + } + } + + wxToolData *data = new wxToolData(ico); #ifdef wxAuiToolBar - tb.AddTool(cid, cap, bmp, wxNullBitmap, wxItemKind(type), tip, tip, NULL); - ok = idx < 0; + tb.AddTool(cid, cap, bmp, wxNullBitmap, wxItemKind(type), tip, tip, data); + ok = idx < 0; + idx = tb.GetToolPos(cid); #else - if (idx < 0) - ok = tb.AddTool(cid, cap, bmp, wxNullBitmap, wxItemKind(type), tip) != NULL; - else - ok = tb.InsertTool(idx, cid, cap, bmp, wxNullBitmap, wxItemKind(type), tip) != NULL; + if (idx < 0) + { + ok = tb.AddTool(cid, cap, bmp, wxNullBitmap, wxItemKind(type), tip, wxEmptyString, data) != nullptr; + idx = tb.GetToolPos(cid); + } + else + ok = tb.InsertTool(idx, cid, cap, bmp, wxNullBitmap, wxItemKind(type), tip, wxEmptyString, data) != nullptr; #endif + data->set_pos(idx); } break; } @@ -2705,15 +2746,15 @@ WINDOW xvt_toolbar_create(int cid, int left, int top, int right, int bottom, lon void xvt_toolbar_enable_control(WINDOW win, int cid, BOOLEAN on) { TwxToolBar* ptb = Win2Bar(win); - if (ptb != NULL && cid > 0) + if (ptb != nullptr && cid > 0) ptb->EnableTool(cid, on != 0); } BOOLEAN xvt_toolbar_set_last_tool(WINDOW win, int id) { - BOOLEAN bMoved = FALSE; + BOOLEAN bMoved = false; TwxToolBar* ptb = Win2Bar(win); - if (ptb != NULL) // Is a valid toolbar? + if (ptb != nullptr) // Is a valid toolbar? { const int pos = ptb->GetToolPos(id); if (pos >= 0) @@ -2727,7 +2768,7 @@ BOOLEAN xvt_toolbar_set_last_tool(WINDOW win, int id) wxToolBarToolBase* tool = ptb->RemoveTool(id); ptb->InsertTool(nCount-1, tool); } - bMoved = TRUE; + bMoved = true; #endif } } @@ -2737,11 +2778,11 @@ BOOLEAN xvt_toolbar_set_last_tool(WINDOW win, int id) void xvt_toolbar_realize(WINDOW win) { TwxToolBar* ptb = Win2Bar(win); - if (ptb != NULL) // Is a valid toolbar? + if (ptb != nullptr) // Is a valid toolbar? { ptb->Realize(); // Update tools wxAuiPaneInfo* pi = LockPane(win); - if (pi != NULL) + if (pi != nullptr) { const wxSize szBar = ptb->GetSize(); if (pi->min_size.x < szBar.x || pi->min_size.y < szBar.y) @@ -2754,7 +2795,7 @@ void xvt_toolbar_realize(WINDOW win) // Iucunde repetita juvant: forzo il colore del gripper che viene spesso dimenticato wxAuiDockArt* pArtist = FindArtist(ptb); - if (pArtist != NULL) + if (pArtist != nullptr) pArtist->SetColor(wxAUI_DOCKART_GRIPPER_COLOUR, ptb->GetBackgroundColour()); } } @@ -2763,30 +2804,72 @@ void xvt_toolbar_show_control(WINDOW win, int cid, BOOLEAN on) { if (win != NULL_WIN && cid > 0) { - wxASSERT(on);// Per ora non so come si faccia - /* TwxToolBar* ptb = Win2Bar(win); - if (ptb != NULL && cid > 0) + + if (ptb != nullptr && cid > 0) { - // ???? + const int items = ptb->hidden().GetCount(); + bool found = false; + int i; + + for (i = 0; !found && i < items; i++) + { + wxToolObject & obj = (wxToolObject &) ptb->hidden().Item(i); + wxToolBarToolBase * tool = obj.tool(); + + if (tool->GetId() == cid) + { + found = true; + break; + } + } + if (on) + { + if (found) + { + wxToolObject & obj = (wxToolObject &)ptb->hidden().Item(i); + wxToolBarToolBase * tool = obj.tool(); + wxToolData & data = (wxToolData &)*tool->GetClientData(); + const short pos = data.pos(); + + xvt_toolbar_add_control(win, cid, (TOOL_TYPE) tool->GetKind(), tool->GetLabel(), + data.ico(), -1, pos); + ptb->hidden().RemoveAt(i); + delete tool; + } + } + else + { + const short pos = ptb->GetToolPos(cid); + + if (pos >= 0) + { + wxToolBarToolBase* tool = ptb->RemoveTool(cid); + + if (tool != nullptr) + ptb->hidden().Add((_wxObjArraywxToolArray *) new wxToolObject(tool)); + } + } } - */ } } BOOLEAN xvt_toolbar_remove_control(WINDOW win, int cid) { - BOOLEAN ok = FALSE; + BOOLEAN ok = false; TwxToolBar* ptb = Win2Bar(win); - if (ptb != NULL) + + if (ptb != nullptr) { TwxToolBar& tb = *ptb; + #ifdef wxAuiToolBar - tb.AddSeparator(); - ok = idx < 0; + tb.AddSeparator(); + ok = idx < 0; #else wxToolBarToolBase* tool = tb.RemoveTool(cid); - ok = tool != NULL; + + ok = tool != nullptr; if (ok) delete tool; #endif } @@ -2807,7 +2890,7 @@ void xvt_dwin_draw_tool(WINDOW win, int x, int y, int rid, int size) void xvt_ctl_set_texture(WINDOW win, XVT_IMAGE xvt_img) { TwxToolBar* w = wxDynamicCast((wxObject*)win, TwxToolBar); - if (w != NULL) + if (w != nullptr) w->SetBackgroundTexture(xvt_img); } @@ -2843,11 +2926,11 @@ void TwxPropertyGrid::SetColors(const XVT_COLOR_COMPONENT* colors) void TwxPropertyGrid::OnPropertyChanged(wxPropertyGridEvent& evt) { TwxWindow* win = wxDynamicCast(GetParent(), TwxWindow); - if (win != NULL && !IsFrozen()) + if (win != nullptr && !IsFrozen()) { XVT_EVENT e(E_CONTROL); e.v.ctl.id = evt.GetId(); - e.v.ctl.ci.v.treeview.sgl_click = TRUE; + e.v.ctl.ci.v.treeview.sgl_click = true; e.v.ctl.ci.v.treeview.node = evt.GetProperty(); e.v.ctl.ci.type = WC_PROPGRID; e.v.ctl.ci.win = WINDOW(this); @@ -2862,7 +2945,7 @@ TwxPropertyGrid::TwxPropertyGrid(wxWindow* parent, wxWindowID id, const wxPoint& static BOOLEAN xvt_prop_freeze(WINDOW win, BOOLEAN on) { wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - const BOOLEAN ok = pg != NULL && on != BOOLEAN(pg->IsFrozen()); + const BOOLEAN ok = pg != nullptr && on != BOOLEAN(pg->IsFrozen()); if (ok) { if (on) @@ -2877,10 +2960,10 @@ static BOOLEAN xvt_prop_freeze(WINDOW win, BOOLEAN on) } BOOLEAN xvt_prop_restart(WINDOW win) -{ return xvt_prop_freeze(win, FALSE); } +{ return xvt_prop_freeze(win, false); } BOOLEAN xvt_prop_suspend(WINDOW win) -{ return xvt_prop_freeze(win, TRUE); } +{ return xvt_prop_freeze(win, true); } static wxColour STR2COLOUR(const char* value) { @@ -2911,10 +2994,10 @@ static wxColour STR2COLOUR(const char* value) BOOLEAN xvt_prop_set_data(WINDOW win, XVT_TREEVIEW_NODE node, const char* value) { wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) { wxPGProperty* pgp = wxDynamicCast((wxObject*)node, wxPGProperty); - if (pgp != NULL) + if (pgp != nullptr) { const wxString strType = pgp->GetType(); if (strType == "wxColour") @@ -2928,23 +3011,25 @@ BOOLEAN xvt_prop_set_data(WINDOW win, XVT_TREEVIEW_NODE node, const char* value) if (strType == "long" || strType == "int") pgp->SetValue(atol(value)); else if (strType == "bool") - pgp->SetValue(*value > '0' && strchr("1TXY", *value) != NULL); + pgp->SetValue(*value > '0' && strchr("1TXY", *value) != nullptr); else pgp->SetValue(value); } - return TRUE; + return true; } } - return FALSE; + return false; } XVT_TREEVIEW_NODE xvt_prop_add(WINDOW win, const char* type, const char* name, const char* value, const char* label) { wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + + if (pg != nullptr) { wxPGProperty* pgp = pg->GetPropertyByName(name); - if (pgp == NULL) + + if (pgp == nullptr) { const wxString strLabel = (label && *label) ? label : name; if (type && *type > ' ') @@ -2952,7 +3037,7 @@ XVT_TREEVIEW_NODE xvt_prop_add(WINDOW win, const char* type, const char* name, c switch (toupper(*type)) { case 'B': - pgp = new wxBoolProperty(strLabel, name, *value > '0' && strchr("1TXY", *value) != NULL); + pgp = new wxBoolProperty(strLabel, name, *value > '0' && strchr("1TXY", *value) != nullptr); pgp->SetAttribute(wxString("UseCheckbox"), true); break; case 'C': @@ -2975,23 +3060,23 @@ XVT_TREEVIEW_NODE xvt_prop_add(WINDOW win, const char* type, const char* name, c xvt_prop_set_data(win, pgp, value); return pgp; } - return NULL; + return nullptr; } XVT_TREEVIEW_NODE xvt_prop_current(WINDOW win) { - XVT_TREEVIEW_NODE node = NULL; + XVT_TREEVIEW_NODE node = nullptr; wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) node = pg->GetSelection(); return node; } XVT_TREEVIEW_NODE xvt_prop_find(WINDOW win, const char* name) { - XVT_TREEVIEW_NODE node = NULL; + XVT_TREEVIEW_NODE node = nullptr; wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) node = pg->GetPropertyByName(name); return node; } @@ -2999,33 +3084,33 @@ XVT_TREEVIEW_NODE xvt_prop_find(WINDOW win, const char* name) void xvt_prop_fit_columns(WINDOW win) { wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) pg->FitColumns(); } BOOLEAN xvt_prop_remove(WINDOW win, XVT_TREEVIEW_NODE node) { wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) { wxPGProperty* pgp = wxDynamicCast((wxObject*)node, wxPGProperty); - if (pgp != NULL) + if (pgp != nullptr) { pg->DeleteProperty(pgp->GetId()); - return TRUE; + return true; } } - return FALSE; + return false; } int xvt_prop_get_string(WINDOW win, XVT_TREEVIEW_NODE node, char* label, int maxlen) { int len = -1; wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) { const wxPGProperty* pgp = wxDynamicCast((wxObject*)node, wxPGProperty); - if (pgp != NULL) + if (pgp != nullptr) { const wxString& str = pgp->GetLabel(); if (label && maxlen > 0) @@ -3043,10 +3128,10 @@ int xvt_prop_get_type(WINDOW win, XVT_TREEVIEW_NODE node, char* type, int maxlen { int len = 0; wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) { const wxPGProperty* pgp = wxDynamicCast((wxObject*)node, wxPGProperty); - if (pgp != NULL) + if (pgp != nullptr) { wxString strType = pgp->GetType(); if (strType == "wxColour") @@ -3062,10 +3147,10 @@ int xvt_prop_get_data(WINDOW win, XVT_TREEVIEW_NODE node, char* value, int maxle { int len = -1; wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) { const wxPGProperty* pgp = wxDynamicCast((wxObject*)node, wxPGProperty); - if (pgp != NULL) + if (pgp != nullptr) { wxString str = pgp->GetValueAsString(); wxString strType = pgp->GetType(); @@ -3077,7 +3162,7 @@ int xvt_prop_get_data(WINDOW win, XVT_TREEVIEW_NODE node, char* value, int maxle str.Remove(0, 1); // Toglie la ( } len = str.Len(); - if (value != NULL && maxlen > 0) + if (value != nullptr && maxlen > 0) { wxStrncpy(value, str, maxlen); value[maxlen-1] = '\0'; @@ -3089,7 +3174,7 @@ int xvt_prop_get_data(WINDOW win, XVT_TREEVIEW_NODE node, char* value, int maxle static BOOLEAN xvt_for_each_property(WINDOW pg, const wxPGProperty* prop, PROP_CALLBACK pcb, void* jolly) { - BOOLEAN ok = prop != NULL && pcb != NULL; + BOOLEAN ok = prop != nullptr && pcb != nullptr; if (ok && !prop->IsRoot()) ok = pcb(pg, (XVT_TREEVIEW_NODE)prop, jolly); if (ok) @@ -3103,9 +3188,9 @@ static BOOLEAN xvt_for_each_property(WINDOW pg, const wxPGProperty* prop, PROP_C BOOLEAN xvt_prop_for_each(WINDOW win, PROP_CALLBACK pcb, void* jolly) { - BOOLEAN ok = FALSE; + BOOLEAN ok = false; wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) ok = xvt_for_each_property(win, pg->GetRoot(), pcb, jolly); return ok; } @@ -3113,14 +3198,14 @@ BOOLEAN xvt_prop_for_each(WINDOW win, PROP_CALLBACK pcb, void* jolly) BOOLEAN xvt_prop_set_read_only(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN ro) { wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) { wxPGProperty* pgp = wxDynamicCast((wxObject*)node, wxPGProperty); - if (pgp == NULL) + if (pgp == nullptr) pgp = pg->GetRoot(); pgp->SetFlagRecursively(wxPG_PROP_DISABLED, ro != 0); } - return pg != NULL; + return pg != nullptr; } /////////////////////////////////////////////////////////// @@ -3137,14 +3222,14 @@ END_EVENT_TABLE(); int TwxTreeListCtrl::img2int(XVT_IMAGE xvt_img) { int i = -1; - if (xvt_img != NULL) + if (xvt_img != nullptr) { i = m_img[xvt_img] - 1; // Ho memorizzato indice+1 if (i < 0) // Immagine sconosciuta { const wxImage& img = *(wxImage*)xvt_img; wxImageList* il = GetImageList(); - if (il == NULL) // Lista non ancora creata + if (il == nullptr) // Lista non ancora creata { il = new wxImageList; il->Create(img.GetWidth(), img.GetHeight(), true, 3); @@ -3201,9 +3286,9 @@ void TwxTreeListCtrl::OnExpanding(wxTreeEvent& evt) e.v.ctl.ci.type = WC_TREELIST; e.v.ctl.ci.win = WINDOW(this); e.v.ctl.ci.v.treeview.node = id.m_pItem; - e.v.ctl.ci.v.treeview.expanded = TRUE; + e.v.ctl.ci.v.treeview.expanded = true; if (GetChildrenCount(id) == 0) // Trucco perfido ... - e.v.ctl.ci.v.treeview.collapsed = TRUE; // ... stato indeterminato = EXPANDING + e.v.ctl.ci.v.treeview.collapsed = true; // ... stato indeterminato = EXPANDING TwxWindow* win = wxStaticCast(GetParent(), TwxWindow); win->DoXvtEvent(e); if (GetChildrenCount(id) == 0) // Allora e' proprio vero ... @@ -3226,7 +3311,7 @@ void TwxTreeListCtrl::OnSelChanged(wxTreeEvent& evt) e.v.ctl.ci.type = WC_TREELIST; e.v.ctl.ci.win = WINDOW(this); e.v.ctl.ci.v.treeview.node = evt.GetItem().m_pItem; - e.v.ctl.ci.v.treeview.sgl_click = TRUE; + e.v.ctl.ci.v.treeview.sgl_click = true; TwxWindow* win = wxStaticCast(GetParent(), TwxWindow); win->DoXvtEvent(e); Resume(); @@ -3329,7 +3414,7 @@ XVT_TREEVIEW_NODE xvt_treelist_add_child_node(WINDOW win, XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image, const char* string, XVT_TREEVIEW_CALLBACK WXUNUSED(callback), const char* data) { - XVT_TREEVIEW_NODE node = NULL; + XVT_TREEVIEW_NODE node = nullptr; if (win != NULL_WIN) { CAST_TREELIST(win, tv); @@ -3360,7 +3445,7 @@ XVT_TREEVIEW_NODE xvt_treelist_add_child_node(WINDOW win, XVT_TREEVIEW_NODE xvt_treelist_get_child_node(WINDOW win, XVT_TREEVIEW_NODE parent_node, int position) { - XVT_TREEVIEW_NODE child_node = NULL; + XVT_TREEVIEW_NODE child_node = nullptr; if (win != NULL_WIN && position >= 0) { CAST_TREELIST(win, tv); @@ -3383,13 +3468,13 @@ XVT_TREEVIEW_NODE xvt_treelist_get_child_node(WINDOW win, XVT_TREEVIEW_NODE pare const char* xvt_treelist_get_node_data(WINDOW win, XVT_TREEVIEW_NODE node) { - const char* data = NULL; - if (win != NULL_WIN && node != NULL) + const char* data = nullptr; + if (win != NULL_WIN && node != nullptr) { CAST_TREELIST(win, tv); const wxTreeItemId id(node); TwxTreeItemData* pData = (TwxTreeItemData*)tv.GetItemData(id); - if (pData != NULL) + if (pData != nullptr) data = (const char*)pData->m_strData; } return data; @@ -3397,7 +3482,7 @@ const char* xvt_treelist_get_node_data(WINDOW win, XVT_TREEVIEW_NODE node) void xvt_treelist_destroy_node(WINDOW win, XVT_TREEVIEW_NODE node) { - if (win != NULL_WIN && node != NULL) + if (win != NULL_WIN && node != nullptr) { CAST_TREELIST(win, tv); wxTreeItemId id(node); @@ -3407,19 +3492,19 @@ void xvt_treelist_destroy_node(WINDOW win, XVT_TREEVIEW_NODE node) BOOLEAN xvt_treelist_enable_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN on) { - BOOLEAN ok = (win != NULL_WIN) && (node != NULL); + BOOLEAN ok = (win != NULL_WIN) && (node != nullptr); if (ok) { CAST_TREELIST(win, tv); wxTreeItemId id(node); - tv.Enable(id, on != FALSE); + tv.Enable(id, on != false); } return ok; } BOOLEAN xvt_treelist_expand_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN recurse) { - BOOLEAN ok = (win != NULL_WIN) && (node != NULL); + BOOLEAN ok = (win != NULL_WIN) && (node != nullptr); if (ok) { CAST_TREELIST(win, tv); @@ -3436,7 +3521,7 @@ BOOLEAN xvt_treelist_expand_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN rec XVT_TREEVIEW_NODE xvt_treelist_get_root_node(WINDOW win) { - XVT_TREEVIEW_NODE pRoot = NULL; + XVT_TREEVIEW_NODE pRoot = nullptr; if (win != NULL_WIN) { CAST_TREELIST(win, tv); @@ -3455,7 +3540,7 @@ XVT_TREEVIEW_NODE xvt_treelist_get_selected_node(WINDOW win) SLIST xvt_treelist_get_selected_list(WINDOW win) { - SLIST list = NULL; + SLIST list = nullptr; CAST_TREELIST(win, tv); wxArrayTreeItemIds selections; const size_t nSel = tv.GetSelections(selections); @@ -3466,10 +3551,10 @@ SLIST xvt_treelist_get_selected_list(WINDOW win) { const wxTreeItemId& id = selections[i]; const TwxTreeItemData* pData = (const TwxTreeItemData*)tv.GetItemData(id); - if (pData != NULL) - xvt_slist_add_at_elt(list, NULL, pData->m_strData, (long)id.m_pItem); + if (pData != nullptr) + xvt_slist_add_at_elt(list, nullptr, pData->m_strData, (long)id.m_pItem); else - xvt_slist_add_at_elt(list, NULL, "", (long)id.m_pItem); + xvt_slist_add_at_elt(list, nullptr, "", (long)id.m_pItem); } } return list; @@ -3478,7 +3563,7 @@ SLIST xvt_treelist_get_selected_list(WINDOW win) BOOLEAN xvt_treelist_remove_child_node(WINDOW win, XVT_TREEVIEW_NODE node) { - BOOLEAN ok = (win != NULL_WIN) && (node != NULL); + BOOLEAN ok = (win != NULL_WIN) && (node != nullptr); if (ok) { CAST_TREELIST(win, tv); @@ -3497,7 +3582,7 @@ BOOLEAN xvt_treelist_remove_child_node(WINDOW win, XVT_TREEVIEW_NODE node) BOOLEAN xvt_treelist_remove_node_children(WINDOW win, XVT_TREEVIEW_NODE node) { - BOOLEAN ok = FALSE; + BOOLEAN ok = false; if (win != NULL_WIN) { CAST_TREELIST(win, tv); @@ -3507,7 +3592,7 @@ BOOLEAN xvt_treelist_remove_node_children(WINDOW win, XVT_TREEVIEW_NODE node) id = tv.GetRootItem(); tv.DeleteChildren(id); tv.Resume(); - ok = TRUE; + ok = true; } return ok; } @@ -3520,7 +3605,7 @@ void xvt_treelist_resume(WINDOW win) void xvt_treelist_select_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN sel) { - if (win != NULL_WIN && node != NULL) + if (win != NULL_WIN && node != nullptr) { CAST_TREELIST(win, tv); const wxTreeItemId id(node); @@ -3539,7 +3624,7 @@ void xvt_treelist_select_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN sel) void xvt_treelist_set_node_images(WINDOW win, XVT_TREEVIEW_NODE node, XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image) { - if (win != NULL_WIN && node != NULL) + if (win != NULL_WIN && node != nullptr) { CAST_TREELIST(win, tv); const wxTreeItemId id(node); @@ -3554,7 +3639,7 @@ void xvt_treelist_set_node_string(WINDOW win, XVT_TREEVIEW_NODE node, const char CAST_TREELIST(win, tv); const int cc = tv.GetColumnCount(); wxStringTokenizer tok(text, "\t", wxTOKEN_RET_EMPTY); - if (node != NULL) + if (node != nullptr) { const wxTreeItemId id(node); for (int c = 0; c < cc && tok.HasMoreTokens(); c++) @@ -3598,11 +3683,11 @@ void xvt_treelist_suspend(WINDOW win) void xvt_treelist_set_node_bold(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN bold) { - if (win != NULL_WIN && node != NULL) + if (win != NULL_WIN && node != nullptr) { CAST_TREELIST(win, tv); const wxTreeItemId id(node); - tv.SetItemBold(id, bold != FALSE); + tv.SetItemBold(id, bold != false); } } @@ -3611,7 +3696,7 @@ static XVT_TREEVIEW_NODE FindTreeListNodeString(wxTreeListCtrl& tv, const wxTree if (parent.IsOk()) { TwxTreeItemData* pData = (TwxTreeItemData*)tv.GetItemData(parent); - if (pData != NULL && pData->m_strData == text) + if (pData != nullptr && pData->m_strData == text) return parent.m_pItem; wxTreeItemIdValue cookie; @@ -3619,7 +3704,7 @@ static XVT_TREEVIEW_NODE FindTreeListNodeString(wxTreeListCtrl& tv, const wxTree id = tv.GetNextChild(parent, cookie)) { XVT_TREEVIEW_NODE node = FindTreeListNodeString(tv, id, text); - if (node != NULL) + if (node != nullptr) return node; } } @@ -3628,12 +3713,12 @@ static XVT_TREEVIEW_NODE FindTreeListNodeString(wxTreeListCtrl& tv, const wxTree XVT_TREEVIEW_NODE xvt_treelist_find_node_string(WINDOW win, const char* text) { - XVT_TREEVIEW_NODE node = NULL; + XVT_TREEVIEW_NODE node = nullptr; if (win != NULL_WIN && text && *text) { CAST_TREELIST(win, tv); node = FindTreeListNodeString(tv, tv.GetSelection(), text); - if (node == NULL) + if (node == nullptr) node = FindTreeListNodeString(tv, tv.GetRootItem(), text); } return node; @@ -3641,8 +3726,8 @@ XVT_TREEVIEW_NODE xvt_treelist_find_node_string(WINDOW win, const char* text) BOOLEAN xvt_html_set_url(WINDOW win, const char* url) { - BOOLEAN done = FALSE; - wxHtmlWindow* w = win ? wxDynamicCast((wxObject*)win, wxHtmlWindow) : NULL; + BOOLEAN done = false; + wxHtmlWindow* w = win ? wxDynamicCast((wxObject*)win, wxHtmlWindow) : nullptr; if (w) { const wxString strLocation = url; @@ -3670,11 +3755,11 @@ WIN_TYPE xvt_vobj_get_type(WINDOW win) return W_PRINT; const TwxWindow* w = wxDynamicCast((wxObject*)win, TwxWindow); - if (w != NULL) + if (w != nullptr) return w->_type; const wxControl* ctl = wxDynamicCast((wxObject*)win, wxControl); - if (ctl != NULL) + if (ctl != nullptr) { if (ctl->IsKindOf(CLASSINFO(wxHtmlWindow))) return WC_HTML; if (ctl->IsKindOf(CLASSINFO(wxTreeCtrl))) return WC_TREE; @@ -3685,10 +3770,10 @@ WIN_TYPE xvt_vobj_get_type(WINDOW win) { // ... non deriva da wxControl :-) const wxPropertyGrid* pg = wxDynamicCast((wxObject*)win, wxPropertyGrid); - if (pg != NULL) + if (pg != nullptr) return WC_PROPGRID; const TwxMetroBar* mb = wxDynamicCast((wxObject*)win, TwxMetroBar); - if (mb != NULL) + if (mb != nullptr) return WC_METROBAR; } diff --git a/src/xvaga/xvtmail.cpp b/src/xvaga/xvtmail.cpp index f8e5a27b7..ca5570b58 100755 --- a/src/xvaga/xvtmail.cpp +++ b/src/xvaga/xvtmail.cpp @@ -119,8 +119,7 @@ BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn, wxStringTokenizer tokTo(to, _T(";")); wxMailMessage Msg(subject, tokTo.GetNextToken(), msg); - if (flags & 0x2) - Msg.m_query_receipt = true; + Msg.m_query_receipt = flags & 0x2; while (tokTo.HasMoreTokens()) Msg.AddTo(tokTo.GetNextToken()); @@ -167,7 +166,7 @@ BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn, } AppendQuotedString(cmd, "from", from); - if ((flags | 0x2) && from.Find("@") > 0) + if ((flags & 0x2) && from.Find("@") > 0) { //AppendQuotedString(cmd, "rt", from); AppendQuotedString(cmd, "rrr", from); @@ -186,7 +185,7 @@ BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn, // Lista dei destinatari in copia nascosta for (size_t i = 0; i < Msg.m_bcc.size(); i++) AppendQuotedString(cmd, "bc", Msg.m_bcc[i]); - if (from.Find("@") > 0) + if ((flags & 0x4) && from.Find("@") > 0) { wxString strMyself; strMyself << "c " << from; if (cmd.Find(strMyself) < 0) @@ -282,7 +281,6 @@ BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn, ok = Msg.Send(wxEmptyString, ui); xvt_fsys_restore_dir(); } - return ok; } @@ -316,7 +314,7 @@ BOOLEAN xvt_powermail_send(const char* to, const char* cc, const char* ccn, */ wxStringTokenizer portTok(port, " "); wxString port_number; - bool ssl = false, bcc = true; + bool ssl = false, hasccn = ccn && *ccn, hascc = cc && *cc; while(portTok.HasMoreTokens()) { @@ -326,7 +324,7 @@ BOOLEAN xvt_powermail_send(const char* to, const char* cc, const char* ccn, if (tok.Upper() == "-SSL") ssl = true; if (tok.Upper() == "-NBCC") - bcc = false; + hasccn = false; } // Hard code and no play makes Tolla a dull programmer @@ -347,19 +345,32 @@ BOOLEAN xvt_powermail_send(const char* to, const char* cc, const char* ccn, file.Write("$To = \""); file.Write(to); file.Write("\";\n"); file.Write("$Subject = \""); file.Write(subject); file.Write("\";\n"); file.Write("$Body = \""); file.Write(msg); file.Write("\";\n"); + if (hascc) + { + file.Write("$CC = \""); file.Write(cc); file.Write("\";\n"); + } + if (hasccn) + { + file.Write("$Bcc = \""); file.Write(ccn); file.Write("\";\n"); + } file.Write( "$message = new-object Net.Mail.MailMessage;\n" "$message.From = $From\n" "$message.To.Add($To);\n"); - if (bcc) - file.Write("$message.Bcc.Add($From);\n"); + if (hascc == true) + file.Write("$message.CC.Add($CC);\n"); + if (hasccn == true) + file.Write("$message.Bcc.Add($Bcc);\n"); file.Write( "$message.Subject = $Subject;\n" "$message.Body = $Body;\n" ); + if (flags & 0x2) + file.Write("$message.DeliveryNotificationOptions = 1;\n"); + // Aggiungo a schiena gli allegati if (attach && *attach) { @@ -396,7 +407,7 @@ BOOLEAN xvt_powermail_send(const char* to, const char* cc, const char* ccn, file.Close(); wxString command; - command << R"(PowerShell -ExecutionPolicy ByPass -NonInteractive -NoProfile -Command "&{)" << powerFile << R"(; exit $LastExitCode }")"; + command << R"(PowerShell -ExecutionPolicy ByPass -NonInteractive -NoProfile -Command "{)" << powerFile << R"(; exit $LastExitCode }")"; BOOLEAN sys_command = (BOOLEAN)system(command); if (!sys_command)