1994-09-22 07:48:15 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <xvt.h>
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
#include <extcdecl.h>
|
|
|
|
#include <modaut.h>
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
#include <applicat.h>
|
1995-01-03 14:19:41 +00:00
|
|
|
#include <colors.h>
|
1994-11-10 14:17:03 +00:00
|
|
|
#include <config.h>
|
1994-09-22 07:48:15 +00:00
|
|
|
#include <mask.h>
|
|
|
|
#include <prefix.h>
|
|
|
|
#include <progind.h>
|
|
|
|
#include <relation.h>
|
|
|
|
#include <urldefid.h>
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
#include <bagn002.h>
|
|
|
|
|
1994-11-07 16:32:57 +00:00
|
|
|
#define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Metodi di accesso globali all'applicazione corrente
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
HIDDEN TApplication* _application = NULL;
|
1994-11-08 16:51:02 +00:00
|
|
|
|
|
|
|
TString16 TApplication::_user;
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
TApplication& main_app()
|
|
|
|
{
|
|
|
|
CHECK(_application, "NULL application!");
|
|
|
|
return *_application;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool xvt_running() { return _application != NULL; }
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Gestione dello sfondo della finestra principale
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
HIDDEN long backdrop_eh( WINDOW win, EVENT* ep)
|
|
|
|
{
|
1995-01-03 14:19:41 +00:00
|
|
|
clear_window(win, MASK_DARK_COLOR);
|
1994-09-22 07:48:15 +00:00
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
HIDDEN void create_backdrop( void )
|
|
|
|
{
|
1994-10-31 12:09:58 +00:00
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
xvt_create_statbar();
|
|
|
|
xvt_statbar_set("");
|
|
|
|
#else
|
1994-09-22 07:48:15 +00:00
|
|
|
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_MENU, COLOR_BLACK, COLOR_WHITE);
|
|
|
|
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_DIALOG, COLOR_BLUE, COLOR_WHITE);
|
|
|
|
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_WINDOW, COLOR_RED, COLOR_WHITE);
|
|
|
|
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_CONTROL, COLOR_BLACK, COLOR_WHITE);
|
|
|
|
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_DISABLED, COLOR_GRAY, COLOR_WHITE);
|
|
|
|
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_MNEMONIC, COLOR_RED, COLOR_WHITE);
|
|
|
|
|
|
|
|
RCT rct;
|
|
|
|
get_client_rect( SCREEN_WIN, &rct );
|
|
|
|
create_window(W_PLAIN, &rct, (char*) "BACKDROP", 0, TASK_WIN,
|
|
|
|
WSF_NO_MENUBAR | WSF_CH_BACKDROP , EM_UPDATE,
|
|
|
|
backdrop_eh, 0L );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Gestione del banner iniziale
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TBanner : public TWindow
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual void handler(WINDOW win, EVENT* ep);
|
|
|
|
|
|
|
|
public:
|
|
|
|
TBanner();
|
1994-11-29 17:31:42 +00:00
|
|
|
virtual ~TBanner();
|
1994-09-22 07:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TBanner::TBanner()
|
|
|
|
{
|
1994-10-03 08:47:32 +00:00
|
|
|
create(-1, 6, 72, 6, "BANNER", WSF_NONE, W_PLAIN);
|
1994-09-22 07:48:15 +00:00
|
|
|
hide_brush();
|
1994-11-14 10:00:06 +00:00
|
|
|
open();
|
1994-09-22 07:48:15 +00:00
|
|
|
do_events();
|
|
|
|
}
|
|
|
|
|
|
|
|
TBanner::~TBanner()
|
1994-11-14 10:00:06 +00:00
|
|
|
{
|
|
|
|
if (is_open())
|
|
|
|
close();
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TBanner::handler(WINDOW win, EVENT* ep)
|
|
|
|
{
|
|
|
|
if (ep->type == E_UPDATE)
|
|
|
|
{
|
1994-10-31 12:09:58 +00:00
|
|
|
const int BIGY = CHARY<<1;
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
clear(COLOR_LTGRAY);
|
|
|
|
RCT r; get_client_rect(win, &r);
|
|
|
|
|
|
|
|
set_color(COLOR_WHITE, COLOR_LTGRAY);
|
1994-10-31 12:09:58 +00:00
|
|
|
set_font(FF_TIMES, FS_BOLD | FS_ITALIC, BIGY);
|
1994-09-22 07:48:15 +00:00
|
|
|
char* t = (char*)(const char*)main_app().title();
|
|
|
|
int w = win_get_text_width(win, t, -1);
|
1994-11-03 12:46:49 +00:00
|
|
|
int a; win_get_font_metrics(win, NULL, &a, NULL);
|
1994-11-07 13:51:11 +00:00
|
|
|
int x = (r.right-w)>>1, y = (r.bottom+a)>>1 ;
|
1994-09-22 07:48:15 +00:00
|
|
|
win_draw_text(win, x+1, y+1, t, -1);
|
|
|
|
set_color(COLOR_BLACK, COLOR_LTGRAY);
|
|
|
|
win_draw_text(win, x, y, t, -1);
|
|
|
|
|
|
|
|
set_font(FF_TIMES);
|
|
|
|
t = "PRASSI S.p.A.";
|
|
|
|
w = win_get_text_width(win, t, -1);
|
1994-10-31 12:09:58 +00:00
|
|
|
x = (r.right-r.left-w)>>1, y = BIGY;
|
1994-09-22 07:48:15 +00:00
|
|
|
win_draw_text(win, x, y, t, -1);
|
|
|
|
|
|
|
|
t = "Caricamento in corso";
|
|
|
|
w = win_get_text_width(win, t, -1);
|
1994-10-31 12:09:58 +00:00
|
|
|
x = (r.right-r.left-w)>>1, y = r.bottom - CHARY;
|
1994-09-22 07:48:15 +00:00
|
|
|
win_draw_text(win, x, y, t, -1);
|
|
|
|
|
1995-02-03 09:38:46 +00:00
|
|
|
r.left += 5; r.right -= 4;
|
|
|
|
r.top += 5; r.bottom -= 4;
|
1994-09-22 07:48:15 +00:00
|
|
|
set_pen(COLOR_WHITE); win_draw_rect(win, &r);
|
1995-01-16 15:10:52 +00:00
|
|
|
offset_rect(&r, -1, -1);
|
|
|
|
set_pen(COLOR_BLACK); win_draw_rect(win, &r);
|
1994-11-03 12:46:49 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
win_draw_icon(win, CHARX<<1, CHARX<<1, ICON_RSRC);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TWindow::handler(win, ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
long TApplication::task_eh(WINDOW win, EVENT *ep)
|
|
|
|
{
|
|
|
|
switch (ep->type)
|
|
|
|
{
|
|
|
|
case E_CREATE:
|
|
|
|
create_backdrop();
|
|
|
|
#if defined(DBG) && XVT_OS == XVT_OS_SCOUNIX
|
|
|
|
message_box("Attach to process %d ...", getpid());
|
|
|
|
#endif
|
|
|
|
do_events();
|
|
|
|
break;
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
case E_UPDATE:
|
|
|
|
backdrop_eh(win, ep);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _application->handler(win, ep);
|
|
|
|
}
|
|
|
|
|
1994-10-31 12:09:58 +00:00
|
|
|
long TApplication::handler(WINDOW win, EVENT* ep)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
|
|
|
switch (ep->type)
|
|
|
|
{
|
|
|
|
case E_CREATE:
|
|
|
|
{
|
|
|
|
TBanner banner;
|
1994-11-10 14:17:03 +00:00
|
|
|
_create_ok = create();
|
1994-10-31 12:09:58 +00:00
|
|
|
}
|
1994-11-30 09:04:03 +00:00
|
|
|
if (_create_ok)
|
|
|
|
{
|
|
|
|
on_firm_change();
|
|
|
|
on_config_change();
|
1994-12-05 18:57:23 +00:00
|
|
|
#if XVT_OS == XVT_OS_SCOUNIX
|
|
|
|
do_events();
|
|
|
|
#endif
|
1994-11-30 09:04:03 +00:00
|
|
|
}
|
|
|
|
else
|
1994-11-11 18:04:29 +00:00
|
|
|
stop_run();
|
1994-09-22 07:48:15 +00:00
|
|
|
break;
|
|
|
|
case E_COMMAND:
|
1994-10-31 12:09:58 +00:00
|
|
|
switch(ep->v.cmd.tag)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
|
|
|
case M_FILE_QUIT:
|
|
|
|
if (can_close())
|
|
|
|
stop_run();
|
|
|
|
break;
|
|
|
|
case M_FILE_PG_SETUP:
|
|
|
|
printer().set();
|
|
|
|
break;
|
|
|
|
case M_FILE_PRINT:
|
|
|
|
print();
|
|
|
|
break;
|
|
|
|
case M_FILE_NEW:
|
|
|
|
set_firm();
|
|
|
|
break;
|
|
|
|
case M_FILE_REVERT:
|
|
|
|
config();
|
1994-11-30 09:04:03 +00:00
|
|
|
on_config_change();
|
1994-09-22 07:48:15 +00:00
|
|
|
break;
|
|
|
|
case (M_FILE+11):
|
|
|
|
about();
|
|
|
|
break;
|
|
|
|
default:
|
1994-10-31 12:09:58 +00:00
|
|
|
if (ep->v.cmd.tag >= BAR_ITEM(1))
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1994-10-31 12:09:58 +00:00
|
|
|
if(!menu(ep->v.cmd.tag))
|
1994-09-22 07:48:15 +00:00
|
|
|
stop_run();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1994-10-31 12:09:58 +00:00
|
|
|
break;
|
1994-09-22 07:48:15 +00:00
|
|
|
case E_CLOSE:
|
1994-10-31 12:09:58 +00:00
|
|
|
if (can_close())
|
|
|
|
stop_run();
|
1994-09-22 07:48:15 +00:00
|
|
|
break;
|
|
|
|
case E_QUIT:
|
1994-10-31 12:09:58 +00:00
|
|
|
if (ep->v.query)
|
|
|
|
{
|
|
|
|
if (can_close())
|
|
|
|
quit_OK();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
stop_run();
|
|
|
|
break;
|
1994-09-22 07:48:15 +00:00
|
|
|
default:
|
1994-10-31 12:09:58 +00:00
|
|
|
break;
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
1994-10-31 12:09:58 +00:00
|
|
|
|
|
|
|
return 0L;
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TApplication::stop_run()
|
|
|
|
{
|
1994-11-10 14:17:03 +00:00
|
|
|
if (_savefirm) prefhndl->set_codditta(_savefirm);
|
1994-09-22 07:48:15 +00:00
|
|
|
terminate();
|
|
|
|
xvt_terminate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
TApplication::TApplication() : _printer(NULL), _savefirm(0), _create_ok(FALSE)
|
1994-12-07 11:10:57 +00:00
|
|
|
, _bar(TASK_MENUBAR)
|
|
|
|
{}
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
TApplication::~TApplication()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
TPrinter* TApplication::set_printer(TPrinter* p)
|
|
|
|
{
|
1994-11-10 14:17:03 +00:00
|
|
|
TPrinter* printer = _printer;
|
1994-09-22 07:48:15 +00:00
|
|
|
_printer = p;
|
|
|
|
return printer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TPrinter& TApplication::printer()
|
|
|
|
{
|
|
|
|
if (_printer == NULL)
|
|
|
|
_printer = new TPrinter;
|
|
|
|
return *_printer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TApplication::create()
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TApplication::destroy()
|
1994-12-07 11:10:57 +00:00
|
|
|
{
|
1994-09-22 07:48:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TApplication::terminate()
|
|
|
|
{
|
|
|
|
close_all_dialogs();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
if (_create_ok)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1994-11-10 14:17:03 +00:00
|
|
|
destroy(); // Distruzione files e maschere
|
1994-12-27 14:59:25 +00:00
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
|
|
|
|
const HTASK ht = GetCurrentTask();
|
|
|
|
SendMessage(HWND_BROADCAST, WM_WAKEUP, ht, 0L);
|
|
|
|
|
|
|
|
if (fexist("prassi.hlp"))
|
|
|
|
{
|
|
|
|
HWND hwnd = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);
|
|
|
|
WinHelp(hwnd, "prassi.hlp", HELP_QUIT, 0L);
|
|
|
|
}
|
|
|
|
#endif
|
1994-11-10 14:17:03 +00:00
|
|
|
do_events();
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
if (_printer != NULL) // Distruzione dell'eventuale stampante
|
|
|
|
{
|
1994-12-07 11:10:57 +00:00
|
|
|
if (_printer->isopen())
|
|
|
|
_printer->close();
|
1994-11-10 14:17:03 +00:00
|
|
|
delete _printer;
|
|
|
|
_printer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-12-07 11:10:57 +00:00
|
|
|
if (use_files())
|
|
|
|
free_global_vars(); // Distruzione variabili globali
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
customize_controls(FALSE); // Rilascio eventuali DLL
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char* TApplication::get_module_name() const
|
|
|
|
{
|
|
|
|
TScanner scanner("prassi.aut");
|
|
|
|
|
|
|
|
bool ok = FALSE;
|
|
|
|
for (int aut = 0; scanner.line() != ""; aut++)
|
|
|
|
if (strncmp(scanner.token(), _name, 2) == 0) { ok = TRUE; break; }
|
|
|
|
|
|
|
|
const char* module = scanner.token().mid(3);
|
|
|
|
if (ok) ok = has_module(aut);
|
|
|
|
|
|
|
|
if (!ok)
|
1994-11-16 15:51:06 +00:00
|
|
|
{
|
|
|
|
error_box("Il modulo '%s' non e' autorizzato", module);
|
|
|
|
module = "";
|
|
|
|
}
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
|
1994-11-07 16:32:57 +00:00
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
void TApplication::set_perms()
|
1994-12-07 11:10:57 +00:00
|
|
|
{
|
1994-11-07 16:32:57 +00:00
|
|
|
CGetAut(1);
|
1994-11-08 16:51:02 +00:00
|
|
|
_dongle_aut.set(0, TRUE);
|
1994-11-07 16:32:57 +00:00
|
|
|
for (int i = 1 ; i < ENDAUT; i++)
|
|
|
|
{
|
|
|
|
const int af = i - 1;
|
|
|
|
const bool val = BITTEST(_int_tab0[af / 16], af % 16);
|
|
|
|
_dongle_aut.set(i, val);
|
|
|
|
}
|
1994-11-08 16:51:02 +00:00
|
|
|
_user_aut.set(0, TRUE);
|
1994-12-07 11:10:57 +00:00
|
|
|
|
1994-11-07 16:32:57 +00:00
|
|
|
if (_user.not_empty())
|
|
|
|
{
|
|
|
|
if (_user == "PRASSI")
|
|
|
|
{
|
|
|
|
for (int i = 1 ; i < ENDAUT; i++)
|
|
|
|
_user_aut.set(i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TLocalisamfile users(LF_USER);
|
|
|
|
|
|
|
|
users.zero();
|
|
|
|
users.put("USERNAME", _user);
|
|
|
|
if (users.read() == NOERR)
|
|
|
|
{
|
|
|
|
const TString80 aut(users.get("AUTSTR"));
|
|
|
|
const int max = aut.len();
|
|
|
|
|
|
|
|
for (int i = 1 ; i < max; i++)
|
|
|
|
_user_aut.set(i, aut[i] == 'X');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-11-08 16:51:02 +00:00
|
|
|
void TApplication::check_parameters(int & argc, char* argv[])
|
1994-11-07 16:32:57 +00:00
|
|
|
{
|
1994-11-11 18:04:29 +00:00
|
|
|
if (strncmp(argv[argc-1], "-u", 2) == 0)
|
|
|
|
_user = &argv[--argc][2];
|
1994-11-10 14:17:03 +00:00
|
|
|
#ifdef DBG
|
|
|
|
else _user = "PRASSI";
|
|
|
|
#endif
|
1994-11-11 18:04:29 +00:00
|
|
|
|
1994-11-14 12:03:26 +00:00
|
|
|
#if XVT_OS == XVT_OS_WIN
|
1994-12-27 14:59:25 +00:00
|
|
|
const long twin_style = WSF_ICONIZABLE | WSF_SIZE | WSF_CLOSE | WSF_MAXIMIZED;
|
1994-11-11 18:04:29 +00:00
|
|
|
set_value(NULL_WIN,ATTR_WIN_PM_TWIN_STARTUP_STYLE, twin_style);
|
1994-11-14 12:03:26 +00:00
|
|
|
#endif
|
1994-11-07 16:32:57 +00:00
|
|
|
}
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
void TApplication::run(int argc, char* argv[], const char* title)
|
|
|
|
{
|
|
|
|
TFilename base(argv[0]);
|
1994-11-07 16:32:57 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
base.ext(""); base.lower();
|
|
|
|
_title = title;
|
1994-11-08 16:51:02 +00:00
|
|
|
if (_user.empty())
|
1994-11-07 16:32:57 +00:00
|
|
|
check_parameters(argc, argv);
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
__argc = argc;
|
|
|
|
__argv = (const char**)argv;
|
|
|
|
|
|
|
|
int addbar;
|
|
|
|
if (argc > 1)
|
|
|
|
{
|
|
|
|
addbar = atoi(argv[1]+1);
|
|
|
|
_name = cmd2name(argv[0], argv[1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
addbar = 0;
|
|
|
|
_name = cmd2name(argv[0]);
|
|
|
|
}
|
1994-12-07 11:10:57 +00:00
|
|
|
|
|
|
|
const int sn = get_serial_number();
|
|
|
|
if (sn < 0)
|
|
|
|
{
|
|
|
|
error_box("Perhaps you forgot to connect the dongle");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_files())
|
|
|
|
init_global_vars();
|
|
|
|
|
1994-11-07 16:32:57 +00:00
|
|
|
set_perms();
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1994-11-16 15:51:06 +00:00
|
|
|
const TFixed_string mod(get_module_name());
|
|
|
|
if (mod.empty()) return;
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
TString80 caption;
|
1994-11-16 15:51:06 +00:00
|
|
|
caption << "PRASSI S.p.A. - " << mod;
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
static XVT_CONFIG cfg;
|
|
|
|
cfg.base_appl_name = (char*)base.name();
|
|
|
|
cfg.appl_name = (char*)(const char*)_title;
|
|
|
|
cfg.taskwin_title = (char*)(const char*)caption;
|
|
|
|
cfg.menu_bar_ID = TASK_MENUBAR+addbar;
|
|
|
|
cfg.about_box_ID = 0;
|
|
|
|
|
|
|
|
customize_controls(TRUE);
|
|
|
|
|
|
|
|
_application = this;
|
|
|
|
xvt_system(argc, argv, 0L, task_eh, &cfg);
|
|
|
|
}
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
// About box: risposta alla opzione Informazioni del menu File
|
|
|
|
void TApplication::about() const
|
|
|
|
{
|
|
|
|
#include <prassi.ver>
|
|
|
|
const TFilename n(__argv[0]);
|
1995-02-09 14:47:31 +00:00
|
|
|
message_box("PRASSI Versione %s\nProgramma %s\nLibreria del %s",
|
1994-09-22 07:48:15 +00:00
|
|
|
VERSION, (const char*)n.name(), __DATE__);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Risposta alla selezione Stampa del menu File
|
|
|
|
void TApplication::print()
|
|
|
|
{
|
|
|
|
#ifdef DBG
|
|
|
|
error_box("Non saprei bene cosa stampare!");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void TApplication::check_menu_item(MENU_TAG item)
|
|
|
|
{
|
|
|
|
win_menu_check(TASK_WIN, item, TRUE);
|
|
|
|
win_update_menu_bar(TASK_WIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TApplication::uncheck_menu_item(MENU_TAG item)
|
|
|
|
{
|
|
|
|
win_menu_check(TASK_WIN, item, FALSE);
|
|
|
|
win_update_menu_bar(TASK_WIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TApplication::enable_menu_item(MENU_TAG item, bool on)
|
|
|
|
{
|
|
|
|
win_menu_enable(TASK_WIN, item, on);
|
|
|
|
win_update_menu_bar(TASK_WIN);
|
|
|
|
}
|
|
|
|
|
1994-12-16 15:50:08 +00:00
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
void TApplication::dispatch_e_menu(MENU_TAG item)
|
|
|
|
{
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
HWND w = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);
|
|
|
|
PostMessage(w, WM_COMMAND, item, 0L);
|
|
|
|
#else
|
1994-11-29 17:31:42 +00:00
|
|
|
::dispatch_e_menu(TASK_WIN, item);
|
1994-09-22 07:48:15 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-11-07 16:32:57 +00:00
|
|
|
bool TApplication::has_module(int module, int checktype) const
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1994-11-07 16:32:57 +00:00
|
|
|
bool ok = TRUE;
|
|
|
|
if (checktype == CHK_ALL || checktype == CHK_DONGLE)
|
|
|
|
ok = _dongle_aut[module];
|
|
|
|
if (ok && checktype == CHK_ALL || checktype == CHK_USER)
|
|
|
|
ok = _user_aut[module];
|
|
|
|
return ok;
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long TApplication::get_firm() const
|
|
|
|
{
|
|
|
|
return prefhndl->get_codditta();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* TApplication::get_firm_dir() const
|
|
|
|
{
|
|
|
|
return format("%s%s", __ptprf, prefhndl->name());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TApplication::set_firm(long newfirm)
|
|
|
|
{
|
|
|
|
const long oldfirm = get_firm();
|
|
|
|
|
|
|
|
if (newfirm < 1)
|
|
|
|
{
|
|
|
|
TMask mask("bagn002");
|
1994-12-14 14:33:46 +00:00
|
|
|
TString80 pp(__ptprf); pp.cut(pp.len()-1);
|
|
|
|
mask.set(F_PATHPREF, pp);
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1994-12-14 14:33:46 +00:00
|
|
|
mask.show(-2, extended_firm());
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1994-12-14 14:33:46 +00:00
|
|
|
disable_menu_item(M_FILE_NEW);
|
|
|
|
const KEY k = mask.run();
|
1994-09-22 07:48:15 +00:00
|
|
|
enable_menu_item(M_FILE_NEW);
|
1994-12-14 14:33:46 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
if (k == K_ENTER)
|
|
|
|
{
|
|
|
|
newfirm = mask.get_long(F_CODDITTA);
|
|
|
|
const int tipodir = mask.get_int(F_TIPO);
|
|
|
|
|
1994-11-10 11:15:47 +00:00
|
|
|
if (tipodir == 0 && !prefhndl->exist(newfirm) &&
|
|
|
|
!build_firm_data(newfirm))
|
|
|
|
return FALSE;
|
1994-09-22 07:48:15 +00:00
|
|
|
if (tipodir > 0)
|
|
|
|
{
|
1994-11-10 14:17:03 +00:00
|
|
|
if (_savefirm == 0) _savefirm = oldfirm;
|
1994-09-22 07:48:15 +00:00
|
|
|
prefhndl->set(tipodir == 1 ? "com" : "");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newfirm == oldfirm || newfirm < 1)
|
1994-10-26 15:03:17 +00:00
|
|
|
return newfirm > 0;
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
if (prefhndl->test(newfirm))
|
|
|
|
{
|
|
|
|
prefhndl->set_codditta(newfirm);
|
1994-11-10 14:17:03 +00:00
|
|
|
_savefirm = 0;
|
1994-11-30 09:04:03 +00:00
|
|
|
|
|
|
|
WINDOW w = cur_win();
|
|
|
|
if (w != NULL_WIN)
|
|
|
|
{
|
|
|
|
EVENT e;
|
|
|
|
e.type = E_COMMAND;
|
|
|
|
e.v.cmd.tag = M_FILE_NEW;
|
|
|
|
e.v.cmd.shift = e.v.cmd.control = 0;
|
|
|
|
dispatch_event(w, &e);
|
|
|
|
}
|
|
|
|
|
|
|
|
on_firm_change();
|
|
|
|
on_config_change();
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TApplication::config()
|
|
|
|
// gestisce le voci di configurazione
|
|
|
|
// 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 di quel paragrafo specifica
|
|
|
|
// la maschera da usare
|
|
|
|
{
|
|
|
|
TConfig cnf(CONFIG_DITTA);
|
|
|
|
bool ok = FALSE;
|
|
|
|
|
1994-12-07 11:10:57 +00:00
|
|
|
const TFilename maskname(cnf.get("EdMask"));
|
|
|
|
if (maskname.empty())
|
|
|
|
return warning_box("Nessun parametro da configurare");
|
|
|
|
|
|
|
|
TMask m(maskname);
|
|
|
|
|
|
|
|
// carica campi
|
|
|
|
for (int i = 0; i < m.fields(); i++)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1994-12-07 11:10:57 +00:00
|
|
|
TMask_field& f = m.fld(i);
|
|
|
|
const TFieldref* fref = f.field();
|
|
|
|
if (fref != NULL)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1994-12-07 11:10:57 +00:00
|
|
|
const char* fname = fref->name();
|
|
|
|
if (fname != NULL)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1994-12-07 11:10:57 +00:00
|
|
|
TString& oldvl = cnf.get(fname);
|
|
|
|
if (!oldvl.empty())
|
|
|
|
f.set(oldvl);
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
1994-12-07 11:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// run mask
|
|
|
|
disable_menu_item(M_FILE_REVERT);
|
|
|
|
|
|
|
|
if (m.run() == K_ENTER && m.dirty())
|
|
|
|
{
|
|
|
|
// aggiusta campi
|
|
|
|
for (i = 0; i < m.fields(); i++)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1994-12-07 11:10:57 +00:00
|
|
|
TMask_field& f = m.fld(i);
|
|
|
|
if (f.dirty())
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1994-12-07 11:10:57 +00:00
|
|
|
const TFieldref* fref = f.field();
|
|
|
|
if (fref != NULL)
|
|
|
|
cnf.set(fref->name(), f.get(), NULL, TRUE);
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
1994-12-07 11:10:57 +00:00
|
|
|
ok = TRUE;
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
1994-12-07 11:10:57 +00:00
|
|
|
|
|
|
|
enable_menu_item(M_FILE_REVERT);
|
|
|
|
return ok;
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
1995-01-03 14:19:41 +00:00
|
|
|
void TApplication::set_cursor(bool w)
|
|
|
|
{
|
1995-01-10 11:44:41 +00:00
|
|
|
static int _count = 0;
|
|
|
|
WINDOW ww = cur_win();
|
|
|
|
if (ww == NULL_WIN) ww = TASK_WIN;
|
|
|
|
|
1995-01-03 14:19:41 +00:00
|
|
|
if (w)
|
|
|
|
{
|
1995-01-03 16:22:44 +00:00
|
|
|
if (_count == 0)
|
1995-01-10 11:44:41 +00:00
|
|
|
::set_cursor(ww, CURSOR_WAIT);
|
1995-01-03 16:22:44 +00:00
|
|
|
_count++;
|
1995-01-03 14:19:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_count--;
|
1995-01-16 15:10:52 +00:00
|
|
|
CHECK(_count >= 0, "end_wait without matching begin_wait");
|
1995-01-03 14:19:41 +00:00
|
|
|
if (_count == 0)
|
1995-01-10 11:44:41 +00:00
|
|
|
::set_cursor(ww, CURSOR_ARROW);
|
1995-01-03 14:19:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-11-30 09:04:03 +00:00
|
|
|
void TApplication::on_firm_change()
|
|
|
|
{}
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1994-11-30 09:04:03 +00:00
|
|
|
void TApplication::on_config_change()
|
|
|
|
{}
|