Porting 32 Bit

git-svn-id: svn://10.65.10.50/trunk@4483 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1997-06-02 09:55:35 +00:00
parent ddb6256d91
commit 9be3e3eedf

View File

@ -5,7 +5,7 @@
#include <xvt.h> #include <xvt.h>
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
#include <toolhelp.h> #include <toolhelp.h>
#endif #endif
#include <applicat.h> #include <applicat.h>
@ -52,10 +52,10 @@ TApplication& main_app()
// //
// @flag TRUE | Se se e' stata definita una <c TApplication> // @flag TRUE | Se se e' stata definita una <c TApplication>
// @flag FALSE | Se se non e' stata definita una <c TApplication> // @flag FALSE | Se se non e' stata definita una <c TApplication>
bool xvt_running() bool xvt_running()
{ return _application != NULL; } { return _application != NULL; }
// Ritorna il nome della ditta che vende il programma attuale // Ritorna il nome della ditta che vende il programma attuale
HIDDEN char* prassi_spa() HIDDEN char* prassi_spa()
{ {
TString firm(80); TString firm(80);
@ -63,7 +63,7 @@ HIDDEN char* prassi_spa()
if (p == NULL) if (p == NULL)
p = "PR.A.S.S.I. S.p.A."; p = "PR.A.S.S.I. S.p.A.";
return p; return p;
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Gestione dello sfondo della finestra principale // Gestione dello sfondo della finestra principale
@ -86,7 +86,7 @@ HIDDEN void create_backdrop(void)
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TBanner : public TWindow class TBanner : public TWindow
{ {
protected: protected:
virtual void handler(WINDOW win, EVENT* ep); virtual void handler(WINDOW win, EVENT* ep);
@ -104,7 +104,7 @@ TBanner::TBanner()
} }
TBanner::~TBanner() TBanner::~TBanner()
{ {
if (is_open()) if (is_open())
close(); close();
} }
@ -112,9 +112,9 @@ TBanner::~TBanner()
void TBanner::handler(WINDOW win, EVENT* ep) void TBanner::handler(WINDOW win, EVENT* ep)
{ {
if (ep->type == E_UPDATE) if (ep->type == E_UPDATE)
{ {
const int BIGY = 3*CHARY/2; const int BIGY = 3*CHARY/2;
clear(COLOR_LTGRAY); clear(COLOR_LTGRAY);
RCT r; xvt_vobj_get_client_rect(win, &r); RCT r; xvt_vobj_get_client_rect(win, &r);
@ -144,8 +144,8 @@ void TBanner::handler(WINDOW win, EVENT* ep)
set_pen(COLOR_WHITE); xvt_dwin_draw_rect(win, &r); set_pen(COLOR_WHITE); xvt_dwin_draw_rect(win, &r);
xvt_rect_offset(&r, -1, -1); xvt_rect_offset(&r, -1, -1);
set_pen(COLOR_BLACK); xvt_dwin_draw_rect(win, &r); set_pen(COLOR_BLACK); xvt_dwin_draw_rect(win, &r);
xvt_dwin_draw_icon(win, CHARX<<1, CHARX<<1, ICON_RSRC); xvt_dwin_draw_icon(win, CHARX<<1, CHARX<<1, ICON_RSRC);
} }
else else
TWindow::handler(win, ep); TWindow::handler(win, ep);
@ -157,7 +157,7 @@ long XVT_CALLCONV1 TApplication::task_eh(WINDOW win, EVENT *ep)
{ {
case E_CREATE: case E_CREATE:
if (_application->pre_create()) if (_application->pre_create())
{ {
TTemp_window tw(win); TTemp_window tw(win);
TString cap; TString cap;
cap << prassi_spa() << " - " << main_app().get_module_name(); cap << prassi_spa() << " - " << main_app().get_module_name();
@ -165,15 +165,15 @@ long XVT_CALLCONV1 TApplication::task_eh(WINDOW win, EVENT *ep)
customize_controls(TRUE); customize_controls(TRUE);
create_backdrop(); create_backdrop();
#if defined(DBG) && XVT_OS == XVT_OS_SCOUNIX #if defined(DBG) && XVT_OS == XVT_OS_SCOUNIX
message_box("Attach to process %d ...", getpid()); message_box("Attach to process %d ...", getpid());
#endif #endif
do_events(); do_events();
allow_another_instance(); allow_another_instance();
} }
break; break;
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
case E_UPDATE: case E_UPDATE:
backdrop_eh(win, ep); backdrop_eh(win, ep);
break; break;
@ -193,15 +193,16 @@ long TApplication::handler(WINDOW win, EVENT* ep)
{ {
TBanner banner; TBanner banner;
_create_ok = create(); _create_ok = create();
} }
if (_create_ok) if (_create_ok)
{ {
on_firm_change(); on_firm_change();
on_config_change(); on_config_change();
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
do_events(); do_events();
#endif #endif
} /* allow_another_instance(); */
}
else else
stop_run(); stop_run();
break; break;
@ -241,8 +242,8 @@ long TApplication::handler(WINDOW win, EVENT* ep)
{ {
if(!menu(ep->v.cmd.tag)) if(!menu(ep->v.cmd.tag))
stop_run(); stop_run();
} }
} }
break; break;
} }
break; break;
@ -250,26 +251,26 @@ long TApplication::handler(WINDOW win, EVENT* ep)
if (can_close()) if (can_close())
stop_run(); stop_run();
break; break;
case E_FONT: case E_FONT:
{ {
XVT_FNTID new_font = ep->v.font.font_id; XVT_FNTID new_font = ep->v.font.font_id;
char font_ser_desc[512]; char font_ser_desc[512];
TConfig font(CONFIG_USER, "Font"); TConfig font(CONFIG_USER, "Font");
xvt_font_serialize(new_font, font_ser_desc, sizeof(font_ser_desc)); xvt_font_serialize(new_font, font_ser_desc, sizeof(font_ser_desc));
font.set("FontDesc", font_ser_desc); font.set("FontDesc", font_ser_desc);
font.set_paragraph("Colors"); // Forza la scrittura del paragrafo font.set_paragraph("Colors"); // Forza la scrittura del paragrafo
xvt_load_default_font(); xvt_load_default_font();
} }
break; break;
case E_QUIT: case E_QUIT:
if (ep->v.query) if (ep->v.query)
{ {
if (can_close()) if (can_close())
xvt_app_allow_quit(); xvt_app_allow_quit();
} }
else else
stop_run(); stop_run();
break; break;
default: default:
@ -289,7 +290,7 @@ void TApplication::stop_run()
bool TApplication::add_menu(TString_array& menu, MENU_TAG id) bool TApplication::add_menu(TString_array& menu, MENU_TAG id)
{ {
TTemp_window tw(TASK_WIN); TTemp_window tw(TASK_WIN);
return tw.add_menu(menu,id,TRUE); return tw.add_menu(menu,id,TRUE);
} }
@ -301,7 +302,7 @@ bool TApplication::remove_menu(MENU_TAG id)
} }
TApplication::TApplication() TApplication::TApplication()
: _savefirm(0), _create_ok(FALSE), _bar(TASK_MENUBAR), : _savefirm(0), _create_ok(FALSE), _bar(TASK_MENUBAR),
_name(80), _title(80) _name(80), _title(80)
{} {}
@ -317,7 +318,7 @@ bool TApplication::create()
bool TApplication::destroy() bool TApplication::destroy()
{ {
return TRUE; return TRUE;
} }
@ -325,29 +326,34 @@ bool TApplication::destroy()
void TApplication::terminate() void TApplication::terminate()
{ {
close_all_dialogs(); close_all_dialogs();
if (_create_ok) if (_create_ok)
{ {
destroy(); // Distruzione files e maschere destroy(); // Distruzione files e maschere
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP"); const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
#if XVT_OS == XVT_OS_WIN
const HTASK ht = GetCurrentTask(); const HTASK ht = GetCurrentTask();
#else
const HANDLE ht = GetCurrentProcess();
#endif
// SendMessage(HWND_BROADCAST, WM_WAKEUP, (WPARAM)ht, 0L); // SendMessage(HWND_BROADCAST, WM_WAKEUP, (WPARAM)ht, 0L);
PostMessage(HWND_BROADCAST, WM_WAKEUP, (WPARAM)ht, 0L); PostMessage(HWND_BROADCAST, WM_WAKEUP, (WPARAM)ht, 0L);
if (fexist("prassi.hlp")) if (fexist("prassi.hlp"))
{ {
HWND hwnd = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW); HWND hwnd = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
WinHelp(hwnd, "prassi.hlp", HELP_QUIT, 0L); WinHelp(hwnd, "prassi.hlp", HELP_QUIT, 0L);
} }
#endif #endif
} }
do_events(); do_events();
if (use_files()) if (use_files())
free_global_vars(); // Distruzione variabili globali free_global_vars(); // Distruzione variabili globali
printer_destroy(); printer_destroy();
customize_controls(FALSE); // Rilascio eventuali DLL customize_controls(FALSE); // Rilascio eventuali DLL
} }
@ -363,9 +369,9 @@ const char* TApplication::get_module_name() const
TString module(scanner.token().mid(3)); TString module(scanner.token().mid(3));
if (ok) ok = has_module(aut); if (ok) ok = has_module(aut);
if (!ok)
if (!ok)
{ {
TToken_string em(extra_modules()); TToken_string em(extra_modules());
const int items = em.items(); const int items = em.items();
@ -376,18 +382,18 @@ const char* TApplication::get_module_name() const
if (!ok) if (!ok)
break; break;
} }
if (!ok) if (!ok)
{ {
error_box("Il modulo '%s' non e' autorizzato", (const char*)module); error_box("Il modulo '%s' non e' autorizzato", (const char*)module);
module = ""; module = "";
} }
} }
return module; return module;
} }
void TApplication::set_perms() void TApplication::set_perms()
{ {
CGetAut(1); CGetAut(1);
_dongle_aut.set(0, TRUE); _dongle_aut.set(0, TRUE);
for (int i = 1 ; i < ENDAUT; i++) for (int i = 1 ; i < ENDAUT; i++)
@ -397,7 +403,7 @@ void TApplication::set_perms()
_dongle_aut.set(i, val); _dongle_aut.set(i, val);
} }
_user_aut.set(0, TRUE); _user_aut.set(0, TRUE);
const TString& utente = user(); const TString& utente = user();
if (utente.not_empty()) if (utente.not_empty())
{ {
@ -407,11 +413,11 @@ void TApplication::set_perms()
_user_aut.set(i); _user_aut.set(i);
} }
else else
{ {
if (use_files()) if (use_files())
{ {
TLocalisamfile users(LF_USER); TLocalisamfile users(LF_USER);
users.zero(); users.zero();
users.put("USERNAME", utente); users.put("USERNAME", utente);
if (users.read() == NOERR) if (users.read() == NOERR)
@ -435,7 +441,7 @@ void TApplication::check_parameters(
// @comm Nel caso si identifichi che il paramentro <p argc> sia il nome dell'utente // @comm Nel caso si identifichi che il paramentro <p argc> sia il nome dell'utente
// si setta la variabile col nome dell'utente, altrimenti l'utente diventa PRASSI, // si setta la variabile col nome dell'utente, altrimenti l'utente diventa PRASSI,
// e si diminuisce di uno il numero di argomenti da passare. // e si diminuisce di uno il numero di argomenti da passare.
{ {
if (argc > 1) if (argc > 1)
{ {
const TFixed_string u(argv[argc-1]); const TFixed_string u(argv[argc-1]);
@ -443,7 +449,7 @@ void TApplication::check_parameters(
{ {
user() = u.mid(2); user() = u.mid(2);
argc--; argc--;
} }
} }
} }
@ -479,32 +485,32 @@ void TApplication::run(
addbar = 0; addbar = 0;
_name = cmd2name(argv[0]); _name = cmd2name(argv[0]);
} }
const int sn = get_serial_number(); const int sn = get_serial_number();
if (sn < 0) if (sn < 0)
{ {
error_box("Perhaps you forgot to connect the dongle"); error_box("Perhaps you forgot to connect the dongle");
return; return;
} }
if (use_files()) if (use_files())
init_global_vars(); init_global_vars();
else else
CGetPref(); CGetPref();
set_perms(); set_perms();
const TFixed_string mod(get_module_name()); const TFixed_string mod(get_module_name());
if (mod.empty()) if (mod.empty())
return; return;
XVT_CONFIG cfg; XVT_CONFIG cfg;
cfg.menu_bar_ID = TASK_MENUBAR+addbar; cfg.menu_bar_ID = TASK_MENUBAR+addbar;
cfg.about_box_ID = 0; cfg.about_box_ID = 0;
cfg.base_appl_name = (char*)base.name(); cfg.base_appl_name = (char*)base.name();
cfg.appl_name = (char*)title; cfg.appl_name = (char*)title;
cfg.taskwin_title = "PR.A.S.S.I."; cfg.taskwin_title = "PR.A.S.S.I.";
set_xvt_hooks(); set_xvt_hooks();
_application = this; _application = this;
@ -514,10 +520,10 @@ void TApplication::run(
// About box: risposta alla opzione Informazioni del menu File // About box: risposta alla opzione Informazioni del menu File
void TApplication::about() const void TApplication::about() const
{ {
#include <prassi.ver> #include <prassi.ver>
const TFilename n(__argv[0]); const TFilename n(__argv[0]);
message_box("Versione %s\nProgramma %s\nLibreria del %s\nN.ro di serie %d-%s", message_box("Versione %s\nProgramma %s\nLibreria del %s\nN.ro di serie %d-%s",
VERSION, (const char*)n.name(), __DATE__, SerNo, INTERNAL_VERSION); VERSION, (const char*)n.name(), __DATE__, SerNo, INTERNAL_VERSION);
} }
@ -558,12 +564,12 @@ void TApplication::enable_menu_item(
void TApplication::dispatch_e_menu(MENU_TAG item) void TApplication::dispatch_e_menu(MENU_TAG item)
{ {
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
HWND w = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW); HWND w = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
PostMessage(w, WM_COMMAND, item, 0L); PostMessage(w, WM_COMMAND, item, 0L);
#else #else
::dispatch_e_menu(TASK_WIN, item); ::dispatch_e_menu(TASK_WIN, item);
#endif #endif
} }
// @cmember Setta il cursore a clessidra (To be removed soon) // @cmember Setta il cursore a clessidra (To be removed soon)
@ -574,7 +580,7 @@ void TApplication::begin_wait()
// @cmember Setta il cursore standard (To be removed soon) // @cmember Setta il cursore standard (To be removed soon)
void TApplication::end_wait() void TApplication::end_wait()
{ {
::end_wait(); ::end_wait();
} }
@ -640,12 +646,12 @@ bool TApplication::set_firm(long newfirm)
{ {
prefix().set_codditta(newfirm); prefix().set_codditta(newfirm);
_savefirm = 0; _savefirm = 0;
WINDOW w = cur_win(); WINDOW w = cur_win();
if (w != NULL_WIN) if (w != NULL_WIN)
{ {
TWindow * win = (TWindow *) xvt_vobj_get_data(w); TWindow * win = (TWindow *) xvt_vobj_get_data(w);
win->on_firm_change(); win->on_firm_change();
} }
on_firm_change(); on_firm_change();
@ -663,20 +669,20 @@ bool TApplication::set_firm(long newfirm)
bool TApplication::config() bool TApplication::config()
// @comm Le si passa il file in cui cercare il proprio paragrafo (comunque relativo // @comm Le si passa il file in cui cercare il proprio paragrafo (comunque relativo
// alla ditta) se non c'e', viene creato copiando il default la variabile EdMask // alla ditta) se non c'e', viene creato copiando il default la variabile EdMask
// di quel paragrafo specifica la maschera da usare. // di quel paragrafo specifica la maschera da usare.
{ {
bool ok = FALSE; bool ok = FALSE;
TConfig cnf(CONFIG_DITTA); TConfig cnf(CONFIG_DITTA);
const TFilename maskname = cnf.get("EdMask"); const TFilename maskname = cnf.get("EdMask");
if (maskname.empty()) if (maskname.empty())
return warning_box("Nessun parametro da configurare"); return warning_box("Nessun parametro da configurare");
TMask* msk = new TMask(maskname); // Evito problemi di stack TMask* msk = new TMask(maskname); // Evito problemi di stack
TMask& m = *msk; TMask& m = *msk;
// carica campi // carica campi
for (int i = 0; i < m.fields(); i++) for (int i = 0; i < m.fields(); i++)
{ {
@ -693,10 +699,10 @@ bool TApplication::config()
} }
} }
} }
// run mask // run mask
disable_menu_item(M_FILE_REVERT); disable_menu_item(M_FILE_REVERT);
if (m.run() == K_ENTER && m.dirty()) if (m.run() == K_ENTER && m.dirty())
{ {
// aggiusta campi // aggiusta campi
@ -712,7 +718,7 @@ bool TApplication::config()
} }
ok = TRUE; ok = TRUE;
} }
delete msk; delete msk;
enable_menu_item(M_FILE_REVERT); enable_menu_item(M_FILE_REVERT);
return ok; return ok;
@ -729,13 +735,13 @@ bool TApplication::config()
bool TApplication::firm_change_enabled() const bool TApplication::firm_change_enabled() const
// @comm Praticamente controlla se e' stato lanciato da ba0 o dal program manager // @comm Praticamente controlla se e' stato lanciato da ba0 o dal program manager
{ {
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
static bool can = 2; static bool can = 2;
if (can == 2) if (can == 2)
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
TASKENTRY te; te.dwSize = sizeof(TASKENTRY); TASKENTRY te; te.dwSize = sizeof(TASKENTRY);
HTASK ct = GetCurrentTask(); HTASK ct = GetCurrentTask();
TaskFindHandle(&te, ct); TaskFindHandle(&te, ct);
TaskFindHandle(&te, te.hTaskParent); TaskFindHandle(&te, te.hTaskParent);
@ -743,17 +749,17 @@ bool TApplication::firm_change_enabled() const
#ifdef DBG #ifdef DBG
stricmp(te.szModule, "CVW4") == 0 || stricmp(te.szModule, "CVW4") == 0 ||
stricmp(te.szModule, "MSVC") == 0 || stricmp(te.szModule, "MSVC") == 0 ||
#endif #endif
stricmp(te.szModule, "Explorer") == 0 || stricmp(te.szModule, "Explorer") == 0 ||
stricmp(te.szModule, "PROGMAN") == 0; stricmp(te.szModule, "PROGMAN") == 0;
#else #else
can = TRUE; can = TRUE;
#endif #endif
} }
return can; return can;
#else #else
return TRUE; return TRUE;
#endif #endif
} }