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