Patch level : aga 2.0 patch 335

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Riportata la versione Partners 2.0 patch 335


git-svn-id: svn://10.65.10.50/trunk@10496 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2002-09-13 14:56:23 +00:00
parent e4c4b79fbe
commit 6e0d5b4275
49 changed files with 1381 additions and 851 deletions

View File

@ -6,6 +6,7 @@
#include <config.h>
#include <controls.h>
#include <currency.h>
#include <diction.h>
#include <dongle.h>
#include <execp.h>
#include <image.h>
@ -358,6 +359,7 @@ TColor_mask::TColor_mask()
TConfig color(CONFIG_USER, "Colors");
_color = color.list_variables();
set(113, color.get_bool("Campi3D") ? "X" : "");
set(115, color.get_bool("SmallIcons") ? "X" : "");
}
PNT TColor_mask::log2dev(long x, long y) const
@ -439,6 +441,7 @@ void TColor_mask::save_colors()
FOR_EACH_ASSOC_STRING(_color, obj, key, str)
colors.set(key, str);
colors.set("Campi3D", get_bool(113) ? "X" : "");
colors.set("SmallIcons", get_bool(115) ? "X" : "");
}
COLOR TColor_mask::get_color_entry(const char* name) const
@ -685,6 +688,7 @@ void TMenuitem::create(const char* t)
start = get_next_string(t, start, _caption, brace);
start = get_next_string(t, start, _action, _type);
start = get_next_string(t, start, flags, brace);
_caption = dictionary_translate(_caption);
for (int i = flags.len()-1; i >= 0; i--)
{
@ -874,7 +878,10 @@ void TSubmenu::read(TScanner& scanner)
char brace;
if (line.compare("Caption", 7, TRUE) == 0)
get_next_string(line, 8, _caption, brace); else
{
get_next_string(line, 8, _caption, brace);
_caption = dictionary_translate(_caption);
} else
if (line.compare("Module", 6, TRUE) == 0)
{
const int equal = line.find('=');
@ -1109,7 +1116,7 @@ TImage& TMenu::image(const char* name)
{
image = (TTimed_image*)_images.objptr(_default_bmp);
if (image == NULL)
fatal_box("Impossibile trovare l'immagine %s", (const char*)_default_bmp);
fatal_box("%s %s", TR("Impossibile trovare l'immagine"), (const char*)_default_bmp);
}
if (_images.items() > 3)
@ -1317,13 +1324,13 @@ int TMenu_application::do_level()
mask.disable(id);
}
TEdit_field& ef = mask.add_string(DLG_USER, 0, "Cerca ", 1, -3, 50, "", 50);
TEdit_field& ef = mask.add_string(DLG_USER, 0, PR("Cerca "), 1, -3, 50, "", 50);
ef.set_handler(menu_find_handler);
const bool top = _menu.at_top();
TButton_field& bf = mask.add_button(DLG_QUIT, 0, "Fine", -12, -1, bwidth, 2);
TButton_field& bf = mask.add_button(DLG_QUIT, 0, TR("Fine"), -12, -1, bwidth, 2);
if (!top)
mask.add_button(DLG_CANCEL, 0, "Menu precedente", -22, -1, bwidth, 2);
mask.add_button(DLG_CANCEL, 0, TR("Menu precedente"), -22, -1, bwidth, 2);
mask.first_focus(101+_menu.selected());
@ -1360,10 +1367,9 @@ void TMenu_application::test_temp()
TString_array files;
const int count = list_files(dir, files);
if (count > 0 && yesno_box("Cancellare %d file temporane%c in %s?",
count, (count > 1) ? 'i' : 'o', dir.path()))
if (count > 0 && yesno_box(TR("Cancellare tutti i file temporanei in %s?"), dir.path()))
{
TProgind bar(count, "Cancellazione file temporanei", TRUE, TRUE);
TProgind bar(count, TR("Cancellazione file temporanei"), TRUE, TRUE);
for (int i = count-1; i >= 0; i--)
{
if (bar.iscancelled()) break;
@ -1475,8 +1481,9 @@ bool TMenu_application::check_user()
ok = !users.get_bool("CONNECTED");
if (!ok)
{
ok = yesno_box("L'utente %s risulta essere gia' collegato\n"
"Si desidera continuare ugualmente?", (const char*)utente);
ok = yesno_box("%s\n%s",
TR("L'utente risulta essere già collegato"),
TR("Si desidera continuare ugualmente?"));
}
if (ok)
@ -1485,15 +1492,15 @@ bool TMenu_application::check_user()
users.read(_isequal);
if (users.get("AUTSTR") == "CONVERTING")
{
TString msg = "E' in corso una conversione archivi:\n";
TString msg; msg << TR("E' in corso una conversione archivi") << ":\n";
if (utente == dongle().administrator())
{
msg << "Si desidera continuare ugualmente?";
msg << TR("Si desidera continuare ugualmente?");
ok = yesno_box(msg);
}
else
{
msg << "Accesso negato.";
msg << TR("Accesso negato.");
ok = error_box(msg);
}
}
@ -1505,12 +1512,12 @@ bool TMenu_application::check_user()
dongle().logout();
ok = get_serial_number() >= 0;
if (!ok)
error_box("Probabilmente e' stato superato il numero massimo di utenti");
error_box(TR("Probabilmente e' stato superato il numero massimo di utenti"));
}
}
else
{
error_box("Utente e/o password errata:\nfare attenzione alle maiuscole");
error_box(TR("Utente e/o password errata: fare attenzione alle maiuscole"));
m.set(F_PASSWORD,"");
}
@ -1602,7 +1609,7 @@ bool TMenu_application::test_programs()
remote_name.add("install.ini");
if (remote_name.exist())
{
TProgind pi(3, "Controllo aggiornamento programmi", FALSE, TRUE);
TProgind pi(3, TR("Controllo aggiornamento programmi"), FALSE, TRUE);
TConfig remote_install(remote_name, "Main");
TAssoc_array my_modules, his_modules;
pi.addstatus(1);
@ -1637,7 +1644,7 @@ bool TMenu_application::test_programs()
if (more)
break;
if (dangerous.empty() ||
(!more && !yesno_box("Si desidera aggiornare i moduli adesso?")))
(!more && !yesno_box(TR("Si desidera aggiornare i moduli adesso?"))))
break;
app.run(FALSE, TRUE, TRUE, TRUE);
more = TRUE; // ricontrolla
@ -1654,12 +1661,12 @@ bool TMenu_application::create()
#ifdef _DEMO_
{
TMask w("ATTENZIONE", 1, 68, 12);
w.add_static(DLG_NULL, 0 ,"@bATTENZIONE" , 30 , 1);
w.add_static(DLG_NULL, 0 ,"Questo programma è in versione dimostrativa." , 1 , 3);
w.add_static(DLG_NULL, 0 ,"Non si possono memorizzare date con mese successivo a Marzo." , 1 , 5);
w.add_static(DLG_NULL, 0 ,"Il programma funziona circa per due ore ogni giorno." , 1 , 7);
w.add_static(DLG_NULL, 0 ,"Il numero di registrazioni è stato limitato ad un migliaio." , 1 , 9);
TMask w(TR("ATTENZIONE"), 1, 68, 12);
w.add_static(DLG_NULL, 0 , PR("@bATTENZIONE") , 30 , 1);
w.add_static(DLG_NULL, 0 , TR("Questo programma è in versione dimostrativa.") , 1 , 3);
w.add_static(DLG_NULL, 0 , TR("Non si possono memorizzare date con mese successivo a Marzo.") , 1 , 5);
w.add_static(DLG_NULL, 0 , TR("Il programma funziona circa per due ore ogni giorno.") , 1 , 7);
w.add_static(DLG_NULL, 0 , TR("Il numero di registrazioni è stato limitato ad un migliaio.") , 1 , 9);
w.add_button(DLG_OK, 0, "", -11, -1, 10, 2);
w.run();
}
@ -1767,7 +1774,7 @@ HIDDEN bool browse_file_handler(TMask_field& f, KEY k)
DIRECTORY dir;
xvt_fsys_get_dir(&dir);
const int err = xvt_dm_post_file_open(&fs, "Selezione programma");
const int err = xvt_dm_post_file_open(&fs, TR("Selezione programma"));
xvt_fsys_set_dir(&dir);
if (err == FL_OK)
{
@ -1861,18 +1868,17 @@ HIDDEN bool study_handler(TMask_field& f, KEY k)
path.add("com");
path.add("dir.gen");
if (!path.exist())
ok = f.error_box("La directory %s non e' uno studio valido!",
(const char*)f.get());
ok = f.error_box("%s %s", (const char*)f.get(), TR("non e' uno studio valido!"));
}
return ok;
}
bool TMenu_application::choose_study()
{
TMask m("Scelta studio", 1, 60, 5);
TMask m(TR("Scelta studio"), 1, 60, 5);
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
m.add_string(DLG_USER, 0, "Studio ", 1, 1, 50);
m.add_string(DLG_USER, 0, PR("Studio "), 1, 1, 50);
m.set_handler(DLG_USER, study_handler);
m.set(DLG_USER, prefix().get_studio());
bool ok = m.run() == K_ENTER;
@ -2381,7 +2387,7 @@ void TMenu_application::add_to_preferred()
}
}
else
error_box("Non e' possibile memorizzare piu' di %d preferenze", maxpref);
error_box(TR("Non e' possibile memorizzare piu' di %d preferenze"), maxpref);
}
class TPreferred_mask : public TAutomask
@ -2498,15 +2504,15 @@ int TMenu_application::do_tree()
tree_fld.set_handler(tree_handler);
RCT rct; tree_fld.get_rect(rct);
TMask_field& sf = mask.add_static(DLG_NULL, 0, "Cerca", -2, 0);
TMask_field& sf = mask.add_static(DLG_NULL, 0, TR("Cerca"), -2, 0);
TEdit_field& ef = mask.add_string(DLG_USER, 0, "", -2, 1, 50, "", bwidth);
ef.set_handler(tree_find_handler);
TButton_field& mf = mask.add_button(102, 0, "Menu principale", -1, 2, bwidth, 2);
TButton_field& mf = mask.add_button(102, 0, TR("Menu Principale"), -1, 2, bwidth, 2);
mf.set_handler(tree_shrink_handler);
TButton_field& bf = mask.add_button(DLG_QUIT, 0, "Fine", -56, -1, bwidth/2, 2);
TButton_field& bf = mask.add_button(DLG_QUIT, 0, TR("Fine"), -56, -1, bwidth/2, 2);
mask.first_focus(101);
KEY key = mask.run();
@ -2583,11 +2589,11 @@ int main(int argc, char** argv)
if (menu.exist())
{
TMenu_application *ma = new TMenu_application(menu);
ma->run(argc, argv, "Menu Principale");
ma->run(argc, argv, TR("Menu Principale"));
delete ma;
}
else
error_box("Non esiste il menu %s", (const char*)menu);
error_box(TR("Non esiste il menu %s"), (const char*)menu);
return 0;
}

View File

@ -1,6 +1,6 @@
#include "ba0100a.h"
PAGE "Selezione utente" -1 -1 30 7
PAGE "Selezione utente" -1 -1 30 6
STRING F_USER 8
BEGIN

View File

@ -87,12 +87,17 @@ END
BOOLEAN 113
BEGIN
PROMPT 2 -1 "Campi 3D"
PROMPT 2 18 "Campi 3D"
END
BOOLEAN 115
BEGIN
PROMPT 2 17 "Icone alternative"
END
BUTTON 114 10 2
BEGIN
PROMPT 19 -1 "Font"
PROMPT 20 -1 "Font"
END
GROUPBOX DLG_NULL 14 8

View File

@ -428,29 +428,6 @@ void TFconv_ini::export_module(const char* module, const char* summary)
}
}
///////////////////////////////////////////////////////////
// TAuto_token_string
///////////////////////////////////////////////////////////
/*
TAuto_token_string& TAuto_token_string::create(const char* ts)
{
// Copia la stringa
set(ts);
// Calcola il separatore
for (const char* s = get_buffer(); *s; s++)
{
if (strchr("|;,!^&+\t\n", *s) != NULL)
{
separator(*s);
break;
}
}
return *this;
}
*/
///////////////////////////////////////////////////////////
// Maschera composizione del modulo
///////////////////////////////////////////////////////////

View File

@ -1166,7 +1166,7 @@ bool TInstaller_mask::on_key(KEY key)
TInstaller_mask::TInstaller_mask()
: TArray_sheet(0, 0, 0, 0, "Installazione",
"@1C|Modulo@30|Cod.|Versione da\ninstallare@11|Livello\nPatch@8|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch@8|Data\nInstallazione@13|Aggiornamento",
"@1|Modulo@30|Cod.|Versione da\ninstallare@11|Livello\nPatch@8|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch@8|Data\nInstallazione@13|Aggiornamento",
0x18, 3)
{
_curr_mask = this;
@ -1212,7 +1212,7 @@ TInstaller_mask::~TInstaller_mask()
switch (_reboot_program)
{
case NEW_MENU:
msg << "sono stati aggiornati i menu'";
msg << "sono stati aggiornati i menu";
default:
if (ba0exfile.exist())
{
@ -1220,7 +1220,7 @@ TInstaller_mask::~TInstaller_mask()
msg << " e ";
else
msg << "e' stato ";
msg << "aggiornato il navigatore dei menu'";
msg << "aggiornato il navigatore dei menu";
}
if (ba1exfile.exist())
{

View File

@ -31,7 +31,7 @@ public:
bool TDevotoOli_mask::something_selected() const
{
TSheet_field& sheet = sfield(F_MODULES);
FOR_EACH_SHEET_ROW_BACK(sheet, i, row)
FOR_EACH_SHEET_ROW(sheet, i, row)
if (row->get_char(0) > ' ')
break;
return i >= 0;

View File

@ -52,6 +52,6 @@ bool TComuni_app::user_destroy()
int ba4100(int argc, char* argv[])
{
TComuni_app a ;
a.run(argc, argv, "Anagrafica Comuni");
a.run(argc, argv, TR("Anagrafica Comuni"));
return 0;
}

View File

@ -708,6 +708,6 @@ int ba4200(int argc, char* argv[])
TApplication::check_parameters(argc, argv);
const char ta = (argc > 2 && toupper(*argv[2]) == 'G') ? 'G' : 'F';
TPersone_app a(ta);
a.run(argc, argv, "Anagrafica Persone");
a.run(argc, argv, TR("Anagrafica Persone"));
return 0;
}

View File

@ -193,6 +193,7 @@ public:
void convert_ca7() const;
void change_ca7(TRectype& rec) const;
void convert_quadst() const;
TConversione_archivi() : _oldditta(0), _codditta(0), _error(0) {}
};
@ -929,7 +930,7 @@ void TConversione_archivi::rebuild_dir_indexes()
d.get(i);
TFilename s(d.name());
s.ext("dbf");
if (f.is_valid() == NOERR && fexist(s))
if (f.is_valid(true) == NOERR && fexist(s))
{
TSystemisamfile f(i);
f.packindex();
@ -1840,4 +1841,3 @@ int main(int argc,char** argv)
return 0;
}

View File

@ -869,15 +869,20 @@ bool TBill::find()
bool TBill::read(TRectype &r)
{
TLocalisamfile pcon(LF_PCON);
pcon.put(PCN_GRUPPO, _gruppo);
pcon.put(PCN_CONTO, _conto);
pcon.put(PCN_SOTTOCONTO, _sottoconto);
bool ok = FALSE;
const int err = pcon.read();
if (err == NOERR)
if (tipo() <= ' ' || sottoconto() <= 0)
{
TString16 key; key.format("%d|%d|%ld", gruppo(), conto(), sottoconto());
const TRectype& pcon = cache().get(LF_PCON, key);
if (!pcon.empty())
{
r = pcon;
ok = TRUE;
}
}
if (ok)
{
r = pcon.curr();
_tipo_cr = r.get_int(PCN_TIPOSPRIC);
_sezione = r.get_char(PCN_SEZSALDI);
set_description(r.get(PCN_DESCR));
@ -886,7 +891,7 @@ bool TBill::read(TRectype &r)
else
r.zero();
return err == NOERR;
return ok;
}
int TBill::tipo_att()
@ -946,9 +951,8 @@ char TBill::sezione() const
// Certified 99% (uses __tmp_string)
const char* TBill::string(int mode) const
{
TFixed_string s(&__tmp_string[256], 80);
s.cut(0);
TString& s = get_tmp_string(80);
if (mode & 0x4)
{
const int cr = tipo_cr();

View File

@ -237,6 +237,8 @@ long TApplication::task_eh(WINDOW win, EVENT *ep)
xvt_menu_set_tree(win, menu);
xvt_res_free_menu_tree(menu);
}
if (dictionary_active())
xvt_menu_translate_tree(win, dictionary_translate_menu_item);
// Setta la caption della task window
TString cap;
@ -251,9 +253,6 @@ long TApplication::task_eh(WINDOW win, EVENT *ep)
// Crea il banner iniziale
create_backdrop();
#if defined(DBG) && XVT_OS == XVT_OS_SCOUNIX
message_box("Attach to process %d ...", getpid());
#endif
do_events();
os_allow_another_instance();
}
@ -414,7 +413,7 @@ void TApplication::stop_run()
c.set(hname, encode(remaining_time.string()));
}
else
message_box("Questo e' un programma dimostrativo.\n Oggi rimangono %s minuti di utilizzo.", remaining_time.string(3, 0));
message_box(TR("Questo e' un programma dimostrativo.\nOggi rimangono %s minuti di utilizzo."), remaining_time.string(3, 0));
}
#endif
terminate();
@ -478,6 +477,8 @@ void TApplication::terminate()
printer_destroy();
dictionary_close();
customize_controls(FALSE); // Rilascio eventuali DLL
}
@ -520,7 +521,7 @@ const char* TApplication::get_module_name() const
}
if (!ok)
{
error_box("Il modulo '%s' non e' autorizzato per l'utente %s", (const char*)module, ((const char*)user()));
error_box(TR("Il modulo '%s' non e' autorizzato per l'utente %s"), (const char*)module, ((const char*)user()));
module.cut(0);
}
}
@ -650,12 +651,12 @@ void TApplication::run(
if (sn < 0)
{
error_box("Probabilmente non e' stata inserita la chiave di protezione");
error_box(TR("Probabilmente non e' stata inserita la chiave di protezione"));
return;
}
if (!test_assistance_year())
{
error_box("Probabilmente e' necessario attivare il contratto di assistenza");
error_box(TR("Probabilmente e' necessario attivare il contratto di assistenza"));
return;
}
@ -702,7 +703,7 @@ void TApplication::about() const
if (get_version_info(year, release, tag, patch))
{
message_box("Versione %d.%02d\nProgramma %s\nN.ro di serie %u-%02d.%03d \nUtente %s",
message_box(TR("Versione %d.%02d\nProgramma %s\nN.ro di serie %u-%02d.%03d \nUtente %s"),
year, release, (const char*)n.name(), ser_no, tag, patch, (const char*)user());
}
else
@ -791,8 +792,8 @@ bool TApplication::build_firm_data(long codditta, bool flagcom)
exist = fexist(s);
}
if (exist)
return message_box("Direttorio dati danneggiato, impossibile attivare la ditta %ld", codditta);
if (!yesno_box("Gli archivi della ditta %ld non esistono: si desidera generarli?", codditta))
return message_box(TR("Direttorio dati danneggiato, impossibile attivare la ditta %ld"), codditta);
if (!yesno_box(TR("Gli archivi della ditta %ld non esistono: si desidera generarli?"), codditta))
return FALSE;
TLocalisamfile ditte(LF_NDITTE);
@ -800,24 +801,24 @@ bool TApplication::build_firm_data(long codditta, bool flagcom)
ditte.put("CODDITTA",codditta);
if (ditte.read(_isequal,_testandlock) == _islocked)
{
message_box("Archivi della ditta %ld in fase di creazione da parte di un altro utente.",codditta);
message_box(TR("Archivi della ditta %ld in fase di creazione da parte di un altro utente."),codditta);
return FALSE;
}
set_autoload_new_files(yesno_box("Si desidera precaricare gli archivi standard"));
set_autoload_new_files(yesno_box(TR("Si desidera precaricare gli archivi standard")));
s = s.path(); s.rtrim(1);
if (!fexist(s) && !make_dir(s))
return error_box("Impossibile creare il direttorio della ditta %ld (%s)",
return error_box(TR("Impossibile creare il direttorio della ditta %ld (%s)"),
codditta, (const char*)s);
s << ndir;
if (!fcopy(&ndir[1], s))
return error_box("Impossibile copiare il file %s della ditta %ld",
return error_box(TR("Impossibile copiare il file %s della ditta %ld"),
&ndir[1], codditta);
s = s.path(); s << ntrc;
if (!fcopy(&ntrc[1], s))
return error_box("Impossibile copiare il file %s della ditta %ld",
return error_box(TR("Impossibile copiare il file %s della ditta %ld"),
ntrc, codditta);
TDir dir, dir1;
@ -844,7 +845,7 @@ bool TApplication::build_firm_data(long codditta, bool flagcom)
dir.put(LF_DIR, _nordir, _sysdirop);
rec.zero();
}
TString mess("Generazione archivi della ditta "); mess << codditta;
TString mess(TR("Generazione archivi della ditta ")); mess << codditta;
TProgind p(maxeod0 ? maxeod0 : 1, mess, FALSE, TRUE, 70);
for (int i = LF_DIR + 1; i <= maxeod0; i++)

View File

@ -9,6 +9,10 @@
#include <strings.h>
#endif
#ifndef __DICTION_H
#include <diction.h>
#endif
#define MSG_AI "AI" // message auto_insert (relapp)
#define MSG_FS "FS" // message filtered start (relapp)
#define MSG_LN "LN" // message link (printapp -> relapp)

View File

@ -360,3 +360,73 @@ TAssoc_array & TAssoc_array::copy(
return * this;
}
///////////////////////////////////////////////////////////
// TCache
// Un simpatico contenitore che può dimenticare i contenuti
// a patto che riusciate a fornire un metodo per ricrearli!
///////////////////////////////////////////////////////////
TObject* TCache::key2obj(const char* key)
{
NFCHECK("Pure key2obj function not implemented");
return new TString(key); // Place holder
}
void TCache::discarding(const THash_object* obj)
{
// Nothing to do normally
}
TObject* TCache::objptr(const TString& key)
{
const int hv = key.hash() % _data.size();
THash_object* ho = (THash_object*)_data.objptr(hv);
TObject* obj = NULL;
if (ho != NULL && ho->key() == key)
{
obj = &ho->obj();
}
else
{
obj = key2obj(key);
if (obj != NULL)
{
if (ho != NULL)
{
discarding(ho);
_data.destroy(hv);
}
ho = new THash_object(key, obj);
_data.add(ho, hv);
}
}
return obj;
}
TObject* TCache::objptr(size_t s)
{
TString16 key; key.format("%10lu", s);
return objptr(key);
}
void TCache::destroy()
{
for (int i = _data.last(); i >= 0; i--)
{
THash_object* ho = (THash_object*)_data.objptr(i);
if (ho != NULL)
{
discarding(ho);
_data.destroy(i);
}
}
}
TCache::TCache(size_t size) : _data(size > 0 ? size : HASH_SIZE)
{ }
TCache::~TCache()
{
destroy();
}

View File

@ -148,6 +148,23 @@ public:
{ destroy(); }
};
class TCache : public TObject
{
TArray _data;
protected:
virtual void discarding(const THash_object* obj);
virtual TObject* key2obj(const char* key) pure;
public:
TObject* objptr(const TString& key);
TObject* objptr(size_t nkey);
void destroy(); // Not very useful, but who knows?
TCache(size_t size = 0); // 883 assigned by default
virtual ~TCache();
};
#define FOR_EACH_ASSOC_STRING(__ass, __obj, __key, __str) \
const char *__key, *__str; __ass.restart(); \
for (THash_object* __obj = __ass.get_hashobj(); \

View File

@ -26,6 +26,7 @@ COLOR FOCUS_COLOR = NORMAL_COLOR;
COLOR FOCUS_BACK_COLOR = COLOR_YELLOW;
bool CAMPI_SCAVATI = TRUE;
bool AUTOSELECT = FALSE;
bool SMALL_ICONS=FALSE;
#ifndef STX_DATA
// Very deep hacking
@ -118,7 +119,17 @@ bool TPicture_array::add(short id)
TImage* i = (TImage*)objptr(id);
if (i == NULL)
{
i = new TImage(id);
if (SMALL_ICONS)
{
ignore_xvt_errors(TRUE);
i = new TImage(10000+id);
ignore_xvt_errors(FALSE);
if (!i->ok())
i->load(id);
}
else
i = new TImage(id);
if (i->ok())
{
i->convert_transparent_color(BTN_BACK_COLOR);
@ -135,14 +146,10 @@ bool TPicture_array::add(short id)
void TPicture_array::reload()
{
for (int id = last(); id >= 0; id--)
for (short id = last(); id > 0; id--) if (exist(id))
{
TImage* i = (TImage*)objptr(id);
if (i)
{
i->load(id);
i->convert_transparent_color(BTN_BACK_COLOR);
}
destroy(id);
add(id);
}
}
@ -288,6 +295,7 @@ void customize_colors()
TOOL_BACK_COLOR = colors.get_color("ToolBack", NULL, -1, MASK_DARK_COLOR);
CAMPI_SCAVATI = colors.get_bool("Campi3D", NULL, -1, CAMPI_SCAVATI);
AUTOSELECT = colors.get_bool("AutoSelect", NULL, -1, AUTOSELECT);
SMALL_ICONS = colors.get_bool("SmallIcons", NULL, -1, SMALL_ICONS);
xi_set_pref(XI_PREF_COLOR_LIGHT, MASK_LIGHT_COLOR);
xi_set_pref(XI_PREF_COLOR_CTRL, MASK_BACK_COLOR);
@ -1368,7 +1376,7 @@ void TButton_control::create(WINDOW win, short cid,
{
bool bold;
COLOR color;
TString txt(text);
TString80 txt(text); txt.trim();
char mnemonic = '\0';
int underscore = -1;
@ -1562,30 +1570,6 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
else
_bmp_up = _bmp_dn = 0;
_obj->v.btn->drawable = _bmp_up > 0;
/*
if (bmp_up > 0)
{
XI_BITMAP* b1 = xi_bitmap_create_res(bmp_up, XI_BITMAP_NORMAL);
xi_bitmap_background_set(b1, BTN_BACK_COLOR);
xi_bitmap_hcenter_set(b1, TRUE);
xi_bitmap_vcenter_set(b1, TRUE);
xi_set_bitmap(_obj, b1);
if (bmp_dn <= 0)
bmp_dn = bmp_up;
}
else
xi_set_bitmap(_obj, NULL);
if (bmp_dn > 0)
{
XI_BITMAP* b2 = xi_bitmap_create_res(bmp_dn, XI_BITMAP_NORMAL);
xi_bitmap_background_set(b2, BTN_BACK_COLOR);
xi_bitmap_hcenter_set(b2, TRUE);
xi_bitmap_vcenter_set(b2, TRUE);
xi_set_down_bitmap(_obj, b2);
}
else
xi_set_down_bitmap(_obj, NULL);
*/
}
void TPushbutton_control::update()
@ -1623,39 +1607,62 @@ void TPushbutton_control::update()
if (bmp > 0)
{
const TImage& i = _picture->image(bmp);
int x = (rct.right + rct.left - i.width()) / 2;
int y = (rct.bottom + rct.top - i.height()) / 2;
if (_obj->v.btn->down)
{
x += 2;
y += 2;
}
if (!SMALL_ICONS || i.width() > i.height()*2)
{
int x = (rct.right + rct.left - i.width()) / 2;
int y = (rct.bottom + rct.top - i.height()) / 2;
if (_obj->v.btn->down)
{
x += 2;
y += 2;
}
i.draw(win, x, y);
i.draw(win, x, y);
if (!(attrib & XI_ATR_ENABLED))
{
CPEN pen;
pen.width = 1;
pen.pat = PAT_SOLID;
pen.style = P_SOLID;
pen.color = BTN_BACK_COLOR;
xvt_dwin_set_cpen(win, &pen);
for (int py = y + i.height(); py >= y; py -= 2)
{
PNT p; p.v = py; p.h = x;
xvt_dwin_draw_set_pos(win, p);
p.h += i.width();
xvt_dwin_draw_line(win, p);
}
for (int px = x + i.width(); px >= x; px -= 2)
{
PNT p; p.v = y; p.h = px;
xvt_dwin_draw_set_pos(win, p);
p.v += i.height();
xvt_dwin_draw_line(win, p);
}
}
if (!(attrib & XI_ATR_ENABLED))
{
CPEN pen;
pen.width = 1;
pen.pat = PAT_SOLID;
pen.style = P_SOLID;
pen.color = BTN_BACK_COLOR;
xvt_dwin_set_cpen(win, &pen);
for (int py = y + i.height(); py >= y; py -= 2)
{
PNT p; p.v = py; p.h = x;
xvt_dwin_draw_set_pos(win, p);
p.h += i.width();
xvt_dwin_draw_line(win, p);
}
for (int px = x + i.width(); px >= x; px -= 2)
{
PNT p; p.v = y; p.h = px;
xvt_dwin_draw_set_pos(win, p);
p.v += i.height();
xvt_dwin_draw_line(win, p);
}
}
}
else
{
const char* cap = caption();
int width = i.width();
if (*cap)
width += xvt_dwin_get_text_width(win, cap, -1) + 1;
int x = (rct.right + rct.left - width) / 2 + _obj->v.btn->down;
int y = (rct.bottom + rct.top - i.height()) / 2 + _obj->v.btn->down;
i.draw(win, x, y);
if (*cap)
{
const int height = xvt_dwin_get_font_size_mapped(win);
x += i.width()+1;
y = (rct.top + rct.bottom + height) / 2 + _obj->v.btn->down;
xvt_dwin_set_fore_color(win, (attrib & XI_ATR_ENABLED) ? NORMAL_COLOR : DISABLED_COLOR);
xvt_dwin_draw_text(win, x, y, cap, -1);
}
}
}
#ifdef XI_R4
xi_set_clip(xiwin, NULL);

View File

@ -4,18 +4,22 @@
#define __DATE_CPP
#include <date.h>
#include <diction.h>
#include <real.h>
#include <strings.h>
#define DAYYEAR 365
#define DAYBIAS 36525L
static const byte _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_leap(int year)
{ return (year % 4) == 0; }
///////////////////////////////////////////////////////////
// Utility functions
///////////////////////////////////////////////////////////
HIDDEN const byte _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
TDate::TDate(const TDate &d) : _val(d._val)
{}
@ -27,9 +31,10 @@ TDate::TDate(long l) : _val(l)
if (time(&lt) == -1)
return;
struct tm * timeloc = localtime(&lt);
if (timeloc == NULL)
fatal_box("Impossibile reperire la data corrente del sistema.");
_val = makedata(timeloc->tm_mday, timeloc->tm_mon+1, timeloc->tm_year + 1900);
if (timeloc != NULL)
_val = makedata(timeloc->tm_mday, timeloc->tm_mon+1, timeloc->tm_year + 1900);
else
_val = NULLDATE;
}
else
{
@ -52,9 +57,8 @@ TDate::TDate(long l) : _val(l)
cnt -= 100;
wd += DAYBIAS;
}
int m, y, leap;
for(y = 0; wd > DAYYEAR + (leap = ((y % 4 ) == 0)); y++)
int m, y, leap;
for(y = 0; wd > DAYYEAR + (leap = is_leap(y)); y++)
wd -= (DAYYEAR + leap);
for(m = 0; wd > (_days_in_month[m] + (leap && (m == 1))); m++)
wd -= (_days_in_month[m] + (leap && (m == 1)));
@ -119,22 +123,9 @@ int TDate::last_day(int month, int year)
// son ventotto case uno
// per default ce n'ha trentuno");
{
int d;
switch(month)
{
case 4:
case 6:
case 9:
case 11:
d = 30;
break;
case 2:
d = year % 4 ? 28 : 29;
break;
default:
d = 31;
break;
}
int d = _days_in_month[month-1];
if (month == 2 && is_leap(year) == 0)
d++;
return d;
}
@ -296,7 +287,7 @@ char* TDate::string(
else if (monthf == quarter)
{
if (ord < m_date) ord = ma_date;
mf.format("%do trimestre", (month() / 3) + 1);
mf.format("%s %d", TR("trimestre"), (month()/3)+1);
}
else
mf.format(monthf == brief ? "%d" : "%02d", month());
@ -662,11 +653,13 @@ const char* itom(
// mese corrispondente a tale cifra (es. 15 = "Marzo")
{
CHECK(m>=1, "Il mese indicato deve essere un numero da 1 a 12 ");
const char* nomi[12] =
const char* const nomi[12] =
{
"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno",
"Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
};
TR("Gennaio"), TR("Febbraio"), TR("Marzo"),
TR("Aprile"), TR("Maggio"), TR("Giugno"),
TR("Luglio"), TR("Agosto"), TR("Settembre"),
TR("Ottobre"), TR("Novembre"), TR("Dicembre")
};
return nomi[(m-1) % 12];
}
@ -681,8 +674,9 @@ const char* itow(
// giorno corrispondente a tale cifra (es. 15 = "Lunedi")
{
CHECKD(d >= 1 && d <= 7, "Bad week day ", d);
const char* nomi[7] =
{ "Lunedi", "Martedi", "Mercoledi", "Giovedi", "Venerdi", "Sabato", "Domenica" };
const char* const nomi[7] =
{ TR("Lunedì"), TR("Martedì"), TR("Mercoledì"), TR("Giovedì"),
TR("Venerdì"), TR("Sabato"), TR("Domenica") };
return nomi[(d-1) % 7];
}

306
include/diction.cpp Executable file
View File

@ -0,0 +1,306 @@
/*
<xml>
<dictionary>
<entry module="ba">
<ita>Attezione: premere OK per cancellare</ita>
<eng>Atension: pres OK to dilit</eng>
</entry>
</dictionary>
</xml>
*/
#include <xvt.h>
#include <config.h>
#include <diction.h>
#include <netsock.h>
#include <scanner.h>
#include <utility.h>
///////////////////////////////////////////////////////////
// TTraduttore
///////////////////////////////////////////////////////////
class TTraduttore : public TCache
{
TString _str;
TSocketClient _client;
CONNID _connection;
protected:
virtual TObject* key2obj(const char* key);
public:
bool active() const { return _connection != 0; }
const char* translate(const char* sentence);
TTraduttore();
virtual ~TTraduttore();
};
TObject* TTraduttore::key2obj(const char* key)
{
const char* const prefix = "<sentence>";
const char* const posfix = "</sentence>";
_str.cut(0);
_str << "<m:Translate>\n"
<< prefix << unesc(key) << posfix << '\n'
<< "</m:Translate>\n";
if (_client.HttpSoap(_connection, _str))
{
_str.cut(0);
size_t size;
const TFixed_string buf((const char*)_client.GetBuffer(size));
int start = buf.find("<sentence");
if (start > 0)
start = buf.find('>', start+1)+1;
if (start > 0)
{
const int stop = buf.find('<', start);
if (stop > 0)
_str = esc(buf.sub(start, stop));
}
// _client.ReleaseBuffer(); // Non perdiamo tempo in 'ste cose
}
else
return NULL;
return _str.dup();
}
const char* TTraduttore::translate(const char* sentence)
{
if (sentence && *sentence && active())
{
TString str = sentence; str.trim();
bool has_letters = false;
for (int i = 0; str[i]; i++)
{
if (isalpha(str[i]))
{
has_letters = true;
break;
}
}
if (has_letters)
{
TString* trans = (TString*)objptr(str);
if (trans != NULL && trans->not_empty())
sentence = (const char*)*trans;
}
}
return sentence;
}
TTraduttore::TTraduttore() : _connection(0)
{
TConfig ini(CONFIG_INSTALL, "Server");
const TString& server = ini.get("Dictionary");
if (server.not_empty())
_connection = _client.QueryConnection("", server);
}
TTraduttore::~TTraduttore()
{
// Autoclose connection
}
static TTraduttore* _DevotoOli = NULL;
const char* dictionary_translate(const char* sentence)
{
if (_DevotoOli == NULL)
_DevotoOli = new TTraduttore;
return _DevotoOli->translate(sentence);
}
const char* dictionary_translate_macro(const char* sentence)
{
if (memcmp(sentence, TO_BE_TRANSLATED, 4) == 0)
sentence = dictionary_translate(sentence+4);
return sentence;
}
char strip_accelerator(TString& str)
{
char tilde= '\0';
for (int i = 0; str[i]; i++)
{
if (str[i] == '~' || str[i] == '&')
{
tilde = str[i+1];
str.strip("~&");
break;
}
}
return tilde;
}
void restore_accelerator(TString& str, char acc, char tilde)
{
if (acc > ' ')
{
int newtilde = 0;
for (int m = 0; str[m]; m++)
{
if (toupper(str[m]) == acc)
{
newtilde = m;
break;
}
}
const char s[2] = { tilde, '\0' };
str.insert(s, newtilde);
}
}
// len - Effect
// -1 - No length limit
// 0 - Exactly same lenght as original
// >0 - Maximum specified length
const char* dictionary_translate_prompt(const char* prompt, int maxlen)
{
if (prompt && *prompt && dictionary_active())
{
TString& str = get_tmp_string();
str = prompt;
TString8 prefix;
if (str[0] == '@')
{
prefix = str.left(2); // Usually bold = @b
str.ltrim(2);
}
const char matilde = strip_accelerator(str); // Ricorda tasto rapido
const int oldlen = str.len(); // Memorizza vecchia lunghezza
str = dictionary_translate(str);
if (maxlen >= 0)
{
const int limit = maxlen == 0 ? oldlen : maxlen;
if (str.len() > limit)
{
// Abbrevio all'ultima consonante
for (int i = limit-2; i > 0; i--)
{
if (strchr("aeiou", str[i]) == NULL)
{
str.cut(i+1);
str << '.';
break;
}
}
if (i <= 0)
str.cut(limit);
}
if (maxlen == 0 && str.len() < limit)
str.left_just(limit);
}
restore_accelerator(str, matilde, '~');
str.insert(prefix);
return str;
}
return prompt;
}
const char* dictionary_translate_macro_prompt(const char* sentence, int maxlen)
{
if (memcmp(sentence, TO_BE_TRANSLATED, 4) == 0)
sentence = dictionary_translate_prompt(sentence+4, maxlen);
return sentence;
}
const char* dictionary_translate_header(const char* head)
{
if (head && *head && dictionary_active())
{
TString str = head;
const int at = str.rfind('@');
if (at >= 0)
{
TString8 postfix;
postfix = str.mid(at);
str.cut(at);
str = dictionary_translate(str);
str << postfix;
return str;
}
if (str.right(1)[0] == ' ')
return dictionary_translate_prompt(head);
return dictionary_translate(head);
}
return head;
}
const char* dictionary_translate_macro_header(const char* head)
{
if (memcmp(head, TO_BE_TRANSLATED, 4) == 0)
head = dictionary_translate_header(head+4);
return head;
}
const char* dictionary_translate_menu_item(const char* text)
{
TString& str = get_tmp_string();
str = text;
const char matilde = strip_accelerator(str);
TString16 posfix;
int start = str.find('\t');
if (start < 0)
start = str.find("...");
if (start > 0)
{
posfix = str.mid(start);
str.cut(start);
}
const char* newtext = dictionary_translate(str);
if (str != newtext)
{
str = newtext;
restore_accelerator(str, matilde, '&');
if (posfix.not_empty())
str << posfix;
return str;
}
return text;
}
void dictionary_translate_menu(MENU_ITEM* menu)
{
if (menu && dictionary_active()) for (int m = 0; menu[m].tag != 0; m++)
{
MENU_ITEM& mi = menu[m];
if (!mi.separator)
{
const char* newtext = dictionary_translate_menu_item(mi.text);
if (strlen(newtext) > strlen(mi.text)) // Posso sovrascrivere?
mi.text = xvt_mem_realloc(mi.text, strlen(newtext)+1);
strcpy(mi.text, newtext);
if (mi.child)
dictionary_translate_menu(mi.child);
}
}
}
bool dictionary_active()
{
return _DevotoOli != NULL && _DevotoOli->active();
}
void dictionary_close()
{
if (_DevotoOli != NULL)
{
delete _DevotoOli;
_DevotoOli = NULL;
}
}

28
include/diction.h Executable file
View File

@ -0,0 +1,28 @@
#ifndef __DICTION_H
#define __DICTION_H
#define TO_BE_TRANSLATED "\03\02\01\00"
#define ALREADY_TRANSLATED "\01\02\03\00"
#ifndef XVT_INCL_XVT
typedef unsigned long WINDOW;
#endif
const char* dictionary_translate(const char* sentence);
const char* dictionary_translate_macro(const char* sentence);
const char* dictionary_translate_prompt(const char* prompt, int maxlen = 0);
const char* dictionary_translate_macro_prompt(const char* prompt, int maxlen = 0);
const char* dictionary_translate_header(const char* head);
const char* dictionary_translate_macro_header(const char* head);
const char* dictionary_translate_menu_item(const char* menu);
void dictionary_translate_menu(WINDOW win);
bool dictionary_active();
void dictionary_close();
#define TR(str) dictionary_translate_macro(TO_BE_TRANSLATED##str)
#define PR(str) dictionary_translate_macro_prompt(TO_BE_TRANSLATED##str)
#define BR(str) dictionary_translate_macro_prompt(TO_BE_TRANSLATED##str, -1)
#define HR(str) dictionary_translate_macro_header(TO_BE_TRANSLATED##str)
#endif

View File

@ -1367,7 +1367,7 @@ bool TMail_messages::remove()
///////////////////////////////////////////////////////////
// Obsolete DDE management
///////////////////////////////////////////////////////////
/*
#include <dde.h>
///////////////////////////////////////////////////////////
@ -1580,3 +1580,4 @@ void TDDE::terminate()
}
}
*/

View File

@ -3,12 +3,12 @@
#include <checks.h>
#include <isamrpc.h>
#define NO_MFC
#define XVAGA
#include <netsock.h>
static TSocketClient* _client = NULL;
static DWORD _connection = 0;
static CONNID _connection = 0;
bool rpc_Start()
{
@ -44,7 +44,7 @@ bool rpc_Call(const char* cmd)
return ok;
}
char* rpc_Request(const char* cmd, DWORD& size, real& total)
char* rpc_Request(const char* cmd, size_t& size, real& total)
{
CHECK(_connection, "Server not connected");
const clock_t start = clock();
@ -60,7 +60,7 @@ static TString _rpc_string;
inline bool BoolCall()
{
CHECK(_connection, "Server not connected");
BOOL yes;
bool yes;
bool ok = _client->RequestBool(_connection, _rpc_call, yes) != 0;
if (!ok)
{
@ -176,7 +176,7 @@ bool rpc_DongleHasModule(word af)
bool rpc_DongleModules(TBit_array& ba)
{
DWORD size;
size_t size;
real time;
word* buff = (word*)rpc_Request("DongleModules()", size, time);
@ -240,7 +240,7 @@ bool rpc_UserLogin(const char* server, const char* user,
cmd << "UserLogin(" << user << ")";
_rpc_call.format("UserLogin(%s,%s,%s)", user, password, application);
BOOL logged = FALSE;
bool logged = FALSE;
bool connected = _client->RequestBool(_connection, _rpc_call, logged) != 0;
if (connected)
{
@ -293,12 +293,12 @@ bool http_get(const char* server,
if (!client.IsOk())
return error_box("Impossibile inizializzare il client HTTP");
unsigned long connection = client.QueryConnection("80", server);
CONNID connection = client.QueryConnection("80", server);
bool ok = connection != 0;
if (ok)
{
ok = client.HttpGetFile(remote_file, local_file) != 0;
client.RemoveConnection(connection);
ok = client.HttpGetFile(connection, remote_file, local_file) != 0;
client.RemoveConnection(connection);
}
return ok;
@ -314,7 +314,7 @@ bool http_dir(const char* server, const char* remote_dir, TString_array& list)
bool ok = connection != 0;
if (ok)
{
ok = client.HttpGetDir(remote_dir, list) != 0;
ok = client.HttpGetDir(connection, remote_dir, list) != 0;
client.RemoveConnection(connection);
}

View File

@ -156,6 +156,7 @@
#define LF_EXTERNAL 1000 // Files with id >= are considered to be externals
#define CNF_GENERAL 10000
#define CNF_STUDIO CNF_GENERAL + 1
#define CNF_DITTA CNF_GENERAL + 2
@ -168,4 +169,3 @@

View File

@ -4,6 +4,7 @@
#include <controls.h>
#include <browfile.h>
#include <colors.h>
#include <diction.h>
#include <msksheet.h>
#include <os_dep.h>
#include <prefix.h>
@ -180,8 +181,8 @@ void TMask::read_mask(
CHECKD(_pages < MAX_PAGES, "Maschera con troppe pagine: ", _pages);
WINDOW w = read_page(scanner, FALSE);
TString title(80);
xvt_vobj_get_title(w, (char*)(const char*)title, title.size());
TString80 title;
xvt_vobj_get_title(w, title.get_buffer(), title.size());
captions.add(title);
_pagewin[_pages++] = w;
@ -945,7 +946,7 @@ WINDOW TMask::read_page(
static int tooly;
static RCT rect;
TString title(scanner.string());
const TString title = dictionary_translate(scanner.string());
RCT r;
if (toolwin())

View File

@ -3,6 +3,7 @@
#include <colors.h>
#include <controls.h>
#include <diction.h>
#include <execp.h>
#include <expr.h>
#include <msksheet.h>
@ -320,7 +321,7 @@ bool TMask_field::parse_item(TScanner& scanner)
{
_ctl_data._x = scanner.integer();
_ctl_data._y = scanner.integer();
_ctl_data._prompt = scanner.string();
_ctl_data._prompt = dictionary_translate_prompt(scanner.string(), is_editable() ? 0 : -1);
return TRUE;
}
@ -1059,23 +1060,23 @@ void TButton_field::create(WINDOW parent)
{
case DLG_OK:
if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Conferma")
_ctl_data._prompt = "~Conferma";
_ctl_data._prompt = BR("~Conferma");
_exit_key = K_ENTER;
if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == "~Conferma")
if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("~Conferma"))
_ctl_data._bmp_up = BMP_OK;
break;
case DLG_CANCEL:
if (_ctl_data._prompt.empty())
_ctl_data._prompt = "Annulla";
_ctl_data._prompt = BR("Annulla");
_virtual_key = _exit_key = K_ESC;
if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == "Annulla")
if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("Annulla"))
_ctl_data._bmp_up = BMP_CANCEL;
break;
case DLG_DELREC:
if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Elimina")
_ctl_data._prompt = "~Elimina";
_ctl_data._prompt = BR("~Elimina");
_exit_key = K_DEL;
if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == "~Elimina")
if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("~Elimina"))
{
_ctl_data._bmp_up = BMP_DELREC;
_ctl_data._bmp_dn = BMP_DELRECDN;
@ -1083,17 +1084,17 @@ void TButton_field::create(WINDOW parent)
break;
case DLG_PRINT:
if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Stampa")
_ctl_data._prompt = "~Stampa";
_ctl_data._prompt = BR("~Stampa");
_exit_key = K_ENTER;
if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == "~Stampa")
if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == BR("~Stampa"))
_ctl_data._bmp_up = BMP_PRINT;
break;
case DLG_QUIT:
if (_ctl_data._prompt.empty())
_ctl_data._prompt = "Fine";
_ctl_data._prompt = BR("Fine");
_virtual_key = K_F4;
_exit_key = K_QUIT;
if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == "Fine")
if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == BR("Fine"))
{
_ctl_data._bmp_up = BMP_QUIT;
_ctl_data._bmp_dn = BMP_QUITDN;
@ -1338,7 +1339,8 @@ bool TEditable_field::parse_item(TScanner& scanner)
if (scanner.key() == "WA")
{
set_warning(scanner.string());
const char* msg = dictionary_translate(scanner.string());
set_warning(msg);
return TRUE;
}
@ -1866,9 +1868,8 @@ TBrowse::~TBrowse()
// Certified 100%
void TBrowse::parse_display(TScanner& scanner)
{
const char* s;
s = scanner.string();
_head.add(s);
const char* s = scanner.string();
_head.add(dictionary_translate_header(s));
s = scanner.line();
_items.add(s);
}
@ -2294,12 +2295,9 @@ bool TBrowse::do_link(bool insert)
{
TString nm(_insert.mid(1));
if (nm.compare("tb", 2, TRUE) == 0) // Programma gestione tabelle
{
_cursor->file().get_relapp(app);
}
else // Programma generico di browse/edit
app.format("ba3 -3 %s %d", (const char*)nm, _cursor->file().num());
// Obbligatorio usare la format globale
}
else
{
@ -4216,7 +4214,7 @@ void TList_field::read_item(TScanner& scanner)
TToken_string ts(scanner.string());
_codes.add(ts.get());
const char* v = ts.get();
const char* v = dictionary_translate_prompt(ts.get(), _ctl_data._width);
_values.add(v);
CHECKS(v == NULL || strlen(v) <= (word)_ctl_data._width, "List item is too long:", v);
@ -4306,9 +4304,18 @@ void TList_field::add_list()
csafe = _codes; _codes = "";
vsafe = _values; _values = "";
}
/*
_codes.add("01|02|03|04|05|06|07|08|09|10|11|12");
_values.add("Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|"
"Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre");
*/
for (int i = 1; i <= 12; i++)
{
char num[4]; sprintf(num, "%02d", i);
_codes.add(num);
_values.add(itom(i));
}
if (atoi(csafe) > 0)
{
_codes.add(csafe);

View File

@ -3,6 +3,7 @@
#define XVT_INCL_NATIVE
#include <progind.h>
#include <config.h>
#include <agasys.h>
// skstream.h
// Copyright (C) 1995, 1996 by John C. Wang. All Rights Reserved.
@ -456,16 +457,134 @@ int sockbuf::sync()
// end of skstreams
///////////////////////////////////////////////////////////
#define NO_MFC
#define CObject TObject
#define CString TString
#define CStringArray TString_array
#include "NetSock.h"
#include <windows.h>
class TSocket_connection : public TConnection
{
TString _server;
skstream::service _service;
static TLanManager* pSocketManager = NULL;
static skstream* cur_socket = NULL;
skstream* _socket;
protected:
bool connect();
public:
virtual bool Execute(const char* cmd);
bool WriteLine(const char* cmd);
bool ReadLine(TString& str);
bool Read(byte* buf, size_t size);
skstream* GetSocket();
TSocket_connection(TLanManager* lm, const char* service, const char* server);
~TSocket_connection();
};
bool TSocket_connection::Execute(const char* cmd)
{
bool ok = GetSocket() != NULL;
if (ok)
{
const size_t buflen = strlen(cmd)+1;
_socket->sync();
_socket->write(cmd, buflen);
_socket->flush();
ok = _socket->good() != 0;
}
return ok;
}
bool TSocket_connection::WriteLine(const char* cmd)
{
bool ok = GetSocket() != NULL;
if (ok)
{
const size_t buflen = strlen(cmd); // Unica differenza da Execute
_socket->sync();
_socket->write(cmd, buflen);
_socket->flush();
ok = _socket->good() != 0;
}
return ok;
}
bool TSocket_connection::ReadLine(TString& str)
{
bool ok = GetSocket() != NULL;
if (ok)
{
char *buf = str.get_buffer(4096);
_socket->getline(buf, str.size(), '\n');
}
return ok;
}
bool TSocket_connection::Read(byte* buf, size_t size)
{
bool ok = GetSocket() != NULL;
if (ok)
{
_socket->read(buf, size);
ok = _socket->good() != 0;
}
return ok;
}
bool TSocket_connection::connect()
{
if (_socket != NULL)
delete _socket;
_socket = new skstream(_server, _service);
if (_socket->is_open())
SetId((CONNID)_socket);
else
{
delete _socket;
_socket = NULL;
SetId(0);
}
return _socket != NULL;
}
skstream* TSocket_connection::GetSocket()
{
if (_socket == NULL || !_socket->is_open())
connect();
return _socket;
}
TSocket_connection::TSocket_connection(TLanManager* lm,
const char* service, const char* server)
: TConnection(lm, 0), _socket(NULL)
{
_service = (skstream::service)((service && *service) ? atoi(service) : 0);
_server = server;
int pos = _server.find("://");
if (pos > 0)
_server.ltrim(pos+3);
pos = _server.rfind(':');
if (pos >= 0)
{
_service = (skstream::service)atoi(_server.mid(pos+1));
_server.cut(pos);
}
if (_server.blank() || stricmp(_server, "localhost") == 0)
_server = "127.0.0.1";
connect();
}
TSocket_connection::~TSocket_connection()
{
if (_socket)
delete _socket;
}
TSocketClient::TSocketClient()
: m_pData(NULL), m_dwSize(0)
@ -475,95 +594,23 @@ TSocketClient::~TSocketClient()
{
ReleaseBuffer();
RemoveAllConnections();
ShutDown();
}
BOOL TSocketClient::Boot()
TConnection* TSocketClient::OnQueryConnection(const char* service, const char* server)
{
return TRUE;
}
BOOL TSocketClient::ShutDown()
{
pSocketManager = NULL;
if (cur_socket)
{
delete cur_socket;
cur_socket = NULL;
}
return TRUE;
}
BOOL TSocketClient::OnRemoveConnection(DWORD id)
{
if (cur_socket)
{
delete cur_socket;
cur_socket = NULL;
}
return TRUE;
}
TConnection* TSocketClient::OnQueryConnection(const char* service,
const char* server)
{
if (pSocketManager == NULL)
Boot();
TConnection* pConnection = NULL;
if (cur_socket == NULL)
{
int porta = service != NULL ? atoi(service) : 0;
TString strServer = server;
int pos = strServer.find("://");
if (pos > 0)
strServer.ltrim(pos+3);
pos = strServer.rfind(':');
if (pos > 0)
{
porta = atoi(strServer.mid(pos+1));
strServer.cut(pos);
}
if (strServer.empty() || stricmp(strServer, "localhost") == 0)
strServer = "127.0.0.1";
cur_socket = new skstream(strServer, (skstream::service)porta);
if (cur_socket->is_open())
pConnection = OnCreateConnection((DWORD)cur_socket);
else
{
delete cur_socket;
cur_socket = NULL;
}
}
TSocket_connection* pConnection = new TSocket_connection(this, service, server);
if (pConnection->Id() == 0)
{
delete pConnection;
pConnection = NULL;
}
return pConnection;
}
BOOL TSocketClient::Execute(DWORD id, const char* cmd)
{
BOOL ok = cur_socket != NULL && cur_socket->is_open();
if (ok)
{
const int buflen = strlen(cmd)+1;
cur_socket->sync();
cur_socket->write(cmd, buflen);
cur_socket->flush();
ok = cur_socket->good();
}
return ok;
}
BOOL TSocketClient::Request(DWORD id, const char* cmd)
bool TSocketClient::Request(CONNID id, const char* cmd)
{
static BOOL semaphore = FALSE;
BOOL ok = FALSE;
static bool semaphore = FALSE;
bool ok = FALSE;
if (!semaphore)
{
@ -573,14 +620,14 @@ BOOL TSocketClient::Request(DWORD id, const char* cmd)
ok = Execute(id, cmd);
if (ok)
{
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
m_dwSize = 0;
cur_socket->read((char*)&m_dwSize, sizeof(m_dwSize));
conn->Read((byte*)&m_dwSize, sizeof(m_dwSize));
ok = m_dwSize > 0;
if (ok)
{
m_pData = new BYTE[m_dwSize];
cur_socket->read(m_pData, (int)m_dwSize);
ok = cur_socket->good();
m_pData = new byte[m_dwSize];
ok = conn->Read(m_pData, m_dwSize);
}
}
@ -589,63 +636,61 @@ BOOL TSocketClient::Request(DWORD id, const char* cmd)
return ok;
}
BYTE* TSocketClient::GetBuffer(DWORD& dwSize)
byte* TSocketClient::GetBuffer(size_t& dwSize)
{
dwSize = m_dwSize;
return m_pData;
}
BOOL TSocketClient::WriteLine(DWORD, const char* str)
bool TSocketClient::WriteLine(CONNID id, const char* str)
{
if (!cur_socket->is_open())
return FALSE;
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
if (conn)
return conn->WriteLine(str);
return FALSE;
}
if (str && *str)
bool TSocketClient::ReadLine(CONNID id, TString& str)
{
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
if (conn)
return conn->ReadLine(str);
return FALSE;
}
void TSocketClient::ReleaseBuffer()
{
if (m_pData)
{
cur_socket->sync();
cur_socket->write(str, strlen(str));
cur_socket->flush();
delete m_pData;
m_pData = NULL;
m_dwSize = 0;
}
return cur_socket->good();
}
BOOL TSocketClient::ReadLine(DWORD, TString& str)
bool TSocketClient::HttpGetFile(CONNID id, const char* remote, const char* local)
{
char *buf = str.get_buffer(4096);
cur_socket->getline(buf, str.size(), '\n');
return TRUE;
}
BOOL TSocketClient::HttpGetFile(const char* remote, const char* local)
{
if (cur_socket == NULL || !cur_socket->is_open())
return FALSE;
BOOL ok = FALSE;
bool ok = FALSE;
TString buf(4096);
buf << "GET " << remote << " HTTP/1.0\r\n\r\n";
cur_socket->sync();
cur_socket->write(buf, buf.len());
cur_socket->flush();
if (cur_socket->good())
if (WriteLine(id, buf))
{
const clock_t start = clock();
long size = 0;
for (int r = 0; !cur_socket->eof(); r++)
for (int r = 0; ; r++)
{
cur_socket->getline(buf.get_buffer(), buf.size(), '\n');
ReadLine(id, buf);
if (buf.blank())
break;
if (r == 0 && buf.find("404") > 0)
return FALSE; // File not found
if (buf.compare("Content-length:", 15, TRUE) == 0)
{
const int colon = buf.find(':');
size = atol(buf.mid(colon+1));
const int colon = buf.find(':');
size = atol(buf.mid(colon+1));
}
}
ofstream outfile(local, ios::out | ios::binary);
@ -661,6 +706,7 @@ BOOL TSocketClient::HttpGetFile(const char* remote, const char* local)
TProgind pi(size, msg, TRUE, TRUE);
long total = 0;
skstream* cur_socket = ((TSocket_connection*)GetConnection(id))->GetSocket();
while (!cur_socket->eof())
{
cur_socket->read(buf.get_buffer(), buf.size());
@ -700,10 +746,10 @@ BOOL TSocketClient::HttpGetFile(const char* remote, const char* local)
return ok;
}
BOOL TSocketClient::HttpGetDir(const char* remote, TString_array& list)
bool TSocketClient::HttpGetDir(CONNID id, const char* remote, TString_array& list)
{
TFilename local; local.temp();
const BOOL ok = HttpGetFile(remote, local);
const bool ok = HttpGetFile(id, remote, local);
if (ok)
{
ifstream s(local);
@ -733,12 +779,65 @@ BOOL TSocketClient::HttpGetDir(const char* remote, TString_array& list)
return ok;
}
void TSocketClient::ReleaseBuffer()
bool TSocketClient::HttpSoap(CONNID id, const char* cmd)
{
if (m_pData)
bool ok = false;
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
if (conn == NULL)
return ok;
if (cmd == NULL || *cmd == '\0')
return ok;
char hostname[64];
aga_get_host_name(hostname, sizeof(hostname));
TString content(256);
content = cmd;
if (content.find("<SOAP-ENV") < 0) // Controllo se c'è tutto
{
content.insert("<SOAP-ENV:Envelope>\n<SOAP-ENV:Body>\n");
content << "</SOAP-ENV:Body>\n</SOAP-ENV:Envelope>\r\n";
}
TString buf(4096);
buf << "POST / HTTP/1.1\n"
<< "User-Agent: Campo\n"
<< "Host: " << hostname << "\n"
<< "Content-Type: text/xml; charset=utf-8\n"
<< "Content-length: " << content.len() << "\n"
<< "SOAPAction: \"/\"\r\n\r\n"
<< content;
if (conn->WriteLine(buf))
{
delete m_pData;
m_pData = NULL;
m_dwSize = 0;
}
}
skstream* cur_socket = conn->GetSocket();
unsigned long size = 0;
for (int r = 0; !cur_socket->eof(); r++)
{
conn->ReadLine(buf);
if (buf.blank())
break;
if (buf.compare("Content-length:", 15, TRUE) == 0)
{
const int colon = buf.find(':');
size = atol(buf.mid(colon+1));
}
}
if (size > 0)
{
if (size >= m_dwSize)
{
ReleaseBuffer();
m_dwSize = size+1;
m_pData = new BYTE[m_dwSize];
}
memset(m_pData, 0, m_dwSize);
cur_socket->read(m_pData, size);
ok = true;
}
}
return ok;
}

View File

@ -5,28 +5,26 @@
#include "NetUtils.h"
#endif
class TConnection;
class TSocketServer : public TLanServer
{
BYTE* m_pData;
DWORD m_dwSize;
byte* m_pData;
unsigned int m_dwSize;
protected: // TLanManager
virtual BOOL Boot();
virtual BOOL ShutDown();
virtual bool Boot();
virtual bool ShutDown();
virtual BOOL OnRemoveConnection(DWORD id);
virtual bool OnRemoveConnection(CONNID id);
public:
BYTE* GetBuffer(DWORD dwSize);
const BYTE* GetData() const { return m_pData; }
byte* GetBuffer(size_t dwSize);
const byte* GetData() const { return m_pData; }
BOOL OnConnect(const CString& topic);
void OnConnectConfirm(DWORD id);
bool OnConnect(const TString& topic);
void OnConnectConfirm(CONNID id);
public:
virtual BOOL IsOk() const;
virtual bool IsOk() const;
TSocketServer(const char* name);
virtual ~TSocketServer();
@ -34,30 +32,24 @@ public:
class TSocketClient : public TLanClient
{
BYTE* m_pData;
DWORD m_dwSize;
byte* m_pData;
size_t m_dwSize;
protected: // TLanManager
virtual BOOL Boot();
virtual BOOL ShutDown();
virtual OnRemoveConnection(DWORD id);
protected: // TLanClient
virtual TConnection* OnQueryConnection(const char* service,
const char* server);
virtual TConnection* OnQueryConnection(const char* service, const char* server);
public:
virtual BOOL Execute(DWORD id, const char* cmd);
virtual BOOL Request(DWORD id, const char* cmd);
virtual BYTE* GetBuffer(DWORD& dwSize);
virtual bool Request(CONNID id, const char* cmd);
virtual byte* GetBuffer(size_t& dwSize);
virtual void ReleaseBuffer();
virtual BOOL IsOk() const { return TRUE; }
virtual bool IsOk() const { return TRUE; }
BOOL WriteLine(DWORD id, const char* str);
BOOL ReadLine(DWORD id, TString& str);
bool WriteLine(CONNID id, const char* str);
bool ReadLine(CONNID id, TString& str);
BOOL HttpGetFile(const char* remote, const char* local);
BOOL HttpGetDir(const char* remote, TString_array& list);
bool HttpGetFile(CONNID id, const char* remote, const char* local);
bool HttpGetDir(CONNID id, const char* remote, TString_array& list);
bool HttpSoap(CONNID id, const char* query);
TSocketClient();
virtual ~TSocketClient();

View File

@ -1,4 +1,3 @@
#define NO_MFC
#include "NetUtils.h"
TLanManager::TLanManager()
@ -9,72 +8,55 @@ TLanManager::~TLanManager()
RemoveAllConnections();
}
TConnection* TLanManager::OnCreateConnection(DWORD id)
TConnection* TLanManager::OnCreateConnection(CONNID id)
{
return new TConnection(this, id);
}
BOOL TLanManager::HasConnections() const
bool TLanManager::HasConnections() const
{
#ifdef NO_MFC
return m_mapConn.items() > 0;
#else
return m_mapConn.GetCount() > 0;
#endif
}
BOOL TLanManager::Request(DWORD id, const char* cmd)
bool TLanManager::Request(CONNID id, const char* cmd)
{
TConnection* conn = GetConnection(id) ;
return conn ? conn->Request(cmd) : FALSE;
}
BOOL TLanManager::Execute(DWORD id, const char* cmd)
bool TLanManager::Execute(CONNID id, const char* cmd)
{
TConnection* conn = GetConnection(id) ;
return conn ? conn->Execute(cmd) : FALSE;
}
// Physically disconnect
BOOL TLanManager::OnRemoveConnection(DWORD id)
bool TLanManager::OnRemoveConnection(CONNID id)
{
return id != NULL;
return TRUE;
}
DWORD TLanManager::AddConnection(TConnection* pConn)
CONNID TLanManager::AddConnection(TConnection* pConn)
{
DWORD id = 0;
CONNID id = 0;
if (pConn)
{
id = pConn->Id();
#ifdef NO_MFC
TString16 key; key.format("%lu", id);
m_mapConn.add(key, pConn, TRUE);
#else
TConnection* c;
BOOL ok = m_mapConn.Lookup(id, c);
if (ok)
delete c;
m_mapConn.SetAt(id, pConn);
#endif
}
return id;
}
BOOL TLanManager::RemoveConnection(DWORD id)
bool TLanManager::RemoveConnection(CONNID id)
{
TConnection* pConn = GetConnection(id);
BOOL ok = FALSE;
if (pConn != NULL && OnRemoveConnection(id))
{
#ifdef NO_MFC
TConnection* pConn = GetConnection(id);
bool ok = FALSE;
if (pConn != NULL && OnRemoveConnection(id))
{
TString16 key; key.format("%lu", id);
m_mapConn.remove(key);
#else
delete pConn;
VERIFY(m_mapConn.RemoveKey(id));
#endif
ok = TRUE;
}
@ -83,36 +65,17 @@ BOOL TLanManager::RemoveConnection(DWORD id)
void TLanManager::RemoveAllConnections()
{
TConnection* pConn;
#ifdef NO_MFC
m_mapConn.restart();
for (pConn = (TConnection*)m_mapConn.get(); pConn; pConn = (TConnection*)m_mapConn.get())
for (TConnection* pConn = (TConnection*)m_mapConn.get();
pConn != NULL; pConn = (TConnection*)m_mapConn.get())
OnRemoveConnection(pConn->Id());
m_mapConn.destroy();
#else
for (POSITION pos = m_mapConn.GetStartPosition(); pos != NULL;)
{
DWORD key;
m_mapConn.GetNextAssoc(pos, key, pConn);
{
OnRemoveConnection(pConn->Id());
delete pConn;
}
}
m_mapConn.RemoveAll();
#endif
}
TConnection* TLanManager::GetConnection(DWORD id) const
TConnection* TLanManager::GetConnection(CONNID id) const
{
TConnection* pConn = NULL;
#ifdef NO_MFC
TString16 key; key.format("%lu", id);
pConn = (TConnection*)m_mapConn.objptr(key);
#else
m_mapConn.Lookup(id, pConn);
#endif
TConnection* pConn = (TConnection*)m_mapConn.objptr(key);
return pConn;
}
@ -121,20 +84,11 @@ int TLanManager::ForEachConnection(ConnectionFunction f, void* pJolly)
int result = 0;
TConnection* pConn;
#ifdef NO_MFC
m_mapConn.restart();
for (pConn = (TConnection*)m_mapConn.get();
pConn != NULL;
pConn = (TConnection*)m_mapConn.get())
result += f(*pConn, pJolly);
#else
DWORD key;
for (POSITION pos = m_mapConn.GetStartPosition(); pos != NULL; )
{
m_mapConn.GetNextAssoc(pos, key, pConn);
result += f(*pConn, pJolly);
}
#endif
return result;
}
@ -143,96 +97,89 @@ int TLanManager::ForEachConnection(ConnectionFunction f, void* pJolly)
// TLanServer
///////////////////////////////////////////////////////////
BYTE* TLanServer::GetBufferSetString(const char* str)
byte* TLanServer::GetBufferSetString(const char* str)
{
if (str == NULL)
str = "";
const size_t dwSize = strlen(str)+1;
BYTE* buff = GetBuffer(dwSize);
byte* buff = GetBuffer(dwSize);
memcpy(buff, str, dwSize);
return buff;
}
BYTE* TLanServer::GetBufferSetBool(BOOL n)
byte* TLanServer::GetBufferSetBool(bool n)
{
const size_t dwSize = sizeof(DWORD);
BYTE* buff = GetBuffer(dwSize);
*(DWORD*)buff = n ? -1 : 0;
const size_t dwSize = sizeof(size_t);
byte* buff = GetBuffer(dwSize);
*(size_t*)buff = n ? -1 : 0;
return buff;
}
BYTE* TLanServer::GetBufferSetInteger(long n)
byte* TLanServer::GetBufferSetInteger(long n)
{
const size_t dwSize = sizeof(DWORD);
BYTE* buff = GetBuffer(dwSize);
*(DWORD*)buff = n;
const size_t dwSize = sizeof(size_t);
byte* buff = GetBuffer(dwSize);
*(size_t*)buff = n;
return buff;
}
///////////////////////////////////////////////////////////
// TLanClient
///////////////////////////////////////////////////////////
DWORD TLanClient::QueryConnection(const char* service,
const char* server)
CONNID TLanClient::QueryConnection(const char* service, const char* server)
{
TConnection* pConn = OnQueryConnection(service, server);
return AddConnection(pConn) ;
}
BOOL TLanClient::Execute(DWORD id, const char* cmd)
bool TLanClient::Execute(CONNID id, const char* cmd)
{
return FALSE;
TConnection* pConn = GetConnection(id);
return pConn ? pConn->Execute(cmd) : FALSE;
}
BOOL TLanClient::Request(DWORD id, const char* cmd)
bool TLanClient::Request(CONNID id, const char* cmd)
{
return FALSE;
TConnection* pConn = GetConnection(id);
return pConn ? pConn->Request(cmd) : FALSE;
}
BOOL TLanClient::RequestString(DWORD id, const char* cmd, CString& res)
bool TLanClient::RequestString(CONNID id, const char* cmd, TString& res)
{
BOOL valid = Request(id, cmd);
bool valid = Request(id, cmd);
if (valid)
{
DWORD dwSize;
BYTE* pData = GetBuffer(dwSize);
#ifdef NO_MFC
size_t dwSize;
byte* pData = GetBuffer(dwSize);
char* ptr = res.get_buffer((int)dwSize);
memcpy(ptr, pData, (size_t)dwSize);
#else
char* ptr = res.GetBuffer((int)dwSize);
memcpy(ptr, pData, dwSize);
res.ReleaseBuffer();
#endif
ReleaseBuffer();
}
return valid;
}
BOOL TLanClient::RequestInteger(DWORD id, const char* cmd, long& num)
bool TLanClient::RequestInteger(CONNID id, const char* cmd, long& num)
{
BOOL valid = Request(id, cmd);
bool valid = Request(id, cmd);
if (valid)
{
DWORD dwSize;
BYTE* pData = GetBuffer(dwSize);
size_t dwSize;
byte* pData = GetBuffer(dwSize);
num = *(long*)pData;
ReleaseBuffer();
}
return valid;
}
BOOL TLanClient::RequestBool(DWORD id, const char* cmd, BOOL& ok)
bool TLanClient::RequestBool(CONNID id, const char* cmd, bool& ok)
{
BOOL valid = Request(id, cmd);
bool valid = Request(id, cmd);
if (valid)
{
DWORD dwSize;
BYTE* pData = GetBuffer(dwSize);
ok = *(DWORD*)pData != 0;
size_t dwSize;
byte* pData = GetBuffer(dwSize);
ok = *(size_t*)pData != 0;
ReleaseBuffer();
}
return valid;
@ -242,7 +189,7 @@ BOOL TLanClient::RequestBool(DWORD id, const char* cmd, BOOL& ok)
// TConnection
///////////////////////////////////////////////////////////
TConnection::TConnection(TLanManager* pManager, DWORD id)
TConnection::TConnection(TLanManager* pManager, CONNID id)
: m_pManager(pManager), m_dwId(id)
{
}
@ -253,25 +200,17 @@ TConnection::~TConnection()
TLanServer& TConnection::Server() const
{
#ifdef NO_MFC
CHECK(Manager().IsServer(), "Can't cast client to server");
#else
ASSERT(Manager().IsServer());
#endif
return (TLanServer&)Manager();
return (TLanServer&)Manager();
}
int TConnection::ParseCommand(const char* cmd, CStringArray& argv)
int TConnection::ParseCommand(const char* cmd, TString_array& argv)
{
#ifdef NO_MFC
argv.destroy();
#else
argv.RemoveAll();
#endif
BOOL is_quoted = FALSE;
bool is_quoted = FALSE;
char end_quote = '\0';
CString token;
TString token;
const char* token_start = NULL;
for (char* c = (char*)cmd; *c; c++)
@ -302,27 +241,19 @@ int TConnection::ParseCommand(const char* cmd, CStringArray& argv)
*c = '\0';
token = token_start;
*c = old;
#ifdef NO_MFC
token.rtrim();
#else
token.TrimRight();
#endif
}
}
#ifdef NO_MFC
argv.add(token);
#else
argv.Add(token);
#endif
token_start = NULL;
token = "";
is_quoted = FALSE;
continue;
}
if (*c == '"' || *c == '\'' || *c == '|' || BYTE(*c) >= 254)
if (*c == '"' || *c == '\'' || *c == '|' || byte(*c) >= 254)
{
end_quote = *c;
token_start = c+1;
@ -334,22 +265,18 @@ int TConnection::ParseCommand(const char* cmd, CStringArray& argv)
}
}
#ifdef NO_MFC
return argv.items();
#else
return argv.GetSize();
#endif
}
BOOL TConnection::Execute(const char* cmd)
bool TConnection::Execute(const char* cmd)
{
CStringArray argv;
TString_array argv;
return ParseCommand(cmd, argv) > 0;
}
BOOL TConnection::Request(const char* cmd)
bool TConnection::Request(const char* cmd)
{
CStringArray argv;
TString_array argv;
return ParseCommand(cmd, argv) > 0;
}

View File

@ -1,48 +1,37 @@
#ifndef __NETUTILS_H__
#define __NETUTILS_H__
#ifdef NO_MFC
#define BOOL int
#define BYTE unsigned char
#define DWORD unsigned long
#define CObject TObject
#define CString TString
#define CStringArray TString_array
#include "assoc.h"
#endif
class TConnection;
typedef unsigned long CONNID;
typedef int (*ConnectionFunction)(TConnection& conn, void* pJolly);
class TLanManager : public CObject
class TLanManager : public TObject
{
#ifdef NO_MFC
TAssoc_array m_mapConn;
#else
CMap<DWORD, DWORD, TConnection*, TConnection*> m_mapConn;
#endif
protected:
DWORD AddConnection(TConnection* pConn);
CONNID AddConnection(TConnection* pConn);
virtual TConnection* OnCreateConnection(DWORD id);
virtual BOOL OnRemoveConnection(DWORD id);
virtual TConnection* OnCreateConnection(CONNID id);
virtual bool OnRemoveConnection(CONNID id);
public:
virtual BOOL IsServer() const { return FALSE; }
virtual BOOL IsClient() const { return FALSE; }
virtual BOOL IsOk() const { return FALSE; }
virtual bool IsServer() const { return FALSE; }
virtual bool IsClient() const { return FALSE; }
virtual bool IsOk() const { return FALSE; }
virtual BOOL Execute(DWORD id, const char* cmd);
virtual BOOL Request(DWORD id, const char* cmd);
virtual bool Execute(CONNID id, const char* cmd);
virtual bool Request(CONNID id, const char* cmd);
int ForEachConnection(ConnectionFunction f, void* pJolly);
BOOL HasConnections() const;
TConnection* GetConnection(DWORD id) const;
bool HasConnections() const;
TConnection* GetConnection(CONNID id) const;
BOOL RemoveConnection(DWORD id);
bool RemoveConnection(CONNID id);
void RemoveAllConnections();
TLanManager();
@ -51,17 +40,17 @@ public:
class TLanServer : public TLanManager
{
CString m_strName;
TString m_strName;
public:
const CString& Name() const { return m_strName; }
const TString& Name() const { return m_strName; }
virtual BOOL IsServer() const { return TRUE; }
virtual bool IsServer() const { return TRUE; }
virtual BYTE* GetBuffer(DWORD dwSize) = 0;
BYTE* GetBufferSetString(const char* str);
BYTE* GetBufferSetBool(BOOL ok);
BYTE* GetBufferSetInteger(long n);
virtual byte* GetBuffer(unsigned int dwSize) pure;
byte* GetBufferSetString(const char* str);
byte* GetBufferSetBool(bool ok);
byte* GetBufferSetInteger(long n);
TLanServer(const char* name) : m_strName(name) { }
virtual ~TLanServer() { }
@ -70,46 +59,46 @@ public:
class TLanClient : public TLanManager
{
protected:
virtual TConnection* OnQueryConnection(const char* service,
const char* server) = 0;
public:
virtual BOOL IsClient() const { return TRUE; }
DWORD QueryConnection(const char* service,
const char* server = NULL);
virtual TConnection* OnQueryConnection(const char* service, const char* server) pure;
virtual BOOL Execute(DWORD id, const char* cmd);
virtual BOOL Request(DWORD id, const char* cmd);
virtual BYTE* GetBuffer(DWORD& dwSize) = 0;
public:
virtual bool IsClient() const { return TRUE; }
CONNID QueryConnection(const char* service, const char* server = NULL);
virtual bool Execute(CONNID id, const char* cmd);
virtual bool Request(CONNID id, const char* cmd);
virtual byte* GetBuffer(unsigned int& dwSize) = 0;
virtual void ReleaseBuffer() = 0;
BOOL RequestString(DWORD id, const char* cmd, CString& res);
BOOL RequestInteger(DWORD id, const char* cmd, long& num);
BOOL RequestBool(DWORD id, const char* cmd, BOOL& ok);
bool RequestString(CONNID id, const char* cmd, TString& res);
bool RequestInteger(CONNID id, const char* cmd, long& num);
bool RequestBool(CONNID id, const char* cmd, bool& ok);
};
class TConnection : public CObject
class TConnection : public TObject
{
TLanManager* m_pManager;
DWORD m_dwId;
CONNID m_dwId;
protected:
int ParseCommand(const char* cmd, CStringArray& argv);
int ParseCommand(const char* cmd, TString_array& argv);
void SetId(CONNID id) { m_dwId = id; } // Internal use only
public:
DWORD Id() const { return m_dwId; }
CONNID Id() const { return m_dwId; }
TLanManager& Manager() const { return *m_pManager; }
TLanServer& Server() const;
virtual BOOL Execute(const char* cmd);
virtual BOOL Request(const char* cmd);
virtual bool Execute(const char* cmd);
virtual bool Request(const char* cmd);
BOOL ReturnBool(int b) const { return Server().GetBufferSetBool(b) != NULL; }
BOOL ReturnInteger(long n) const { return Server().GetBufferSetInteger(n) != NULL; }
BOOL ReturnString(const CString& s) const { return Server().GetBufferSetString(s) != NULL; }
bool ReturnBool(bool b) const { return Server().GetBufferSetBool(b) != NULL; }
bool ReturnInteger(long n) const { return Server().GetBufferSetInteger(n) != NULL; }
bool ReturnString(const TString& s) const { return Server().GetBufferSetString(s) != NULL; }
TConnection(TLanManager* lm, DWORD id);
TConnection(TLanManager* lm, CONNID id);
virtual ~TConnection();
};

View File

@ -881,14 +881,9 @@ void TPrinter::init_formlen(
_formwidth=(mincol+maxcol)/2;
}
if (isfax())
_horz_offset = 56;
else
{
_horz_offset = (_formwidth > 80) ? (int)(pw - w)/2 : 0;
if (_horz_offset < 0)
_horz_offset = 0;
}
_horz_offset = (_formwidth > 80) ? (int)(pw - w)/2 : 0;
if (_horz_offset < 0)
_horz_offset = 0;
}
else
{
@ -1018,19 +1013,6 @@ TPrinter::TPrinter()
_finker = _isgraphics && _fink_mode ? NULL : new TPrint_intersector(_fink, _formlen);
}
bool TPrinter::isfax() const
{
bool fax = FALSE;
#ifndef XVAGA
if (_printertype == winprinter)
{
const char* name = (const char*)((TPrinter*)this)->get_printrcd() + 4;
fax = strncmp(name, "FaxMan", 6) == 0;
}
#endif
return fax;
}
// @doc EXTERNAL
// @mfunc Legge la configurazione della stampante
@ -1532,9 +1514,6 @@ bool TPrinter::open()
// prepare text object for new text
_txt.destroy();
_txt.interactive(FALSE);
if (isfax())
start_fax_server();
}
}
@ -2007,39 +1986,3 @@ int TPrinter::calc_num_cols() const
return numcols;
}
///////////////////////////////////////////////////////////
// Gestione fax
///////////////////////////////////////////////////////////
bool TPrinter::start_fax_server() const
{
TDDE dde;
return dde.execute("EASYFAX", "FAX", "", "bafax");
}
void TPrinter::close_fax_server() const
{
TDDE dde;
const bool running = dde.initiate("EASYFAX", "FAX");
if (running)
dde.execute("[FileClose]");
}
bool TPrinter::send_fax(const char* tipo, const char* codice)
{
bool ok = isopen() && isfax();
if (ok)
{
if (tipo && codice)
{
TString cmd;
cmd << "[SetRecipient(" << tipo << ',' << codice << ")]";
TDDE dde;
dde.execute("EASYFAX", "FAX", cmd, "bafax");
}
close(); // termina la stampa corrente e la spedisce
open(); // riapre la stampante
}
return ok;
}

View File

@ -324,9 +324,6 @@ protected:
// @cmember Salva i parametri di configurazione correnti
void save_configuration();
// @cmember Chiude il fax server
void close_fax_server() const;
// @access Public Member
public:
@ -598,12 +595,6 @@ public:
void set_offset(int a, int b) { _l_offset=a; _c_offset=b;}
// @cmember ritorna la riga di background se si stampa in modo testo
const char* background_chars(int l) const;
// @cmember Ritorna TRUE se la stampante e' un fax
bool isfax() const;
// @cmember Lancia il fax server
bool start_fax_server() const;
// @cmember Spedisce la stampa attuale via fax
bool send_fax(const char* tipo, const char* codice);
// @cmember Ritorna la dimensione dei caratteri da stampare
int get_char_size() const

View File

@ -30,7 +30,8 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
: _text(NULL), _cancel(NULL), _bar(0),
_status(0L), _max(max), _flags(0x0)
{
if (_max <= 0) _max = 1;
if (_max <= 0)
_max = 1;
TToken_string testo(txt, '\n');
word maxlen = div;

View File

@ -1654,6 +1654,7 @@ bool TRelation_application::load_transaction()
error_box("Ditta inesistente: %ld", firm);
}
if (_curr_transaction == TRANSACTION_RUN)
@ -1889,4 +1890,3 @@ bool TRelation_application::mask2mail(const TMask& m)
}
return ok;
}

View File

@ -4,6 +4,7 @@
#include <colors.h>
#include <config.h>
#include <controls.h>
#include <diction.h>
#include <relation.h>
#include <sheet.h>
#include <urldefid.h>
@ -985,18 +986,18 @@ TSheet::TSheet(short x, short y, short dx, short dy,
fields_array().add(qf);
_sheet = qf->sheet();
if (!(buttons & 0x10)) add_button(DLG_SELECT, "~Selezione", K_ENTER);
if (!(buttons & 0x10)) add_button(DLG_SELECT, TR("~Selezione"), K_ENTER);
if (check_enabled())
{
add_button(DLG_USER, "~Tutti", 0);
add_button(DLG_USER, TR("~Tutti"), 0);
set_handler(DLG_USER, tutti_handler);
}
if (buttons & 0x01) add_button(DLG_LINK, "~Gestione", K_CTRL+'G');
if (buttons & 0x02) add_button(DLG_NEWREC, "~Nuovo", K_INS, BMP_NEWREC, BMP_NEWRECDN);
if (buttons & 0x04) add_button(DLG_DELREC, "~Elimina", K_DEL, BMP_DELREC, BMP_DELRECDN);
if (buttons & 0x08) add_button(DLG_QUIT, "Fine", K_ESC);
else add_button(DLG_CANCEL, "Annulla", K_ESC);
if (buttons & 0x01) add_button(DLG_LINK, TR("~Gestione"), K_CTRL+'G');
if (buttons & 0x02) add_button(DLG_NEWREC, TR("~Nuovo"), K_INS, BMP_NEWREC, BMP_NEWRECDN);
if (buttons & 0x04) add_button(DLG_DELREC, "", K_DEL);
if (buttons & 0x08) add_button(DLG_QUIT, "", K_ESC);
else add_button(DLG_CANCEL, "", K_ESC);
}
TSheet::~TSheet()
@ -1466,6 +1467,7 @@ void TBrowse_sheet::handler(
MENU_ITEM* menu = xvt_res_get_menu(BROWSE_BAR);
if (menu)
{
dictionary_translate_menu(menu);
const PNT& p = ep->v.mouse.where;
RCT cr; xvt_vobj_get_client_rect(win, &cr);
XVT_POPUP_ALIGNMENT pa = XVT_POPUP_CENTER;

View File

@ -630,6 +630,11 @@ int TString::compare(
return res;
}
bool TString::starts_with(const char* s, bool ignorecase) const
{
return compare(s, strlen(s), ignorecase) == 0;
}
// Certified 100%
// @doc EXTERNAL

View File

@ -258,6 +258,8 @@ public:
bool match(const char* pat) const;
// @cmember Compara due stringhe (o i primi max caratteri)
int compare(const char* s, int max = -1, bool ignorecase = FALSE) const;
// @cmember Controlla se la strinvga comincia per s
bool starts_with(const char* s, bool ignorecase = FALSE) const;
};
// @doc EXTERNAL

View File

@ -334,18 +334,14 @@ const char* itor(
// @func Permette di codificare i caratteri di escape
//
// @rdesc Ritorna il carattere codificato
const char *esc(
const char* s) // @parm Carattere da codificare
// @comm Viene utilizzata soprattuto in UNIX.
const char* esc(
const char* s) // @parm Stringa da codificare
{
const char *s1 = s;
char *s2 = __tmp_string;
int base;
if (s1)
while (*s1)
{
const char *s1 = s == NULL ? "" : s;
char* encoded = get_tmp_string().get_buffer(strlen(s));
char* s2 = encoded;
while (*s1)
{
if (*s1 == '\\')
{
s1++;
@ -359,48 +355,84 @@ const char *esc(
case 't' : *s2++ = '\t'; break;
default :
{
if (isdigit(*s1))
{
if (*s1 == '0')
{
s1++;
if (tolower(*s1) == 'x')
{
s1++;
base = 16;
}
else base = 8;
}
else base = 10;
*s2 = 0;
char c = tolower(*s1);
while (isdigit(c) || (base == 16 && c >= 'a' && c <= 'f'))
{
*s2 *= base;
if (isdigit(*s1)) *s2 += (*s1 - 48);
else *s2 += (*s1 - 'a' + 10) & 0x0F;
s1++;
c = tolower(*s1);
}
s2++; s1--;
}
else *s2++ = *s1;
}
}
}
else
if (*s1 == '^')
{
s1++;
*s2++ = (tolower(*s1) - 'a' + 1);
if (isdigit(*s1))
{
int base = 10;
if (*s1 == '0')
{
s1++;
if (tolower(*s1) == 'x')
{
s1++;
base = 16;
}
else
base = 8;
}
*s2 = 0;
char c = tolower(*s1);
while (isdigit(c) || (base == 16 && c >= 'a' && c <= 'f'))
{
*s2 *= base;
if (isdigit(*s1)) *s2 += (*s1 - 48);
else *s2 += (*s1 - 'a' + 10) & 0x0F;
s1++;
c = tolower(*s1);
}
s2++; s1--;
}
else *s2++ = *s1;
}
else *s2++ = *s1 ;
s1++;
}
}
else
if (*s1 == '^')
{
s1++;
*s2++ = (tolower(*s1) - 'a' + 1);
}
else *s2++ = *s1 ;
s1++;
}
*s2 = '\0';
return(__tmp_string);
return encoded;
}
const char* unesc(
const char* s) // @parm Stringa da decodificare
{
char *decoded = get_tmp_string().get_buffer(strlen(s)*4);
char* s2 = decoded;
for (const char *s1 = s; *s1; s1++)
{
const char& c = *s1;
if (c >= '\0' && c < ' ')
{
switch(c)
{
case '\n':
*s2++ = '\\'; *s2++ = 'n';
break;
case '\r':
*s2++ = '\\'; *s2++ = 'r';
break;
case '\t':
*s2++ = '\\'; *s2++ = 't';
break;
default:
*s2++ = '\\'; *s2++ = '0'; *s2++ = 'x';
sprintf(s2, "%02x", int(c)); s2 += 2;
break;
}
}
else
*s2++ = c;
}
*s2 = '\0';
return decoded;
}
HIDDEN const char * const encryption_key = "QSECOFR-";
// @doc EXTERNAL

View File

@ -35,7 +35,8 @@ inline bool is_not_slash(
char s) // @parm Carattere da confrontare
{ return s != '\\' && s != '/'; }
const char* esc(const char*);
const char* esc(const char* str); // Trasforma le sequenze "\n" nel carattere '\n'
const char* unesc(const char* str); // Trasforma i caratteri '\n' nella sequenza "\n"
#define ODD(x) (x & 1)
#define EVEN(x) !(x & 1)

View File

@ -1749,12 +1749,6 @@ int TStampaEC_application::print_ec(TEC_Game_list* games)
{
f.ultima_pagina();
printer().formfeed();
if (printer().isfax())
{
const char* tipo = clf.get_char(CLI_TIPOCF) == 'C' ? "Clienti" : "Fornitori";
const char* codice = clf.get(CLI_CODCF);
printer().send_fax(tipo, codice);
}
}
else
update_numec(clf, -1);

View File

@ -186,13 +186,7 @@ int TStampaSol_application::print_sol()
if (one_printed)
{
f.ultima_pagina();
printer().formfeed();
if (printer().isfax())
{
const char* tipo = clf.get_char(CLI_TIPOCF) ? "Clienti" : "Fornitori";
const char* codice = clf.get(CLI_CODCF);
printer().send_fax(tipo, codice);
}
printer().formfeed();
}
return one_printed ? 1 : 0;

View File

@ -1,12 +1,19 @@
#include "wx/wx.h"
#include "wx/wfstream.h"
#include "wx/protocol/http.h"
#include <wx/wx.h>
#include <wx/wfstream.h>
#include <wx/socket.h>
#include <wx/config.h>
#include <wx/msw/iniconf.h>
#include <ctype.h>
#include "Soap.h"
#include "Diction.h"
//////////////////////////////////////////////////////////
// TDictionaryEntry
///////////////////////////////////////////////////////////
class TDictionaryEntry : public wxObject
{
public:
@ -14,6 +21,21 @@ public:
TDictionaryEntry(const wxChar* str) : m_str(str) { }
};
//////////////////////////////////////////////////////////
// Sorted array of TDictionaryEntry
///////////////////////////////////////////////////////////
static int CompareNodes(wxNode** n1, wxNode** n2)
{
return strcmp((*n1)->GetKeyString(), (*n2)->GetKeyString());
}
WX_DEFINE_ARRAY(wxNode*, TArrayOfNodes);
//////////////////////////////////////////////////////////
// TDictionary
///////////////////////////////////////////////////////////
class TDictionary : public wxHashTable
{
bool m_bDirty;
@ -21,18 +43,27 @@ class TDictionary : public wxHashTable
protected:
wxString Accentuate(const wxString& str) const;
const TDictionaryEntry* AddEntry(const wxString& ita, const wxChar* eng);
wxString GetFileName() const;
static bool FillCallback(TXmlItem& item, long jolly);
bool Load();
public:
wxString Translate(const wxString& ita);
wxString Translate(const wxString& ita, const wxString& lan);
TDictionary();
~TDictionary();
};
static TDictionary DevotoOli;
wxString TDictionary::GetFileName() const
{
wxIniConfig ini("", "", "./server.ini");
ini.SetPath("/Dictionary");
wxString fname = ini.Read("FileName", "campo.dic");
return fname;
}
wxString TDictionary::Accentuate(const wxString& str) const
{
const int pos = str.Find('\'');
@ -114,7 +145,7 @@ bool TDictionary::FillCallback(TXmlItem& item, long jolly)
bool TDictionary::Load()
{
wxFileInputStream inf("Campo.dic");
wxFileInputStream inf(GetFileName());
if (inf.Ok())
{
TXmlItem item;
@ -126,7 +157,7 @@ bool TDictionary::Load()
return GetCount() > 0;
}
wxString TDictionary::Translate(const wxString& ita)
wxString TDictionary::Translate(const wxString& ita, const wxString& lan)
{
if (GetCount() == 0)
Load();
@ -153,11 +184,18 @@ TDictionary::~TDictionary()
if (m_bDirty)
{
wxFileOutputStream outf("Campo.dic");
outf << "<xml><dictionary>\n";
// Fill an array of nodes and sort them out
TArrayOfNodes arr;
BeginFind();
for (wxNode* pNode = Next(); pNode != NULL; pNode = Next())
arr.Add(pNode);
arr.Sort(CompareNodes);
wxFileOutputStream outf(GetFileName());
outf << "<xml><dictionary>\n";
for (size_t i = 0; i < arr.GetCount(); i++)
{
const wxNode* pNode = arr[i];
outf << " <entry>\n";
outf << " <ita>" << pNode->GetKeyString() << "</ita>\n";
outf << " <eng>" << ((TDictionaryEntry*)pNode->GetData())->m_str << "</eng>\n";
@ -170,15 +208,14 @@ TDictionary::~TDictionary()
bool DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer)
{
const TXmlItem* xmlSentence = xmlMethod.FindFirst("sentence");
if (xmlSentence != NULL)
// const TXmlItem* xmlLanguage = xmlMethod.FindFirst("language");
if (xmlSentence != NULL /* && xmlLanguage != NULL */)
{
const TXmlItem* xmlItalian = xmlSentence->GetChild(0);
if (xmlItalian != NULL)
{
wxString result = DevotoOli.Translate(xmlItalian->GetText());
xmlAnswer.AddSoapString("sentence", result);
return true;
}
const wxString ita = xmlSentence->GetEnclosedText();
const wxString lan; // = xmlLanguage->GetEnclosedText();
wxString result = DevotoOli.Translate(ita, lan);
xmlAnswer.AddSoapString("sentence", result);
return true;
}
return false;
}

View File

@ -16,9 +16,12 @@
// headers
// --------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wx.h"
#include "wx/socket.h"
#include <wx/wx.h>
#include <wx/socket.h>
#include <wx/config.h>
#include <wx/msw/iniconf.h>
#include "soap.h"
@ -36,16 +39,22 @@ public:
// Define a new frame type: this is going to be our main frame
class SoapFrame : public wxFrame
{
clock_t m_last_text;
public:
SoapFrame();
~SoapFrame();
// event handlers (these functions should _not_ be virtual)
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnServerEvent(wxSocketEvent& event);
void OnSocketEvent(wxSocketEvent& event);
// Roba mia
void AppendText(const wxChar* str);
int GetDefaultPort() const;
void ProcessSoapCommand(wxSocketBase *sock);
// convenience functions
@ -118,51 +127,77 @@ bool SoapServerApp::OnInit()
// main frame
// --------------------------------------------------------------------------
int SoapFrame::GetDefaultPort() const
{
int nPort = 3883;
wxIniConfig ini("", "", "./campo.ini");
ini.SetPath("/Server");
const wxString str = ini.Read("Dictionary", "");
const int colon = str.Find(':');
if (colon > 0)
nPort = atoi(str.Mid(colon+1));
return nPort;
}
void SoapFrame::AppendText(const wxChar* str)
{
const clock_t now = clock();
if (now - m_last_text > 60000)
m_text->SetValue(str);
else
m_text->AppendText(str);
m_last_text = now;
}
// frame constructor
SoapFrame::SoapFrame() : wxFrame((wxFrame *)NULL, -1,
_("Soap Server"),
wxDefaultPosition, wxSize(300, 200))
SoapFrame::SoapFrame() : wxFrame((wxFrame *)NULL, -1, "Soap Server",
wxDefaultPosition, wxSize(300, 300))
{
// Give the frame an icon
SetIcon(wxICON(mondrian));
// Make menus
m_menuFile = new wxMenu();
m_menuFile->Append(SERVER_ABOUT, _("&About...\tCtrl-A"), _("Show about dialog"));
m_menuFile->Append(SERVER_ABOUT, "&About...\tCtrl-A", "Show about dialog");
m_menuFile->AppendSeparator();
m_menuFile->Append(SERVER_QUIT, _("E&xit\tAlt-X"), _("Quit server"));
m_menuFile->Append(SERVER_QUIT, "E&xit\tAlt-X", "Quit server");
// Append menus to the menubar
m_menuBar = new wxMenuBar();
m_menuBar->Append(m_menuFile, _("&File"));
m_menuBar->Append(m_menuFile, "&File");
SetMenuBar(m_menuBar);
// Make a textctrl for logging
m_text = new wxTextCtrl(this, -1,
"Welcome to SOAP Server\n",
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_READONLY);
// Status bar
CreateStatusBar(2);
// Make a textctrl for logging
m_text = new wxTextCtrl(this, -1,
_("Welcome to SOAP Server\n"),
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_READONLY);
// Create the address - defaults to localhost:0 initially
wxIPV4address addr;
addr.Service(3000);
addr.Service(GetDefaultPort());
// Create the socket
m_server = new wxSocketServer(addr);
m_last_text = clock();
// We use Ok() here to see if the server is really listening
if (! m_server->Ok())
{
m_text->AppendText(_("Could not listen at the specified port !\n\n"));
wxString str;
str << "Could not listen to port " << addr.Service() << "\n\n";
AppendText(str);
return;
}
else
{
m_text->AppendText(_("Server listening.\n\n"));
wxString str;
str << "Server listening on port " << addr.Service() << "\n\n";
AppendText(str);
}
// Setup the event handler and subscribe to connection events
@ -191,45 +226,41 @@ void SoapFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
void SoapFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox(_("Soap Server\n(c) 2002 by Aga\n"),
_("About Soap Server"),
wxMessageBox("Soap Server\n(c) 2002 by Aga\n",
"About Soap Server",
wxOK | wxICON_INFORMATION, this);
}
void SoapFrame::ProcessSoapCommand(wxSocketBase *sock)
{
m_text->SetValue(_("Processing begins\n\n"));
sock->SetFlags(wxSOCKET_NOWAIT);
// Read the data
char buf[4096]; memset(buf, 0, sizeof(buf));
wxChar buf[4096]; memset(buf, 0, sizeof(buf));
unsigned int len = sock->Read(buf, sizeof(buf)).LastCount();
m_text->AppendText(_(buf));
AppendText(buf);
wxString strAnswer = SoapProcessMessage(buf, len);
m_text->AppendText(_("\nSending response\n\n"));
m_text->AppendText(_(strAnswer));
AppendText("\n\n");
AppendText(strAnswer);
// Write it back
sock->Write(strAnswer, strAnswer.Length());
m_text->AppendText(_("\n\nProcessing ends\n\n"));
}
void SoapFrame::OnServerEvent(wxSocketEvent& event)
{
wxString s = _("OnServerEvent: ");
wxString s = "OnServerEvent: ";
wxSocketBase *sock;
switch(event.GetSocketEvent())
{
case wxSOCKET_CONNECTION : s.Append(_("wxSOCKET_CONNECTION\n")); break;
default : s.Append(_("Unexpected event !\n")); break;
case wxSOCKET_CONNECTION : s.Append("wxSOCKET_CONNECTION\n"); break;
default : s.Append("Unexpected event !\n"); break;
}
m_text->AppendText(s);
AppendText(s);
// Accept new connection if there is one in the pending
// connections queue, else exit. We use Accept(FALSE) for
@ -240,11 +271,11 @@ void SoapFrame::OnServerEvent(wxSocketEvent& event)
if (sock)
{
m_text->AppendText(_("New client connection accepted\n\n"));
AppendText("New client connection accepted\n\n");
}
else
{
m_text->AppendText(_("Error: couldn't accept a new connection\n\n"));
AppendText("Error: couldn't accept a new connection\n\n");
sock->Destroy();
return;
}
@ -259,18 +290,18 @@ void SoapFrame::OnServerEvent(wxSocketEvent& event)
void SoapFrame::OnSocketEvent(wxSocketEvent& event)
{
wxString s = _("OnSocketEvent: ");
wxString s = "OnSocketEvent: ";
wxSocketBase *sock = event.GetSocket();
// First, print a message
switch(event.GetSocketEvent())
{
case wxSOCKET_INPUT : s.Append(_("wxSOCKET_INPUT\n")); break;
case wxSOCKET_LOST : s.Append(_("wxSOCKET_LOST\n")); break;
default : s.Append(_("Unexpected event !\n")); break;
case wxSOCKET_INPUT : s.Append("wxSOCKET_INPUT\n"); break;
case wxSOCKET_LOST : s.Append("wxSOCKET_LOST\n"); break;
default : s.Append("Unexpected event !\n"); break;
}
m_text->AppendText(s);
AppendText(s);
// Now we process the event
switch(event.GetSocketEvent())
@ -300,7 +331,7 @@ void SoapFrame::OnSocketEvent(wxSocketEvent& event)
// middle of a test or something. Destroy() takes care of all
// this for us.
m_text->AppendText(_("Deleting socket.\n\n"));
AppendText("Deleting socket.\n\n");
sock->Destroy();
break;
}
@ -315,6 +346,6 @@ void SoapFrame::OnSocketEvent(wxSocketEvent& event)
void SoapFrame::UpdateStatusBar()
{
wxString s;
s.Printf(_("%d clients connected"), m_numClients);
s.Printf("%d clients connected", m_numClients);
SetStatusText(s, 1);
}

View File

@ -236,18 +236,20 @@ TXmlItem& TXmlItem::AddChild(const wxChar* strTagName)
return i;
}
TXmlItem& TXmlItem::AddSoapString(const wxChar* name, const wxChar* value)
TXmlItem& TXmlItem::AddSoapString(const wxChar* name, const wxChar* value, bool typized)
{
TXmlItem& xmlVar = AddChild(name);
xmlVar.SetAttr("xsi:type", "xsd:string");
if (typized)
xmlVar.SetAttr("xsi:type", "xsd:string");
xmlVar.AddChild("").SetText(value);
return xmlVar;
}
TXmlItem& TXmlItem::AddSoapInt(const wxChar* name, int value)
TXmlItem& TXmlItem::AddSoapInt(const wxChar* name, int value, bool typized)
{
TXmlItem& xmlVar = AddChild(name);
xmlVar.SetAttr("xsi:type", "xsd:int");
if (typized)
xmlVar.SetAttr("xsi:type", "xsd:int");
wxString str; str += value;
xmlVar.AddChild("").SetText(str);
return xmlVar;
@ -302,6 +304,26 @@ TXmlItem* TXmlItem::ForEach(XmlItemCallback cb, long jolly)
return NULL;
}
static bool GetEnclosedTextCallback(TXmlItem& item, long jolly)
{
wxString* strText = (wxString*)jolly;
const wxString& str = item.GetText();
if (!str.IsEmpty())
{
if (!strText->IsEmpty())
*strText << " ";
*strText << str;
}
return false;
}
wxString TXmlItem::GetEnclosedText() const
{
wxString text;
((TXmlItem*)this)->ForEach(GetEnclosedTextCallback, (long)&text);
return text;
}
void TXmlItem::Write(wxOutputStream& outf, int tab) const
{
if (!GetTag().IsEmpty())
@ -347,7 +369,6 @@ wxString TXmlItem::AsString() const
char* buf = str.GetWriteBuf(nSize);
memset(buf, 0, nSize);
wxMemoryOutputStream outf(buf, nSize);
// outf << "<?xml Version=\"1.0\" ?>"; // Non dovrebbe servire a nulla
Write(outf);
str.UngetWriteBuf();
if (buf[nSize-1] == '\0')
@ -357,7 +378,7 @@ wxString TXmlItem::AsString() const
return str;
}
bool FindFirstCallback(TXmlItem& item, long jolly)
static bool FindFirstCallback(TXmlItem& item, long jolly)
{
const wxChar* strTag = (const wxChar*)jolly;
return item.GetTag() == strTag;
@ -417,8 +438,7 @@ wxString SoapProcessMessage(const char* buf, unsigned int len)
break;
if (pxmlMethod->GetTag().StartsWith("m:"))
{
wxString str;
str = pxmlMethod->GetTag(); str += "Result";
wxString str = pxmlMethod->GetTag(); str += "Result";
TXmlItem& xmlAnswer = xmlBody.AddChild(str);
SoapProcessMethod(*pxmlMethod, xmlAnswer);
}
@ -433,10 +453,8 @@ wxString SoapProcessMessage(const char* buf, unsigned int len)
strAnswer += "Connection: close\n";
strAnswer += "Content-Length: "; strAnswer += strLength;
strAnswer += "\nContent-Type: text/xml; charset=utf-8\n";
strAnswer += "Date: ";
strAnswer += wxDateTime::Now().Format("%#c");
strAnswer += "\nServer: ";
strAnswer += wxGetHostName();
strAnswer += "Date: "; strAnswer += wxDateTime::Now().Format("%#c");
strAnswer += "\nServer: "; strAnswer += wxGetHostName();
strAnswer += "\r\n\r\n";
strAnswer += strResult;

View File

@ -28,13 +28,14 @@ public:
const wxString& GetText() const { return m_strText; }
void SetText(const wxChar* str) { m_strText = str; }
wxString GetEnclosedText() const;
void SetAttr(const wxChar* strAttr, const wxChar* strVal);
wxString GetAttr(const wxChar* strAttr) const;
TXmlItem& AddChild(const wxChar* strTag);
TXmlItem& AddSoapString(const wxChar* name, const wxChar* value);
TXmlItem& AddSoapInt(const wxChar* name, int value);
TXmlItem& AddSoapString(const wxChar* name, const wxChar* value, bool typized = false);
TXmlItem& AddSoapInt(const wxChar* name, int value, bool typized = false);
int GetChildren() const;
TXmlItem* GetChild(size_t n) const;

Binary file not shown.

View File

@ -1,38 +0,0 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: SoapServ - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "c:\temp\RSPA1C2.TMP" with contents
[
/nologo /MTd /W3 /Gm /GX /ZI /Od /I "\wx229\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FR"Debug/" /Fo"Debug/" /Fd"Debug/" /FD /c
"C:\U\GUY\R020200\SOAP\server.cpp"
]
Creating command line "cl.exe @c:\temp\RSPA1C2.TMP"
Creating temporary file "c:\temp\RSPA1C3.TMP" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib xpmd.lib pngd.lib zlibd.lib jpegd.lib tiffd.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/server.pdb" /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"Debug/server.exe" /pdbtype:sept /libpath:"/wx229/lib"
.\Debug\Diction.obj
.\Debug\server.obj
.\Debug\soap.obj
.\Debug\server.res
]
Creating command line "link.exe @c:\temp\RSPA1C3.TMP"
<h3>Output Window</h3>
Compiling...
server.cpp
Linking...
Creating command line "bscmake.exe /nologo /o"Debug/SoapServ.bsc" .\Debug\Diction.sbr .\Debug\server.sbr .\Debug\soap.sbr"
Creating browse info file...
<h3>Output Window</h3>
<h3>Results</h3>
server.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -193,7 +193,7 @@ bool TScontrino_mask::save_ini(KEY k)
bool TScontrino_mask::send_er400_data(bool extra)
{
TSheet_field& sheet = sfield(F_SHEET);
/* TSheet_field& sheet = sfield(F_SHEET);
const int rows = sheet.items();
if (rows <= 0)
return FALSE;
@ -277,7 +277,7 @@ bool TScontrino_mask::send_er400_data(bool extra)
cmd << m.get(101) << ']';
smart.execute(cmd);
smart.terminate();
smart.terminate();*/
return TRUE;
}

View File

@ -220,3 +220,12 @@ void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
}
}
void OsWin32_Beep(int severity)
{
switch (severity)
{
case 0: MessageBeep(MB_OK); break;
case 1: MessageBeep(MB_ICONEXCLAMATION); break;
default: MessageBeep(MB_ICONSTOP); break;
}
}

View File

@ -1,6 +1,9 @@
void OsWin32_Beep(int severity);
bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size);
void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal, unsigned int& nSize);
void* OsWin32_ConvertToNativePrinterInfo(void* data, unsigned int nSize);
void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
int xd, int yd, int wd, int hd, int xs, int ys, int ws, int hs);
int OsWin32_EnumerateFamilies(unsigned int hDC, char** families, int max_count);
int OsWin32_EnumerateSizes(unsigned int hDC, const char* name, long* sizes, short* scalable, int max_count);
void OsWin32_SetCaptionStyle(unsigned int handle, bool set);
@ -8,7 +11,5 @@ void* OsWin32_GetPrinterInfo(int& size, const char* printer);
void OsWin32_SetClippingRect(unsigned int hDC, int x, int y, int w, int h);
void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd,
unsigned int hSrc, int xs, int ys, int ws, int hs);
void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
int xd, int yd, int wd, int hd, int xs, int ys, int ws, int hs);
void OsWin32_UpdateWindow(unsigned int handle);

View File

@ -674,12 +674,22 @@ void TwxWindow::DoXvtEvent(EVENT& e)
void TwxWindow::OnChar(wxKeyEvent& event)
{
static bool bDot2Comma = FALSE;
static bool bSkipNextDotKey = FALSE;
EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_CHAR;
int k = event.GetKeyCode();
if (bSkipNextDotKey)
{
bSkipNextDotKey = FALSE;
if (k == '.')
{
event.Skip();
return;
}
}
switch (k)
{
case WXK_ALT:
@ -698,9 +708,9 @@ void TwxWindow::OnChar(wxKeyEvent& event)
return;
case WXK_NUMPAD_DECIMAL: // ??? Non arriva mai
case WXK_DECIMAL: // ??? Arriva sia '.' sia WXK_DECIMAL=340
event.Skip();
bDot2Comma = TRUE;
return;
k = ',';
bSkipNextDotKey = TRUE;
break;
case WXK_DOWN : k = K_DOWN; break;
case WXK_LEFT : k = K_LEFT; break;
case WXK_NEXT : k = K_NEXT; break;
@ -711,13 +721,6 @@ void TwxWindow::OnChar(wxKeyEvent& event)
if (event.ShiftDown())
k = K_BTAB;
break;
case '.':
if (bDot2Comma)
{
k = ',';
bDot2Comma = FALSE;
}
break;
default:
if (k >= WXK_F1 && k <= WXK_F24)
k = K_F1 + k - WXK_F1;
@ -782,6 +785,7 @@ void TwxWindow::OnMouseDown(wxMouseEvent& event)
e.v.mouse.button = event.RightDown() ? 1 : 0;
e.v.mouse.control = event.ControlDown();
e.v.mouse.shift = event.ShiftDown();
int x, y; event.GetPosition(&x, &y);
e.v.mouse.where.h = x;
e.v.mouse.where.v = y;
@ -1291,8 +1295,24 @@ void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check)
// Debug functions
///////////////////////////////////////////////////////////
void xvt_debug_printf(const char* fmt, const char* str)
{ SORRY_BOX(); }
void xvt_debug_printf(const char* fmt, ...)
{
#ifndef NDEBUG
static FILE* f = NULL;
if (f == NULL)
f = fopen("trace.log", "w");
if (f != NULL)
{
char msg[256];
va_list argptr;
va_start(argptr,fmt);
vsprintf(msg,fmt,argptr);
va_end(argptr);
fprintf(f, "%s\n", msg);
fflush(f);
}
#endif
}
///////////////////////////////////////////////////////////
// Common dialogs
@ -1310,7 +1330,7 @@ void xvt_dm_post_error(char *fmt)
void xvt_dm_post_fatal_exit(char *fmt)
{ wxLogFatalError(fmt); }
FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, char *msg)
FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, const char *msg)
{
const int flags = wxOPEN | wxHIDE_READONLY | wxFILE_MUST_EXIST;
wxString path = fsp->dir.path;
@ -1327,7 +1347,7 @@ FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, char *msg)
return FL_OK;
}
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, char *msg)
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, const char *msg)
{
const int flags = wxSAVE | wxHIDE_READONLY;
wxString path = fsp->dir.path;
@ -1561,7 +1581,7 @@ void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt)
dc._pnt.y = pnt.v;
}
void xvt_dwin_draw_text(WINDOW win, int x, int y, char *s, int len)
void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len)
{
if (s && *s && len != 0)
{
@ -1622,7 +1642,7 @@ long xvt_dwin_get_font_size_mapped(WINDOW win)
return height;
}
int xvt_dwin_get_text_width(WINDOW win, char *s, int len)
int xvt_dwin_get_text_width(WINDOW win, const char *s, int len)
{
int width = 0, height;
@ -2229,7 +2249,10 @@ void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RC
///////////////////////////////////////////////////////////
DATA_PTR xvt_mem_alloc(size_t size)
{ return (DATA_PTR)malloc(size); }
{
DATA_PTR ptr = (DATA_PTR)malloc(size);
return ptr;
}
void xvt_mem_free(DATA_PTR p)
{ free(p); }
@ -2303,6 +2326,46 @@ MENU_ITEM* xvt_menu_get_tree(WINDOW win)
return m;
}
static TranslateMenu(wxMenu* pMenu, TRANSLATE_CALLBACK tc)
{
wxMenuItemList& list = pMenu->GetMenuItems();
for (unsigned i = 0; i < list.GetCount(); i++)
{
wxMenuItem* mi = list[i];
if (!mi->IsSeparator())
{
const char* ita = mi->GetText();
const char* eng = tc(ita);
mi->SetText(eng);
wxMenu* pMenu = mi->GetSubMenu();
if (pMenu != NULL)
TranslateMenu(pMenu, tc);
}
}
}
void xvt_menu_translate_tree(WINDOW win, TRANSLATE_CALLBACK tc)
{
if (win == TASK_WIN)
{
TTaskWin& w = *(TTaskWin*)win;
wxMenuBar* pMenuBar = w.GetMenuBar();
if (pMenuBar != NULL)
{
for (int m = pMenuBar->GetMenuCount()-1; m >= 0; m--)
{
const char* ita = pMenuBar->GetLabelTop(m);
const char* eng = tc(ita);
pMenuBar->SetLabelTop(m, eng);
wxMenu* pMenu = pMenuBar->GetMenu(m);
TranslateMenu(pMenu, tc);
}
// w.SetMenuBar(pMenuBar);
}
}
}
void xvt_menu_set_font_sel(WINDOW win, XVT_FNTID font_id)
{ /* Ignored */ }
@ -2470,8 +2533,9 @@ void xvt_res_free_menu_tree(MENU_ITEM* tree)
XVT_IMAGE xvt_res_get_image(int rid)
{
const wxString strFileName = ::GetResourceName("Image", rid);
XVT_ASSERT(!strFileName.IsEmpty());
return xvt_image_read(strFileName);
const bool ok = !strFileName.IsEmpty();
XVT_ASSERT(ok);
return ok ? xvt_image_read(strFileName) : NULL;
}
static int SplitString(const wxString& str, wxArrayString& a)
@ -2575,7 +2639,7 @@ char* xvt_res_get_str(int rid, char *s, int sz_s)
XVT_ASSERT(s != NULL && sz_s > 0);
const wxString str = ::GetResourceName("String", rid);
strncpy(s, str, sz_s);
s[sz_s] = '\0';
s[sz_s-1] = '\0';
return s;
}
@ -2689,7 +2753,11 @@ void xvt_sbar_set_range(WINDOW win, SCROLL_TYPE t, int min, int max)
void xvt_scr_beep(void)
{
#ifdef WIN32
OsWin32_Beep(0);
#else
wxBell();
#endif
}
WINDOW xvt_scr_get_focus_topwin(void)

View File

@ -52,13 +52,13 @@ void xvt_ctl_check_radio_button(WINDOW Win, WINDOW* Wins, int NbrWindows);
WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data);
void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check);
void xvt_debug_printf(const char* fmt, const char* str);
void xvt_debug_printf(const char* fmt, ...);
ASK_RESPONSE xvt_dm_post_ask(const char* Btn1, const char*Btn2, const char* Btn3, const char* xin_buffer);
void xvt_dm_post_error(char *fmt);
void xvt_dm_post_fatal_exit(char *fmt);
FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, char *msg);
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, char *msg);
FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, const char *msg);
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, const char *msg);
BOOLEAN xvt_dm_post_font_sel(WINDOW win, XVT_FNTID font_id, PRINT_RCD *precp, unsigned long reserved);
void xvt_dm_post_note(char *fmt);
BOOLEAN xvt_dm_post_page_setup(PRINT_RCD *precp);
@ -73,13 +73,13 @@ void xvt_dwin_draw_pie(WINDOW win, RCT *rctp, int start_x, int start_y,
void xvt_dwin_draw_polygon(WINDOW win, PNT *lpnts, int npnts);
void xvt_dwin_draw_rect(WINDOW win, RCT *rctp);
void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt);
void xvt_dwin_draw_text(WINDOW win, int x, int y, char *s, int len);
void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len);
RCT* xvt_dwin_get_clip(WINDOW win, RCT* rct);
DRAW_CTOOLS* xvt_dwin_get_draw_ctools(WINDOW win, DRAW_CTOOLS *ctoolsp);
XVT_FNTID xvt_dwin_get_font(WINDOW win);
void xvt_dwin_get_font_metrics(WINDOW win, int *leadingp, int *ascentp, int *descentp);
long xvt_dwin_get_font_size_mapped(WINDOW win);
int xvt_dwin_get_text_width(WINDOW win, char *s, int len);
int xvt_dwin_get_text_width(WINDOW win, const char *s, int len);
void xvt_dwin_invalidate_rect(WINDOW win, RCT *rctp);
BOOLEAN xvt_dwin_is_update_needed(WINDOW Win, RCT* rctp);
void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv);
@ -156,6 +156,9 @@ void xvt_menu_set_item_enabled(WINDOW win, MENU_TAG tag, BOOLEAN enable);
void xvt_menu_set_item_title(WINDOW win, MENU_TAG tag, char* text);
void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree);
void xvt_menu_update(WINDOW win);
// Added by Guy
typedef const char* TRANSLATE_CALLBACK(const char* ita);
void xvt_menu_translate_tree(WINDOW win, TRANSLATE_CALLBACK tc);
short xvt_palet_add_colors(XVT_PALETTE palet, COLOR *colorsp, short numcolors);
short xvt_palet_add_colors_from_image(XVT_PALETTE palet, XVT_IMAGE image);