2003-01-28 14:27:05 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <controls.h>
|
|
|
|
|
#include <dongle.h>
|
2008-03-19 15:31:53 +00:00
|
|
|
|
#include <execp.h>
|
2006-12-13 16:22:33 +00:00
|
|
|
|
#include <modaut.h>
|
2003-01-28 14:27:05 +00:00
|
|
|
|
#include <execp.h>
|
2006-07-11 15:33:09 +00:00
|
|
|
|
#include <recarray.h>
|
|
|
|
|
#include <relation.h>
|
2003-01-28 14:27:05 +00:00
|
|
|
|
#include <progind.h>
|
2003-09-11 09:19:16 +00:00
|
|
|
|
#include <sheet.h>
|
2003-01-28 14:27:05 +00:00
|
|
|
|
#include <utility.h>
|
|
|
|
|
#include <urldefid.h>
|
|
|
|
|
|
|
|
|
|
#include <nditte.h>
|
2006-07-11 13:10:51 +00:00
|
|
|
|
#include <user.h>
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
#include "ba0.h"
|
|
|
|
|
#include "ba0101.h"
|
|
|
|
|
#include "ba0102.h"
|
2008-01-31 14:19:39 +00:00
|
|
|
|
#include "ba0103.h"
|
2004-03-31 12:48:16 +00:00
|
|
|
|
#include "ba0100.h"
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
#include "ba0100a.h"
|
|
|
|
|
#include "ba0400a.h"
|
|
|
|
|
|
2006-07-11 15:33:09 +00:00
|
|
|
|
#define MEN_FILE "bamenu.men"
|
2003-01-28 14:27:05 +00:00
|
|
|
|
#define PREFERRED_MENU M_STYLE
|
|
|
|
|
|
|
|
|
|
#define DLG_TREE 301
|
|
|
|
|
#define DLG_LIST 302
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TMenu_application declaration
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-04-17 08:54:31 +00:00
|
|
|
|
class TMenu_application : public TSkeleton_application
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2006-07-11 13:10:51 +00:00
|
|
|
|
TFilename _menuname;
|
2004-03-31 12:48:16 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TMenu _menu;
|
|
|
|
|
int _tree_view;
|
|
|
|
|
TString_array _preferred;
|
|
|
|
|
|
|
|
|
|
TMask* _mask;
|
2004-03-31 12:48:16 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
protected: // TApplication
|
2005-09-23 16:07:40 +00:00
|
|
|
|
virtual bool user_create();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
virtual bool destroy();
|
|
|
|
|
virtual bool menu(MENU_TAG m);
|
|
|
|
|
virtual long handler(WINDOW win, EVENT* ep);
|
2008-09-29 14:34:21 +00:00
|
|
|
|
virtual bool firm_change_enabled() const;
|
2003-10-20 13:12:34 +00:00
|
|
|
|
virtual void on_firm_change();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
virtual bool test_assistance_year() const;
|
|
|
|
|
|
2007-04-03 11:06:56 +00:00
|
|
|
|
bool ask_user_password(TString& utente);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
protected:
|
2003-06-11 11:02:13 +00:00
|
|
|
|
void deconnect_user();
|
2003-04-17 08:54:31 +00:00
|
|
|
|
virtual void main_loop();
|
2004-03-31 12:48:16 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
void test_temp();
|
|
|
|
|
int do_level();
|
|
|
|
|
int do_tree();
|
|
|
|
|
int do_explore();
|
2008-01-31 14:19:39 +00:00
|
|
|
|
int do_outlook();
|
2007-09-25 14:11:37 +00:00
|
|
|
|
|
2008-03-19 15:31:53 +00:00
|
|
|
|
int get_user_status(const char* usr) const;
|
|
|
|
|
bool set_user_status(const char* usr, int status) const;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
bool check_user();
|
|
|
|
|
|
|
|
|
|
static bool menu_item_handler(TMask_field& f, KEY k);
|
|
|
|
|
static bool menu_find_handler(TMask_field& f, KEY k);
|
|
|
|
|
static bool tree_handler(TMask_field& f, KEY k);
|
|
|
|
|
static bool explore_handler(TMask_field& f, KEY k);
|
|
|
|
|
|
|
|
|
|
bool choose_colors();
|
|
|
|
|
bool choose_editors();
|
|
|
|
|
bool choose_study();
|
2004-03-31 12:48:16 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
void load_preferences();
|
|
|
|
|
void save_preferences();
|
2003-10-14 13:44:01 +00:00
|
|
|
|
void update_preferred_tree();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
void update_preferred();
|
|
|
|
|
void add_to_preferred();
|
|
|
|
|
void manage_preferred();
|
|
|
|
|
|
|
|
|
|
bool test_programs();
|
2007-10-17 09:35:51 +00:00
|
|
|
|
bool copy_setup(const TString& remote_path);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2004-03-31 12:48:16 +00:00
|
|
|
|
public:
|
2008-10-24 15:41:41 +00:00
|
|
|
|
TTree_field& tree_field() const;
|
2004-04-23 08:59:58 +00:00
|
|
|
|
void select_tree_current();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
static bool tree_find_handler(TMask_field& f, KEY k);
|
|
|
|
|
static bool tree_shrink_handler(TMask_field& f, KEY k);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void reload_images();
|
|
|
|
|
TMenu& main_menu() { return _menu; }
|
|
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
TMenu_application(const char* name) : _menuname(name), _mask(NULL) { }
|
2003-01-28 14:27:05 +00:00
|
|
|
|
virtual ~TMenu_application() { }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline TMenu_application& app()
|
|
|
|
|
{ return (TMenu_application&)main_app(); }
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Picture Mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TPicture_mask : public TMask
|
|
|
|
|
{
|
2003-03-11 11:09:18 +00:00
|
|
|
|
TSubmenu* _submenu;
|
2004-04-21 15:49:15 +00:00
|
|
|
|
TImage* _logo;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
protected: // TMask
|
|
|
|
|
virtual void update();
|
|
|
|
|
virtual bool on_key(KEY k);
|
|
|
|
|
virtual void on_firm_change();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual bool stop_run(KEY key);
|
2003-03-11 11:09:18 +00:00
|
|
|
|
void set_current(const TSubmenu& sm);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2003-03-11 11:09:18 +00:00
|
|
|
|
TPicture_mask(const char* name, int dx, int dy, const TSubmenu& sm, int x = -1, int y = -1);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
virtual ~TPicture_mask();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool TPicture_mask::stop_run(KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_FORCE_CLOSE)
|
|
|
|
|
key = K_QUIT;
|
|
|
|
|
return TWindow::stop_run(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPicture_mask::update()
|
|
|
|
|
{
|
2003-05-26 13:00:26 +00:00
|
|
|
|
if (!ADVANCED_GRAPHICS)
|
|
|
|
|
return;
|
|
|
|
|
|
2003-03-11 11:09:18 +00:00
|
|
|
|
TImage& image = _submenu->image();
|
|
|
|
|
if (image.ok())
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2004-05-17 15:39:53 +00:00
|
|
|
|
int x = 1, y = 1, imgx = 640, imgy = 480; // Default values
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
RCT client; xvt_vobj_get_client_rect(win(), &client);
|
2004-04-22 11:15:05 +00:00
|
|
|
|
const bool tree_view = id2pos(DLG_TREE) >= 0;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2004-05-17 15:39:53 +00:00
|
|
|
|
int lx = 1, ly = ROWY, logx = 320, logy = 120;
|
|
|
|
|
|
2004-04-22 11:15:05 +00:00
|
|
|
|
if (tree_view) // TreeView == 1
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2008-10-24 15:41:41 +00:00
|
|
|
|
RCT rctree; tfield(DLG_TREE).get_rect(rctree);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2004-05-17 15:39:53 +00:00
|
|
|
|
const int maxx = client.right - rctree.right - 2 * CHARX;
|
2008-03-27 15:41:11 +00:00
|
|
|
|
const int maxy = client.bottom - 10 * ROWY;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2003-03-11 11:09:18 +00:00
|
|
|
|
const double ratiox = double(maxx) / image.width();
|
|
|
|
|
const double ratioy = double(maxy) / image.height();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
const double ratio = min(ratiox, ratioy);
|
|
|
|
|
|
2004-05-17 15:39:53 +00:00
|
|
|
|
imgx = int(ratio * image.width());
|
|
|
|
|
imgy = int(ratio * image.height());
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
x = client.right - maxx - 4;
|
2008-03-27 15:41:11 +00:00
|
|
|
|
y = client.bottom - maxy;
|
2004-05-17 15:39:53 +00:00
|
|
|
|
|
|
|
|
|
//stabilisce la dimensione del logo
|
|
|
|
|
if (_logo != NULL)
|
|
|
|
|
{
|
|
|
|
|
lx = rctree.right + CHARX;
|
|
|
|
|
|
|
|
|
|
const double ratio = (double)maxx / _logo->width();
|
|
|
|
|
logx = int(ratio * _logo->width());
|
|
|
|
|
logy = int(ratio * _logo->height());
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RCT rctbut; field(101).get_rect(rctbut);
|
|
|
|
|
|
2004-05-17 15:39:53 +00:00
|
|
|
|
int maxx = rctbut.left - CHARX;
|
|
|
|
|
int maxy = client.bottom - 5 * ROWY; //il logo va staccato dall'immagine
|
2004-04-21 15:49:15 +00:00
|
|
|
|
if (_logo != NULL)
|
|
|
|
|
maxy -= _logo->height();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2003-03-11 11:09:18 +00:00
|
|
|
|
const double ratiox = double(maxx) / image.width();
|
|
|
|
|
const double ratioy = double(maxy) / image.height();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
const double ratio = min(ratiox, ratioy);
|
|
|
|
|
|
2004-05-17 15:39:53 +00:00
|
|
|
|
imgx = int(ratio * image.width());
|
|
|
|
|
imgy = int(ratio * image.height());
|
2003-01-28 14:27:05 +00:00
|
|
|
|
x = 1;
|
2008-03-27 15:41:11 +00:00
|
|
|
|
y = client.bottom - imgy - 1;
|
2004-05-17 15:39:53 +00:00
|
|
|
|
|
|
|
|
|
//stabilisce la dimensione del logo
|
|
|
|
|
if (_logo != NULL)
|
|
|
|
|
{
|
|
|
|
|
const double ratio = (double)maxx / _logo->width();
|
|
|
|
|
logx = int(ratio * _logo->width());
|
|
|
|
|
logy = int(ratio * _logo->height());
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RCT dst;
|
2004-04-21 15:49:15 +00:00
|
|
|
|
if (_logo != NULL)
|
2004-04-22 11:15:05 +00:00
|
|
|
|
{
|
2004-05-17 15:39:53 +00:00
|
|
|
|
::xvt_rect_set(&dst, lx, ly, lx+logx, ly+logy);
|
|
|
|
|
if (::xvt_dwin_is_update_needed(win(), &dst))
|
|
|
|
|
_logo->draw(win(), dst);
|
2004-04-22 11:15:05 +00:00
|
|
|
|
}
|
2004-05-17 15:39:53 +00:00
|
|
|
|
|
|
|
|
|
::xvt_rect_set(&dst, x, y, x+imgx, y+imgy);
|
|
|
|
|
if (::xvt_dwin_is_update_needed(win(), &dst))
|
|
|
|
|
image.draw(win(), dst);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TPicture_mask::on_key(KEY k)
|
|
|
|
|
{
|
|
|
|
|
switch (k)
|
|
|
|
|
{
|
|
|
|
|
case K_F3:
|
|
|
|
|
case K_F8:
|
2006-12-13 16:22:33 +00:00
|
|
|
|
set(DLG_USER, app().main_menu().last_search_string(), true);
|
|
|
|
|
return true;
|
2008-10-24 15:41:41 +00:00
|
|
|
|
/* Obsoleto coi nuovi alberi
|
2003-01-28 14:27:05 +00:00
|
|
|
|
case K_ENTER:
|
|
|
|
|
case K_UP:
|
|
|
|
|
case K_DOWN:
|
|
|
|
|
case K_LEFT:
|
|
|
|
|
case K_RIGHT:
|
|
|
|
|
if (focus_field().is_kind_of(CLASS_TREE_FIELD))
|
|
|
|
|
{
|
|
|
|
|
TTree_field& tf = (TTree_field&)focus_field();
|
|
|
|
|
return tf.win().on_key(k);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2008-10-24 15:41:41 +00:00
|
|
|
|
*/
|
2003-01-28 14:27:05 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TMask::on_key(k);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPicture_mask::on_firm_change()
|
|
|
|
|
{
|
|
|
|
|
force_update();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-11 11:09:18 +00:00
|
|
|
|
void TPicture_mask::set_current(const TSubmenu& sm)
|
|
|
|
|
{
|
|
|
|
|
_submenu = (TSubmenu*)&sm;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TPicture_mask::TPicture_mask(const char* name, int dx, int dy,
|
2003-03-11 11:09:18 +00:00
|
|
|
|
const TSubmenu& submenu, int x, int y)
|
2007-04-03 11:06:56 +00:00
|
|
|
|
: TMask(name, 1, dx, dy, x, y), _submenu(NULL), _logo(NULL)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2003-03-11 11:09:18 +00:00
|
|
|
|
set_current(submenu);
|
2008-10-23 13:11:15 +00:00
|
|
|
|
_logo = new TImage("menulogo");
|
|
|
|
|
if (_logo->ok())
|
2004-04-21 15:49:15 +00:00
|
|
|
|
{
|
2008-10-23 13:11:15 +00:00
|
|
|
|
if (can_be_transparent(*_logo))
|
|
|
|
|
_logo->convert_transparent_color(MASK_BACK_COLOR);
|
2004-04-21 15:49:15 +00:00
|
|
|
|
}
|
2008-10-23 13:11:15 +00:00
|
|
|
|
else
|
2004-04-21 15:49:15 +00:00
|
|
|
|
{
|
2008-10-23 13:11:15 +00:00
|
|
|
|
delete _logo;
|
|
|
|
|
_logo = NULL;
|
2004-04-21 15:49:15 +00:00
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TPicture_mask::~TPicture_mask()
|
|
|
|
|
{
|
2004-04-21 15:49:15 +00:00
|
|
|
|
if (_logo != NULL)
|
|
|
|
|
delete _logo;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Color Mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TColor_mask : public TAutomask
|
2008-05-09 15:47:09 +00:00
|
|
|
|
{
|
|
|
|
|
class TPreview_panel : public TWindow
|
|
|
|
|
{
|
|
|
|
|
TColor_mask* _owner;
|
|
|
|
|
protected:
|
|
|
|
|
COLOR get_color_entry(const char* name) const;
|
|
|
|
|
virtual void update();
|
|
|
|
|
public:
|
|
|
|
|
TPreview_panel(short x, short y, short dx, short dy, TColor_mask* owner);
|
|
|
|
|
} *_preview;
|
2008-09-29 14:34:21 +00:00
|
|
|
|
|
2008-05-09 15:47:09 +00:00
|
|
|
|
class TPreview_icons : public TWindow
|
|
|
|
|
{
|
|
|
|
|
TColor_mask* _owner;
|
|
|
|
|
protected:
|
|
|
|
|
virtual void update();
|
|
|
|
|
public:
|
|
|
|
|
TPreview_icons(short x, short y, short dx, short dy, TColor_mask* owner);
|
|
|
|
|
} *_icons;
|
|
|
|
|
|
2008-09-29 14:34:21 +00:00
|
|
|
|
int _cur_theme;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TAssoc_array _color;
|
2008-09-29 14:34:21 +00:00
|
|
|
|
TString256 _font_desc;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
protected: // TMask
|
|
|
|
|
virtual bool stop_run(KEY key) { return TWindow::stop_run(key); }
|
|
|
|
|
virtual bool on_field_event(TOperable_field& f, TField_event e, long jolly);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
COLOR get_color_entry(const char* c) const;
|
|
|
|
|
void set_color_entry(const char* name, COLOR col);
|
2008-09-29 14:34:21 +00:00
|
|
|
|
const TString& get_font_desc() const { return _font_desc; }
|
2003-01-28 14:27:05 +00:00
|
|
|
|
const char* cid2name(short cid) const;
|
|
|
|
|
COLOR cid2color(short cid) const;
|
2007-12-12 16:14:54 +00:00
|
|
|
|
COLOR cid2syscolor(short cid, const XVT_COLOR_COMPONENT* cc) const;
|
2008-09-29 14:34:21 +00:00
|
|
|
|
|
2008-06-16 09:01:21 +00:00
|
|
|
|
void load_themes();
|
|
|
|
|
bool apply_theme();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2008-09-29 14:34:21 +00:00
|
|
|
|
void save_colors(TConfig& colors);
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
public:
|
|
|
|
|
void save_colors();
|
|
|
|
|
TColor_mask();
|
|
|
|
|
};
|
|
|
|
|
|
2008-05-09 15:47:09 +00:00
|
|
|
|
COLOR TColor_mask::TPreview_panel::get_color_entry(const char* name) const
|
|
|
|
|
{ return _owner->get_color_entry(name); }
|
|
|
|
|
|
|
|
|
|
TColor_mask::TPreview_panel::TPreview_panel(short x, short y, short dx, short dy, TColor_mask* owner)
|
|
|
|
|
: _owner(owner)
|
|
|
|
|
{ create(x, y, dx, dy, "", 0, W_PLAIN, owner->page_win(0)); }
|
|
|
|
|
|
|
|
|
|
void TColor_mask::TPreview_panel::update()
|
|
|
|
|
{
|
|
|
|
|
COLOR p, b;
|
|
|
|
|
|
|
|
|
|
const int x = 0;
|
|
|
|
|
const int y = 0;
|
|
|
|
|
const int w = columns();
|
|
|
|
|
const int h = rows();
|
|
|
|
|
|
|
|
|
|
b = get_color_entry("MaskBack");
|
|
|
|
|
clear(b);
|
|
|
|
|
|
|
|
|
|
set_pen(p = get_color_entry("MaskLight"));
|
|
|
|
|
line(x+1, y, x+w-2, y);
|
|
|
|
|
line(x+1, y, x+1, y+h-1);
|
|
|
|
|
|
|
|
|
|
set_pen(p = get_color_entry("MaskDark"));
|
|
|
|
|
line(x+1, y+h-1, x+w-2, y+h-1);
|
|
|
|
|
line(x+w-2, y+h-1, x+w-2, y);
|
|
|
|
|
|
2008-09-29 14:34:21 +00:00
|
|
|
|
const TString& font_desc = _owner->get_font_desc();
|
|
|
|
|
if (font_desc.full())
|
|
|
|
|
{
|
|
|
|
|
XVT_FNTID fontid = xvt_font_create();
|
|
|
|
|
xvt_font_deserialize(fontid, font_desc);
|
|
|
|
|
xvt_dwin_set_font(win(), fontid);
|
|
|
|
|
xvt_font_destroy(fontid);
|
|
|
|
|
}
|
|
|
|
|
else
|
2008-11-13 12:30:31 +00:00
|
|
|
|
xvt_dwin_set_font(win(), xvtil_default_font());
|
2008-09-29 14:34:21 +00:00
|
|
|
|
|
2008-05-09 15:47:09 +00:00
|
|
|
|
set_opaque_text(false);
|
|
|
|
|
set_pen(p = get_color_entry("Normal"));
|
|
|
|
|
set_brush(b = get_color_entry("NormalBack"));
|
|
|
|
|
frame(x+3, y+1, x+w-3, y+2, 0);
|
|
|
|
|
set_color(p, b);
|
|
|
|
|
stringat(x+4, y+1, "Campo normale");
|
|
|
|
|
|
|
|
|
|
set_pen(p = get_color_entry("Normal")); // Stesso inchiostro del normale
|
|
|
|
|
set_brush(b = get_color_entry("RequiredBack"));
|
|
|
|
|
frame(x+3, y+3, x+w-3, y+4, 0);
|
|
|
|
|
set_color(p, b);
|
|
|
|
|
stringat(x+4, y+3, "Campo obbligatorio");
|
|
|
|
|
|
|
|
|
|
set_pen(p = get_color_entry("Focus"));
|
|
|
|
|
set_brush(b = get_color_entry("FocusBack"));
|
|
|
|
|
frame(x+3, y+5, x+w-3, y+6, 0);
|
|
|
|
|
set_color(p, b);
|
|
|
|
|
stringat(x+4, y+5, "Campo attivo");
|
|
|
|
|
|
|
|
|
|
set_pen(p = get_color_entry("Disabled"));
|
|
|
|
|
set_brush(b = get_color_entry("DisabledBack"));
|
|
|
|
|
frame(x+3, y+7, x+w-3, y+8, 0);
|
|
|
|
|
set_color(p, b);
|
|
|
|
|
stringat(x+4, y+7, "Campo disabilitato");
|
|
|
|
|
|
|
|
|
|
set_pen(p = get_color_entry("ButtonLight"));
|
|
|
|
|
set_brush(b = get_color_entry("ButtonBack"));
|
|
|
|
|
frame(x+3, y+9, x+w-3, y+10, 0);
|
|
|
|
|
set_color(get_color_entry("Normal"), b);
|
|
|
|
|
stringat(x+4, y+9, "Bottone normale");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TColor_mask::TPreview_icons::update()
|
|
|
|
|
{
|
|
|
|
|
RCT rct; xvt_vobj_get_client_rect(win(), &rct);
|
|
|
|
|
clear(MASK_BACK_COLOR);
|
|
|
|
|
set_pen(MASK_DARK_COLOR);
|
|
|
|
|
xvt_dwin_draw_rect(win(), &rct);
|
|
|
|
|
|
|
|
|
|
const int s = _owner->get_int(217);
|
|
|
|
|
const int sz = 16 + s*8;
|
|
|
|
|
const int y = (rct.bottom - sz)/2;
|
|
|
|
|
int x = (rct.right - 3*sz)/2;
|
|
|
|
|
for (short id = 201; id <= 203; id++, x += sz)
|
|
|
|
|
xvt_dwin_draw_tool(win(), x, y, id, sz);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TColor_mask::TPreview_icons::TPreview_icons(short x, short y, short dx, short dy, TColor_mask* owner)
|
|
|
|
|
: _owner(owner)
|
|
|
|
|
{ create(x, y, dx, dy, "", 0, W_PLAIN, owner->page_win(1)); }
|
|
|
|
|
|
2008-06-16 09:01:21 +00:00
|
|
|
|
void TColor_mask::load_themes()
|
|
|
|
|
{
|
|
|
|
|
TList_field& fl = lfield(211);
|
2008-09-29 14:34:21 +00:00
|
|
|
|
|
2008-06-16 09:01:21 +00:00
|
|
|
|
TToken_string codes = fl.get_codes();
|
2008-09-29 14:34:21 +00:00
|
|
|
|
TToken_string values = fl.get_values();
|
|
|
|
|
|
|
|
|
|
const int default_items = 3; // Corrente, Campo, Sistema
|
|
|
|
|
// Elimina tutti gli elementi non standard (oltre il terzo)
|
|
|
|
|
if (codes.items() > default_items)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& str = i == 0 ? codes : values;
|
|
|
|
|
int pos = 0;
|
|
|
|
|
for (int j = 0; j < default_items; j++)
|
|
|
|
|
pos = str.find(str.separator(), pos);
|
|
|
|
|
str.cut(pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-16 09:01:21 +00:00
|
|
|
|
int k = codes.items();
|
2008-09-29 14:34:21 +00:00
|
|
|
|
TConfig default_themes("res/themes.ini");
|
|
|
|
|
TString_array pl;
|
|
|
|
|
default_themes.list_paragraphs(pl);
|
|
|
|
|
FOR_EACH_ARRAY_ROW(pl, i, row)
|
2008-06-16 09:01:21 +00:00
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
codes.add(k++);
|
|
|
|
|
values.add(row->left(15));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TConfig user_themes(CONFIG_GUI);
|
|
|
|
|
user_themes.list_paragraphs(pl);
|
|
|
|
|
FOR_EACH_ARRAY_ROW(pl, j, raw)
|
|
|
|
|
{
|
|
|
|
|
if (raw->starts_with("Theme_"))
|
2008-06-16 09:01:21 +00:00
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
codes.add(k++);
|
|
|
|
|
values.add(raw->mid(6, 15));
|
2008-06-16 09:01:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-29 14:34:21 +00:00
|
|
|
|
|
|
|
|
|
if (k > default_items)
|
|
|
|
|
fl.replace_items(codes, values);
|
2008-06-16 09:01:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TColor_mask::apply_theme()
|
|
|
|
|
{
|
|
|
|
|
bool applied = false;
|
|
|
|
|
|
|
|
|
|
const int theme = get_int(211);
|
2008-09-29 14:34:21 +00:00
|
|
|
|
if (theme > 2) // Normal theme
|
2008-06-16 09:01:21 +00:00
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
const TList_field& fl = lfield(211);
|
2008-06-16 09:01:21 +00:00
|
|
|
|
TToken_string values = fl.get_values();
|
2008-09-29 14:34:21 +00:00
|
|
|
|
|
|
|
|
|
TString name = values.get(theme);
|
|
|
|
|
TConfig def_themes("res/themes.ini", name);
|
|
|
|
|
TAssoc_array& def_colors = def_themes.list_variables();
|
|
|
|
|
|
|
|
|
|
name.insert("Theme_");
|
|
|
|
|
TConfig usr_themes(CONFIG_GUI, name);
|
|
|
|
|
TAssoc_array& usr_colors = usr_themes.list_variables();
|
|
|
|
|
|
|
|
|
|
TAssoc_array& colors = usr_colors.empty() ? def_colors : usr_colors;
|
2008-06-16 09:01:21 +00:00
|
|
|
|
if (!colors.empty())
|
|
|
|
|
{
|
|
|
|
|
TToken_string rgb(15, ',');
|
|
|
|
|
FOR_EACH_ASSOC_STRING(colors, obj, key, value)
|
|
|
|
|
{
|
|
|
|
|
rgb = value;
|
2008-09-29 14:34:21 +00:00
|
|
|
|
if (rgb.items() == 3) // Trattasi di colore
|
|
|
|
|
{
|
|
|
|
|
const byte r = (byte)rgb.get_int(0);
|
|
|
|
|
const byte g = (byte)rgb.get_int();
|
|
|
|
|
const byte b = (byte)rgb.get_int();
|
|
|
|
|
set_color_entry(key, XVT_MAKE_COLOR(r,g,b));
|
|
|
|
|
} else
|
|
|
|
|
if (xvt_str_compare_ignoring_case(key, "FontDesc") == 0)
|
|
|
|
|
{
|
|
|
|
|
_font_desc = value;
|
|
|
|
|
}
|
2008-06-16 09:01:21 +00:00
|
|
|
|
}
|
|
|
|
|
applied = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!applied)
|
|
|
|
|
{
|
|
|
|
|
switch (theme)
|
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
case 1: // Campo default colors
|
2008-06-16 09:01:21 +00:00
|
|
|
|
{
|
|
|
|
|
for (short bid = 101; bid <= 113; bid++)
|
|
|
|
|
{
|
|
|
|
|
const char* name = cid2name(bid);
|
2008-09-29 14:34:21 +00:00
|
|
|
|
const COLOR color = cid2color(bid);
|
2008-06-16 09:01:21 +00:00
|
|
|
|
set_color_entry(name, color);
|
|
|
|
|
}
|
2008-09-29 14:34:21 +00:00
|
|
|
|
_font_desc.cut(0);
|
2008-06-16 09:01:21 +00:00
|
|
|
|
applied = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2008-09-29 14:34:21 +00:00
|
|
|
|
case 2: // System colors
|
2008-06-16 09:01:21 +00:00
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
XVT_COLOR_COMPONENT* cc = (XVT_COLOR_COMPONENT*)xvt_vobj_get_attr(NULL_WIN, ATTR_APP_CTL_COLORS);
|
2008-06-16 09:01:21 +00:00
|
|
|
|
for (short bid = 101; bid <= 113; bid++)
|
|
|
|
|
{
|
|
|
|
|
const char* name = cid2name(bid);
|
2008-09-29 14:34:21 +00:00
|
|
|
|
const COLOR color = cid2syscolor(bid, cc);
|
2008-06-16 09:01:21 +00:00
|
|
|
|
set_color_entry(name, color);
|
|
|
|
|
}
|
2008-09-29 14:34:21 +00:00
|
|
|
|
xvt_mem_free((DATA_PTR)cc);
|
|
|
|
|
|
2008-11-13 12:30:31 +00:00
|
|
|
|
XVT_FNTID defont = xvtil_default_font(false, false); // Legge il font standard
|
2008-10-22 14:20:20 +00:00
|
|
|
|
XVT_FNTID fontid = xvt_res_get_font(0); // Legge il font di sistema
|
|
|
|
|
xvt_font_set_size(fontid, xvt_font_get_size(defont)); // Forza l'altezza standard
|
2008-09-29 14:34:21 +00:00
|
|
|
|
xvt_font_serialize(fontid, _font_desc.get_buffer(), _font_desc.size());
|
2008-10-22 14:20:20 +00:00
|
|
|
|
xvt_font_destroy(fontid); // Rilascia il font di sistema
|
2008-09-29 14:34:21 +00:00
|
|
|
|
set(214, "X"); // System buttons
|
2008-06-16 09:01:21 +00:00
|
|
|
|
applied = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2008-09-29 14:34:21 +00:00
|
|
|
|
default: // User defined settings
|
|
|
|
|
{
|
|
|
|
|
TConfig color(CONFIG_GUI, "Colors");
|
|
|
|
|
_color = color.list_variables();
|
2008-11-13 12:30:31 +00:00
|
|
|
|
xvt_font_serialize(xvtil_default_font(), _font_desc.get_buffer(), _font_desc.size());
|
2008-09-29 14:34:21 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2008-06-16 09:01:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (applied)
|
2008-09-29 14:34:21 +00:00
|
|
|
|
{
|
2008-06-16 09:01:21 +00:00
|
|
|
|
_preview->force_update();
|
2008-09-29 14:34:21 +00:00
|
|
|
|
_cur_theme = theme;
|
|
|
|
|
}
|
2008-06-16 09:01:21 +00:00
|
|
|
|
|
|
|
|
|
return applied;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
bool TColor_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
const short id = f.dlg();
|
2006-12-13 16:22:33 +00:00
|
|
|
|
bool ok = true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
switch (id)
|
|
|
|
|
{
|
2007-12-12 16:14:54 +00:00
|
|
|
|
case 211:
|
2008-06-16 09:01:21 +00:00
|
|
|
|
if (e == fe_init)
|
|
|
|
|
load_themes();
|
2008-09-29 14:34:21 +00:00
|
|
|
|
if (e == fe_modify && is_running())
|
|
|
|
|
{
|
|
|
|
|
const int new_theme = atoi(f.get());
|
|
|
|
|
if (new_theme != _cur_theme)
|
|
|
|
|
apply_theme();
|
|
|
|
|
}
|
2007-12-12 16:14:54 +00:00
|
|
|
|
break;
|
2008-05-09 15:47:09 +00:00
|
|
|
|
case 217:
|
|
|
|
|
if (e == fe_init || e == fe_modify)
|
|
|
|
|
_icons->force_update();
|
|
|
|
|
break;
|
2008-09-29 14:34:21 +00:00
|
|
|
|
case DLG_OK:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
stop_run(K_CTRL+'R');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_SAVEREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
stop_run(K_ENTER);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_NEWREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TString name = user();
|
|
|
|
|
xvt_dm_post_string_prompt(TR("Nome del tema"), name.get_buffer(), 16);
|
|
|
|
|
if (name.full())
|
|
|
|
|
{
|
|
|
|
|
name.trim();
|
|
|
|
|
name.upper();
|
|
|
|
|
name.insert("Theme_");
|
|
|
|
|
{
|
|
|
|
|
TConfig ini(CONFIG_GUI, name);
|
|
|
|
|
save_colors(ini);
|
|
|
|
|
}
|
|
|
|
|
load_themes();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_DELREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TList_field& themes = lfield(211);
|
|
|
|
|
const int pos = atoi(themes.get());
|
|
|
|
|
bool can_delete = pos > 2;
|
|
|
|
|
if (can_delete) // Tema non standard
|
|
|
|
|
{
|
|
|
|
|
TToken_string values = themes.get_values();
|
|
|
|
|
TString name = values.get(pos);
|
|
|
|
|
bool done = yesno_box(FR("Confermare la cancellazione del tema %s"), name.get_buffer());
|
|
|
|
|
if (done)
|
|
|
|
|
{
|
|
|
|
|
name.insert("Theme_");
|
|
|
|
|
TConfig ini(CONFIG_GUI, name);
|
|
|
|
|
if (ini.new_paragraph())
|
|
|
|
|
done = can_delete = false;
|
|
|
|
|
else
|
|
|
|
|
ini.remove_all();
|
|
|
|
|
}
|
|
|
|
|
if (done)
|
|
|
|
|
load_themes();
|
|
|
|
|
}
|
|
|
|
|
if (!can_delete)
|
|
|
|
|
error_box(TR("Tema non cancellabile"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-12-12 16:14:54 +00:00
|
|
|
|
case DLG_USER:
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
XVT_FNTID fontid = xvt_font_create();
|
|
|
|
|
if (_font_desc.full())
|
|
|
|
|
xvt_font_deserialize(fontid, _font_desc);
|
|
|
|
|
else
|
2008-11-13 12:30:31 +00:00
|
|
|
|
xvt_font_copy(fontid, xvtil_default_font(), XVT_FA_ALL);
|
2008-09-29 14:34:21 +00:00
|
|
|
|
if (xvt_dm_post_font_sel(win(), fontid, NULL, 0))
|
2004-03-23 16:39:40 +00:00
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
xvt_font_serialize(fontid, _font_desc.get_buffer(), _font_desc.size());
|
|
|
|
|
_preview->force_update();
|
2004-03-23 16:39:40 +00:00
|
|
|
|
}
|
2008-09-29 14:34:21 +00:00
|
|
|
|
xvt_font_destroy(fontid);
|
|
|
|
|
return false;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2008-09-29 14:34:21 +00:00
|
|
|
|
if (e == fe_button && id >= 101 && id <= 113)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
const char* name = cid2name(f.dlg());
|
|
|
|
|
COLOR col = get_color_entry(name);
|
|
|
|
|
col = choose_color(col, win());
|
|
|
|
|
if (col != COLOR_INVALID)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
set_color_entry(name, col);
|
|
|
|
|
_preview->force_update();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2008-09-29 14:34:21 +00:00
|
|
|
|
return false;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TColor_mask::TColor_mask()
|
2008-09-29 14:34:21 +00:00
|
|
|
|
: TAutomask("ba0200a"), _cur_theme(0)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2003-10-14 13:44:01 +00:00
|
|
|
|
TConfig color(CONFIG_GUI, "Colors");
|
2003-01-28 14:27:05 +00:00
|
|
|
|
_color = color.list_variables();
|
2003-05-26 13:00:26 +00:00
|
|
|
|
set(213, CAMPI_SCAVATI ? "X" : "");
|
2007-12-12 16:14:54 +00:00
|
|
|
|
set(214, NATIVE_CONTROLS ? "X" : "");
|
2003-05-26 13:00:26 +00:00
|
|
|
|
set(215, ADVANCED_GRAPHICS ? "X" : "");
|
2008-05-09 15:47:09 +00:00
|
|
|
|
set(216, color.get_int("TreeView"));
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2008-09-29 14:34:21 +00:00
|
|
|
|
_preview = new TPreview_panel(1, 7, 33, 8, this);
|
2008-05-09 15:47:09 +00:00
|
|
|
|
_icons = new TPreview_icons(1, 10, -2, -2, this);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2008-05-09 15:47:09 +00:00
|
|
|
|
const int sz = color.get_int("ToolSize");
|
|
|
|
|
set(217, (sz-16)/8);
|
2008-05-15 15:01:55 +00:00
|
|
|
|
|
|
|
|
|
set(218, EASY_RIDER ? "X" : "");
|
2008-06-13 08:41:37 +00:00
|
|
|
|
set(219, TOOL_TEXT ? "X" : "");
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2008-11-13 12:30:31 +00:00
|
|
|
|
xvt_font_serialize(xvtil_default_font(), _font_desc.get_buffer(), _font_desc.size());
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-09-29 14:34:21 +00:00
|
|
|
|
void TColor_mask::save_colors(TConfig& colors)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
|
|
|
|
FOR_EACH_ASSOC_STRING(_color, obj, key, str)
|
|
|
|
|
colors.set(key, str);
|
2008-06-16 09:01:21 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
colors.set("Campi3D", get_bool(213) ? "X" : "");
|
2007-12-12 16:14:54 +00:00
|
|
|
|
colors.set("NativeControls", get_bool(214) ? "X" : "");
|
2003-05-26 13:00:26 +00:00
|
|
|
|
colors.set("AdvancedGraphics", get_bool(215) ? "X" : "");
|
2008-05-09 15:47:09 +00:00
|
|
|
|
colors.set("TreeView", get_int(216));
|
|
|
|
|
const int sz = get_int(217);
|
|
|
|
|
colors.set("ToolSize", 16+sz*8);
|
2008-05-15 15:01:55 +00:00
|
|
|
|
colors.set("EasyRider", get_bool(218) ? "X" : "");
|
2008-06-13 08:41:37 +00:00
|
|
|
|
colors.set("ToolText", get_bool(219) ? "X" : "");
|
2008-09-29 14:34:21 +00:00
|
|
|
|
|
|
|
|
|
if (colors.get_paragraph() == "Colors") // nel caso di default CONFIG_GUI
|
|
|
|
|
colors.set("FontDesc", _font_desc, "Font"); // per tradizione e' nel paragrafo Font
|
|
|
|
|
else
|
|
|
|
|
colors.set("FontDesc", _font_desc); // il font e' insieme al resto
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TColor_mask::save_colors()
|
|
|
|
|
{
|
|
|
|
|
TConfig colors(CONFIG_GUI, "Colors");
|
|
|
|
|
save_colors(colors);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
COLOR TColor_mask::get_color_entry(const char* name) const
|
|
|
|
|
{
|
|
|
|
|
COLOR c = COLOR_INVALID;
|
|
|
|
|
const TObject* s = ((TColor_mask*)this)->_color.objptr(name);
|
|
|
|
|
if (s)
|
|
|
|
|
{
|
|
|
|
|
TToken_string colore(*(TString*)s, ',');
|
|
|
|
|
const byte r = (byte)colore.get_int();
|
|
|
|
|
const byte g = (byte)colore.get_int();
|
|
|
|
|
const byte b = (byte)colore.get_int();
|
|
|
|
|
c = RGB2COLOR(r, g, b);
|
|
|
|
|
}
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TColor_mask::set_color_entry(const char* name, COLOR col)
|
|
|
|
|
{
|
|
|
|
|
TString* s = (TString*)_color.objptr(name);
|
|
|
|
|
if (s == NULL)
|
|
|
|
|
{
|
|
|
|
|
s = new TString(15);
|
|
|
|
|
_color.add(name, s);
|
|
|
|
|
}
|
|
|
|
|
s->format("%d,%d,%d", XVT_COLOR_GET_RED(col), XVT_COLOR_GET_GREEN(col), XVT_COLOR_GET_BLUE(col));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* TColor_mask::cid2name(short cid) const
|
|
|
|
|
{
|
|
|
|
|
const int colors = 13;
|
|
|
|
|
const char* name[colors] = { "MaskBack", "MaskLight", "MaskDark",
|
|
|
|
|
"Normal", "NormalBack", "RequiredBack",
|
|
|
|
|
"Focus", "FocusBack",
|
|
|
|
|
"Disabled", "DisabledBack",
|
|
|
|
|
"ButtonBack", "ButtonLight", "ButtonDark"
|
|
|
|
|
};
|
|
|
|
|
const int i = cid - 101;
|
|
|
|
|
CHECK(i >= 0 && i < colors, "Invalid color id");
|
|
|
|
|
return name[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
COLOR TColor_mask::cid2color(short cid) const
|
|
|
|
|
{
|
2008-10-10 15:11:46 +00:00
|
|
|
|
COLOR color[] = { XVT_MAKE_COLOR(201,194,188), COLOR_WHITE, COLOR_GRAY,
|
2003-05-14 13:35:51 +00:00
|
|
|
|
COLOR_BLACK, COLOR_WHITE, blend_colors(COLOR_WHITE, COLOR_YELLOW, 0.60),
|
2003-01-28 14:27:05 +00:00
|
|
|
|
COLOR_BLACK, COLOR_YELLOW,
|
|
|
|
|
COLOR_DKGRAY, COLOR_LTGRAY,
|
|
|
|
|
COLOR_LTGRAY, COLOR_WHITE, COLOR_GRAY };
|
|
|
|
|
|
|
|
|
|
const int i = cid - 101;
|
|
|
|
|
CHECK(i >= 0 && i < 13, "Invalid color id");
|
|
|
|
|
return color[i];
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-12 16:14:54 +00:00
|
|
|
|
COLOR TColor_mask::cid2syscolor(short cid, const XVT_COLOR_COMPONENT* cc) const
|
|
|
|
|
{
|
2008-06-13 08:41:37 +00:00
|
|
|
|
int entry[] = { XVT_COLOR_BACKGROUND /*XVT_COLOR_TROUGH*/, XVT_COLOR_BLEND, XVT_COLOR_BORDER,
|
2007-12-12 16:14:54 +00:00
|
|
|
|
XVT_COLOR_FOREGROUND, XVT_COLOR_BACKGROUND, XVT_COLOR_BACKGROUND,
|
|
|
|
|
XVT_COLOR_HIGHLIGHT, XVT_COLOR_SELECT,
|
|
|
|
|
XVT_COLOR_BLEND, XVT_COLOR_BORDER,
|
|
|
|
|
XVT_COLOR_BACKGROUND, XVT_COLOR_BLEND, XVT_COLOR_BORDER };
|
2008-01-17 14:04:52 +00:00
|
|
|
|
const unsigned int component = entry[cid-101];
|
2008-06-13 08:41:37 +00:00
|
|
|
|
for (int i = 0; cc[i].type != XVT_COLOR_NULL; i++) if (cc[i].type == component)
|
2007-12-12 16:14:54 +00:00
|
|
|
|
{
|
2008-06-13 08:41:37 +00:00
|
|
|
|
switch (cid)
|
2007-12-12 16:14:54 +00:00
|
|
|
|
{
|
2008-06-13 08:41:37 +00:00
|
|
|
|
case 105: return COLOR_WHITE;
|
|
|
|
|
case 106: return blend_colors(cid2syscolor(105, cc), cid2syscolor(108, cc), 0.60);
|
|
|
|
|
default : return cc[i].color;
|
2007-12-12 16:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return COLOR_BLACK;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Menu application
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::test_assistance_year() const
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::menu_item_handler(TMask_field&f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
app()._menu.select(f.dlg()-101);
|
2005-09-23 16:07:40 +00:00
|
|
|
|
f.set_focusdirty(false);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
return f.mask().stop_run(K_AUTO_ENTER);
|
|
|
|
|
}
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::menu_find_handler(TMask_field&f, KEY k)
|
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
if (k == K_TAB && f.focusdirty() && !f.empty())
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
|
|
|
|
const TString& v = f.get();
|
2008-09-29 14:34:21 +00:00
|
|
|
|
if (app()._menu.find_string(v))
|
|
|
|
|
{
|
|
|
|
|
f.set_focusdirty(false);
|
|
|
|
|
return f.mask().stop_run(K_F9);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
beep();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TMenu_application::do_level()
|
|
|
|
|
{
|
|
|
|
|
const TSubmenu& curr = _menu.current();
|
|
|
|
|
const int bwidth = 20;
|
|
|
|
|
|
2008-03-27 15:41:11 +00:00
|
|
|
|
TPicture_mask mask(curr.caption(), 0, 0, curr, 0, 0);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
CHECK(_mask == NULL, "Two masks are better than one?");
|
|
|
|
|
_mask = &mask;
|
|
|
|
|
|
2004-05-13 15:12:14 +00:00
|
|
|
|
const int ampiezza = 51;
|
|
|
|
|
const int margin = (mask.columns()-80) / 2;
|
|
|
|
|
const int x = mask.columns() - ampiezza -margin;
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
int y = 1;
|
|
|
|
|
|
|
|
|
|
TString caption;
|
|
|
|
|
for (int i = 0; i < curr.items(); i++, y++)
|
|
|
|
|
{
|
|
|
|
|
const TMenuitem& item = curr[i];
|
|
|
|
|
caption = item.caption();
|
|
|
|
|
if (item.is_submenu() && caption.right(3) != "...")
|
|
|
|
|
caption << "...";
|
|
|
|
|
|
|
|
|
|
mask.add_static(-1, 0, caption, x+4, y);
|
|
|
|
|
const short id = 100+y;
|
|
|
|
|
mask.add_button(id, 0, "", x, y, 1, 1, "", BMP_STOPREC);
|
|
|
|
|
mask.set_handler(id, menu_item_handler);
|
|
|
|
|
if (item.disabled())
|
|
|
|
|
mask.disable(id);
|
|
|
|
|
}
|
2004-05-13 15:12:14 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2004-05-13 15:12:14 +00:00
|
|
|
|
mask.add_static(DLG_NULL, 0, PR("Cerca"), x, -4);
|
|
|
|
|
|
|
|
|
|
TEdit_field& ef = mask.add_string(DLG_USER, 0, "", x, -3, 50, "", ampiezza - 2);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
ef.set_handler(menu_find_handler);
|
|
|
|
|
|
2004-05-13 15:12:14 +00:00
|
|
|
|
const int bottone = ampiezza / 3;
|
|
|
|
|
const int spazio = (ampiezza - bottone * 2) / 3;
|
|
|
|
|
|
|
|
|
|
const bool top = _menu.at_top();
|
|
|
|
|
mask.add_button(DLG_QUIT, 0, PR("Fine"), x + spazio, -1, bottone, 2);
|
|
|
|
|
if (!top)
|
|
|
|
|
mask.add_button(DLG_CANCEL, 0, PR("Menu precedente"), x + spazio * 2 + bottone, -1, bottone, 2);
|
|
|
|
|
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
mask.first_focus(101+_menu.selected());
|
|
|
|
|
|
|
|
|
|
const int k = mask.run();
|
|
|
|
|
_mask = NULL;
|
|
|
|
|
|
|
|
|
|
int m = 0;
|
|
|
|
|
switch (k)
|
|
|
|
|
{
|
|
|
|
|
case K_ESC:
|
|
|
|
|
_menu.pop();
|
|
|
|
|
m = -1;
|
|
|
|
|
break;
|
|
|
|
|
case K_QUIT:
|
|
|
|
|
mask.reset();
|
|
|
|
|
m = -2;
|
|
|
|
|
break;
|
|
|
|
|
case K_F9:
|
|
|
|
|
case K_CTRL+'R':
|
|
|
|
|
m = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
m = _menu.selected() + 1; // Sempre > 0
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TMenu_application::test_temp()
|
|
|
|
|
{
|
|
|
|
|
TFilename dir; dir.tempdir(); // Directory temporanea
|
|
|
|
|
dir.add("*");
|
|
|
|
|
TString_array files;
|
|
|
|
|
const int count = list_files(dir, files);
|
|
|
|
|
|
|
|
|
|
if (count > 0 && yesno_box(TR("Cancellare tutti i file temporanei in %s?"), dir.path()))
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
TProgind bar(count, TR("Cancellazione file temporanei"), true, true);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
for (int i = count-1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
bar.addstatus(1);
|
2003-03-20 11:39:42 +00:00
|
|
|
|
if (bar.iscancelled())
|
|
|
|
|
break;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
const char* e = files.row(i);
|
|
|
|
|
::remove(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HIDDEN bool pwd_handler(TMask_field& fld, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_F8)
|
|
|
|
|
{
|
|
|
|
|
TMask& m = fld.mask();
|
2006-07-11 13:10:51 +00:00
|
|
|
|
TString pwd;
|
|
|
|
|
TString usr = dongle().administrator(&pwd);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TLocalisamfile users(LF_USER);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
users.put(USR_USERNAME, usr);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
users.read();
|
2006-07-11 13:10:51 +00:00
|
|
|
|
pwd = decode(users.get(USR_PASSWORD));
|
2003-01-28 14:27:05 +00:00
|
|
|
|
m.set(F_USER, usr);
|
|
|
|
|
m.set(F_PASSWORD, pwd);
|
|
|
|
|
m.stop_run(K_ENTER);
|
|
|
|
|
}
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TMenu_application::reload_images()
|
|
|
|
|
{
|
|
|
|
|
_menu.reload_images();
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-03 11:06:56 +00:00
|
|
|
|
bool TMenu_application::ask_user_password(TString& utente)
|
2006-07-11 13:10:51 +00:00
|
|
|
|
{
|
2007-04-03 11:06:56 +00:00
|
|
|
|
bool ok = false;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2003-03-11 11:09:18 +00:00
|
|
|
|
// Disabilita le voci di personalizzazione
|
2008-09-29 14:34:21 +00:00
|
|
|
|
enable_options_menu(false);
|
2007-12-19 11:42:57 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TMask m("ba0100a");
|
2004-06-08 10:00:49 +00:00
|
|
|
|
|
2005-09-23 16:07:40 +00:00
|
|
|
|
if (is_power_station())
|
2004-06-08 10:00:49 +00:00
|
|
|
|
{
|
|
|
|
|
m.set_handler(F_USER, pwd_handler);
|
|
|
|
|
m.set_handler(F_PASSWORD, pwd_handler);
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
m.set(F_USER, utente);
|
|
|
|
|
m.first_focus(F_PASSWORD);
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TEdit_field& e = m.efield(F_USER);
|
|
|
|
|
e.browse()->set_filter("ISGROUP!=\"X\"");
|
|
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
TLocalisamfile& users = e.browse()->cursor()->file();
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TString pwd;
|
2005-09-23 16:07:40 +00:00
|
|
|
|
for (int i = 0; i < 3 && !ok; i++)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (utente.not_empty() && utente != dongle().administrator())
|
|
|
|
|
{
|
|
|
|
|
m.set(F_USER, utente);
|
|
|
|
|
m.first_focus(F_PASSWORD);
|
|
|
|
|
}
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (m.run() == K_ESC)
|
|
|
|
|
break;
|
2007-12-19 11:42:57 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
utente = m.get(F_USER);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
TString pwd;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
users.put(USR_USERNAME, utente);
|
2003-02-25 11:28:12 +00:00
|
|
|
|
if (users.read() == NOERR)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2006-07-11 13:10:51 +00:00
|
|
|
|
pwd = decode(users.get(USR_PASSWORD));
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-07-11 13:10:51 +00:00
|
|
|
|
// Creo l'amministratore se necessario
|
2003-02-25 11:28:12 +00:00
|
|
|
|
users.zero();
|
2006-07-11 13:10:51 +00:00
|
|
|
|
if (utente == dongle().administrator(&pwd))
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2006-07-11 13:10:51 +00:00
|
|
|
|
users.put(USR_USERNAME, utente);
|
|
|
|
|
users.put(USR_USERDESC, "Amministratore");
|
|
|
|
|
users.put(USR_PASSWORD, encode(pwd));
|
2003-01-28 14:27:05 +00:00
|
|
|
|
users.write();
|
|
|
|
|
}
|
2003-05-14 13:35:51 +00:00
|
|
|
|
else
|
|
|
|
|
utente.cut(0);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
|
|
|
|
const TString& pass = m.get(F_PASSWORD);
|
|
|
|
|
ok = utente.full() && pwd == pass;
|
|
|
|
|
|
|
|
|
|
if (ok)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (users.get_bool(USR_CONNECTED))
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
|
|
|
|
ok = yesno_box("%s\n%s",
|
2006-07-11 13:10:51 +00:00
|
|
|
|
TR("L'utente risulta essere gi<67> collegato"),
|
|
|
|
|
TR("Si desidera continuare ugualmente?"));
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2006-07-11 13:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error_box(TR("Utente e/o password errata: fare attenzione alle maiuscole"));
|
|
|
|
|
m.reset(F_PASSWORD);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (ok && users.curr().exist(USR_DATAPWD))
|
2006-07-11 13:10:51 +00:00
|
|
|
|
{
|
|
|
|
|
TConfig studio_ini(CONFIG_STUDIO, "Main");
|
|
|
|
|
const long expiration = studio_ini.get_long("PasswordExpiration");
|
|
|
|
|
bool runba = expiration > 0;
|
|
|
|
|
while (runba)
|
|
|
|
|
{
|
|
|
|
|
runba = users.get(USR_PASSWORD).empty();
|
|
|
|
|
if (!runba)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2006-07-11 13:10:51 +00:00
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
|
const TDate datapwd = users.get_date(USR_DATAPWD);
|
|
|
|
|
if (datapwd.ok())
|
|
|
|
|
runba = expiration < (oggi-datapwd); // Password scaduta
|
|
|
|
|
else
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2006-07-11 13:10:51 +00:00
|
|
|
|
// Scrivi la data se necessario
|
|
|
|
|
users.put(USR_DATAPWD, oggi);
|
|
|
|
|
users.rewrite();
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2006-07-11 13:10:51 +00:00
|
|
|
|
if (runba)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2007-04-03 11:06:56 +00:00
|
|
|
|
warning_box(TR("E' necessario inserire una nuova password"));
|
2003-01-28 14:27:05 +00:00
|
|
|
|
user() = utente;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
TExternal_app app("ba1 -3");
|
|
|
|
|
app.run();
|
|
|
|
|
users.reread();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2006-07-11 13:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Abilita le voci di personalizzazione
|
2008-09-29 14:34:21 +00:00
|
|
|
|
enable_options_menu(true);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2007-04-03 11:06:56 +00:00
|
|
|
|
return ok;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-03-19 15:31:53 +00:00
|
|
|
|
// Testa stato utente: 0 inesistente; 1 = esiste; 2 connesso; 4 conversione in corso
|
|
|
|
|
// ATTENZIONE: non usare mai cache() in ba0!
|
|
|
|
|
int TMenu_application::get_user_status(const char* usr) const
|
|
|
|
|
{
|
|
|
|
|
CHECK(usr && *usr, "Utente nullo");
|
|
|
|
|
|
|
|
|
|
int status = 0;
|
2008-05-09 15:47:09 +00:00
|
|
|
|
if (prefix_valid())
|
2008-03-19 15:31:53 +00:00
|
|
|
|
{
|
|
|
|
|
TLocalisamfile utonti(LF_USER);
|
|
|
|
|
utonti.put(USR_USERNAME, usr);
|
|
|
|
|
status = utonti.read() == NOERR;
|
|
|
|
|
if (status)
|
|
|
|
|
{
|
|
|
|
|
if (utonti.get_bool(USR_CONNECTED))
|
|
|
|
|
status |= 2;
|
|
|
|
|
if (dongle().administrator() == usr && utonti.get(USR_AUTSTR) == "CONVERTING")
|
|
|
|
|
status |= 4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Senza file aperti questo e' il massimo che posso fare
|
|
|
|
|
status = dongle().administrator() == usr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::set_user_status(const char* usr, int status) const
|
|
|
|
|
{
|
|
|
|
|
CHECK(usr && *usr, "Utente nullo");
|
|
|
|
|
|
|
|
|
|
bool ok = false;
|
2008-05-09 15:47:09 +00:00
|
|
|
|
if (prefix_valid())
|
2008-03-19 15:31:53 +00:00
|
|
|
|
{
|
|
|
|
|
TLocalisamfile utonti(LF_USER);
|
|
|
|
|
utonti.put(USR_USERNAME, usr);
|
|
|
|
|
if (utonti.read(_isequal, _lock) == NOERR)
|
|
|
|
|
{
|
|
|
|
|
utonti.put(USR_CONNECTED, status & 2 ? "X" : "");
|
|
|
|
|
ok = utonti.rewrite() == NOERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (status & 2)
|
|
|
|
|
{
|
|
|
|
|
// Memorizza utente per riproporlo la prossima volta
|
|
|
|
|
TConfig campo_ini(CONFIG_INSTALL, "Main");
|
|
|
|
|
campo_ini.set("User", usr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
bool TMenu_application::check_user()
|
|
|
|
|
{
|
2007-04-03 11:06:56 +00:00
|
|
|
|
bool ok = dongle().type() == _no_dongle;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
if (!ok)
|
|
|
|
|
{
|
2007-04-03 11:06:56 +00:00
|
|
|
|
TString utente = user();
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (_mask == NULL) // Primo login della sessione;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2007-04-03 11:06:56 +00:00
|
|
|
|
TConfig campo_ini(CONFIG_INSTALL, "Main");
|
|
|
|
|
const bool use_system_user = campo_ini.get_bool("AutoLogin");
|
|
|
|
|
if (use_system_user)
|
2007-09-25 14:11:37 +00:00
|
|
|
|
ok = !cache().get(LF_USER, utente).empty();
|
2006-07-11 13:10:51 +00:00
|
|
|
|
}
|
2007-12-19 11:42:57 +00:00
|
|
|
|
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (!ok)
|
|
|
|
|
ok = ask_user_password(utente);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
{
|
2007-09-25 14:11:37 +00:00
|
|
|
|
const TString& autstr = cache().get(LF_USER, dongle().administrator(), USR_AUTSTR);
|
|
|
|
|
if (autstr == "CONVERTING")
|
2006-07-11 13:10:51 +00:00
|
|
|
|
{
|
2007-04-03 11:06:56 +00:00
|
|
|
|
TString msg; msg << TR("E' in corso una conversione archivi") << ":\n";
|
|
|
|
|
if (utente == dongle().administrator())
|
|
|
|
|
{
|
|
|
|
|
msg << TR("Si desidera continuare ugualmente?");
|
|
|
|
|
ok = yesno_box(msg);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
msg << TR("Accesso negato.");
|
|
|
|
|
ok = error_box(msg);
|
|
|
|
|
}
|
2006-07-11 13:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (ok)
|
2007-09-25 14:11:37 +00:00
|
|
|
|
{
|
|
|
|
|
dongle().logout();
|
|
|
|
|
user() = utente;
|
|
|
|
|
ok = get_serial_number() >= 0;
|
|
|
|
|
if (!ok)
|
|
|
|
|
error_box(TR("Probabilmente <20> stato superato il numero massimo di utenti"));
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (ok)
|
2008-03-25 16:00:37 +00:00
|
|
|
|
set_user_status(utente, 3); // Esistente e connesso (1 | 2 = 3)
|
|
|
|
|
}
|
2007-04-03 11:06:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
customize_colors(); // Aggiorna set di colori
|
|
|
|
|
reload_images(); // Ritrasparentizza immagini
|
|
|
|
|
xvt_dwin_invalidate_rect(TASK_WIN, NULL); // Ridisegna sfondo
|
|
|
|
|
load_preferences();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HIDDEN int compare_version(const char* v1, int p1, const char* v2, int p2)
|
|
|
|
|
{
|
|
|
|
|
TString16 ver1(v1), ver2(v2);
|
|
|
|
|
ver1.trim();
|
|
|
|
|
if (ver1.len() == 4)
|
|
|
|
|
ver1.insert((v1[0] == '9') ? "19" : "20", 0);
|
|
|
|
|
ver2.trim();
|
|
|
|
|
if (ver2.len() == 4)
|
|
|
|
|
ver2.insert((v2[0] == '9') ? "19" : "20", 0);
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
int res = ver1.compare(ver2, -1, true);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (res == 0)
|
|
|
|
|
res = p1 - p2;
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int get_module_version(TConfig& cfg, void* jolly)
|
|
|
|
|
{
|
|
|
|
|
const TString& p = cfg.get_paragraph();
|
|
|
|
|
if (p.len() == 2)
|
|
|
|
|
{
|
|
|
|
|
TAssoc_array& map = *(TAssoc_array*)jolly;
|
|
|
|
|
TToken_string* tok = new TToken_string(15);
|
|
|
|
|
*tok = cfg.get("Versione");
|
|
|
|
|
tok->add(cfg.get("Patch"));
|
|
|
|
|
map.add(p, tok);
|
|
|
|
|
}
|
2005-09-23 16:07:40 +00:00
|
|
|
|
return false;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-10-17 09:35:51 +00:00
|
|
|
|
bool TMenu_application::copy_setup(const TString& remote_path)
|
2007-09-25 12:38:08 +00:00
|
|
|
|
{
|
2007-10-17 09:35:51 +00:00
|
|
|
|
bool ok = false;
|
2007-09-25 12:38:08 +00:00
|
|
|
|
const TFilename local_setupdir = "setup";
|
|
|
|
|
|
|
|
|
|
TFilename remote_setupdir = remote_path;
|
|
|
|
|
remote_setupdir.add(local_setupdir.name());
|
2007-12-19 11:42:57 +00:00
|
|
|
|
//controlla se esiste la directory;<3B> necessario in quanto se <20> una vecchia 4.0 potrebbe non esserci
|
2007-11-29 11:12:45 +00:00
|
|
|
|
if (remote_setupdir.exist())
|
|
|
|
|
{
|
2007-12-19 11:42:57 +00:00
|
|
|
|
remote_setupdir.add("*.*");
|
2007-09-25 12:38:08 +00:00
|
|
|
|
|
2007-12-19 11:42:57 +00:00
|
|
|
|
TString_array ar;
|
|
|
|
|
list_files(remote_setupdir, ar);
|
|
|
|
|
|
|
|
|
|
if (!ar.empty())
|
|
|
|
|
{
|
|
|
|
|
make_dir(local_setupdir);
|
2007-11-29 11:12:45 +00:00
|
|
|
|
|
2007-12-19 11:42:57 +00:00
|
|
|
|
ok = true;
|
|
|
|
|
TFilename strsrc, strdst;
|
|
|
|
|
FOR_EACH_ARRAY_ROW (ar, i, row)
|
|
|
|
|
{
|
|
|
|
|
strsrc = *row;
|
|
|
|
|
strdst = local_setupdir;
|
|
|
|
|
strdst.add(strsrc.name());
|
|
|
|
|
//se la copia dei files si inchioda esce
|
|
|
|
|
if (!fcopy(strsrc, strdst))
|
|
|
|
|
{
|
|
|
|
|
ok = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} //FOR_EACH_ARRAY...
|
|
|
|
|
} //if(!ar.empty...
|
|
|
|
|
} //if(remote_setupdir...
|
2007-10-17 09:35:51 +00:00
|
|
|
|
|
|
|
|
|
return ok;
|
2007-09-25 12:38:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
bool TMenu_application::test_programs()
|
|
|
|
|
{
|
|
|
|
|
TToken_string dangerous;
|
2007-09-25 12:38:08 +00:00
|
|
|
|
int update_needed = 0;
|
2007-10-04 15:20:11 +00:00
|
|
|
|
bool is_client = false;
|
2008-12-03 11:12:51 +00:00
|
|
|
|
bool sy_needed = false;
|
|
|
|
|
|
2007-09-25 12:38:08 +00:00
|
|
|
|
//parentesi necessaria per richiudere subito il .ini!
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
|
|
|
|
TConfig prawin(CONFIG_INSTALL, "Main");
|
2007-10-04 15:20:11 +00:00
|
|
|
|
const int type = prawin.get_int("Type");
|
2008-12-03 11:12:51 +00:00
|
|
|
|
is_client = type == 3 || prawin.get_bool("TestPrograms");
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-03 11:12:51 +00:00
|
|
|
|
TString msg = TR("I seguenti moduli devono essere aggiornati prima dell'utilizzo:\n");
|
2007-10-04 15:20:11 +00:00
|
|
|
|
if (is_client)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
|
|
|
|
TConfig install("install.ini", "Main");
|
|
|
|
|
TFilename remote_name = install.get("DiskPath");
|
|
|
|
|
remote_name.add("install.ini");
|
2004-04-09 11:37:43 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (remote_name.exist())
|
|
|
|
|
{
|
2007-05-09 12:50:42 +00:00
|
|
|
|
TProgind pi(3, TR("Controllo aggiornamento programmi"), false, true);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
|
2004-04-09 11:37:43 +00:00
|
|
|
|
TConfig remote_install(remote_name, "Main");
|
|
|
|
|
remote_install.write_protect();
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TAssoc_array my_modules, his_modules;
|
|
|
|
|
pi.addstatus(1);
|
|
|
|
|
install.for_each_paragraph(get_module_version, &my_modules);
|
|
|
|
|
pi.addstatus(1);
|
|
|
|
|
remote_install.for_each_paragraph(get_module_version, &his_modules);
|
|
|
|
|
pi.addstatus(1);
|
2004-04-09 11:37:43 +00:00
|
|
|
|
|
2007-09-25 12:38:08 +00:00
|
|
|
|
//giro su tutti i moduli che sono sul server
|
|
|
|
|
const TDongle& chiavetta = dongle();
|
|
|
|
|
FOR_EACH_ASSOC_STRING(his_modules, h, str_code, str_tok)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2007-09-25 12:38:08 +00:00
|
|
|
|
//per prima cosa controlla se deve aggiornare SY e/o BA
|
|
|
|
|
const TString4 code = str_code;
|
2008-12-03 11:12:51 +00:00
|
|
|
|
if (code == "sr")
|
|
|
|
|
continue; // Un client non pu<70> aggiornare il modulo server!
|
|
|
|
|
|
|
|
|
|
int module = 0;
|
2007-09-25 12:38:08 +00:00
|
|
|
|
if (code != "sy" && code != "ba")
|
|
|
|
|
module = chiavetta.module_name2code(code);
|
|
|
|
|
|
|
|
|
|
if (chiavetta.active(module) && chiavetta.shown(module))
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2007-09-25 12:38:08 +00:00
|
|
|
|
//const TString4 code = dongle().module_code2name(module);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TToken_string* mytok = (TToken_string*)my_modules.objptr(code);
|
|
|
|
|
TToken_string* histok = (TToken_string*)his_modules.objptr(code);
|
|
|
|
|
|
|
|
|
|
const TString16 v1 = mytok ? mytok->get(0) : "";
|
|
|
|
|
const int p1 = mytok ? mytok->get_int() : 0;
|
|
|
|
|
const TString16 v2 = histok ? histok->get(0) : "";
|
|
|
|
|
const int p2 = histok ? histok->get_int() : 0;
|
|
|
|
|
if (!v1.blank() && compare_version(v1, p1, v2, p2) < 0)
|
|
|
|
|
{
|
2007-09-25 12:38:08 +00:00
|
|
|
|
// Non disabilitare mai il modulo base! Se non funzionasse qualcosa (vedi anno di assistenza)...
|
|
|
|
|
//...non lascierebbe funzionare nulla!!!!
|
|
|
|
|
if (module > 0)
|
2006-12-13 16:22:33 +00:00
|
|
|
|
dangerous.add(code);
|
2008-12-03 11:12:51 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (code == "sy")
|
|
|
|
|
sy_needed = true;
|
|
|
|
|
}
|
2007-09-25 12:38:08 +00:00
|
|
|
|
|
|
|
|
|
if (msg.len() < 200)
|
2004-04-09 11:37:43 +00:00
|
|
|
|
{
|
2007-09-25 12:38:08 +00:00
|
|
|
|
TString name;
|
|
|
|
|
if (code == "sy")
|
|
|
|
|
name = TR("Sistema");
|
2004-04-09 11:37:43 +00:00
|
|
|
|
else
|
2007-09-25 12:38:08 +00:00
|
|
|
|
name = chiavetta.module_code2desc(module);
|
|
|
|
|
if (update_needed > 0)
|
|
|
|
|
msg << ", ";
|
|
|
|
|
msg << name;
|
2004-04-09 11:37:43 +00:00
|
|
|
|
}
|
2007-09-25 12:38:08 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (msg.right(1) != ".")
|
|
|
|
|
msg << ",etc.";
|
|
|
|
|
}
|
|
|
|
|
update_needed++;
|
2007-10-17 09:35:51 +00:00
|
|
|
|
} //if (!v1.blank()...
|
|
|
|
|
} //if (chiavetta.active(module...
|
|
|
|
|
} //FOR_EACH_ASSOC_STR
|
|
|
|
|
} //if(remote_name.exist()...
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2008-12-03 11:12:51 +00:00
|
|
|
|
if (update_needed > 0 && yesno_box(msg))
|
2007-09-25 12:38:08 +00:00
|
|
|
|
{
|
|
|
|
|
//copia il contenuto della setup del server nella setup del client
|
2008-12-03 11:12:51 +00:00
|
|
|
|
if (sy_needed && copy_setup(remote_name.path()))
|
2007-10-17 09:35:51 +00:00
|
|
|
|
{
|
|
|
|
|
//mette il flag di installing
|
|
|
|
|
set_installing_flag();
|
2007-12-20 10:43:10 +00:00
|
|
|
|
//lancia setup in modalita' aggiornamento client e si suicida! (banzai!!)
|
2008-12-03 11:12:51 +00:00
|
|
|
|
TExternal_app app("setup\\setup.exe -uc");
|
|
|
|
|
app.run(true, 0, false);
|
2007-12-19 11:42:57 +00:00
|
|
|
|
}
|
|
|
|
|
else //lancia l'installazione moduli alla vecchia maniera (e' una vecchia 4.0)
|
2007-11-29 11:36:40 +00:00
|
|
|
|
{
|
|
|
|
|
TExternal_app app("ba1 -6 /uADMIN");
|
2008-12-03 11:12:51 +00:00
|
|
|
|
app.run(true, 0, false);
|
2007-11-29 11:36:40 +00:00
|
|
|
|
}
|
2007-12-19 11:42:57 +00:00
|
|
|
|
//se lancia un'installazione->esce!!!
|
2007-11-29 11:36:40 +00:00
|
|
|
|
return false;
|
2007-12-19 11:42:57 +00:00
|
|
|
|
|
2007-10-17 09:35:51 +00:00
|
|
|
|
} //(if(update_needed>0...
|
|
|
|
|
} //if(is_client..
|
2007-09-25 12:38:08 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
_menu.set_dangerous_modules(dangerous);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 16:07:40 +00:00
|
|
|
|
bool TMenu_application::user_create()
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2007-12-19 11:42:57 +00:00
|
|
|
|
disable_menu_item(M_FILE_PRINT); // Questa voce di menu non serve per ora
|
|
|
|
|
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (dongle().type() == _no_dongle)
|
2008-05-09 15:47:09 +00:00
|
|
|
|
warning_box(TR("ATTENZIONE\nQuesto programma <20> in versione dimostrativa.\n"
|
|
|
|
|
"Esso funzionera' per circa due ore al giorno con un numero limitato di registrazioni."));
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
if (!check_user())
|
2005-09-23 16:07:40 +00:00
|
|
|
|
return false;
|
2007-12-19 11:42:57 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (!TApplication::test_assistance_year())
|
|
|
|
|
{
|
|
|
|
|
TExternal_app app("ba1 -4");
|
|
|
|
|
app.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_perms();
|
|
|
|
|
test_temp();
|
|
|
|
|
|
|
|
|
|
if (!test_programs())
|
2005-09-23 16:07:40 +00:00
|
|
|
|
return false;
|
2003-06-26 15:03:27 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (!_menu.ok())
|
|
|
|
|
{
|
|
|
|
|
TWait_cursor hourglass;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
TFilename menu = _menuname;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
menu.ext("men");
|
|
|
|
|
_menu.read(menu);
|
2003-10-14 13:44:01 +00:00
|
|
|
|
update_preferred_tree();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-11 11:02:13 +00:00
|
|
|
|
void TMenu_application::deconnect_user()
|
|
|
|
|
{
|
2008-03-19 15:31:53 +00:00
|
|
|
|
if (get_user_status(user()) & 2) // Se e' connesso
|
|
|
|
|
set_user_status(user(), 1); // Sconnettilo
|
2003-06-11 11:02:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::destroy()
|
|
|
|
|
{
|
|
|
|
|
deconnect_user();
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-17 08:54:31 +00:00
|
|
|
|
void TMenu_application::main_loop()
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2005-09-23 16:07:40 +00:00
|
|
|
|
bool run = user_create();
|
2006-12-13 16:22:33 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
while (run)
|
|
|
|
|
{
|
|
|
|
|
int m = 0;
|
|
|
|
|
switch (_tree_view)
|
|
|
|
|
{
|
2008-01-31 14:19:39 +00:00
|
|
|
|
case 1: m = do_tree(); break;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
case 2: m = do_explore(); break;
|
2008-01-31 14:19:39 +00:00
|
|
|
|
case 3: m = do_outlook(); break;
|
|
|
|
|
default: m = do_level(); break;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (m > 0)
|
|
|
|
|
_menu.perform();
|
|
|
|
|
else
|
|
|
|
|
run = m >= -1;
|
2007-05-09 12:50:42 +00:00
|
|
|
|
if (installing()) //esce dal ciclo se ha lanciato una installazione moduli
|
|
|
|
|
break;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-29 14:34:21 +00:00
|
|
|
|
void enable_options_menu(bool on)
|
|
|
|
|
{
|
|
|
|
|
const WINDOW tw = TASK_WIN;
|
|
|
|
|
xvt_menu_set_item_enabled(tw, M_FILE_NEW, on); // Cambio ditta
|
|
|
|
|
xvt_menu_set_item_enabled(tw, M_FILE_PG_SETUP, on); // Imposta Stampante
|
|
|
|
|
for (int i = 2; i <= 7; i++) // Menu opzioni
|
|
|
|
|
xvt_menu_set_item_enabled(tw, MENU_ITEM(i), on);
|
|
|
|
|
xvt_menu_update(tw);
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
bool TMenu_application::choose_colors()
|
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
enable_options_menu(false);
|
|
|
|
|
|
|
|
|
|
bool update_needed = false;
|
|
|
|
|
KEY key = K_CTRL+'R';
|
|
|
|
|
while (key == K_CTRL+'R')
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
TColor_mask cm;
|
|
|
|
|
key = cm.run();
|
|
|
|
|
if (key == K_ENTER || key == K_CTRL+'R') // Salva o Applica
|
|
|
|
|
{
|
|
|
|
|
_tree_view = cm.get_int(216); // Aggiorna stile menu
|
|
|
|
|
cm.save_colors(); // Aggiorna config
|
|
|
|
|
customize_colors(); // Aggiorna set di colori
|
|
|
|
|
reload_images(); // Aggiorna bitmaps del menu
|
|
|
|
|
|
|
|
|
|
// Ridisegna sfondo
|
|
|
|
|
TTemp_window tw(TASK_WIN);
|
|
|
|
|
tw.force_update();
|
|
|
|
|
update_needed = true;
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2008-09-29 14:34:21 +00:00
|
|
|
|
|
|
|
|
|
// Provoca chiusura forzata del menu
|
|
|
|
|
if (update_needed && _mask != NULL)
|
|
|
|
|
_mask->stop_run(K_CTRL + 'R');
|
|
|
|
|
|
|
|
|
|
enable_options_menu(true);
|
|
|
|
|
return key == K_ENTER;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HIDDEN bool browse_file_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
bool ok = true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
if (k == K_F9)
|
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
TFilename n = f.get(); n.ext("exe");
|
|
|
|
|
FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(n, &fs);
|
|
|
|
|
|
|
|
|
|
//DIRECTORY dir; xvt_fsys_get_dir(&dir);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
const int err = xvt_dm_post_file_open(&fs, TR("Selezione programma"));
|
2008-09-29 14:34:21 +00:00
|
|
|
|
//xvt_fsys_set_dir(&dir);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (err == FL_OK)
|
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
xvt_fsys_convert_fspec_to_str(&fs, n.get_buffer(), n.size());
|
2003-01-28 14:27:05 +00:00
|
|
|
|
f.set(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TFilename infile(f.get());
|
|
|
|
|
if (infile.not_empty())
|
|
|
|
|
{
|
|
|
|
|
TFilename outfile;
|
|
|
|
|
if (!infile.search_in_path(outfile))
|
2004-03-31 12:48:16 +00:00
|
|
|
|
{
|
|
|
|
|
if (*infile.ext() == '\0')
|
|
|
|
|
infile.ext("exe");
|
|
|
|
|
if (!infile.search_in_path(outfile))
|
|
|
|
|
ok = error_box("Il programma %s non esiste!", (const char*)infile);
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HIDDEN bool link_notify(TSheet_field& s, int r, KEY k)
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
bool ok = true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (k == K_INS)
|
|
|
|
|
{
|
|
|
|
|
ok = s.items() < 29; // Accetta 29 righe al massimo
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::choose_editors()
|
|
|
|
|
{
|
2008-09-29 14:34:21 +00:00
|
|
|
|
enable_options_menu(false);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2003-10-14 13:44:01 +00:00
|
|
|
|
TConfig link(CONFIG_GUI, "Link");
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
TMask* msk = new TMask("ba0300a");
|
|
|
|
|
TMask& m = *msk;
|
|
|
|
|
|
|
|
|
|
TSheet_field& sheet = m.sfield(201);
|
|
|
|
|
sheet.set_notify(link_notify);
|
|
|
|
|
TMask& sm = sheet.sheet_mask();
|
|
|
|
|
sm.set_handler(102, browse_file_handler);
|
|
|
|
|
|
|
|
|
|
TAssoc_array& var = (TAssoc_array&)link.list_variables();
|
|
|
|
|
FOR_EACH_ASSOC_STRING(var, obj, key, str)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& row = sheet.row(-1);
|
|
|
|
|
if (strlen(key) <= 3)
|
|
|
|
|
{
|
|
|
|
|
row = key;
|
|
|
|
|
row.lower();
|
|
|
|
|
row.add(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sheet.rows_array().sort();
|
|
|
|
|
|
|
|
|
|
if (m.run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
link.remove_all();
|
|
|
|
|
FOR_EACH_SHEET_ROW_BACK(sheet, r, row)
|
|
|
|
|
{
|
|
|
|
|
TString16 ext = row->get(0);
|
|
|
|
|
if (!ext.blank())
|
|
|
|
|
{
|
|
|
|
|
ext.lower();
|
|
|
|
|
TFilename prg = row->get();
|
|
|
|
|
link.set(ext, prg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete msk;
|
|
|
|
|
|
2008-09-29 14:34:21 +00:00
|
|
|
|
enable_options_menu(true);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-04 13:40:28 +00:00
|
|
|
|
HIDDEN int dir_sort(const TObject** d1, const TObject** d2)
|
|
|
|
|
{
|
|
|
|
|
const TString& s1 = (const TString&)**d1;
|
|
|
|
|
const TString& s2 = (const TString&)**d2;
|
2004-03-31 12:48:16 +00:00
|
|
|
|
return xvt_str_compare_ignoring_case(s1, s2);
|
2004-03-04 13:40:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
HIDDEN bool study_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
bool ok = true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (f.to_check(k))
|
|
|
|
|
{
|
|
|
|
|
TFilename path(f.get());
|
|
|
|
|
path.add("com");
|
|
|
|
|
path.add("dir.gen");
|
2007-10-04 15:20:11 +00:00
|
|
|
|
if (!path.exist() || path.find(' ') >= 0)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
ok = f.error_box("%s %s", (const char*)f.get(), TR("non e' uno studio valido!"));
|
2003-09-11 09:19:16 +00:00
|
|
|
|
} else
|
|
|
|
|
if (k == K_F9)
|
|
|
|
|
{
|
|
|
|
|
TFilename str = firm2dir(-1);
|
|
|
|
|
for (int i = str.len()-2; i > 0; i--)
|
|
|
|
|
{
|
|
|
|
|
if (str[i] == '\\' || str[i] == '/')
|
|
|
|
|
{
|
|
|
|
|
str.cut(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
str.add("*");
|
2006-12-13 16:22:33 +00:00
|
|
|
|
SLIST dirs = xvt_fsys_list_files(DIR_TYPE, str.get_buffer(), true);
|
2003-09-11 09:19:16 +00:00
|
|
|
|
|
2003-10-07 13:03:04 +00:00
|
|
|
|
TFilename dirgen;
|
2006-12-13 16:22:33 +00:00
|
|
|
|
TArray_sheet sht(-1, -1, 78, 16, TR("Scelta studio"), HR("Studio@76"));
|
2003-09-11 09:19:16 +00:00
|
|
|
|
for (SLIST_ELT e = xvt_slist_get_first(dirs); e; e = xvt_slist_get_next(dirs, e))
|
|
|
|
|
{
|
|
|
|
|
const char* f = xvt_slist_get(dirs, e, NULL);
|
2003-10-07 13:03:04 +00:00
|
|
|
|
dirgen = f;
|
2007-10-04 15:20:11 +00:00
|
|
|
|
if (dirgen.find(' ') < 0)
|
|
|
|
|
{
|
|
|
|
|
dirgen.add("com/dir.gen");
|
|
|
|
|
if (dirgen.exist())
|
|
|
|
|
sht.add(f);
|
|
|
|
|
}
|
2003-09-11 09:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
xvt_slist_destroy(dirs);
|
|
|
|
|
|
2004-03-04 13:40:28 +00:00
|
|
|
|
sht.rows_array().TArray::sort(dir_sort);
|
2003-09-11 09:19:16 +00:00
|
|
|
|
if (sht.run() == K_ENTER)
|
|
|
|
|
f.set(sht.row(-1)); // -1 = selected row
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::choose_study()
|
|
|
|
|
{
|
2008-03-19 15:31:53 +00:00
|
|
|
|
// Disbilita le voci di personalizzazione
|
2008-09-29 14:34:21 +00:00
|
|
|
|
enable_options_menu(false);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2003-09-11 09:19:16 +00:00
|
|
|
|
TMask m(TR("Scelta studio"), 1, 62, 4);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
|
|
|
|
|
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
|
2003-09-11 09:19:16 +00:00
|
|
|
|
m.add_string(DLG_USER, 0, PR("Studio "), 1, 1, 50, "B");
|
2003-01-28 14:27:05 +00:00
|
|
|
|
m.set_handler(DLG_USER, study_handler);
|
|
|
|
|
m.set(DLG_USER, prefix().get_studio());
|
|
|
|
|
bool ok = m.run() == K_ENTER;
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
2003-06-11 11:02:13 +00:00
|
|
|
|
deconnect_user();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
prefix().set_studio(m.get(DLG_USER));
|
2003-09-11 09:19:16 +00:00
|
|
|
|
ok = check_user();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
{
|
2003-10-20 13:12:34 +00:00
|
|
|
|
_menu.set_firm(0);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
_mask->stop_run(K_F9); // Ricarica maschera
|
|
|
|
|
}
|
|
|
|
|
else
|
2008-07-25 15:10:18 +00:00
|
|
|
|
{
|
|
|
|
|
dispatch_e_menu(M_FILE_QUIT); // Termina applicazione gracefully
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
2008-03-19 15:31:53 +00:00
|
|
|
|
// Abilita le voci di personalizzazione
|
2008-09-29 14:34:21 +00:00
|
|
|
|
enable_options_menu(true);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long TMenu_application::handler(WINDOW win, EVENT* ep)
|
|
|
|
|
{
|
|
|
|
|
long ret = TApplication::handler(win, ep);
|
|
|
|
|
if (ep->type == E_FONT)
|
|
|
|
|
{
|
|
|
|
|
if (_mask != NULL)
|
|
|
|
|
_mask->stop_run(K_CTRL + 'R');
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Tree view implementation
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::tree_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_CTRL + K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
TTree_field& tf = (TTree_field&)f;
|
|
|
|
|
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
|
|
|
|
|
const TMenuitem& mi = mt.curr_item();
|
|
|
|
|
mi.perform();
|
|
|
|
|
|
2004-04-22 11:15:05 +00:00
|
|
|
|
if (mi.is_submenu())
|
|
|
|
|
{
|
2003-03-11 11:09:18 +00:00
|
|
|
|
TPicture_mask& pm = (TPicture_mask&)f.mask();
|
2004-04-22 11:15:05 +00:00
|
|
|
|
if (mt.expanded())
|
|
|
|
|
{
|
|
|
|
|
TMenu& menu = mt.curr_submenu().menu();
|
|
|
|
|
pm.set_current(menu.current());
|
|
|
|
|
}
|
|
|
|
|
pm.force_update();
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2004-04-22 11:15:05 +00:00
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-24 15:41:41 +00:00
|
|
|
|
TTree_field& TMenu_application::tree_field() const
|
|
|
|
|
{
|
|
|
|
|
CHECK(_tree_view > 0, "No menu tree");
|
|
|
|
|
return _mask->tfield(_tree_view == 3 ? 101 : 301);
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
void TMenu_application::select_tree_current()
|
|
|
|
|
{
|
2008-10-24 15:41:41 +00:00
|
|
|
|
TTree_field& tf = tree_field();
|
2008-01-31 14:19:39 +00:00
|
|
|
|
synchronize_tree_field(tf);
|
|
|
|
|
tf.set_focus();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::tree_find_handler(TMask_field&f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_TAB && f.focusdirty() && !f.empty())
|
|
|
|
|
{
|
|
|
|
|
const TString& v = f.get();
|
2008-10-24 15:41:41 +00:00
|
|
|
|
TTree_field& tf = app().tree_field();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
|
|
|
|
|
if (mt.find_string(v))
|
|
|
|
|
app().select_tree_current();
|
|
|
|
|
else
|
|
|
|
|
beep();
|
|
|
|
|
}
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TMenu_application::tree_shrink_handler(TMask_field&f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
2008-10-24 15:41:41 +00:00
|
|
|
|
TTree_field& tf = app().tree_field();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
TMenu_tree& mt = (TMenu_tree&)*tf.tree();
|
|
|
|
|
mt.shrink_all();
|
|
|
|
|
mt.goto_root();
|
|
|
|
|
app().select_tree_current();
|
|
|
|
|
}
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TMenu_application::update_preferred()
|
|
|
|
|
{
|
|
|
|
|
MENU_ITEM* mm = xvt_menu_get_tree(TASK_WIN);
|
2004-03-31 12:48:16 +00:00
|
|
|
|
MENU_ITEM* mi;
|
|
|
|
|
for (mi = mm; mi != NULL && mi->tag != 0 && mi->tag != PREFERRED_MENU; mi++);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (mi == NULL || mi->tag <= 0 || mi->child == NULL)
|
|
|
|
|
{
|
|
|
|
|
NFCHECK("Can't find Preferiti Menu");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
MENU_ITEM* pm = (MENU_ITEM*)xvt_mem_zalloc((_preferred.items()+4)*sizeof(MENU_ITEM));
|
|
|
|
|
memcpy(pm, mi->child, 3*sizeof(MENU_ITEM));
|
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
|
{
|
|
|
|
|
const char* src = mi->child[i].text;
|
|
|
|
|
pm[i].text = xvt_str_duplicate(src);
|
|
|
|
|
}
|
|
|
|
|
xvt_res_free_menu_tree(mi->child);
|
|
|
|
|
mi->child = pm;
|
|
|
|
|
|
|
|
|
|
for (i = -1; i < _preferred.items(); i++)
|
|
|
|
|
{
|
|
|
|
|
MENU_ITEM& m = pm[i+3];
|
|
|
|
|
if (i >= 0)
|
|
|
|
|
{
|
|
|
|
|
m.tag = MENU_ITEM(50+i);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
m.enabled = true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
const char* src = _preferred.row(i).get(0);
|
|
|
|
|
m.text = xvt_str_duplicate(src);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m.tag = -1;
|
2006-12-13 16:22:33 +00:00
|
|
|
|
m.separator = true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-09 15:47:09 +00:00
|
|
|
|
xvt_menu_set_tree(TASK_WIN, mm);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
xvt_menu_update(TASK_WIN);
|
|
|
|
|
xvt_res_free_menu_tree(mm);
|
2003-10-14 13:44:01 +00:00
|
|
|
|
|
|
|
|
|
update_preferred_tree();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TMenu_application::update_preferred_tree()
|
|
|
|
|
{
|
|
|
|
|
TSubmenu* pref = _menu.find("MENU_PREFERITI");
|
|
|
|
|
if (pref != NULL && _preferred.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
TToken_string node(16, '.');
|
|
|
|
|
pref->destroy_items();
|
|
|
|
|
FOR_EACH_ARRAY_ROW(_preferred, i, row)
|
|
|
|
|
{
|
|
|
|
|
int slash = row->rfind('/');
|
|
|
|
|
if (slash < 0)
|
|
|
|
|
slash = row->rfind(row->separator());
|
|
|
|
|
node = row->mid(slash+1);
|
|
|
|
|
if (node.items() == 2)
|
|
|
|
|
{
|
|
|
|
|
const char* sub = node.get(0);
|
|
|
|
|
TSubmenu* sm = _menu.find(sub);
|
|
|
|
|
if (sm != NULL)
|
|
|
|
|
{
|
|
|
|
|
const int num = node.get_int(1);
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (num >= 0 && num < sm->items())
|
2005-11-08 16:44:19 +00:00
|
|
|
|
pref->add(new TMenuitem(sm->item(num)));
|
2003-10-14 13:44:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TMenu_application::load_preferences()
|
|
|
|
|
{
|
2003-10-14 13:44:01 +00:00
|
|
|
|
TConfig cfg(CONFIG_GUI, "ba0");
|
2003-01-28 14:27:05 +00:00
|
|
|
|
_preferred.destroy();
|
2008-05-09 15:47:09 +00:00
|
|
|
|
for (int i = 0; ; i++)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2008-05-09 15:47:09 +00:00
|
|
|
|
TToken_string row = cfg.get("Preferred", NULL, i);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (row.empty_items())
|
|
|
|
|
break;
|
|
|
|
|
_preferred.add(row);
|
|
|
|
|
}
|
2008-05-09 15:47:09 +00:00
|
|
|
|
update_preferred();
|
|
|
|
|
|
|
|
|
|
_tree_view = cfg.get_int("TreeView", "Colors", -1, 3);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TMenu_application::save_preferences()
|
|
|
|
|
{
|
2003-10-14 13:44:01 +00:00
|
|
|
|
TConfig cfg(CONFIG_GUI, "ba0");
|
2008-01-31 16:37:24 +00:00
|
|
|
|
int i;
|
2004-03-31 12:48:16 +00:00
|
|
|
|
for (i = 0; i < _preferred.items(); i++)
|
2006-12-13 16:22:33 +00:00
|
|
|
|
cfg.set("Preferred", _preferred.row(i), NULL, true, i);
|
|
|
|
|
cfg.set("Preferred", "", NULL, true, i);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TMenu_application::add_to_preferred()
|
|
|
|
|
{
|
|
|
|
|
if (_mask == NULL) // Succede durante il login!
|
|
|
|
|
return;
|
|
|
|
|
|
2008-10-24 15:41:41 +00:00
|
|
|
|
if (_preferred.items() < 16) // Massimo numero di preferiti
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
|
|
|
|
TToken_string tok;
|
2003-10-14 13:44:01 +00:00
|
|
|
|
|
|
|
|
|
switch (_tree_view)
|
|
|
|
|
{
|
2008-10-24 15:41:41 +00:00
|
|
|
|
case 0:
|
2003-10-14 13:44:01 +00:00
|
|
|
|
{
|
|
|
|
|
const TMask_field& butt = _mask->focus_field();
|
|
|
|
|
const int index = butt.dlg() - 101;
|
|
|
|
|
if (index >= 0 && index < 16)
|
|
|
|
|
{
|
|
|
|
|
_menu.select(index);
|
|
|
|
|
tok = _menu.curr_item().caption();
|
|
|
|
|
tok.add(_menu.current().name());
|
|
|
|
|
tok << '.' << index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2008-10-24 15:41:41 +00:00
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
TMenulist_field& mf = (TMenulist_field&)_mask->field(DLG_LIST);
|
|
|
|
|
mf.curr_item(tok);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
TTree_field& tf = tree_field();
|
|
|
|
|
tf.goto_selected();
|
|
|
|
|
tf.tree()->get_description(tok);
|
|
|
|
|
TString id; tf.tree()->curr_id(id);
|
|
|
|
|
tok.add(id);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
2008-05-09 15:47:09 +00:00
|
|
|
|
if (tok.full() && _preferred.find(tok) < 0)
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
|
|
|
|
_preferred.add(tok);
|
|
|
|
|
save_preferences();
|
2003-10-14 13:44:01 +00:00
|
|
|
|
update_preferred();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2008-10-24 15:41:41 +00:00
|
|
|
|
error_box(TR("Non e' possibile memorizzare piu' di %d preferenze"), _preferred.items());
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TPreferred_mask : public TAutomask
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TPreferred_mask() : TAutomask("ba0400a") { }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool TPreferred_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case F_PREF_SHEET:
|
|
|
|
|
switch (e)
|
|
|
|
|
{
|
|
|
|
|
case se_query_add:
|
2005-09-23 16:07:40 +00:00
|
|
|
|
return false;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
case se_enter:
|
|
|
|
|
enable(F_PREF_UP, jolly > 0);
|
|
|
|
|
enable(F_PREF_DN, jolly < ((TSheet_field&)o).items()-1);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_PREF_UP:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sf = sfield(F_PREF_SHEET);
|
|
|
|
|
const int r = sf.selected();
|
|
|
|
|
if (r > 0)
|
|
|
|
|
{
|
|
|
|
|
sf.rows_array().swap(r, r-1);
|
|
|
|
|
sf.select(r-1);
|
|
|
|
|
sf.force_update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_PREF_DN:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sf = sfield(F_PREF_SHEET);
|
|
|
|
|
const int r = sf.selected();
|
|
|
|
|
if (r < sf.items()-1)
|
|
|
|
|
{
|
|
|
|
|
sf.rows_array().swap(r, r+1);
|
|
|
|
|
sf.select(r+1);
|
|
|
|
|
sf.force_update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_DELREC:
|
|
|
|
|
if (e == fe_button && jolly == 0) // Main delete button pressed
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sf = sfield(F_PREF_SHEET);
|
|
|
|
|
const int r = sf.selected();
|
|
|
|
|
if (r >= 0)
|
|
|
|
|
sf.destroy(r);
|
2005-09-23 16:07:40 +00:00
|
|
|
|
return false;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TMenu_application::manage_preferred()
|
|
|
|
|
{
|
|
|
|
|
TPreferred_mask* m = new TPreferred_mask;
|
|
|
|
|
|
|
|
|
|
TSheet_field& sf = m->sfield(F_PREF_SHEET);
|
|
|
|
|
sf.rows_array() = _preferred;
|
|
|
|
|
|
|
|
|
|
sf.force_update();
|
|
|
|
|
|
|
|
|
|
if (m->run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
_preferred = sf.rows_array();
|
|
|
|
|
save_preferences();
|
2003-10-14 13:44:01 +00:00
|
|
|
|
update_preferred();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
delete m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TMenu_application::do_tree()
|
|
|
|
|
{
|
|
|
|
|
_menu.jumpto_root();
|
|
|
|
|
const TSubmenu& curr = _menu.current();
|
2003-03-11 11:09:18 +00:00
|
|
|
|
TPicture_mask mask(curr.caption(), 0, 0, curr, 0, 0);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
CHECK(_mask == NULL, "Two masks are better than one?");
|
|
|
|
|
_mask = &mask;
|
|
|
|
|
|
|
|
|
|
const int margin = (mask.columns()-80) / 2;
|
2004-05-17 15:39:53 +00:00
|
|
|
|
const int twidth = mask.columns() - 51;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
const int bwidth = (mask.columns() - twidth - 8);
|
|
|
|
|
|
|
|
|
|
TMenu_tree tree(_menu);
|
|
|
|
|
TTree_field& tree_fld = mask.add_tree(DLG_TREE, 0, 0, 0, twidth, -1);
|
|
|
|
|
tree_fld.set_tree(&tree);
|
|
|
|
|
tree_fld.set_handler(tree_handler);
|
2004-05-13 15:12:14 +00:00
|
|
|
|
|
|
|
|
|
const int inizio = twidth - margin + 2;
|
|
|
|
|
const int ampiezza = mask.columns() - inizio - margin;
|
|
|
|
|
const int bottone = ampiezza / 3;
|
|
|
|
|
const int spazio = (ampiezza - 2 * bottone) / 3;
|
|
|
|
|
|
|
|
|
|
mask.add_static(DLG_NULL, 0, PR("Cerca"), inizio + 2, -4);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
2004-05-13 15:12:14 +00:00
|
|
|
|
TEdit_field& ef = mask.add_string(DLG_USER, 0, "", inizio + 2, -3, 50, "", ampiezza - 4);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
ef.set_handler(tree_find_handler);
|
|
|
|
|
|
2004-05-13 15:12:14 +00:00
|
|
|
|
TButton_field& mf = mask.add_button(201, 0, PR("Menu Principale"), inizio + spazio * 2 + bottone, -1, bottone, 2);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
mf.set_handler(tree_shrink_handler);
|
|
|
|
|
|
2004-05-13 15:12:14 +00:00
|
|
|
|
mask.add_button(DLG_QUIT, 0, PR("Fine"), inizio + spazio, -1, bottone, 2);
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
mask.first_focus(DLG_TREE);
|
|
|
|
|
KEY key = mask.run();
|
|
|
|
|
_mask = NULL;
|
|
|
|
|
|
|
|
|
|
return key == K_QUIT ? -2 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TMenu_application::do_explore()
|
|
|
|
|
{
|
|
|
|
|
CHECK(_mask == NULL, "Two masks are better than one?");
|
|
|
|
|
_menu.jumpto_root();
|
2004-04-23 08:59:58 +00:00
|
|
|
|
TExplorer_mask mask(_menu);
|
|
|
|
|
_mask = &mask;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
|
|
|
|
|
KEY key = mask.run();
|
|
|
|
|
_mask = NULL;
|
|
|
|
|
|
|
|
|
|
return key == K_QUIT ? -2 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-31 14:19:39 +00:00
|
|
|
|
int TMenu_application::do_outlook()
|
|
|
|
|
{
|
|
|
|
|
CHECK(_mask == NULL, "Two masks are better than one?");
|
|
|
|
|
TOutlook_mask mask(_menu);
|
|
|
|
|
_mask = &mask;
|
|
|
|
|
|
|
|
|
|
KEY key = mask.run();
|
2008-10-02 16:03:09 +00:00
|
|
|
|
|
2008-01-31 14:19:39 +00:00
|
|
|
|
_mask = NULL;
|
|
|
|
|
|
|
|
|
|
return key == K_QUIT ? -2 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-29 14:34:21 +00:00
|
|
|
|
bool TMenu_application::firm_change_enabled() const
|
|
|
|
|
{
|
|
|
|
|
return _mask != NULL; // Impedisci il cambio ditta durante il login
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-20 13:12:34 +00:00
|
|
|
|
void TMenu_application::on_firm_change()
|
|
|
|
|
{
|
|
|
|
|
TConfig cfgs(CONFIG_STUDIO, "Main"); // Forza creazione STUDIO.INI copiandolo eventulamente da PRASSIS.INI
|
|
|
|
|
TConfig cfgd(CONFIG_DITTA, "ba"); // Forza creazione DITTA.INI copiandolo eventulamente da PRASSID.INI
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-28 14:27:05 +00:00
|
|
|
|
bool TMenu_application::menu(MENU_TAG mt)
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
bool ok = true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
switch (mt)
|
|
|
|
|
{
|
2005-09-23 16:07:40 +00:00
|
|
|
|
case BAR_ITEM(1): main_loop(); ok = false; break;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
case MENU_ITEM(2): choose_colors(); break;
|
|
|
|
|
case MENU_ITEM(3): choose_editors(); break;
|
|
|
|
|
case MENU_ITEM(4): choose_study(); break;
|
|
|
|
|
case MENU_ITEM(5): add_to_preferred(); break;
|
|
|
|
|
case MENU_ITEM(6): manage_preferred(); break;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
case MENU_ITEM(7):
|
|
|
|
|
if (check_user())
|
|
|
|
|
_mask->stop_run(K_CTRL + 'R'); // Ricarica maschera
|
|
|
|
|
break;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
default:
|
|
|
|
|
if (mt >= MENU_ITEM(50) && mt < MENU_ITEM(50+_preferred.items()))
|
|
|
|
|
{
|
2005-09-23 16:07:40 +00:00
|
|
|
|
bool ok = false;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
const int index = mt - MENU_ITEM(50);
|
|
|
|
|
TToken_string node(_preferred.row(index).get(1), '/');
|
|
|
|
|
if (_tree_view != 0)
|
|
|
|
|
{
|
2008-10-24 15:41:41 +00:00
|
|
|
|
TMenu_tree& met = *(TMenu_tree*)tree_field().tree();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
ok = node.items() == 1 ? met.find_leaf(node) : met.goto_node(node);
|
|
|
|
|
if (ok)
|
2008-10-24 15:41:41 +00:00
|
|
|
|
{
|
2003-01-28 14:27:05 +00:00
|
|
|
|
select_tree_current();
|
2008-10-24 15:41:41 +00:00
|
|
|
|
if (met.curr_item().is_program())
|
|
|
|
|
tree_field().on_key(K_CTRL+K_SPACE); // Esegue subito il programma
|
|
|
|
|
}
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TToken_string mi(node.get(-2), '.');
|
|
|
|
|
const char* sub = mi.get(0);
|
|
|
|
|
TSubmenu* sm = _menu.find(sub);
|
|
|
|
|
if (sm && _menu.jumpto(sm))
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
ok = true;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
_menu.select(mi.get_int());
|
|
|
|
|
_mask->stop_run(K_CTRL + 'R');
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-10-24 15:41:41 +00:00
|
|
|
|
if (!ok)
|
|
|
|
|
beep();
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ba0100(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
TApplication::check_parameters(argc, argv);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
|
|
|
|
TString& u = user();
|
|
|
|
|
if (u.blank())
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
2006-07-11 13:10:51 +00:00
|
|
|
|
TConfig campo_ini(CONFIG_INSTALL, "Main");
|
|
|
|
|
const bool su = campo_ini.get_bool("AutoLogin");
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (su) // usa utente di windows
|
2006-07-11 13:10:51 +00:00
|
|
|
|
{
|
|
|
|
|
xvt_sys_get_user_name(u.get_buffer(), u.size()+1);
|
|
|
|
|
u.upper();
|
2007-04-03 11:06:56 +00:00
|
|
|
|
if (u.compare("Administrator", -1, true) == 0) // Converti amministratore
|
2006-07-11 13:10:51 +00:00
|
|
|
|
u = dongle().administrator();
|
|
|
|
|
}
|
|
|
|
|
if (u.blank())
|
|
|
|
|
u = campo_ini.get("User"); // Ultimo utente usato
|
|
|
|
|
if (u.blank())
|
|
|
|
|
u = dongle().administrator(); // Usa amministratore come extrema ratio
|
2003-01-28 14:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TFilename menu = (argc < 2) ? MEN_FILE : argv[1];
|
|
|
|
|
|
2005-03-17 18:21:37 +00:00
|
|
|
|
if (menu.custom_path())
|
2003-01-28 14:27:05 +00:00
|
|
|
|
{
|
|
|
|
|
TMenu_application *ma = new TMenu_application(menu);
|
|
|
|
|
ma->run(argc, argv, TR("Menu Principale"));
|
|
|
|
|
delete ma;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
error_box(FR("Non esiste il menu %s"), (const char*)menu);
|
|
|
|
|
|
|
|
|
|
return 0;
|
2007-04-03 11:06:56 +00:00
|
|
|
|
}
|