1994-08-26 13:04:28 +00:00
|
|
|
#include <applicat.h>
|
1995-03-22 09:07:04 +00:00
|
|
|
#include <colors.h>
|
1994-08-26 13:04:28 +00:00
|
|
|
#include <execp.h>
|
|
|
|
#include <mask.h>
|
1994-11-07 16:09:15 +00:00
|
|
|
#include <isam.h>
|
1994-11-07 13:48:44 +00:00
|
|
|
#include <prefix.h>
|
1994-10-04 15:36:42 +00:00
|
|
|
#include <progind.h>
|
1994-08-26 13:04:28 +00:00
|
|
|
#include <utility.h>
|
|
|
|
#include <urldefid.h>
|
|
|
|
|
1995-04-20 14:25:15 +00:00
|
|
|
/*
|
|
|
|
#if XVT_OS == XVT_OS_SCOUNIX
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#else
|
|
|
|
#include <direct.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
#include <dos.h>
|
|
|
|
#else
|
|
|
|
#include <dirent.h>
|
|
|
|
#endif
|
|
|
|
*/
|
1994-08-26 13:04:28 +00:00
|
|
|
|
|
|
|
#include "ba0.h"
|
1994-11-07 16:09:15 +00:00
|
|
|
#include "ba0100a.h"
|
1994-08-26 13:04:28 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Picture Mask
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TPicture_mask : public TMask
|
|
|
|
{
|
1995-04-12 15:41:15 +00:00
|
|
|
TImage & _image;
|
1994-08-26 13:04:28 +00:00
|
|
|
|
1994-09-20 12:20:31 +00:00
|
|
|
protected:
|
1994-08-26 13:04:28 +00:00
|
|
|
virtual void handler(WINDOW win, EVENT* ep);
|
|
|
|
|
|
|
|
public:
|
1995-04-12 15:41:15 +00:00
|
|
|
TPicture_mask(const char* name, int dx, int dy, TImage & image, bool remap);
|
1995-03-22 09:07:04 +00:00
|
|
|
virtual ~TPicture_mask() {}
|
1994-08-26 13:04:28 +00:00
|
|
|
};
|
|
|
|
|
1994-09-20 12:20:31 +00:00
|
|
|
|
1995-04-12 15:41:15 +00:00
|
|
|
TPicture_mask::TPicture_mask(const char* name, int dx, int dy, TImage & image, bool remap)
|
|
|
|
: TMask(name, 1, dx, dy), _image(image)
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
if (_image.ok())
|
1994-09-20 12:20:31 +00:00
|
|
|
{
|
1995-04-12 15:41:15 +00:00
|
|
|
if (!remap && MASK_BACK_COLOR != COLOR_DKCYAN)
|
1995-03-22 09:07:04 +00:00
|
|
|
_image.set_clut(6, MASK_BACK_COLOR);
|
|
|
|
else
|
|
|
|
_image.set_palette(win());
|
|
|
|
_image.set_pos(1, 1);
|
1994-09-20 12:20:31 +00:00
|
|
|
}
|
1994-08-26 13:04:28 +00:00
|
|
|
}
|
|
|
|
|
1994-09-20 12:20:31 +00:00
|
|
|
|
1994-08-26 13:04:28 +00:00
|
|
|
|
|
|
|
void TPicture_mask::handler(WINDOW win, EVENT* ep)
|
|
|
|
{
|
|
|
|
TMask::handler(win, ep);
|
|
|
|
|
|
|
|
if (ep->type == E_UPDATE)
|
|
|
|
{
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
1995-03-22 09:07:04 +00:00
|
|
|
if (_image.ok())
|
|
|
|
{
|
|
|
|
RCT src; xvt_rect_set(&src, 0, 0, _image.width(), _image.height());
|
|
|
|
const short maxx = 42*CHARX;
|
|
|
|
const short maxy = short((long)maxx*src.bottom/src.right);
|
|
|
|
RCT dst; xvt_rect_set(&dst, 1, 1, maxx, maxy);
|
|
|
|
_image.draw(win, dst);
|
|
|
|
}
|
1994-08-26 13:04:28 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
const int max = 16;
|
|
|
|
for (int i = 0; i < max; i++)
|
|
|
|
{
|
|
|
|
TTemp_window w(win);
|
|
|
|
w.rect(i*2, i, max-i*2, max-i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Menu application
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TMenu_application : public TApplication
|
|
|
|
{
|
|
|
|
const char* _name;
|
|
|
|
|
1995-03-23 17:14:42 +00:00
|
|
|
enum { MAXLEVEL = 1024 };
|
1994-08-26 13:04:28 +00:00
|
|
|
int _first[MAXLEVEL];
|
|
|
|
TArray _menu; // TAG|DESCRIPTION|ACTION
|
1994-11-07 16:09:15 +00:00
|
|
|
TBit_array _enabled;
|
1995-04-12 15:41:15 +00:00
|
|
|
TArray _modules, _images;
|
1994-08-26 13:04:28 +00:00
|
|
|
|
|
|
|
int _level, _max;
|
1994-10-24 15:00:02 +00:00
|
|
|
bool _ditta_asked;
|
1994-08-26 13:04:28 +00:00
|
|
|
|
1994-10-12 12:58:08 +00:00
|
|
|
static int _last_button;
|
|
|
|
static bool _find_button;
|
|
|
|
|
1994-08-26 13:04:28 +00:00
|
|
|
protected:
|
1995-03-22 09:07:04 +00:00
|
|
|
void test_temp();
|
1994-08-26 13:04:28 +00:00
|
|
|
void load_menu();
|
|
|
|
int do_level();
|
1994-10-11 17:34:31 +00:00
|
|
|
int find_menu(const char* s) const;
|
1994-11-07 16:09:15 +00:00
|
|
|
bool check_user();
|
1994-09-16 10:43:09 +00:00
|
|
|
virtual bool create();
|
|
|
|
virtual bool menu(MENU_TAG m);
|
1994-11-10 10:57:12 +00:00
|
|
|
virtual bool build_firm_data(long cod, bool flagcom = FALSE);
|
1994-08-26 13:04:28 +00:00
|
|
|
|
1994-10-11 17:34:31 +00:00
|
|
|
static bool menu_item_handler(TMask_field&f, KEY k);
|
|
|
|
static bool menu_find_handler(TMask_field&f, KEY k);
|
1994-11-07 16:09:15 +00:00
|
|
|
bool module_enabled(const char * program) const;
|
|
|
|
bool module_enabled(int module) const { return has_module(module);}
|
1994-10-11 17:34:31 +00:00
|
|
|
|
1994-08-26 13:04:28 +00:00
|
|
|
public:
|
1994-10-24 15:00:02 +00:00
|
|
|
TMenu_application(const char* name) : _name(name), _ditta_asked(FALSE) {}
|
1994-08-26 13:04:28 +00:00
|
|
|
};
|
|
|
|
|
1994-10-12 12:58:08 +00:00
|
|
|
int TMenu_application::_last_button = 0;
|
|
|
|
bool TMenu_application::_find_button = FALSE;
|
1994-10-11 17:34:31 +00:00
|
|
|
|
|
|
|
inline TMenu_application& app()
|
|
|
|
{ return (TMenu_application&)main_app(); }
|
1994-08-26 13:04:28 +00:00
|
|
|
|
1994-11-10 10:57:12 +00:00
|
|
|
|
1995-01-03 15:05:55 +00:00
|
|
|
bool TMenu_application::build_firm_data(long codditta, bool flagcom)
|
1994-11-10 10:57:12 +00:00
|
|
|
{
|
|
|
|
const char * const ndir = "/dir.gen";
|
|
|
|
const char * const ntrc = "/trc.gen";
|
|
|
|
TFilename s(firm2dir(codditta)); s << ndir;
|
|
|
|
bool exist = fexist(s);
|
|
|
|
|
|
|
|
if (!exist)
|
|
|
|
{
|
1995-04-12 15:41:15 +00:00
|
|
|
s = s.path(); s.rtrim(1); s << ntrc;
|
1994-11-10 10:57:12 +00:00
|
|
|
exist = fexist(s);
|
|
|
|
}
|
|
|
|
if (exist)
|
1994-11-15 11:21:00 +00:00
|
|
|
return message_box("Direttorio dati danneggiato, impossibile attivare la ditta %ld", codditta);
|
1994-11-22 15:39:32 +00:00
|
|
|
if (!yesno_box("Gli archivi della ditta %ld non esistono: si desidera generarli?", codditta))
|
1994-11-10 10:57:12 +00:00
|
|
|
return FALSE;
|
1994-11-22 15:39:32 +00:00
|
|
|
set_autoload_new_files(yesno_box("Si desidera precaricare gli archivi standard"));
|
1995-04-12 15:41:15 +00:00
|
|
|
s = s.path(); s.rtrim(1);
|
1995-02-21 15:10:12 +00:00
|
|
|
|
1995-04-20 14:25:15 +00:00
|
|
|
if (!fexist(s) && !make_dir(s))
|
|
|
|
return error_box("Impossibile creare il direttorio della ditta %ld (%s)",
|
|
|
|
codditta, (const char*)s);
|
1995-02-21 15:10:12 +00:00
|
|
|
|
1994-11-10 10:57:12 +00:00
|
|
|
s << ndir;
|
|
|
|
if (!fcopy(&ndir[1], s))
|
|
|
|
return error_box("Impossibile copiare il file %s della ditta %ld",
|
|
|
|
&ndir[1], codditta);
|
|
|
|
s = s.path(); s << ntrc;
|
|
|
|
if (!fcopy(&ntrc[1], s))
|
|
|
|
return error_box("Impossibile copiare il file %s della ditta %ld",
|
|
|
|
ntrc, codditta);
|
|
|
|
|
1995-01-03 15:05:55 +00:00
|
|
|
begin_wait();
|
1994-11-10 10:57:12 +00:00
|
|
|
TDir dir, dir1;
|
|
|
|
TTrec rec;
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
prefix().set("");
|
1994-11-10 10:57:12 +00:00
|
|
|
dir1.get(LF_DIR, _nolock, _nordir, _sysdirop);
|
1995-01-31 16:12:49 +00:00
|
|
|
const long maxeod0 = dir1.eod();
|
1994-11-10 10:57:12 +00:00
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
prefix().set_codditta(codditta);
|
1994-11-10 10:57:12 +00:00
|
|
|
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();
|
|
|
|
}
|
1995-01-03 15:05:55 +00:00
|
|
|
TString80 mess("Generazione archivi della ditta "); mess << codditta;
|
1994-11-10 10:57:12 +00:00
|
|
|
TProgind p(maxeod0 ? maxeod0 : 1, mess, TRUE, TRUE, 70);
|
|
|
|
|
|
|
|
for (int i = LF_DIR + 1; i <= maxeod0; i++)
|
|
|
|
{
|
|
|
|
p.addstatus(1);
|
1995-03-22 09:07:04 +00:00
|
|
|
prefix().set("");
|
1994-11-10 10:57:12 +00:00
|
|
|
dir.get(i, _nolock, _nordir, _sysdirop);
|
|
|
|
rec.get(i);
|
1995-02-02 18:08:50 +00:00
|
|
|
bool create_now = dir.is_active();
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
prefix().set_codditta(codditta);
|
1994-12-05 18:52:37 +00:00
|
|
|
dir.put(i, _nordir, _sysdirop);
|
|
|
|
rec.put(i);
|
1994-11-10 10:57:12 +00:00
|
|
|
const char* name = dir.name();
|
|
|
|
dir.flags() = 0L;
|
1995-02-02 18:08:50 +00:00
|
|
|
create_now = create_now && (flagcom ? dir.is_com() : dir.is_firm());
|
1994-11-10 10:57:12 +00:00
|
|
|
|
1995-02-02 18:08:50 +00:00
|
|
|
if (dir.is_valid() && create_now)
|
1994-11-10 10:57:12 +00:00
|
|
|
{
|
|
|
|
TSystemisamfile f(i);
|
|
|
|
f.build(30);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1995-02-02 18:08:50 +00:00
|
|
|
// if (!flagcom)
|
|
|
|
// {
|
|
|
|
// dir.len() = 0;
|
|
|
|
// rec.zero();
|
|
|
|
// }
|
1994-11-10 10:57:12 +00:00
|
|
|
dir.put(i, _nordir, _sysdirop);
|
|
|
|
rec.put(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-01-31 16:12:49 +00:00
|
|
|
set_firm(codditta);
|
1994-11-22 15:39:32 +00:00
|
|
|
set_autoload_new_files(TRUE);
|
1995-01-03 15:05:55 +00:00
|
|
|
end_wait();
|
|
|
|
|
1994-11-10 10:57:12 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-11-07 16:09:15 +00:00
|
|
|
bool TMenu_application::module_enabled(const char * program) const
|
|
|
|
{
|
|
|
|
bool ok = FALSE;
|
|
|
|
const int nmod = _modules.items();
|
|
|
|
for (int aut = 0; aut < nmod; aut++)
|
|
|
|
{
|
|
|
|
const TString& s = (const TString&) _modules[aut];
|
1995-04-20 14:25:15 +00:00
|
|
|
if (s.compare(program, 2) == 0) { ok = TRUE; break; }
|
1994-11-07 16:09:15 +00:00
|
|
|
}
|
|
|
|
return ok && has_module(aut);
|
|
|
|
}
|
|
|
|
|
1994-08-26 13:04:28 +00:00
|
|
|
void TMenu_application::load_menu()
|
|
|
|
{
|
|
|
|
TScanner s(_name);
|
|
|
|
|
|
|
|
_max = -1;
|
1994-11-07 16:09:15 +00:00
|
|
|
|
1994-08-26 13:04:28 +00:00
|
|
|
while (s.line().not_empty())
|
|
|
|
{
|
|
|
|
TToken_string* ts = new TToken_string(s.token());
|
|
|
|
int l = ts->get_int();
|
|
|
|
|
|
|
|
if (l < _max)
|
|
|
|
{
|
|
|
|
error_box("Item of level %d while %d was expected)", l, _max);
|
|
|
|
l = _max;
|
|
|
|
}
|
|
|
|
if (l > _max)
|
|
|
|
{
|
|
|
|
if (l >= MAXLEVEL)
|
|
|
|
{
|
|
|
|
error_box("Too many menu levels: %d", l);
|
|
|
|
l = _max;
|
|
|
|
}
|
|
|
|
_first[_max = l] = _menu.items();
|
|
|
|
}
|
|
|
|
|
|
|
|
_menu.add(ts);
|
1995-02-21 15:10:12 +00:00
|
|
|
const TString80 action(ts->get(2));
|
1994-11-07 16:09:15 +00:00
|
|
|
const int last = _menu.items() - 1;
|
|
|
|
|
|
|
|
if (atoi(action) > 0)
|
|
|
|
{
|
|
|
|
TToken_string list(ts->get(), ',');
|
1994-12-14 14:30:38 +00:00
|
|
|
const TString& mod = list.get();
|
|
|
|
int module = atoi(mod);
|
1994-11-07 16:09:15 +00:00
|
|
|
|
|
|
|
if (module == 0)
|
1994-12-14 14:30:38 +00:00
|
|
|
{
|
|
|
|
bool on = TRUE;
|
|
|
|
if (mod[0] == 'P')
|
|
|
|
on = user() == "PRASSI";
|
|
|
|
_enabled.set(last, on);
|
|
|
|
}
|
1994-11-07 16:09:15 +00:00
|
|
|
while(!_enabled[last] && module > 0)
|
|
|
|
{
|
|
|
|
if (has_module(module))
|
|
|
|
_enabled.set(last);
|
|
|
|
module = list.get_int();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_enabled.set(last, module_enabled(action));
|
1994-08-26 13:04:28 +00:00
|
|
|
}
|
|
|
|
_first[++_max] = _menu.items();
|
|
|
|
}
|
|
|
|
|
1994-10-11 17:34:31 +00:00
|
|
|
int TMenu_application::find_menu(const char* s) const
|
|
|
|
{
|
|
|
|
TString80 str(s); str.upper();
|
|
|
|
int found = -1;
|
|
|
|
|
|
|
|
for (int i = 0; i < _menu.items(); i++)
|
|
|
|
{
|
1994-11-07 16:09:15 +00:00
|
|
|
if (_enabled[i])
|
1994-10-11 17:34:31 +00:00
|
|
|
{
|
1994-11-07 16:09:15 +00:00
|
|
|
TToken_string& l = (TToken_string&)_menu[i];
|
|
|
|
const int m = l.get_int(0);
|
|
|
|
if (m != _level)
|
1994-10-11 17:34:31 +00:00
|
|
|
{
|
1994-11-07 16:09:15 +00:00
|
|
|
TString80 v(l.get()); v.upper();
|
|
|
|
|
|
|
|
if (v.find(str) >= 0)
|
|
|
|
{
|
|
|
|
found = i;
|
|
|
|
if (isalpha(l.get_char())) break;
|
|
|
|
}
|
|
|
|
}
|
1994-10-11 17:34:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
}
|
1994-08-26 13:04:28 +00:00
|
|
|
|
1994-10-11 17:34:31 +00:00
|
|
|
bool TMenu_application::menu_item_handler(TMask_field&f, KEY k)
|
1994-08-26 13:04:28 +00:00
|
|
|
{
|
|
|
|
if (k == K_SPACE)
|
|
|
|
{
|
1994-10-12 12:58:08 +00:00
|
|
|
_last_button = f.dlg();
|
|
|
|
_find_button = FALSE;
|
1994-08-26 13:04:28 +00:00
|
|
|
f.mask().stop_run(K_AUTO_ENTER);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-10-11 17:34:31 +00:00
|
|
|
bool TMenu_application::menu_find_handler(TMask_field&f, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
|
|
|
{
|
|
|
|
const TString& v = f.get();
|
|
|
|
if (v.not_empty())
|
|
|
|
{
|
1994-10-12 12:58:08 +00:00
|
|
|
_last_button = app().find_menu(v);
|
|
|
|
if (_last_button >= 0)
|
1994-10-11 17:34:31 +00:00
|
|
|
{
|
1994-10-12 12:58:08 +00:00
|
|
|
_find_button = TRUE;
|
1994-10-11 17:34:31 +00:00
|
|
|
f.mask().stop_run(K_AUTO_ENTER);
|
|
|
|
}
|
1994-10-14 09:44:54 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
beep();
|
|
|
|
return FALSE;
|
|
|
|
}
|
1994-10-11 17:34:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-08-26 13:04:28 +00:00
|
|
|
int TMenu_application::do_level()
|
|
|
|
{
|
|
|
|
const int first = _first[_level];
|
|
|
|
const int last = _first[_level+1];
|
1994-09-20 12:20:31 +00:00
|
|
|
TToken_string& row = (TToken_string&)_menu[first];
|
|
|
|
const TString80 head(row.get(1));
|
1994-08-26 13:04:28 +00:00
|
|
|
|
1995-03-23 17:14:42 +00:00
|
|
|
const int width = 78;
|
1994-10-11 17:34:31 +00:00
|
|
|
const int height = 18;
|
1994-08-26 13:04:28 +00:00
|
|
|
const int bwidth = 20;
|
|
|
|
const int x = width-bwidth-12;
|
1995-04-12 15:41:15 +00:00
|
|
|
short id = (short)row.get_int();
|
|
|
|
|
|
|
|
if (_images.objptr(id) == NULL)
|
|
|
|
{
|
|
|
|
char* n = format("ba%02d.bmp", id);
|
|
|
|
if (id > 0 && !fexist(n))
|
|
|
|
n = format("ba%02d.bmp", id = 0);
|
|
|
|
TImage * image = new TImage(n);
|
|
|
|
|
|
|
|
_images.add(image, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
TPicture_mask menu(head, width, height, (TImage &) _images[id], id != 0);
|
1994-08-26 13:04:28 +00:00
|
|
|
|
|
|
|
int y = 1;
|
|
|
|
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
1994-09-20 12:20:31 +00:00
|
|
|
TString16 t(format("#%d", BMP_STOPREC));
|
1994-08-26 13:04:28 +00:00
|
|
|
#else
|
1994-09-20 12:20:31 +00:00
|
|
|
TString16 t;
|
1994-08-26 13:04:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
for (int i = first+1; i < last; i++, y++)
|
|
|
|
{
|
|
|
|
TToken_string& row = (TToken_string&)_menu[i];
|
1994-09-20 12:20:31 +00:00
|
|
|
TString80 item(row.get(1));
|
|
|
|
if (isdigit(*row.get())) item << "...";
|
|
|
|
menu.add_static(-1, 0, item, x+4, y);
|
1994-12-14 14:30:38 +00:00
|
|
|
const short id = 100+y;
|
|
|
|
menu.add_button(id, 0, t, x, y, 1, 1);
|
|
|
|
menu.set_handler(id, menu_item_handler);
|
|
|
|
if (!_enabled[i]) menu.disable(id);
|
1994-08-26 13:04:28 +00:00
|
|
|
}
|
1994-10-14 09:44:54 +00:00
|
|
|
menu.add_static(-1, 0, "Cerca", 1,-3);
|
|
|
|
menu.add_string(99, 0, "", -12, -3, 50, "", bwidth+1);
|
1994-10-11 17:34:31 +00:00
|
|
|
menu.set_handler(99, menu_find_handler);
|
1994-08-26 13:04:28 +00:00
|
|
|
|
|
|
|
t = first ? "Menu precedente" : "Fine";
|
1994-10-11 17:34:31 +00:00
|
|
|
menu.add_button(first ? DLG_CANCEL : DLG_QUIT, 0, t, -22, -1, bwidth, 2);
|
1994-09-20 12:20:31 +00:00
|
|
|
if (first)
|
1994-10-11 17:34:31 +00:00
|
|
|
menu.add_button(DLG_QUIT, 0, "Fine", -12, -1, bwidth, 2);
|
1994-10-12 12:58:08 +00:00
|
|
|
|
|
|
|
if (_find_button && _last_button > first)
|
|
|
|
menu.first_focus(100+_last_button-first);
|
|
|
|
|
|
|
|
_last_button = _find_button = 0;
|
1994-09-20 12:20:31 +00:00
|
|
|
|
|
|
|
const int k = menu.run();
|
|
|
|
int m = 0;
|
|
|
|
switch (k)
|
|
|
|
{
|
|
|
|
case K_ESC:
|
|
|
|
m = -1; break;
|
|
|
|
case K_QUIT:
|
|
|
|
menu.reset();
|
|
|
|
m = -2; break;
|
|
|
|
default:
|
1994-10-12 12:58:08 +00:00
|
|
|
if (_find_button)
|
1994-10-11 17:34:31 +00:00
|
|
|
m = -1;
|
|
|
|
else
|
1994-10-12 12:58:08 +00:00
|
|
|
m = first+_last_button-100;
|
1994-10-11 17:34:31 +00:00
|
|
|
break;
|
1994-09-20 12:20:31 +00:00
|
|
|
}
|
1994-08-26 13:04:28 +00:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
void TMenu_application::test_temp()
|
|
|
|
{
|
|
|
|
begin_wait();
|
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
TFilename dir; dir.tempdir(); // Directory temporanea
|
1995-03-22 09:07:04 +00:00
|
|
|
dir << '/' << '*';
|
|
|
|
TToken_string files(dir);
|
|
|
|
const int count = list_files(files);
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
end_wait();
|
|
|
|
|
|
|
|
if (count > 0 && yesno_box("Cancellare %d file temporane%c in %s?",
|
|
|
|
count, (count > 1) ? 'i' : 'o', dir.path()))
|
|
|
|
{
|
|
|
|
TProgind bar(count, "Cancellazione file temporanei", TRUE, TRUE);
|
|
|
|
for (const char* e = files.get(0); e; e = files.get())
|
|
|
|
{
|
|
|
|
if (bar.iscancelled()) break;
|
|
|
|
remove(e);
|
|
|
|
bar.addstatus(1);
|
|
|
|
}
|
1994-10-03 08:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-11-07 16:09:15 +00:00
|
|
|
bool TMenu_application::check_user()
|
|
|
|
{
|
|
|
|
TMask m("ba0100a");
|
|
|
|
TLocalisamfile users(LF_USER);
|
1995-03-22 09:07:04 +00:00
|
|
|
TString16 utente, pwd;
|
1995-01-05 17:46:16 +00:00
|
|
|
|
|
|
|
bool ok = FALSE;
|
|
|
|
for (int i = 0 ; i < 3 && !ok; i++)
|
1994-11-07 16:09:15 +00:00
|
|
|
{
|
1995-01-05 17:46:16 +00:00
|
|
|
if (m.run() == K_ESC)
|
|
|
|
break;
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
utente = m.get(F_USER);
|
1995-01-05 17:46:16 +00:00
|
|
|
users.zero();
|
1995-03-22 09:07:04 +00:00
|
|
|
users.put("USERNAME", utente);
|
1994-11-15 11:21:00 +00:00
|
|
|
|
1995-01-05 17:46:16 +00:00
|
|
|
pwd = "";
|
|
|
|
if (users.read() == NOERR)
|
|
|
|
pwd = decode(users.get("PASSWORD"));
|
|
|
|
else
|
1995-03-22 09:07:04 +00:00
|
|
|
if (utente == "PRASSI")
|
1995-01-05 17:46:16 +00:00
|
|
|
pwd = "pr.assi";
|
|
|
|
|
|
|
|
ok = pwd.not_empty() && pwd == m.get(F_PASSWORD);
|
|
|
|
if (ok)
|
1995-03-22 09:07:04 +00:00
|
|
|
user() = utente;
|
1995-04-11 15:32:55 +00:00
|
|
|
else
|
|
|
|
{
|
1995-01-05 17:46:16 +00:00
|
|
|
error_box("Utente e/o password errata:\nfare attenzione alle maiuscole");
|
1995-04-11 15:32:55 +00:00
|
|
|
m.set(F_PASSWORD,"");
|
|
|
|
}
|
1994-11-07 16:09:15 +00:00
|
|
|
}
|
1995-01-05 17:46:16 +00:00
|
|
|
return ok;
|
1994-11-07 16:09:15 +00:00
|
|
|
}
|
1994-09-16 10:43:09 +00:00
|
|
|
|
1994-08-26 13:04:28 +00:00
|
|
|
bool TMenu_application::create()
|
|
|
|
{
|
1994-12-07 11:07:54 +00:00
|
|
|
TApplication::create();
|
1994-11-07 16:09:15 +00:00
|
|
|
if (!check_user()) return FALSE;
|
|
|
|
set_perms();
|
1994-10-03 08:42:51 +00:00
|
|
|
test_temp();
|
1994-12-14 14:30:38 +00:00
|
|
|
|
1994-11-07 16:09:15 +00:00
|
|
|
TScanner scanner("prassi.aut");
|
|
|
|
|
|
|
|
for (int aut = 0; scanner.line() != ""; aut++)
|
1994-11-16 12:03:13 +00:00
|
|
|
_modules.add(scanner.token());
|
1994-12-14 14:30:38 +00:00
|
|
|
|
|
|
|
load_menu();
|
|
|
|
dispatch_e_menu(BAR_ITEM(1));
|
|
|
|
return TRUE;
|
1994-09-16 10:43:09 +00:00
|
|
|
}
|
|
|
|
|
1994-10-26 14:52:42 +00:00
|
|
|
|
1994-09-16 10:43:09 +00:00
|
|
|
bool TMenu_application::menu(MENU_TAG)
|
|
|
|
{
|
1994-08-26 13:04:28 +00:00
|
|
|
int refarray[256];
|
1994-10-12 12:58:08 +00:00
|
|
|
memset(refarray, 0, sizeof(refarray));
|
|
|
|
|
1994-08-26 13:04:28 +00:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
_level = 0;
|
|
|
|
while (i >= 0)
|
|
|
|
{
|
1994-09-20 12:20:31 +00:00
|
|
|
const int m = do_level();
|
1994-08-26 13:04:28 +00:00
|
|
|
if (m >= 0)
|
|
|
|
{
|
1994-09-20 12:20:31 +00:00
|
|
|
TToken_string& row = (TToken_string&)_menu[m];
|
1994-10-24 15:00:02 +00:00
|
|
|
const TFilename option(row.get(2));
|
1994-10-26 14:52:42 +00:00
|
|
|
|
1994-10-24 15:00:02 +00:00
|
|
|
if (option.not_empty())
|
1994-08-26 13:04:28 +00:00
|
|
|
{
|
1994-10-26 14:52:42 +00:00
|
|
|
bool ok = TRUE;
|
1994-09-20 12:20:31 +00:00
|
|
|
const int l = atoi(option);
|
1994-11-24 13:58:34 +00:00
|
|
|
if (l > 0 && l < MAXLEVEL)
|
1994-08-26 13:04:28 +00:00
|
|
|
{
|
1994-10-26 14:52:42 +00:00
|
|
|
const TString16 flags(row.get());
|
|
|
|
if (flags.find('F') >= 0)
|
|
|
|
_ditta_asked = ok = set_firm();
|
|
|
|
if (ok)
|
1994-10-24 15:00:02 +00:00
|
|
|
{
|
1994-10-26 14:52:42 +00:00
|
|
|
refarray[i++] = _level;
|
|
|
|
if (l < _max) _level = l;
|
1994-11-16 12:03:13 +00:00
|
|
|
}
|
1994-08-26 13:04:28 +00:00
|
|
|
}
|
|
|
|
else
|
1994-11-16 12:03:13 +00:00
|
|
|
{
|
1994-12-13 13:49:03 +00:00
|
|
|
const TString16 module(cmd2name(option));
|
|
|
|
if (!_ditta_asked && module.left(2) == "cg" && module != "cg5100")
|
1994-11-22 18:06:28 +00:00
|
|
|
_ditta_asked = ok = set_firm();
|
1995-01-31 16:12:49 +00:00
|
|
|
if (ok)
|
|
|
|
{
|
1995-04-10 15:23:52 +00:00
|
|
|
prefix().set("DEF"); // Aggiorna prefix
|
1995-01-31 16:12:49 +00:00
|
|
|
TExternal_app a(option);
|
1995-04-18 10:08:38 +00:00
|
|
|
a.run();
|
1995-01-31 16:12:49 +00:00
|
|
|
}
|
1994-08-26 13:04:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1994-09-20 12:20:31 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m < -1) break;
|
1994-10-12 12:58:08 +00:00
|
|
|
if (_find_button)
|
|
|
|
{
|
|
|
|
TToken_string& row = (TToken_string&)_menu[_last_button];
|
|
|
|
_level = row.get_int(0);
|
|
|
|
}
|
1994-10-11 17:34:31 +00:00
|
|
|
else
|
1994-10-12 12:58:08 +00:00
|
|
|
{
|
|
|
|
_level = (i > 0) ? refarray[--i] : 0;
|
|
|
|
if (_level == 0) i = 0;
|
|
|
|
}
|
1994-09-20 12:20:31 +00:00
|
|
|
}
|
1994-08-26 13:04:28 +00:00
|
|
|
}
|
|
|
|
|
1994-09-16 10:43:09 +00:00
|
|
|
return FALSE;
|
1995-03-22 09:07:04 +00:00
|
|
|
}
|
1994-08-26 13:04:28 +00:00
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
TApplication::check_parameters(argc, argv);
|
1994-08-26 13:04:28 +00:00
|
|
|
const char* menu = (argc < 2) ? "prassi.mnu" : argv[1];
|
1995-03-22 09:07:04 +00:00
|
|
|
|
1994-08-26 13:04:28 +00:00
|
|
|
TMenu_application ma(menu);
|
1994-09-20 12:20:31 +00:00
|
|
|
ma.run(argc, argv, "Menu Principale");
|
1994-08-26 13:04:28 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|