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>
|
1996-12-20 12:09:45 +00:00
|
|
|
#include <controls.h>
|
1998-02-13 13:46:18 +00:00
|
|
|
#include <dongle.h>
|
1997-08-18 14:11:37 +00:00
|
|
|
#include <execp.h>
|
1996-12-20 12:09:45 +00:00
|
|
|
#include <extcdecl.h>
|
1994-09-22 07:48:15 +00:00
|
|
|
#include <mask.h>
|
1996-12-20 12:09:45 +00:00
|
|
|
#include <modaut.h>
|
1998-02-24 10:37:28 +00:00
|
|
|
#include <os_dep.h>
|
1994-09-22 07:48:15 +00:00
|
|
|
#include <prefix.h>
|
1995-04-20 14:35:14 +00:00
|
|
|
#include <printer.h>
|
1999-07-16 14:59:11 +00:00
|
|
|
#include <progind.h>
|
1994-09-22 07:48:15 +00:00
|
|
|
#include <relation.h>
|
1999-07-16 14:59:11 +00:00
|
|
|
#include <tabutil.h>
|
1994-09-22 07:48:15 +00:00
|
|
|
#include <urldefid.h>
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
#include <bagn002.h>
|
|
|
|
|
2003-01-07 12:20:49 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Finestra informazioni
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TInfo_mask : public TMask
|
|
|
|
{
|
|
|
|
int _row, _col;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void add_row(const char* prompt, const char* value);
|
|
|
|
void add_row(const char* prompt, unsigned long value);
|
|
|
|
|
|
|
|
TInfo_mask();
|
|
|
|
};
|
|
|
|
|
|
|
|
void TInfo_mask::add_row(const char* prompt, const char* value)
|
|
|
|
{
|
|
|
|
const int MASK_WIDTH = 72;
|
|
|
|
const int PROMPT_WIDTH = 12;
|
|
|
|
|
|
|
|
TString val(value);
|
|
|
|
const int len = val.len();
|
|
|
|
if (_col + PROMPT_WIDTH + len > MASK_WIDTH)
|
|
|
|
{
|
|
|
|
_row++;
|
|
|
|
_col = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
TString pr(prompt);
|
|
|
|
if (pr.not_empty())
|
|
|
|
pr.left_just(PROMPT_WIDTH);
|
|
|
|
|
|
|
|
const short id = 101 + _row*10 + (_col > 1);
|
|
|
|
TEdit_field& e = add_string(id, 0, pr, _col, _row, len, "", len > 50 ? 50 : len);
|
|
|
|
e.set(value);
|
|
|
|
if (pr.len()+len > MASK_WIDTH/2)
|
|
|
|
_col += MASK_WIDTH;
|
|
|
|
else
|
|
|
|
_col += MASK_WIDTH/2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TInfo_mask::add_row(const char* prompt, unsigned long value)
|
|
|
|
{
|
|
|
|
TString8 str; str.format("%lu", value);
|
|
|
|
add_row(prompt, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
TInfo_mask::TInfo_mask()
|
2003-03-11 09:17:38 +00:00
|
|
|
: TMask("Informazioni", 1, 72, 11, -1, -1), _row(0), _col(1)
|
2003-01-07 12:20:49 +00:00
|
|
|
{
|
|
|
|
const word ser_no = dongle().number();
|
|
|
|
int year, release, tag, patch;
|
|
|
|
|
|
|
|
TString16 versione = "2003.02";
|
|
|
|
TString16 strpatch = "01.001";
|
|
|
|
if (main_app().get_version_info(year, release, tag, patch))
|
|
|
|
{
|
|
|
|
versione.format("%d.%02d", year, release);
|
|
|
|
strpatch.format("%02d.%03d", tag, patch);
|
|
|
|
}
|
|
|
|
|
|
|
|
TString arg;
|
|
|
|
for (int a = 0; a < main_app().argc(); a++)
|
|
|
|
arg << main_app().argv(a) << ' ';
|
|
|
|
arg.trim(); arg.lower();
|
|
|
|
|
|
|
|
const TFirm& firm = prefix().firm();
|
|
|
|
TString prot;
|
|
|
|
switch (dongle().hardware())
|
|
|
|
{
|
|
|
|
case 1: prot = "Hardlock"; break;
|
|
|
|
case 2: prot = "Eutron"; break;
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
TConfig ini(CONFIG_INSTALL, "Server");
|
|
|
|
prot = ini.get("Dongle");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: prot = "NONE"; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TString stampante = printer().printername();
|
|
|
|
const int comma = stampante.find(',');
|
|
|
|
if (comma > 0) stampante.cut(comma);
|
|
|
|
|
|
|
|
add_row(TR("Versione"), versione);
|
|
|
|
add_row(TR("Patch"), strpatch);
|
|
|
|
add_row(TR("N. di serie"), ser_no);
|
|
|
|
add_row(TR("Protezione"), prot);
|
|
|
|
add_row(TR("Programma"), arg);
|
|
|
|
add_row(TR("Utente"), user());
|
2003-03-11 09:17:38 +00:00
|
|
|
add_row(TR("Config"), CGetPrawinName());
|
2003-01-07 12:20:49 +00:00
|
|
|
add_row(TR("Studio"), firm2dir(-1));
|
|
|
|
add_row(TR("Ditta"), firm.codice());
|
|
|
|
add_row(TR("Valuta"), firm.codice_valuta());
|
|
|
|
add_row(TR("Stampante"), stampante);
|
|
|
|
add_row(TR("Mb liberi"), os_get_disk_free_space("c:/", 'M'));
|
|
|
|
|
|
|
|
add_button(DLG_OK, 0, "", -11, -1, 10, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Metodi di accesso globali all'applicazione corrente
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
HIDDEN TApplication* _application = NULL;
|
1998-02-24 10:37:28 +00:00
|
|
|
HIDDEN bool _xvt_running = FALSE;
|
1994-11-08 16:51:02 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
|
1996-01-31 17:19:02 +00:00
|
|
|
// @func Ritorna l'applicazione in corso
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna il reference all'applicazione in corso
|
1994-09-22 07:48:15 +00:00
|
|
|
TApplication& main_app()
|
|
|
|
{
|
|
|
|
CHECK(_application, "NULL application!");
|
|
|
|
return *_application;
|
|
|
|
}
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc INTERNAL
|
|
|
|
|
1996-01-31 17:19:02 +00:00
|
|
|
// @func Controlla se si sta eseguendo xvt
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna i seguenti valori:
|
|
|
|
//
|
|
|
|
// @flag TRUE | Se se e' stata definita una <c TApplication>
|
|
|
|
// @flag FALSE | Se se non e' stata definita una <c TApplication>
|
1997-06-02 09:55:35 +00:00
|
|
|
bool xvt_running()
|
1998-02-13 13:46:18 +00:00
|
|
|
{ return _xvt_running; }
|
1997-06-02 09:55:35 +00:00
|
|
|
|
|
|
|
// Ritorna il nome della ditta che vende il programma attuale
|
2002-12-18 10:56:10 +00:00
|
|
|
HIDDEN const char* producer_name(TString& firm)
|
1997-01-07 11:27:47 +00:00
|
|
|
{
|
1998-01-27 10:27:24 +00:00
|
|
|
TConfig ini("install.ini", "Main");
|
|
|
|
firm = ini.get("Producer");
|
|
|
|
|
|
|
|
if (firm.not_empty())
|
|
|
|
{
|
1998-03-05 13:54:51 +00:00
|
|
|
const char* p = decode(firm);
|
1998-01-27 10:27:24 +00:00
|
|
|
for (const char* c = p; *c; c++)
|
|
|
|
{
|
1998-03-05 13:54:51 +00:00
|
|
|
if (*c > '\0' && *c < ' ') // Hand crafted string?
|
1998-01-27 10:27:24 +00:00
|
|
|
{
|
|
|
|
p = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-03-05 13:54:51 +00:00
|
|
|
firm = p;
|
1998-01-27 10:27:24 +00:00
|
|
|
}
|
|
|
|
|
1998-03-05 13:54:51 +00:00
|
|
|
if (firm.empty())
|
1998-01-27 10:27:24 +00:00
|
|
|
{
|
|
|
|
ignore_xvt_errors(TRUE);
|
1998-03-05 13:54:51 +00:00
|
|
|
char* p = firm.get_buffer(80);
|
|
|
|
xvt_res_get_str(STR_FIRMNAME, p, firm.size());
|
1998-01-27 10:27:24 +00:00
|
|
|
ignore_xvt_errors(FALSE);
|
|
|
|
}
|
|
|
|
|
1998-03-05 13:54:51 +00:00
|
|
|
if (firm.empty())
|
2003-01-07 12:20:49 +00:00
|
|
|
firm = "Campo";
|
1998-01-27 10:27:24 +00:00
|
|
|
|
1998-03-05 13:54:51 +00:00
|
|
|
return firm;
|
1997-06-02 09:55:35 +00:00
|
|
|
}
|
1996-02-05 19:00:53 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Gestione dello sfondo della finestra principale
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
1997-01-07 11:27:47 +00:00
|
|
|
HIDDEN long backdrop_eh(WINDOW win, EVENT* ep)
|
1999-07-16 14:59:11 +00:00
|
|
|
{
|
2002-02-28 11:35:23 +00:00
|
|
|
XVT_DISPLAY_TYPE type = (XVT_DISPLAY_TYPE)xvt_vobj_get_attr(win, ATTR_DISPLAY_TYPE);
|
2003-01-07 12:20:49 +00:00
|
|
|
if (type == XVT_DISPLAY_DIRECT_COLOR) // True color (senza palette)
|
1999-07-16 14:59:11 +00:00
|
|
|
{
|
2003-03-11 09:17:38 +00:00
|
|
|
const int step = 6;
|
1999-07-16 14:59:11 +00:00
|
|
|
RCT r; xvt_vobj_get_client_rect(win, &r);
|
2003-03-11 09:17:38 +00:00
|
|
|
const int bot = r.bottom;
|
1999-07-16 14:59:11 +00:00
|
|
|
|
|
|
|
xvt_dwin_set_std_cpen(win, TL_PEN_HOLLOW);
|
|
|
|
CBRUSH brush = { PAT_SOLID, COLOR_BLACK };
|
|
|
|
|
2003-03-11 09:17:38 +00:00
|
|
|
for (int y = 0; y < bot; y += step)
|
1999-07-16 14:59:11 +00:00
|
|
|
{
|
2003-03-11 09:17:38 +00:00
|
|
|
brush.color = blend_colors(MASK_DARK_COLOR, MASK_LIGHT_COLOR, double(y) / double(bot));
|
1999-07-16 14:59:11 +00:00
|
|
|
xvt_dwin_set_cbrush(win, &brush);
|
2003-03-11 09:17:38 +00:00
|
|
|
r.top = y; r.bottom = y+step;
|
|
|
|
xvt_dwin_draw_rect(win, &r);
|
1999-07-16 14:59:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xvt_dwin_clear(win, MASK_DARK_COLOR);
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
1997-01-07 11:27:47 +00:00
|
|
|
HIDDEN void create_backdrop(void)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1994-10-31 12:09:58 +00:00
|
|
|
xvt_create_statbar();
|
|
|
|
xvt_statbar_set("");
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Gestione del banner iniziale
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TBanner : public TWindow
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1994-09-22 07:48:15 +00:00
|
|
|
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()
|
|
|
|
{
|
2002-02-28 11:35:23 +00:00
|
|
|
create(-1, 1, 76, 4, "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()
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
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)
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
const int BIGY = 3*CHARY/2;
|
1999-07-16 14:59:11 +00:00
|
|
|
RCT r; xvt_vobj_get_client_rect(win, &r);
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
clear(COLOR_LTGRAY);
|
|
|
|
|
|
|
|
set_color(COLOR_WHITE, COLOR_LTGRAY);
|
1995-03-22 09:07:04 +00:00
|
|
|
set_font(XVT_FFN_TIMES, XVT_FS_BOLD | XVT_FS_ITALIC, BIGY);
|
1994-09-22 07:48:15 +00:00
|
|
|
char* t = (char*)(const char*)main_app().title();
|
1995-03-22 09:07:04 +00:00
|
|
|
int w = xvt_dwin_get_text_width(win, t, -1);
|
|
|
|
int a; xvt_dwin_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 ;
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_dwin_draw_text(win, x+1, y+1, t, -1);
|
1994-09-22 07:48:15 +00:00
|
|
|
set_color(COLOR_BLACK, COLOR_LTGRAY);
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_dwin_draw_text(win, x, y, t, -1);
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
set_font(XVT_FFN_TIMES);
|
1998-03-05 13:54:51 +00:00
|
|
|
TString spa;
|
2002-12-18 10:56:10 +00:00
|
|
|
t = (char*)producer_name(spa);
|
1995-03-22 09:07:04 +00:00
|
|
|
w = xvt_dwin_get_text_width(win, t, -1);
|
1997-01-07 11:27:47 +00:00
|
|
|
x = (r.right-r.left-w)>>1; y = BIGY;
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_dwin_draw_text(win, x, y, t, -1);
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1995-02-03 09:38:46 +00:00
|
|
|
r.left += 5; r.right -= 4;
|
|
|
|
r.top += 5; r.bottom -= 4;
|
1995-03-22 09:07:04 +00:00
|
|
|
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);
|
1997-06-02 09:55:35 +00:00
|
|
|
|
|
|
|
xvt_dwin_draw_icon(win, CHARX<<1, CHARX<<1, ICON_RSRC);
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
TWindow::handler(win, ep);
|
|
|
|
}
|
|
|
|
|
2002-02-28 11:35:23 +00:00
|
|
|
long TApplication::task_eh(WINDOW win, EVENT *ep)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
|
|
|
switch (ep->type)
|
|
|
|
{
|
|
|
|
case E_CREATE:
|
1997-01-07 11:27:47 +00:00
|
|
|
if (_application->pre_create())
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1997-12-02 11:57:26 +00:00
|
|
|
#ifdef _DEMO_
|
|
|
|
{
|
|
|
|
const TString16 dname(encode("DATA"));
|
|
|
|
const TString16 hname(encode("ORA"));
|
1998-02-06 16:03:18 +00:00
|
|
|
TConfig c(CONFIG_INSTALL, "Main");
|
1997-12-02 11:57:26 +00:00
|
|
|
TDate data(decode(c.get(dname)));
|
|
|
|
TDate oggi(TODAY);
|
|
|
|
real remaining_time(decode(c.get(hname)));
|
|
|
|
main_app()._start_time = time(NULL);
|
|
|
|
|
|
|
|
if (data < oggi)
|
|
|
|
{
|
|
|
|
data = oggi;
|
|
|
|
c.set(dname, encode(data));
|
|
|
|
c.set(hname, encode("120.00"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (data == oggi)
|
|
|
|
{
|
|
|
|
if (remaining_time <= ZERO)
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
#endif
|
1997-12-24 14:26:25 +00:00
|
|
|
|
|
|
|
// Setta il vero menu principale se diverso dal default
|
|
|
|
const int meno = _application->argc() > 1 ? atoi(_application->argv(1)+1) : 0;
|
|
|
|
ignore_xvt_errors(TRUE);
|
|
|
|
MENU_ITEM* menu = xvt_res_get_menu(MENU_BAR(meno));
|
|
|
|
ignore_xvt_errors(FALSE);
|
|
|
|
if (menu)
|
|
|
|
{
|
|
|
|
xvt_menu_set_tree(win, menu);
|
|
|
|
xvt_res_free_menu_tree(menu);
|
|
|
|
}
|
2002-09-13 14:56:23 +00:00
|
|
|
if (dictionary_active())
|
|
|
|
xvt_menu_translate_tree(win, dictionary_translate_menu_item);
|
1997-12-24 14:26:25 +00:00
|
|
|
|
|
|
|
// Setta la caption della task window
|
1997-01-09 16:33:39 +00:00
|
|
|
TString cap;
|
2001-05-04 10:59:04 +00:00
|
|
|
TString firm;
|
2002-12-18 10:56:10 +00:00
|
|
|
cap << _application->get_module_name() << " - " << producer_name(firm);
|
1997-12-24 14:26:25 +00:00
|
|
|
TTemp_window tw(win);
|
1997-01-09 16:33:39 +00:00
|
|
|
tw.set_caption(cap);
|
1997-12-24 14:26:25 +00:00
|
|
|
|
|
|
|
// Carica colori e font
|
1997-01-07 11:27:47 +00:00
|
|
|
customize_controls(TRUE);
|
1997-12-24 14:26:25 +00:00
|
|
|
|
|
|
|
// Crea il banner iniziale
|
1997-01-07 11:27:47 +00:00
|
|
|
create_backdrop();
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1997-01-07 11:27:47 +00:00
|
|
|
do_events();
|
1998-02-24 10:37:28 +00:00
|
|
|
os_allow_another_instance();
|
1997-06-02 09:55:35 +00:00
|
|
|
}
|
1994-09-22 07:48:15 +00:00
|
|
|
break;
|
|
|
|
case E_UPDATE:
|
|
|
|
backdrop_eh(win, ep);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-02-28 11:35:23 +00:00
|
|
|
return _application->handler(win, ep);
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
1998-02-24 10:37:28 +00:00
|
|
|
void TApplication::dispatch_e_menu(MENU_TAG tag)
|
|
|
|
{
|
|
|
|
::dispatch_e_menu(TASK_WIN, tag);
|
|
|
|
}
|
|
|
|
|
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();
|
1997-06-02 09:55:35 +00:00
|
|
|
}
|
|
|
|
if (_create_ok)
|
1994-11-30 09:04:03 +00:00
|
|
|
{
|
|
|
|
on_firm_change();
|
|
|
|
on_config_change();
|
2002-07-03 14:48:48 +00:00
|
|
|
#ifdef XVAGA
|
|
|
|
return 1;
|
|
|
|
#else
|
1994-12-05 18:57:23 +00:00
|
|
|
do_events();
|
2002-07-03 14:48:48 +00:00
|
|
|
#endif
|
1997-06-02 09:55:35 +00:00
|
|
|
}
|
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;
|
1996-07-26 15:41:29 +00:00
|
|
|
case E_COMMAND:
|
|
|
|
switch(ep->v.cmd.tag)
|
|
|
|
{
|
|
|
|
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:
|
|
|
|
if (config())
|
|
|
|
on_config_change();
|
|
|
|
break;
|
1997-12-24 14:26:25 +00:00
|
|
|
case (M_FILE_ABOUT+1):
|
1996-07-26 15:41:29 +00:00
|
|
|
about();
|
|
|
|
break;
|
1997-12-24 14:26:25 +00:00
|
|
|
case M_HELP_CONTENTS:
|
|
|
|
case M_HELP_SEARCH:
|
|
|
|
case M_HELP_HELPONHELP:
|
2002-12-18 10:56:10 +00:00
|
|
|
{
|
|
|
|
TFilename n = "campo";
|
|
|
|
TString16 module = name(); module.cut(2);
|
|
|
|
if (module != "ba")
|
|
|
|
n.insert(module);
|
|
|
|
FILE_SPEC fs; memset(&fs, 0, sizeof(FILE_SPEC));
|
|
|
|
strcpy(fs.name, n);
|
|
|
|
XVT_HELP_INFO hi = xvt_help_open_helpfile(&fs, 0);
|
|
|
|
xvt_help_process_event(hi, win, ep);
|
|
|
|
}
|
1997-12-24 14:26:25 +00:00
|
|
|
break;
|
1996-07-26 15:41:29 +00:00
|
|
|
default:
|
1996-11-12 14:53:09 +00:00
|
|
|
if (ep->v.cmd.tag > MAX_MENU_TAG)
|
1996-07-26 15:41:29 +00:00
|
|
|
{
|
1996-11-12 14:53:09 +00:00
|
|
|
WINDOW w = cur_win();
|
|
|
|
if (w != NULL_WIN && w != win)
|
|
|
|
::dispatch_e_menu(w, ep->v.cmd.tag);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ep->v.cmd.tag >= BAR_ITEM(1))
|
|
|
|
{
|
|
|
|
if(!menu(ep->v.cmd.tag))
|
|
|
|
stop_run();
|
1997-06-02 09:55:35 +00:00
|
|
|
}
|
|
|
|
}
|
1996-07-26 15:41:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_CLOSE:
|
1994-09-22 07:48:15 +00:00
|
|
|
if (can_close())
|
|
|
|
stop_run();
|
2002-02-28 16:45:27 +00:00
|
|
|
#ifdef XVAGA
|
2002-02-28 11:35:23 +00:00
|
|
|
else
|
|
|
|
return 1; // Divieto!
|
|
|
|
#endif
|
1994-09-22 07:48:15 +00:00
|
|
|
break;
|
1997-06-02 09:55:35 +00:00
|
|
|
case E_FONT:
|
1996-07-26 15:41:29 +00:00
|
|
|
{
|
1997-06-02 09:55:35 +00:00
|
|
|
XVT_FNTID new_font = ep->v.font.font_id;
|
|
|
|
char font_ser_desc[512];
|
1996-07-26 15:41:29 +00:00
|
|
|
TConfig font(CONFIG_USER, "Font");
|
1997-06-02 09:55:35 +00:00
|
|
|
|
|
|
|
xvt_font_serialize(new_font, font_ser_desc, sizeof(font_ser_desc));
|
1996-07-26 15:41:29 +00:00
|
|
|
font.set("FontDesc", font_ser_desc);
|
|
|
|
font.set_paragraph("Colors"); // Forza la scrittura del paragrafo
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1996-07-26 15:41:29 +00:00
|
|
|
xvt_load_default_font();
|
|
|
|
}
|
1994-09-22 07:48:15 +00:00
|
|
|
break;
|
1996-07-26 15:41:29 +00:00
|
|
|
case E_QUIT:
|
1997-06-02 09:55:35 +00:00
|
|
|
if (ep->v.query)
|
1996-07-26 15:41:29 +00:00
|
|
|
{
|
|
|
|
if (can_close())
|
|
|
|
xvt_app_allow_quit();
|
1997-06-02 09:55:35 +00:00
|
|
|
}
|
|
|
|
else
|
1996-07-26 15:41:29 +00:00
|
|
|
stop_run();
|
1994-09-22 07:48:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1994-10-31 12:09:58 +00:00
|
|
|
|
|
|
|
return 0L;
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-30 15:04:10 +00:00
|
|
|
const TString & TApplication::god_string(const char* keyword) const
|
1999-10-22 10:00:18 +00:00
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
if (_god_vars== NULL)
|
|
|
|
((TApplication *)this)->_god_vars = new TAssoc_array;
|
|
|
|
|
2001-04-30 15:04:10 +00:00
|
|
|
TString* s = (TString*)_god_vars->objptr(keyword);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
|
|
if (s == NULL)
|
|
|
|
{
|
|
|
|
TConfig c(CONFIG_GODMODE);
|
|
|
|
s = new TString(c.get(keyword));
|
|
|
|
_god_vars->add(keyword, s);
|
|
|
|
}
|
|
|
|
return *s;
|
1999-10-22 10:00:18 +00:00
|
|
|
}
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
void TApplication::stop_run()
|
|
|
|
{
|
2003-01-07 12:20:49 +00:00
|
|
|
if (_savefirm)
|
|
|
|
prefix().set_codditta(_savefirm);
|
1997-12-02 11:57:26 +00:00
|
|
|
#ifdef _DEMO_
|
|
|
|
{
|
|
|
|
const TString16 hname(encode("ORA"));
|
1998-04-30 14:54:04 +00:00
|
|
|
TConfig c(CONFIG_INSTALL, "Main");
|
1997-12-02 11:57:26 +00:00
|
|
|
real remaining_time(decode(c.get(hname)));
|
|
|
|
if (name() != "ba0100")
|
|
|
|
{
|
|
|
|
time_t wt = time(NULL);
|
|
|
|
int delay = (int) (wt - _start_time);
|
|
|
|
if (delay < 0)
|
|
|
|
remaining_time = ZERO;
|
|
|
|
else
|
|
|
|
remaining_time -= (delay / 60.0);
|
|
|
|
c.set(hname, encode(remaining_time.string()));
|
|
|
|
}
|
|
|
|
else
|
2002-09-13 14:56:23 +00:00
|
|
|
message_box(TR("Questo e' un programma dimostrativo.\nOggi rimangono %s minuti di utilizzo."), remaining_time.string(3, 0));
|
1997-12-02 11:57:26 +00:00
|
|
|
}
|
|
|
|
#endif
|
1994-09-22 07:48:15 +00:00
|
|
|
terminate();
|
1998-11-04 18:04:26 +00:00
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_app_destroy();
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-04-10 16:31:00 +00:00
|
|
|
bool TApplication::add_menu(TString_array& menu, MENU_TAG id)
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1995-04-10 16:31:00 +00:00
|
|
|
TTemp_window tw(TASK_WIN);
|
|
|
|
return tw.add_menu(menu,id,TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TApplication::remove_menu(MENU_TAG id)
|
|
|
|
{
|
|
|
|
TTemp_window tw(TASK_WIN);
|
|
|
|
return tw.remove_menu(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-06-02 09:55:35 +00:00
|
|
|
TApplication::TApplication()
|
1999-10-22 10:00:18 +00:00
|
|
|
: _savefirm(0), _create_ok(FALSE), _god_vars(NULL)
|
1998-02-13 13:46:18 +00:00
|
|
|
{
|
|
|
|
}
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
TApplication::~TApplication()
|
1999-10-22 10:00:18 +00:00
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
if (_god_vars != NULL)
|
|
|
|
delete _god_vars;
|
1999-10-22 10:00:18 +00:00
|
|
|
}
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
bool TApplication::create()
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TApplication::destroy()
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1994-09-22 07:48:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TApplication::terminate()
|
|
|
|
{
|
1998-02-24 10:37:28 +00:00
|
|
|
os_wake_up_caller();
|
1997-06-19 15:14:28 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
close_all_dialogs();
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
if (_create_ok)
|
|
|
|
destroy(); // Distruzione files e maschere
|
1996-11-12 14:53:09 +00:00
|
|
|
|
1995-03-27 14:36:11 +00:00
|
|
|
do_events();
|
1997-06-02 09:55:35 +00:00
|
|
|
|
|
|
|
if (use_files())
|
1998-10-01 13:48:06 +00:00
|
|
|
{
|
|
|
|
_used_files.destroy();
|
1994-12-07 11:10:57 +00:00
|
|
|
free_global_vars(); // Distruzione variabili globali
|
1998-10-01 13:48:06 +00:00
|
|
|
}
|
1997-06-02 09:55:35 +00:00
|
|
|
|
|
|
|
printer_destroy();
|
1994-09-22 07:48:15 +00:00
|
|
|
|
2002-09-13 14:56:23 +00:00
|
|
|
dictionary_close();
|
|
|
|
|
2002-12-18 10:56:10 +00:00
|
|
|
xvt_help_close_helpfile(NULL_HELP_INFO);
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
customize_controls(FALSE); // Rilascio eventuali DLL
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char* TApplication::get_module_name() const
|
1998-02-06 16:03:18 +00:00
|
|
|
{
|
|
|
|
TString& module = ((TApplication*)this)->_module_name; // Fool the compiler
|
|
|
|
if (module.empty())
|
1994-11-16 15:51:06 +00:00
|
|
|
{
|
2002-02-28 11:35:23 +00:00
|
|
|
TScanner scanner(AUT_FILE);
|
1998-02-06 16:03:18 +00:00
|
|
|
|
|
|
|
bool ok = FALSE;
|
|
|
|
for (int aut = 0; scanner.line() != ""; aut++)
|
2002-12-18 10:56:10 +00:00
|
|
|
if (strncmp(scanner.token(), _name, 2) == 0)
|
1998-02-06 16:03:18 +00:00
|
|
|
{ ok = TRUE; break; }
|
|
|
|
module = scanner.token().mid(3);
|
|
|
|
if (ok && check_autorization())
|
|
|
|
ok = has_module(aut);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
1997-06-02 09:55:35 +00:00
|
|
|
if (!ok)
|
1995-09-22 10:53:44 +00:00
|
|
|
{
|
1998-08-10 10:08:03 +00:00
|
|
|
if (module.empty())
|
|
|
|
module = "Tools";
|
1998-02-06 16:03:18 +00:00
|
|
|
TToken_string em(extra_modules());
|
1998-02-13 13:46:18 +00:00
|
|
|
if (!em.empty_items())
|
1998-02-06 16:03:18 +00:00
|
|
|
{
|
1998-02-13 13:46:18 +00:00
|
|
|
if (em != "*")
|
1998-02-06 16:03:18 +00:00
|
|
|
{
|
1998-02-13 13:46:18 +00:00
|
|
|
FOR_EACH_TOKEN(em, cod)
|
1998-02-06 16:03:18 +00:00
|
|
|
{
|
1998-02-13 13:46:18 +00:00
|
|
|
if (has_module(atoi(cod)))
|
|
|
|
{
|
|
|
|
ok = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-02-06 16:03:18 +00:00
|
|
|
}
|
1998-02-13 13:46:18 +00:00
|
|
|
else
|
|
|
|
ok = TRUE;
|
|
|
|
}
|
1998-02-06 16:03:18 +00:00
|
|
|
if (!ok)
|
|
|
|
{
|
2002-09-13 14:56:23 +00:00
|
|
|
error_box(TR("Il modulo '%s' non e' autorizzato per l'utente %s"), (const char*)module, ((const char*)user()));
|
1998-02-06 16:03:18 +00:00
|
|
|
module.cut(0);
|
|
|
|
}
|
1995-09-22 10:53:44 +00:00
|
|
|
}
|
1998-02-06 16:03:18 +00:00
|
|
|
}
|
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()
|
1997-12-02 11:57:26 +00:00
|
|
|
{
|
2002-07-03 14:48:48 +00:00
|
|
|
_user_aut.set(0, TRUE); // Attiva la BASE
|
1997-06-02 09:55:35 +00:00
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
TString& utente = user();
|
2002-07-03 14:48:48 +00:00
|
|
|
if (utente.empty() && god_mode("AdminForever"))
|
2000-05-05 15:25:49 +00:00
|
|
|
utente = ::dongle().administrator();
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
if (utente.not_empty())
|
1994-11-07 16:32:57 +00:00
|
|
|
{
|
1999-03-22 15:55:50 +00:00
|
|
|
if (utente == ::dongle().administrator())
|
1994-11-07 16:32:57 +00:00
|
|
|
{
|
|
|
|
for (int i = 1 ; i < ENDAUT; i++)
|
|
|
|
_user_aut.set(i);
|
|
|
|
}
|
|
|
|
else
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1998-07-20 13:00:14 +00:00
|
|
|
int err = _iskeynotfound;
|
1996-05-14 09:58:45 +00:00
|
|
|
if (use_files())
|
1994-11-07 16:32:57 +00:00
|
|
|
{
|
1996-05-14 09:58:45 +00:00
|
|
|
TLocalisamfile users(LF_USER);
|
|
|
|
users.zero();
|
|
|
|
users.put("USERNAME", utente);
|
1998-07-20 13:00:14 +00:00
|
|
|
err = users.read();
|
|
|
|
if (err == NOERR)
|
1996-05-14 09:58:45 +00:00
|
|
|
{
|
1996-05-28 15:47:35 +00:00
|
|
|
const TString& aut = users.get("AUTSTR");
|
|
|
|
for (int i = aut.len()-1; i > 0; i--)
|
|
|
|
_user_aut.set(i, aut[i] == 'X');
|
1996-05-14 09:58:45 +00:00
|
|
|
}
|
1994-11-07 16:32:57 +00:00
|
|
|
}
|
1998-07-20 13:00:14 +00:00
|
|
|
if (err != NOERR && utente == "GUEST")
|
|
|
|
{
|
|
|
|
for (int i = 1 ; i < ENDAUT; i++)
|
|
|
|
_user_aut.set(i);
|
|
|
|
}
|
1994-11-07 16:32:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
1994-11-07 16:32:57 +00:00
|
|
|
|
1996-01-31 17:19:02 +00:00
|
|
|
// @mfunc Legge il parametro /uUTENTE e lo toglie dalla lista
|
|
|
|
void TApplication::check_parameters(
|
|
|
|
int & argc, // @parm Numero del parametro da controllare
|
|
|
|
char* argv[]) // @parm Array di paramentri da passare all'applicazione
|
|
|
|
|
|
|
|
// @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.
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1995-06-06 08:50:16 +00:00
|
|
|
if (argc > 1)
|
|
|
|
{
|
1997-09-30 10:40:28 +00:00
|
|
|
TString u(argv[argc-1]);
|
|
|
|
u.upper();
|
1995-06-06 08:50:16 +00:00
|
|
|
if (u.compare("-u", 2, TRUE) == 0 || u.compare("/u", 2, TRUE) == 0)
|
|
|
|
{
|
|
|
|
user() = u.mid(2);
|
|
|
|
argc--;
|
1997-06-02 09:55:35 +00:00
|
|
|
}
|
1995-06-06 08:50:16 +00:00
|
|
|
}
|
2001-06-25 10:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TApplication::test_assistance_year() const
|
|
|
|
{
|
|
|
|
#ifndef _DEMO_
|
|
|
|
const int dongle_year = dongle().year_assist();
|
|
|
|
|
|
|
|
int app_year, dum1, dum2, dum3;
|
|
|
|
bool ok = TApplication::get_version_info(app_year, dum1, dum2, dum3);
|
|
|
|
if (ok)
|
|
|
|
ok = app_year <= dongle_year;
|
|
|
|
return ok;
|
|
|
|
#else
|
|
|
|
return TRUE;
|
|
|
|
#endif // _DEMO_
|
1994-11-07 16:32:57 +00:00
|
|
|
}
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
1994-11-10 14:17:03 +00:00
|
|
|
|
1996-01-31 17:19:02 +00:00
|
|
|
// @mfunc Fa partire l'applicazione
|
|
|
|
void TApplication::run(
|
|
|
|
int argc, // @parm Numero deglia argomenti da passara all'applicazione
|
|
|
|
char* argv[], // @parm Argomenti da passare all'applicazione
|
|
|
|
const char* title) // @parm Titolo dell'applicazione
|
|
|
|
|
|
|
|
// @comm E' in questa fase che si controlla se esiste la chiave e' attaccata
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1998-02-13 13:46:18 +00:00
|
|
|
CHECK(_application == NULL, "Sorry, multitasking not implemented");
|
|
|
|
// Devo metterla qui per far funzionare la TDongle::network_login
|
|
|
|
_application = this;
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
TFilename base(argv[0]);
|
|
|
|
base.ext(""); base.lower();
|
1995-04-10 15:28:03 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
_title = title;
|
1995-04-10 15:28:03 +00:00
|
|
|
|
1995-03-22 09:07:04 +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
|
|
|
|
1998-03-13 10:18:29 +00:00
|
|
|
_argc_ = argc;
|
|
|
|
_argv_ = (const char**)argv;
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1995-04-10 15:28:03 +00:00
|
|
|
if (argc > 1 && argv[1][0] == '-')
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
|
|
|
_name = cmd2name(argv[0], argv[1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_name = cmd2name(argv[0]);
|
|
|
|
}
|
1997-06-03 13:51:20 +00:00
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
if (use_files())
|
|
|
|
init_global_vars();
|
|
|
|
else
|
|
|
|
CGetPref();
|
2000-05-05 15:25:49 +00:00
|
|
|
|
1998-02-13 13:46:18 +00:00
|
|
|
const int sn = get_serial_number();
|
|
|
|
|
1997-06-03 13:51:20 +00:00
|
|
|
if (sn < 0)
|
|
|
|
{
|
2002-09-13 14:56:23 +00:00
|
|
|
error_box(TR("Probabilmente non e' stata inserita la chiave di protezione"));
|
1997-06-03 13:51:20 +00:00
|
|
|
return;
|
|
|
|
}
|
1998-01-27 10:27:24 +00:00
|
|
|
if (!test_assistance_year())
|
|
|
|
{
|
2002-09-13 14:56:23 +00:00
|
|
|
error_box(TR("Probabilmente e' necessario attivare il contratto di assistenza"));
|
1998-01-27 10:27:24 +00:00
|
|
|
return;
|
|
|
|
}
|
1997-06-02 09:55:35 +00:00
|
|
|
|
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());
|
1997-06-02 09:55:35 +00:00
|
|
|
if (mod.empty())
|
1997-01-07 11:27:47 +00:00
|
|
|
return;
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
XVT_CONFIG cfg;
|
1998-03-30 13:39:21 +00:00
|
|
|
cfg.menu_bar_ID = TASK_MENUBAR;
|
1994-09-22 07:48:15 +00:00
|
|
|
cfg.about_box_ID = 0;
|
1996-11-12 14:53:09 +00:00
|
|
|
cfg.base_appl_name = (char*)base.name();
|
1997-01-09 16:33:39 +00:00
|
|
|
cfg.appl_name = (char*)title;
|
2002-07-03 14:48:48 +00:00
|
|
|
cfg.taskwin_title = "CAMPO";
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1997-01-14 11:31:13 +00:00
|
|
|
set_xvt_hooks();
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1998-02-13 13:46:18 +00:00
|
|
|
_xvt_running = TRUE;
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_app_create(argc, argv, 0L, task_eh, &cfg);
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
1998-01-27 10:27:24 +00:00
|
|
|
bool TApplication::get_version_info(int& year, int& release, int& tag, int& patch)
|
|
|
|
{
|
2002-07-03 14:48:48 +00:00
|
|
|
const char* const VERSIONANDPATCH = "Don't cry for me Argentina.2002.02.00.000.2004";
|
1998-01-27 10:27:24 +00:00
|
|
|
TToken_string vep(VERSIONANDPATCH, '.');
|
|
|
|
year = vep.get_int(1);
|
|
|
|
release = vep.get_int();
|
|
|
|
tag = vep.get_int();
|
|
|
|
patch = vep.get_int();
|
|
|
|
int checksum = vep.get_int();
|
|
|
|
|
2002-07-03 14:48:48 +00:00
|
|
|
bool valid = year >= 2002 && release > 0 && tag >= 0 && patch >= 0 &&
|
1998-01-27 10:27:24 +00:00
|
|
|
checksum == (year + release + tag + patch);
|
|
|
|
return valid;
|
|
|
|
}
|
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
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
2003-01-07 12:20:49 +00:00
|
|
|
TInfo_mask info;
|
|
|
|
info.run();
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Risposta alla selezione Stampa del menu File
|
|
|
|
void TApplication::print()
|
|
|
|
{
|
|
|
|
#ifdef DBG
|
1998-07-20 13:00:14 +00:00
|
|
|
NFCHECK("Non saprei bene cosa stampare!");
|
1994-09-22 07:48:15 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void TApplication::check_menu_item(MENU_TAG item)
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_menu_set_item_checked(TASK_WIN, item, TRUE);
|
|
|
|
xvt_menu_update(TASK_WIN);
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TApplication::uncheck_menu_item(MENU_TAG item)
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_menu_set_item_checked(TASK_WIN, item, FALSE);
|
|
|
|
xvt_menu_update(TASK_WIN);
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1996-01-31 17:19:02 +00:00
|
|
|
// @mfunc Permette di abilitare/disabilitare una voce di menu'
|
|
|
|
void TApplication::enable_menu_item(
|
|
|
|
MENU_TAG item, // @parm Voce del menu' da abilitare/disabilitare
|
|
|
|
bool on) // @parm Operazione da svolgere sulla voce del menu':
|
|
|
|
//
|
|
|
|
// @flag TRUE | Viene abilitata la voce del menu'
|
|
|
|
// @flag FALSE | Viene disabilitata la voce del menu'
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
xvt_menu_set_item_enabled(TASK_WIN, item, on);
|
|
|
|
xvt_menu_update(TASK_WIN);
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
1994-11-07 16:32:57 +00:00
|
|
|
bool TApplication::has_module(int module, int checktype) const
|
1997-12-02 11:57:26 +00:00
|
|
|
{
|
1994-11-07 16:32:57 +00:00
|
|
|
bool ok = TRUE;
|
1997-12-02 11:57:26 +00:00
|
|
|
#ifndef _DEMO_
|
2002-07-03 14:48:48 +00:00
|
|
|
// Ignora i bit di attivazione della chiave programmatori (sempre attivati)
|
|
|
|
if (get_serial_number() == 0)
|
|
|
|
checktype = CHK_USER;
|
|
|
|
|
2002-12-18 10:56:10 +00:00
|
|
|
|
1994-11-07 16:32:57 +00:00
|
|
|
if (checktype == CHK_ALL || checktype == CHK_DONGLE)
|
2002-07-03 14:48:48 +00:00
|
|
|
ok = dongle().active(module);
|
1997-12-02 11:57:26 +00:00
|
|
|
#endif
|
2002-07-02 16:21:23 +00:00
|
|
|
|
|
|
|
// Testa bit di attivazione dell'utente
|
2000-05-05 15:25:49 +00:00
|
|
|
if (ok && (checktype == CHK_ALL || checktype == CHK_USER))
|
1994-11-07 16:32:57 +00:00
|
|
|
ok = _user_aut[module];
|
|
|
|
return ok;
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long TApplication::get_firm() const
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
return prefix().get_codditta();
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* TApplication::get_firm_dir() const
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
return format("%s%s", __ptprf, prefix().name());
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
bool TApplication::build_firm_data(long codditta, bool flagcom)
|
|
|
|
{
|
|
|
|
const char * const ndir = "/dir.gen";
|
|
|
|
const char * const ntrc = "/trc.gen";
|
|
|
|
TFilename s(firm2dir(codditta)); s << ndir;
|
|
|
|
bool exist = fexist(s);
|
|
|
|
|
|
|
|
if (!exist)
|
|
|
|
{
|
|
|
|
s = s.path(); s.rtrim(1); s << ntrc;
|
|
|
|
exist = fexist(s);
|
|
|
|
}
|
|
|
|
if (exist)
|
2002-09-13 14:56:23 +00:00
|
|
|
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))
|
1999-07-16 14:59:11 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
TLocalisamfile ditte(LF_NDITTE);
|
|
|
|
ditte.zero();
|
|
|
|
ditte.put("CODDITTA",codditta);
|
|
|
|
if (ditte.read(_isequal,_testandlock) == _islocked)
|
|
|
|
{
|
2002-09-13 14:56:23 +00:00
|
|
|
message_box(TR("Archivi della ditta %ld in fase di creazione da parte di un altro utente."),codditta);
|
1999-07-16 14:59:11 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-09-13 14:56:23 +00:00
|
|
|
set_autoload_new_files(yesno_box(TR("Si desidera precaricare gli archivi standard")));
|
1999-07-16 14:59:11 +00:00
|
|
|
s = s.path(); s.rtrim(1);
|
|
|
|
|
|
|
|
if (!fexist(s) && !make_dir(s))
|
2002-09-13 14:56:23 +00:00
|
|
|
return error_box(TR("Impossibile creare il direttorio della ditta %ld (%s)"),
|
1999-07-16 14:59:11 +00:00
|
|
|
codditta, (const char*)s);
|
|
|
|
|
|
|
|
s << ndir;
|
|
|
|
if (!fcopy(&ndir[1], s))
|
2002-09-13 14:56:23 +00:00
|
|
|
return error_box(TR("Impossibile copiare il file %s della ditta %ld"),
|
1999-07-16 14:59:11 +00:00
|
|
|
&ndir[1], codditta);
|
|
|
|
s = s.path(); s << ntrc;
|
|
|
|
if (!fcopy(&ntrc[1], s))
|
2002-09-13 14:56:23 +00:00
|
|
|
return error_box(TR("Impossibile copiare il file %s della ditta %ld"),
|
1999-07-16 14:59:11 +00:00
|
|
|
ntrc, codditta);
|
|
|
|
|
|
|
|
TDir dir, dir1;
|
|
|
|
TTrec rec;
|
|
|
|
|
|
|
|
prefix().set("");
|
|
|
|
dir1.get(LF_DIR, _nolock, _nordir, _sysdirop);
|
|
|
|
const long maxeod0 = dir1.eod();
|
|
|
|
|
|
|
|
prefix().set_codditta(codditta);
|
|
|
|
dir.get(LF_DIR, _nolock, _nordir, _sysdirop);
|
|
|
|
if (dir.eod() == 0)
|
|
|
|
{
|
|
|
|
dir1.eod() = 1L;
|
|
|
|
dir1.put(LF_DIR, _nordir, _sysdirop);
|
|
|
|
dir.get(LF_DIR, _nolock, _nordir, _sysdirop);
|
|
|
|
}
|
|
|
|
const long maxeod1 = dir.eod();
|
|
|
|
|
|
|
|
if (maxeod0 > maxeod1)
|
|
|
|
{
|
|
|
|
dir.get(LF_DIR, _nolock, _nordir, _sysdirop);
|
|
|
|
dir.eod() = maxeod0;
|
|
|
|
dir.put(LF_DIR, _nordir, _sysdirop);
|
|
|
|
rec.zero();
|
|
|
|
}
|
2002-09-13 14:56:23 +00:00
|
|
|
TString mess(TR("Generazione archivi della ditta ")); mess << codditta;
|
1999-07-16 14:59:11 +00:00
|
|
|
TProgind p(maxeod0 ? maxeod0 : 1, mess, FALSE, TRUE, 70);
|
|
|
|
|
|
|
|
for (int i = LF_DIR + 1; i <= maxeod0; i++)
|
|
|
|
{
|
|
|
|
p.addstatus(1);
|
|
|
|
prefix().set("");
|
|
|
|
dir.get(i, _nolock, _nordir, _sysdirop);
|
|
|
|
rec.get(i);
|
|
|
|
bool create_now = dir.is_active();
|
|
|
|
|
|
|
|
prefix().set_codditta(codditta);
|
|
|
|
dir.put(i, _nordir, _sysdirop);
|
|
|
|
rec.put(i);
|
|
|
|
const char* name = dir.name();
|
|
|
|
dir.flags() = 0L;
|
|
|
|
create_now = create_now && (flagcom ? dir.is_com() : dir.is_firm());
|
|
|
|
|
|
|
|
if (dir.is_valid() && create_now)
|
|
|
|
{
|
|
|
|
TSystemisamfile f(i);
|
|
|
|
f.build(30);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dir.put(i, _nordir, _sysdirop);
|
|
|
|
rec.put(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TConfig c(CONFIG_STUDIO, "cg");
|
|
|
|
|
|
|
|
if (c.get_bool("StiReg"))
|
|
|
|
{
|
|
|
|
TTable reg("REG");
|
|
|
|
for (reg.first(_lock); reg.good(); reg.next(_lock))
|
|
|
|
{
|
|
|
|
reg.put("B9", "X");
|
|
|
|
reg.rewrite();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ditte.reread(_unlock);
|
|
|
|
|
|
|
|
set_firm(codditta);
|
|
|
|
set_autoload_new_files(TRUE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
bool TApplication::set_firm(long newfirm)
|
|
|
|
{
|
|
|
|
const long oldfirm = get_firm();
|
2001-04-30 15:04:10 +00:00
|
|
|
const bool interactive = newfirm <= 0;
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1997-12-02 11:57:26 +00:00
|
|
|
#ifndef _DEMO_
|
2001-04-30 15:04:10 +00:00
|
|
|
if (interactive)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
|
|
|
TMask mask("bagn002");
|
1997-10-31 13:43:39 +00:00
|
|
|
TFilename pp(__ptprf); pp.cut(pp.len()-1);
|
1994-12-14 14:33:46 +00:00
|
|
|
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);
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
if (tipodir == 0 && !prefix().exist(newfirm) &&
|
1998-02-24 10:37:28 +00:00
|
|
|
!prefix().build_firm_data(newfirm))
|
1994-11-10 11:15:47 +00:00
|
|
|
return FALSE;
|
1994-09-22 07:48:15 +00:00
|
|
|
if (tipodir > 0)
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
if (_savefirm == 0) _savefirm = oldfirm; // E' necessario ricordare la ditta ...
|
|
|
|
prefix().set(tipodir == 1 ? "com" : ""); // ... se si setta il prefix a com
|
1994-09-22 07:48:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-12-02 11:57:26 +00:00
|
|
|
#endif
|
2001-04-30 15:04:10 +00:00
|
|
|
|
|
|
|
if (interactive)
|
|
|
|
{
|
|
|
|
if (newfirm <= 0)
|
|
|
|
return newfirm > 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (newfirm == oldfirm || newfirm <= 0)
|
|
|
|
return newfirm > 0;
|
|
|
|
}
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
if (prefix().test(newfirm))
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
prefix().set_codditta(newfirm);
|
1994-11-10 14:17:03 +00:00
|
|
|
_savefirm = 0;
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1994-11-30 09:04:03 +00:00
|
|
|
WINDOW w = cur_win();
|
1995-07-19 09:57:25 +00:00
|
|
|
if (w != NULL_WIN)
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1996-06-04 14:22:16 +00:00
|
|
|
TWindow * win = (TWindow *) xvt_vobj_get_data(w);
|
|
|
|
win->on_firm_change();
|
1995-07-19 09:57:25 +00:00
|
|
|
}
|
1994-11-30 09:04:03 +00:00
|
|
|
on_firm_change();
|
|
|
|
on_config_change();
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc INTERNAL
|
1996-01-31 17:19:02 +00:00
|
|
|
|
|
|
|
// @mfunc Gestisce le voci di configurazione
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna TRUE se sono state cambiate delle voci
|
1994-09-22 07:48:15 +00:00
|
|
|
bool TApplication::config()
|
1996-01-31 17:19:02 +00:00
|
|
|
|
|
|
|
// @comm Le si passa il file in cui cercare il proprio paragrafo (comunque relativo
|
1997-06-02 09:55:35 +00:00
|
|
|
// alla ditta) se non c'e', viene creato copiando il default la variabile EdMask
|
1996-01-31 17:19:02 +00:00
|
|
|
// di quel paragrafo specifica la maschera da usare.
|
|
|
|
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1994-09-22 07:48:15 +00:00
|
|
|
bool ok = FALSE;
|
1996-05-28 15:47:35 +00:00
|
|
|
|
1997-08-29 15:06:30 +00:00
|
|
|
TConfig conf(CONFIG_STUDIO);
|
|
|
|
TFilename name = conf.get("EdApp");
|
1997-08-18 14:11:37 +00:00
|
|
|
if (name.not_empty())
|
|
|
|
{
|
|
|
|
TExternal_app app(name);
|
|
|
|
ok = app.run() == 0;
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1997-08-29 15:06:30 +00:00
|
|
|
TConfig cnf(CONFIG_DITTA);
|
1997-08-18 14:11:37 +00:00
|
|
|
name = cnf.get("EdMask");
|
|
|
|
if (name.empty())
|
1994-12-07 11:10:57 +00:00
|
|
|
return warning_box("Nessun parametro da configurare");
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1997-08-18 14:11:37 +00:00
|
|
|
TMask* msk = new TMask(name); // Evito problemi di stack
|
1996-05-28 15:47:35 +00:00
|
|
|
TMask& m = *msk;
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1994-12-07 11:10:57 +00:00
|
|
|
// carica campi
|
|
|
|
for (int i = 0; i < m.fields(); i++)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1996-05-08 11:09:13 +00:00
|
|
|
TEditable_field& f = (TEditable_field&)m.fld(i);
|
1994-12-07 11:10:57 +00:00
|
|
|
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
|
|
|
{
|
1998-01-27 10:27:24 +00:00
|
|
|
const TString& oldvl = cnf.get(fname);
|
1994-12-07 11:10:57 +00:00
|
|
|
if (!oldvl.empty())
|
|
|
|
f.set(oldvl);
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
1994-12-07 11:10:57 +00:00
|
|
|
}
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1994-12-07 11:10:57 +00:00
|
|
|
// run mask
|
|
|
|
disable_menu_item(M_FILE_REVERT);
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1994-12-07 11:10:57 +00:00
|
|
|
if (m.run() == K_ENTER && m.dirty())
|
|
|
|
{
|
|
|
|
// aggiusta campi
|
|
|
|
for (i = 0; i < m.fields(); i++)
|
1994-09-22 07:48:15 +00:00
|
|
|
{
|
1996-05-08 11:09:13 +00:00
|
|
|
TEditable_field& f = (TEditable_field&)m.fld(i);
|
1994-12-07 11:10:57 +00:00
|
|
|
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
|
|
|
}
|
1997-06-02 09:55:35 +00:00
|
|
|
|
1996-05-28 15:47:35 +00:00
|
|
|
delete msk;
|
1994-12-07 11:10:57 +00:00
|
|
|
enable_menu_item(M_FILE_REVERT);
|
|
|
|
return ok;
|
1994-09-22 07:48:15 +00:00
|
|
|
}
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
|
1996-01-31 17:19:02 +00:00
|
|
|
// @mfunc Controlla se al programma corrente e' concesso cambiare ditta da menu.
|
|
|
|
//
|
1996-02-05 19:00:53 +00:00
|
|
|
// @rdesc Ritorna i seguenti valori:
|
1996-01-31 17:19:02 +00:00
|
|
|
//
|
|
|
|
// @flag TRUE | Se e' abilitata la voce di menu' per il cambio della ditta
|
|
|
|
// @flag FALSE | Se non e' possibile cambiare ditta da menu'
|
1995-07-19 09:57:25 +00:00
|
|
|
bool TApplication::firm_change_enabled() const
|
1996-01-31 17:19:02 +00:00
|
|
|
|
|
|
|
// @comm Praticamente controlla se e' stato lanciato da ba0 o dal program manager
|
1997-06-02 09:55:35 +00:00
|
|
|
{
|
1998-02-24 10:37:28 +00:00
|
|
|
#ifdef _DEMO_
|
1998-03-30 13:39:21 +00:00
|
|
|
return FALSE;
|
1996-05-14 09:58:45 +00:00
|
|
|
#else
|
1998-03-30 13:39:21 +00:00
|
|
|
return ::os_spawn_by_menu();
|
1996-05-14 09:58:45 +00:00
|
|
|
#endif
|
1997-12-02 11:57:26 +00:00
|
|
|
}
|
1995-07-19 09:57:25 +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()
|
|
|
|
{}
|
1995-03-13 11:29:10 +00:00
|
|
|
|
1998-10-01 13:48:06 +00:00
|
|
|
void TApplication::open_files(int logicnum, ...)
|
|
|
|
{
|
|
|
|
va_list marker;
|
|
|
|
va_start(marker, logicnum);
|
2000-05-05 15:25:49 +00:00
|
|
|
while (logicnum > 0 && logicnum < 1000)
|
1998-10-01 13:48:06 +00:00
|
|
|
{
|
1999-05-24 13:34:11 +00:00
|
|
|
if (_used_files.objptr(logicnum) == NULL)
|
|
|
|
_used_files.add(new TLocalisamfile(logicnum), logicnum);
|
1998-10-01 13:48:06 +00:00
|
|
|
logicnum = va_arg(marker, int);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-13 14:04:22 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// The Skeleton application!
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
bool TSkeleton_application::create()
|
|
|
|
{
|
|
|
|
dispatch_e_menu(BAR_ITEM(1));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-02-24 10:37:28 +00:00
|
|
|
bool TSkeleton_application::menu(MENU_TAG tag)
|
1997-10-13 14:04:22 +00:00
|
|
|
{
|
1998-02-24 10:37:28 +00:00
|
|
|
if (tag == BAR_ITEM(1))
|
|
|
|
main_loop();
|
1997-10-13 14:04:22 +00:00
|
|
|
return FALSE;
|
2002-12-18 10:56:10 +00:00
|
|
|
}
|