Patch level : 10.0

Files correlati     : ba0 ba1
Ricompilazione Demo : [ ]
Commento            :
Aggiunto supporto per nuovo stile di menu:
un applauso per il nuovo Outlook Fashion Style!


git-svn-id: svn://10.65.10.50/trunk@16067 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-01-31 14:19:39 +00:00
parent 566d5e5efc
commit 7be186e709
12 changed files with 664 additions and 369 deletions

View File

@ -10,7 +10,6 @@
#include <relation.h>
#include <msksheet.h>
#include <progind.h>
#include <sheet.h>
#include <utility.h>
#include <urldefid.h>
@ -21,6 +20,7 @@
#include "ba0.h"
#include "ba0101.h"
#include "ba0102.h"
#include "ba0103.h"
#include "ba0100.h"
#include "ba0100a.h"
@ -65,6 +65,7 @@ protected:
int do_level();
int do_tree();
int do_explore();
int do_outlook();
bool check_user();
@ -279,273 +280,6 @@ TPicture_mask::~TPicture_mask()
delete _logo;
}
///////////////////////////////////////////////////////////
// Explorer Mask
///////////////////////////////////////////////////////////
class TExplorer_mask : public TMask
{
TMenu_tree _tree;
bool _spider;
protected:
virtual bool stop_run(KEY k);
virtual bool on_key(KEY k);
virtual void on_idle();
virtual void on_firm_change();
virtual void update();
virtual void handler(WINDOW win, EVENT* ep);
void draw_spider(int mode, const PNT& mouse) const;
static bool explore_handler(TMask_field& f, KEY k);
public:
TExplorer_mask(TMenu& menu);
~TExplorer_mask();
};
void TExplorer_mask::handler(WINDOW win, EVENT* ep)
{
if (ep->type == E_MOUSE_MOVE && _spider)
draw_spider(0x3, ep->v.mouse.where);
TMask::handler(win, ep);
}
void TExplorer_mask::on_firm_change()
{
force_update();
}
bool TExplorer_mask::stop_run(KEY k)
{
if (k == K_CTRL+'R')
return TWindow::stop_run(k);
if (k == K_QUIT)
{
if (ADVANCED_GRAPHICS)
{
const int divider = 8;
WINDOW window[3] = {
win(),
((TWindowed_field&)field(DLG_TREE)).win().win(),
((TWindowed_field&)field(DLG_LIST)).win().win()
};
XVT_IMAGE image[3];
int i;
for (i = 0; i < 3; i++)
{
WINDOW& w = window[i];
RCT rct; xvt_vobj_get_client_rect(w, &rct);
RCT irct = rct; irct.right /= divider; irct.bottom /= divider;
XVT_IMAGE cap = xvt_image_capture(w, &rct);
XVT_IMAGE img = xvt_image_create(XVT_IMAGE_RGB, irct.right, irct.bottom, 0);
xvt_image_transfer(img, cap, &irct, &rct);
xvt_image_destroy(cap);
for (int y = 0; y < irct.bottom; y++)
{
for (int x = 0; x < irct.right; x++)
{
COLOR rgb = xvt_image_get_pixel(img, x, y);
const unsigned int r = XVT_COLOR_GET_RED(rgb) / 2;
const unsigned int g = XVT_COLOR_GET_GREEN(rgb) / 2;
const unsigned int b = XVT_COLOR_GET_BLUE(rgb) / 2;
xvt_image_set_pixel(img, x, y, MAKE_COLOR(r, g, b));
}
}
image[i] = img;
}
for (i = 2; i >= 0; i--)
{
RCT rct; xvt_vobj_get_client_rect(window[i], &rct);
RCT irct = rct; irct.right /= divider; irct.bottom /= divider;
xvt_dwin_draw_image(window[i], image[i], &rct, &irct);
}
// Butto via le immagini dopo averle disegnate tutte
for (i = 2; i >= 0; i--)
xvt_image_destroy(image[i]);
if (installing()) //se e' stata lanciata la installazione moduli...
{
xvt_sys_sleep(1); //..aspetta un attimo poi forza l'uscita
}
else
{
if (!yesno_box(TR("Si desidera uscire?"))) //..altrimenti chiede educatamente se si desidera uscire
{
for (i = 0; i < 3; i++)
xvt_dwin_invalidate_rect(window[i], NULL);
return false;
}
}
}
}
return TMask::stop_run(k);
}
void TExplorer_mask::on_idle()
{
if (ADVANCED_GRAPHICS)
{
TWindowed_field& lf = (TWindowed_field&)field(DLG_LIST);
lf.win().on_idle();
}
}
void TExplorer_mask::draw_spider(int mode, const PNT& mouse) const
{
WINDOW w = win();
RCT client; xvt_vobj_get_client_rect(w, &client);
const PNT p0 = { client.bottom-20, client.right-60 }; // Centro del ragno
if (mode & 0x1)
{
// Disegno il filo
const PNT p1 = { p0.v-300, p0.h };
xvt_dwin_set_std_cpen(w, TL_PEN_LTGRAY);
xvt_dwin_draw_set_pos(w, p0); xvt_dwin_draw_line(w, p1);
// Disegno il corpicino
xvt_dwin_set_std_cpen(w, TL_PEN_BLACK);
xvt_dwin_set_std_cbrush(w, TL_BRUSH_BLACK);
RCT rct; xvt_rect_set(&rct, p0.h-20, p0.v-10, p0.h+20, p0.v+10);
xvt_dwin_draw_oval(w, &rct);
// Disegno le 4 paia di zampette
const int leg = 20;
const int foot = 10;
for (int i = 0; i < 4; i++)
{
PNT p[8];
p[0].h = rct.left-leg-3*i; p[0].v = rct.bottom-3*i; // Zampa sinistra
p[1].h = p[0].h+foot; p[1].v = p[0].v;
p[2].h = p[0].h; p[2].v = p[0].v-leg-3*i;
p[3] = p0; // Centro del corpo
p[4].h = 2*p0.h-p[2].h; p[4].v = p[2].v; // Zampa destra simmetrica
p[5].h = 2*p0.h-p[1].h; p[5].v = p[1].v;
p[6].h = 2*p0.h-p[0].h; p[6].v = p[0].v;
xvt_dwin_draw_polyline(w, p, 7);
}
}
if (mode & 0x2)
{
const int eye = 7;
const int pupil = 3;
RCT rct; // rettangolo jolly
// Disegno gli occhietti
xvt_dwin_set_std_cpen(w, TL_PEN_BLACK);
for (int i = 0; i < 2; i++)
{
// Calcolo il centro dell'occhietto
const PNT p1 = { p0.v-eye, i == 0 ? p0.h-(5*eye/4) : p0.h+(5*eye/4) };
// Disegno il bulbo
xvt_rect_set(&rct, p1.h-eye, p1.v-eye, p1.h+eye, p1.v+eye);
xvt_dwin_set_std_cbrush(w, TL_BRUSH_WHITE);
xvt_dwin_draw_oval(w, &rct);
// Disegno la pupilla
const int dx = mouse.h <= rct.left ? -pupil : (mouse.h >= rct.right ? +pupil : 0);
const int dy = mouse.v <= rct.top ? -pupil : (mouse.v >= rct.bottom ? +pupil : 0);
xvt_rect_set(&rct, p1.h-pupil+dx, p1.v-pupil+dy, p1.h+pupil+dx, p1.v+pupil+dy);
xvt_dwin_set_std_cbrush(w, TL_BRUSH_BLACK);
xvt_dwin_draw_oval(w, &rct);
}
// Disegno la boccuccia aperta se il mouse e' vicino
const int dx = mouse.h-p0.h, dy = mouse.v-p0.v;
const bool vicino = dx*dx+dy*dy < 65536;
xvt_dwin_set_std_cbrush(w, vicino ? TL_BRUSH_WHITE : TL_BRUSH_BLACK);
xvt_rect_set(&rct, p0.h-eye, p0.v, p0.h+eye, p0.v+eye);
xvt_dwin_draw_oval(w, &rct);
// Il puntatore del mouse diventa una mosca vicino al ragno
xvt_win_set_cursor(w, vicino ? 8883 : CURSOR_ARROW);
}
}
void TExplorer_mask::update()
{
TMask::update();
WINDOW w = win();
RCT client; xvt_vobj_get_client_rect(w, &client);
const TString& ragsoc = prefix().firm().ragione_sociale();
const int len = xvt_dwin_get_text_width(w, ragsoc, -1);
xvt_dwin_draw_text(w, (client.right-len)/2, CHARY, ragsoc, -1);
if (_spider)
{
const PNT pnt = { 0, 0 };
draw_spider(0x3, pnt);
}
}
bool TExplorer_mask::on_key(KEY k)
{
if (k == K_F3 || k == K_F8)
{
set(DLG_USER, app().main_menu().last_search_string(), true);
return true;
}
if (k == K_FORCE_CLOSE || k == K_QUIT)
return stop_run(k);
return TMask::on_key(k);
}
bool TExplorer_mask::explore_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();
if (mi.perform() && mt.goto_firstson())
{
TMenulist_field& mf = (TMenulist_field&)f.mask().field(DLG_LIST);
mf.set_menu(mt);
}
}
return true;
}
TExplorer_mask::TExplorer_mask(TMenu& menu)
: TMask ("", 1, 0, 0, 0, 0), _tree(menu)
{
_spider = ADVANCED_GRAPHICS && is_power_station();
const int margin = (columns()-80) / 2;
const int tree_width = margin+21; // Usa la metà di sinistra
TTree_field& tree_fld = add_tree(DLG_TREE, 0, 0, 0, tree_width, -5);
tree_fld.set_tree(&_tree);
tree_fld.set_handler(explore_handler);
tree_fld.hide_leaves(true);
TMenulist_field* mf = new TMenulist_field(this);
mf->create(DLG_LIST, tree_width-margin+3, 0, -3, -5);
mf->set_menu(_tree);
add_field(mf);
TEdit_field& ef = add_string(DLG_USER, 0, PR("Cerca "), 11, -4, 50);
ef.set_handler(app().tree_find_handler);
add_button(DLG_QUIT, 0, "", -12, -2, 18, 2);
TButton_field& mp = add_button(201, 0, PR("Menu Principale"), -22, -2, 18, 2);
mp.set_handler(app().tree_shrink_handler);
first_focus(DLG_LIST);
}
TExplorer_mask::~TExplorer_mask()
{
}
///////////////////////////////////////////////////////////
// Color Mask
///////////////////////////////////////////////////////////
@ -1436,9 +1170,10 @@ void TMenu_application::main_loop()
int m = 0;
switch (_tree_view)
{
case 1: m = do_tree(); break;
case 1: m = do_tree(); break;
case 2: m = do_explore(); break;
default: m = do_level(); break;
case 3: m = do_outlook(); break;
default: m = do_level(); break;
}
if (m > 0)
_menu.perform();
@ -1705,20 +1440,8 @@ bool TMenu_application::tree_handler(TMask_field& f, KEY k)
void TMenu_application::select_tree_current()
{
TTree_field& tf = _mask->tfield(DLG_TREE);
if (_tree_view == 2)
{
TMenulist_field& mf = (TMenulist_field&)tf.mask().field(DLG_LIST);
TMenu_tree& mt = (TMenu_tree&)*tf.tree();
mf.set_menu(mt);
synchronize_tree_field(tf);
mf.set_focus();
}
else
{
synchronize_tree_field(tf);
tf.set_focus();
}
synchronize_tree_field(tf);
tf.set_focus();
}
bool TMenu_application::tree_find_handler(TMask_field&f, KEY k)
@ -1726,10 +1449,7 @@ bool TMenu_application::tree_find_handler(TMask_field&f, KEY k)
if (k == K_TAB && f.focusdirty() && !f.empty())
{
const TString& v = f.get();
TPicture_mask& m = (TPicture_mask&)f.mask();
TTree_field& tf = (TTree_field&)m.field(DLG_TREE);
TTree_field& tf = f.mask().tfield(DLG_TREE);
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
if (mt.find_string(v))
app().select_tree_current();
@ -2060,6 +1780,18 @@ int TMenu_application::do_explore()
return key == K_QUIT ? -2 : 0;
}
int TMenu_application::do_outlook()
{
CHECK(_mask == NULL, "Two masks are better than one?");
TOutlook_mask mask(_menu);
_mask = &mask;
KEY key = mask.run();
_mask = NULL;
return key == K_QUIT ? -2 : 0;
}
void TMenu_application::on_firm_change()
{
TConfig cfgs(CONFIG_STUDIO, "Main"); // Forza creazione STUDIO.INI copiandolo eventulamente da PRASSIS.INI

View File

@ -1,6 +1,5 @@
#include <applicat.h>
#include <dongle.h>
#include <execp.h>
#include <mask.h>
#include <modaut.h>
#include <nditte.h>
@ -9,22 +8,13 @@
#include <utility.h>
#include "ba0100a.h"
#include "ba0101.h"
#include "ba0103.h"
#include "ba0100.h"
///////////////////////////////////////////////////////////
// Utility
///////////////////////////////////////////////////////////
bool sys_dll_changed()
{
TString_array list;
int k = list_files("*.dl_", list);
if (k == 0)
k = list_files("*.ex_", list);
return k > 0;
}
static bool _installing = false;
void set_installing_flag()
@ -284,10 +274,12 @@ bool TMenuitem::perform_program() const
if (mask.run() == K_ENTER)
{
const TDate oggi(TODAY);
TString16 pwd; pwd << dongle().administrator() << (oggi.month() + oggi.day());
TString pwd;
pwd << dongle().administrator() << (oggi.month() + oggi.day());
ok = pwd == mask.get(F_PASSWORD);
}
if (!ok) error_box("Password di servizio errata!\nAccesso negato.");
if (!ok)
error_box("Password di servizio errata!\nAccesso negato.");
}
if (_firm && main_app().get_firm() == 0)
@ -311,7 +303,12 @@ bool TMenuitem::perform_program() const
set_installing_flag();
}
else
a.run(false,3); //e' un programma normale->sincrono
{
if (submenu().menu().mask_mode() == 3)
a.run(true, 3, false); //e' un programma asincrono
else
a.run(false, 3); //e' un programma sincrono
}
prefix().set("DEF"); // Aggiorna prefix
@ -643,30 +640,15 @@ bool TMenu::perform()
return ok;
}
//setta la trasparenza alle immagini con i 4 corner-pixel di colore uguale
bool TMenu::can_be_transparent(const TImage& i) const
{
const int w = i.width()-1;
const int h = i.height()-1;
const COLOR col = i.get_pixel(0,0);
if (i.get_pixel(w,0) != col)
return false;
if (i.get_pixel(w,h) != col)
return false;
if (i.get_pixel(0,h) != col)
return false;
return true;
}
TImage& TMenu::image(const char* name)
{
TTimed_image* img = (TTimed_image*)_images.objptr(name);
if (img == NULL)
{
TFilename realname;
const char* ext[4] = { "jpg", "gif", "bmp", "png" };
const char* ext[] = { "jpg", "gif", "bmp", "png", NULL };
bool bFound = false;
for (int i = 0; i < 4 && !bFound; i++)
for (int i = 0; ext[i] && !bFound; i++)
{
realname = name;
realname.ext(ext[i]);
@ -726,13 +708,12 @@ bool TMenu::has_module(const char* mod)
bool TMenu::is_dangerous(const char* mod)
{
TString code(mod);
code.cut(2);
const char code[4] = { mod[0], mod[1], '\0', '\0' };
return _dangerous.get_pos(code) >= 0;
}
TMenu::TMenu() : _current(NULL), _item(0)
TMenu::TMenu() : _current(NULL), _item(0), _mask_mode(0)
{ }
TMenu::~TMenu()
{ }
{ }

View File

@ -121,10 +121,8 @@ class TMenu : public TAssoc_array
TString _last_search;
TAssoc_array _ignore_list;
int _mask_mode;
protected:
bool can_be_transparent(const TImage& i) const;
public: // TObject
virtual bool ok() const { return _current != NULL; }
@ -159,13 +157,14 @@ public:
void set_dangerous_modules(const TToken_string& mod)
{ _dangerous = mod; }
void set_mask_mode(int mm) { _mask_mode = mm; }
int mask_mode() const { return _mask_mode; }
TMenu();
virtual ~TMenu();
};
bool sys_dll_changed();
void set_installing_flag();
bool installing();

View File

@ -1,7 +1,10 @@
#include <controls.h>
#include <diction.h>
#include <mask.h>
#include <prefix.h>
#include <statbar.h>
#include <urldefid.h>
#include <utility.h>
#include "ba0102.h"
@ -167,16 +170,18 @@ bool TMenu_tree::goto_rbrother()
bool TMenu_tree::goto_node(const TString &id)
{
const int dot = id.rfind('.');
CHECKS(dot > 0, "Invalid tree node ", (const char*)id);
_menuitem = atoi(id.mid(dot+1));
_curr_id = id.left(dot);
const int slash = _curr_id.rfind('/');
_curr_id = _curr_id.mid(slash+1);
_submenu = _menu->find(_curr_id);
_curr_id = id;
if (_curr_id != id)
{
const int dot = id.rfind('.');
CHECKS(dot > 0, "Invalid tree node ", (const char*)id);
_menuitem = atoi(id.mid(dot+1));
_curr_id = id.left(dot);
const int slash = _curr_id.rfind('/');
_curr_id = _curr_id.mid(slash+1);
_submenu = _menu->find(_curr_id);
_curr_id = id;
}
return _submenu != NULL;
}
@ -283,7 +288,6 @@ void synchronize_tree_field(TTree_field& tf)
mt.goto_node(id); // Torna al nodo corrente
tf.win().force_update(); // Provoca la rigenerazione dell'albero espanso come sopra
tf.select_current(); // Riporta la selezione a posto
}
bool can_be_transparent(const TImage& i)
@ -301,7 +305,7 @@ bool can_be_transparent(const TImage& i)
}
///////////////////////////////////////////////////////////
// TMenulist_field
// TMenulist_images
///////////////////////////////////////////////////////////
class TMenulist_images : public TCache
@ -332,6 +336,9 @@ inline int fast_hypot(int x, int y)
void TMenulist_images::set_owner_info(WINDOW win, int max_side)
{
if (max_side != _max_side)
destroy();
_win = win;
_max_side = max_side;
}
@ -341,8 +348,8 @@ TObject* TMenulist_images::key2obj(const char* key)
TImage* img = NULL;
TFilename name;
const char* ext[3] = { "jpg", "gif", "bmp" };
for (int i = 0; i < 3; i++)
const char* ext[] = { "jpg", "gif", "bmp", "png", NULL };
for (int i = 0; ext[i] != NULL; i++)
{
name = key;
name << '.' << ext[i];
@ -418,6 +425,10 @@ TImage* TMenulist_images::image(const char* name)
return (TImage*)obj;
}
///////////////////////////////////////////////////////////
// TMenulist_field
///////////////////////////////////////////////////////////
class TMenulist_window : public TField_window
{
private:
@ -650,9 +661,7 @@ void TMenulist_window::click_on(int index)
if (ti.action() == mi.action())
{
_tree->goto_firstson();
TString cazzo1; _tree->curr_id(cazzo1);
set_menu(*_tree);
TString cazzo2; _tree->curr_id(cazzo2);
synchronize_buddy_tree();
break;
}
@ -711,6 +720,21 @@ void TMenulist_window::handler(WINDOW w, EVENT* ep)
xvt_vobj_translate_points(w, parent(), &e.v.mouse.where, 1);
xvt_win_dispatch_event(parent(), &e);
}
break;
case E_SIZE:
{
const int h = ep->v.size.height; // Client height
const int w = ep->v.size.width; // Client width
const size_t rh = 32 + 3 * CHARY; // Row height
MENU_ROWS = max(1, h / rh);
const size_t cw = 16*CHARX; // Column width
MENU_COLS = max(1, w / cw);
const int ms = h - 3 * rh; // Max. image size
_images.set_owner_info(win(), ms);
}
break;
default:
break;
@ -865,40 +889,26 @@ void TMenulist_window::set_menu(TMenu_tree& tree)
if (sm.enabled() && sm.action() == sel_act)
break;
}
_image_name = mnu.picture();
force_update();
}
TMenulist_window::TMenulist_window(int x, int y, int dx, int dy, WINDOW parent, TMenulist_field* owner)
: TField_window(x, y, dx, dy, parent, owner), _tree(NULL), MENU_COLS(4), MENU_ROWS(5)
{
set_scroll_max(0, 0); // Get rid of that useless scrollbars
RCT rct; xvt_vobj_get_client_rect(win(), &rct);
const size_t rh = 32 + 3 * CHARY;
const size_t mr = rct.bottom / rh;
if (mr > MENU_ROWS)
MENU_ROWS = mr;
int ms = rct.bottom - 3 * rh;
_images.set_owner_info(win(), ms);
{
set_scroll_max(0, 0); // Get rid of that useless scrollbars
}
TMenulist_window::~TMenulist_window()
{
}
{ }
TField_window* TMenulist_field::create_window(int x, int y, int dx, int dy, WINDOW parent)
{
return new TMenulist_window(x, y, dx, dy, parent, this);
}
{ return new TMenulist_window(x, y, dx, dy, parent, this); }
void TMenulist_field::create(short dlg, int x, int y, int dx, int dy)
void TMenulist_field::create(short dlg, int x, int y, int dx, int dy, WINDOW parent)
{
_dlg = dlg;
_win = create_window(x, y, dx, dy, mask().win());
_win = create_window(x, y, dx, dy, parent);
}
void TMenulist_field::set_menu(TMenu_tree& mt)
@ -912,3 +922,324 @@ void TMenulist_field::curr_item(TToken_string& id) const
TMenulist_window& w = (TMenulist_window&)win();
w.curr_item(id);
}
///////////////////////////////////////////////////////////
// TSpidey_mask
///////////////////////////////////////////////////////////
void draw_spider(WINDOW w, int mode, const PNT& mouse)
{
static int _spider = -1;
if (_spider < 0)
_spider = ADVANCED_GRAPHICS && is_power_station(); // Attiva eventuale ragno
if (_spider && w != NULL_WIN)
{
RCT client; xvt_vobj_get_client_rect(w, &client);
if (client.right > 128 && client.bottom > 64)
{
const PNT p0 = { client.top+64, client.right-64 }; // Centro del ragno
if (mode & 0x1)
{
// Disegno il filo
const PNT p1 = { client.top, p0.h };
xvt_dwin_set_std_cpen(w, TL_PEN_LTGRAY);
xvt_dwin_draw_set_pos(w, p0); xvt_dwin_draw_line(w, p1);
// Disegno il corpicino
xvt_dwin_set_std_cpen(w, TL_PEN_BLACK);
xvt_dwin_set_std_cbrush(w, TL_BRUSH_BLACK);
RCT rct; xvt_rect_set(&rct, p0.h-20, p0.v-10, p0.h+20, p0.v+10);
xvt_dwin_draw_oval(w, &rct);
// Disegno le 4 paia di zampette
const int leg = 20;
const int foot = 10;
for (int i = 0; i < 4; i++)
{
PNT p[8];
p[0].h = rct.left-leg-3*i; p[0].v = rct.bottom-3*i; // Zampa sinistra
p[1].h = p[0].h+foot; p[1].v = p[0].v;
p[2].h = p[0].h; p[2].v = p[0].v-leg-3*i;
p[3] = p0; // Centro del corpo
p[4].h = 2*p0.h-p[2].h; p[4].v = p[2].v; // Zampa destra simmetrica
p[5].h = 2*p0.h-p[1].h; p[5].v = p[1].v;
p[6].h = 2*p0.h-p[0].h; p[6].v = p[0].v;
xvt_dwin_draw_polyline(w, p, 7);
}
}
if (mode & 0x2)
{
const int eye = 7;
const int pupil = 3;
RCT rct; // rettangolo jolly
// Disegno gli occhietti
xvt_dwin_set_std_cpen(w, TL_PEN_BLACK);
for (int i = 0; i < 2; i++)
{
// Calcolo il centro dell'occhietto
const PNT p1 = { p0.v-eye, i == 0 ? p0.h-(5*eye/4) : p0.h+(5*eye/4) };
// Disegno il bulbo
xvt_rect_set(&rct, p1.h-eye, p1.v-eye, p1.h+eye, p1.v+eye);
xvt_dwin_set_std_cbrush(w, TL_BRUSH_WHITE);
xvt_dwin_draw_oval(w, &rct);
// Disegno la pupilla
const int dx = mouse.h <= rct.left ? -pupil : (mouse.h >= rct.right ? +pupil : 0);
const int dy = mouse.v <= rct.top ? -pupil : (mouse.v >= rct.bottom ? +pupil : 0);
xvt_rect_set(&rct, p1.h-pupil+dx, p1.v-pupil+dy, p1.h+pupil+dx, p1.v+pupil+dy);
xvt_dwin_set_std_cbrush(w, TL_BRUSH_BLACK);
xvt_dwin_draw_oval(w, &rct);
}
// Disegno la boccuccia aperta se il mouse e' vicino
const int dx = mouse.h-p0.h, dy = mouse.v-p0.v;
const bool vicino = dx*dx+dy*dy < 65536;
xvt_dwin_set_std_cbrush(w, vicino ? TL_BRUSH_WHITE : TL_BRUSH_BLACK);
xvt_rect_set(&rct, p0.h-eye, p0.v, p0.h+eye, p0.v+eye);
xvt_dwin_draw_oval(w, &rct);
// Il puntatore del mouse diventa una mosca vicino al ragno
xvt_win_set_cursor(w, vicino ? 8883 : CURSOR_ARROW);
}
}
}
}
void TSpidey_mask::on_firm_change()
{
force_update();
}
WINDOW TSpidey_mask::dlg2win(short id) const
{
WINDOW w = NULL_WIN;
const int pos = id2pos(id);
if (pos >= 0)
{
TMask_field& f = fld(pos);
CHECKD(f.is_kind_of(CLASS_WINDOWED_FIELD), "Not a windowed field ", id);
w = ((TWindowed_field&)f).win().win();
}
return w;
}
bool TSpidey_mask::stop_run(KEY k)
{
if (k == K_CTRL+'R')
return TWindow::stop_run(k);
if (k == K_QUIT)
{
if (ADVANCED_GRAPHICS)
{
const int divider = 8;
const WINDOW window[4] = { win(), dlg2win(101),
dlg2win(102), dlg2win(103) };
XVT_IMAGE image[4]; memset(image, 0, sizeof(image));
int i;
for (i = 0; i < 4; i++)
{
const WINDOW& w = window[i];
if (w != NULL_WIN)
{
RCT rct; xvt_vobj_get_client_rect(w, &rct);
RCT irct = rct; irct.right /= divider; irct.bottom /= divider;
XVT_IMAGE cap = xvt_image_capture(w, &rct);
XVT_IMAGE img = xvt_image_create(XVT_IMAGE_RGB, irct.right, irct.bottom, 0);
xvt_image_transfer(img, cap, &irct, &rct);
xvt_image_destroy(cap);
for (int y = 0; y < irct.bottom; y++)
{
for (int x = 0; x < irct.right; x++)
{
COLOR rgb = xvt_image_get_pixel(img, x, y);
const unsigned int r = XVT_COLOR_GET_RED(rgb) / 2;
const unsigned int g = XVT_COLOR_GET_GREEN(rgb) / 2;
const unsigned int b = XVT_COLOR_GET_BLUE(rgb) / 2;
xvt_image_set_pixel(img, x, y, MAKE_COLOR(r, g, b));
}
}
image[i] = img;
}
}
for (i = 3; i >= 0; i--) if (image[i] != NULL)
{
const WINDOW& w = window[i];
if (w != NULL_WIN)
{
RCT rct; xvt_vobj_get_client_rect(w, &rct);
RCT irct = rct; irct.right /= divider; irct.bottom /= divider;
xvt_dwin_draw_image(w, image[i], &rct, &irct);
}
}
// Butto via le immagini dopo averle disegnate tutte
for (i = 2; i >= 0; i--)
xvt_image_destroy(image[i]);
if (installing()) //se e' stata lanciata la installazione moduli...
{
xvt_sys_sleep(1); //..aspetta un attimo poi forza l'uscita
}
else
{
if (!yesno_box(TR("Si desidera uscire?"))) //..altrimenti chiede educatamente se si desidera uscire
{
for (i = 0; i < 3; i++)
xvt_dwin_invalidate_rect(window[i], NULL);
return false;
}
}
}
}
return TMask::stop_run(k);
}
bool TSpidey_mask::on_key(KEY k)
{
if (k == K_FORCE_CLOSE || k == K_QUIT)
return stop_run(k);
return TMask::on_key(k);
}
TSpidey_mask::TSpidey_mask() : TAutomask ("", 1, 0, 0, 0, 0)
{ }
///////////////////////////////////////////////////////////
// TExplorer_mask
///////////////////////////////////////////////////////////
#define DLG_TREE 301
#define DLG_LIST 302
#define DLG_LOOK 303
void TExplorer_mask::update()
{
TMask::update();
if (ADVANCED_GRAPHICS)
{
WINDOW w = toolwin();
RCT client; xvt_vobj_get_client_rect(w, &client);
const TString& ragsoc = prefix().firm().ragione_sociale();
const int len = xvt_dwin_get_text_width(w, ragsoc, -1);
xvt_dwin_draw_text(w, (client.right-len)/2, client.bottom-2, ragsoc, -1);
const PNT pnt = { 0, 0 };
draw_spider(w, 0x3, pnt);
}
}
void TExplorer_mask::handler(WINDOW win, EVENT* ep)
{
if (ep->type == E_MOUSE_MOVE)
draw_spider(toolwin(), 0x3, ep->v.mouse.where);
TSpidey_mask::handler(win, ep);
}
void TExplorer_mask::on_idle()
{
if (ADVANCED_GRAPHICS)
{
TWindowed_field& lf = (TWindowed_field&)field(DLG_LIST);
lf.win().on_idle();
}
}
void TExplorer_mask::select_tree_current()
{
TTree_field& tf = tfield(DLG_TREE);
TMenulist_field& mf = (TMenulist_field&)field(DLG_LIST);
TMenu_tree& mt = (TMenu_tree&)*tf.tree();
mf.set_menu(mt);
synchronize_tree_field(tf);
mf.set_focus();
}
bool TExplorer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch(o.dlg())
{
case DLG_TREE:
if (e == fe_modify)
{
TTree_field& tf = (TTree_field&)o;
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
const TMenuitem& mi = mt.curr_item();
if (mi.perform() && mt.goto_firstson())
{
TMenulist_field& mf = (TMenulist_field&)field(DLG_LIST);
mf.set_menu(mt);
}
}
break;
case DLG_SHRINK:
if (e == fe_button)
{
TTree_field& tf = tfield(DLG_TREE);
TTree& mt = *tf.tree();
mt.shrink_all();
mt.goto_root();
select_tree_current();
}
case DLG_USER:
if (e == fe_modify && !o.empty())
{
const TString& v = o.get();
TTree_field& tf = tfield(DLG_TREE);
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
if (mt.find_string(v))
{
select_tree_current();
_last_search_string = v;
}
else
beep();
}
break;
default:
break;
}
return true;
}
bool TExplorer_mask::on_key(KEY k)
{
if (k == K_F3 || k == K_F8)
{
set(DLG_USER, _last_search_string, true);
return true;
}
return TSpidey_mask::on_key(k);
}
TExplorer_mask::TExplorer_mask(TMenu& menu) : _tree(menu)
{
// Bottom Toolbar
insert_page("4", -1); // Crea toolbar di "4" righe
add_button(DLG_QUIT, -1, "", -12, -2, 18, 2);
add_button(DLG_SHRINK, -1, PR("Menu Principale"), -22, -2, 18, 2);
add_string(DLG_USER, -1, PR("Cerca "), 11, -4, 50);
// Tree view
TTree_field& trifola = add_tree(DLG_TREE, 0, 0, 0, 32, 0);
trifola.set_tree(&_tree);
trifola.hide_leaves(true); // Nascondo le foglie che vengono gestite dal TMenulist_field
// List view
TMenulist_field* mf = new TMenulist_field(this);
mf->create(DLG_LIST, 21, 0, 0, 0, win());
mf->set_menu(*(TMenu_tree*)trifola.tree());
add_field(mf);
xvt_win_add_pane(win(), dlg2win(DLG_LIST), "Main", 0, 0); // Main pane
xvt_win_add_pane(win(), dlg2win(DLG_TREE), "Menu", 1, 0); // Left pane
first_focus(DLG_LIST);
set_handlers();
}

View File

@ -1,8 +1,12 @@
#ifndef __BA0102_H
#define __BA0102_H
#ifndef __MASKFLD_H
#include <maskfld.h>
#ifndef __AUTOMASK_H
#include <automask.h>
#endif
#ifndef __TREECTRL_H
#include <treectrl.h>
#endif
#ifndef __TREE_H
@ -55,6 +59,28 @@ public:
virtual ~TMenu_tree() { }
};
///////////////////////////////////////////////////////////
// TSpidey_mask Intended for internal use only :-)
///////////////////////////////////////////////////////////
class TSpidey_mask : public TAutomask
{
protected: // TMask
virtual void on_firm_change();
virtual bool stop_run(KEY k);
virtual bool on_key(KEY k);
protected:
WINDOW dlg2win(short id) const;
public:
TSpidey_mask();
};
///////////////////////////////////////////////////////////
// TMenulist_field
///////////////////////////////////////////////////////////
class TMenulist_field : public TWindowed_field
{
protected: // TWindowed_field
@ -62,15 +88,40 @@ protected: // TWindowed_field
public:
void set_menu(TMenu_tree& mt);
void create(short dlg, int x, int y, int dx, int dy);
void create(short dlg, int x, int y, int dx, int dy, WINDOW parent);
void curr_item(TToken_string& id) const;
TMenulist_field(TMask* m) : TWindowed_field(m) { }
virtual ~TMenulist_field() { }
};
///////////////////////////////////////////////////////////
// TExplorer_mask
///////////////////////////////////////////////////////////
class TExplorer_mask : public TSpidey_mask
{
TMenu_tree _tree;
TString _last_search_string;
protected: // TMask
virtual void update();
virtual void handler(WINDOW win, EVENT* ep);
virtual void on_idle();
virtual bool on_key(KEY k);
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
protected:
virtual void select_tree_current();
enum { DLG_TREE = 101, DLG_LIST = 102, DLG_SHRINK = 201 };
public:
TExplorer_mask(TMenu& menu);
};
// Utilities
void synchronize_tree_field(TTree_field& tf);
bool can_be_transparent(const TImage& i);
void draw_spider(WINDOW win, int mode, const PNT& mouse);
#endif

169
ba/ba0103.cpp Executable file
View File

@ -0,0 +1,169 @@
#include "ba0103.h"
#include <defmask.h>
#include <xvtility.h>
///////////////////////////////////////////////////////////
// TCampo_window
///////////////////////////////////////////////////////////
class TCampo_window : public TField_window
{
protected:
virtual void update();
virtual void handler(WINDOW win, EVENT* ep);
public:
TCampo_window(int x, int y, int dx, int dy,
WINDOW parent, TWindowed_field* owner);
};
void TCampo_window::update()
{
TField_window::update();
RCT rctw; xvt_vobj_get_client_rect(win(), &rctw);
if (rctw.right >= 32)
{
TImage image("logo.gif");
RCT rcti = image.rect();
if (rcti.right > rctw.right)
{
const double ratio = double(rctw.right) / double(rcti.right);
rcti.right = int(rcti.right * ratio);
rcti.bottom = int(rcti.bottom * ratio);
}
xvt_rect_offset(&rcti, rctw.right - rcti.right, rctw.bottom - rcti.bottom);
image.draw(win(), rcti);
PNT pnt = { 0, 0 };
draw_spider(win(), 0x3, pnt);
}
}
void TCampo_window::handler(WINDOW win, EVENT* ep)
{
if (ep->type == E_MOUSE_MOVE)
draw_spider(win, 0x3, ep->v.mouse.where);
TField_window::handler(win, ep);
}
TCampo_window::TCampo_window(int x, int y, int dx, int dy,
WINDOW parent, TWindowed_field* owner)
: TField_window(x, y, dx, dy, parent, owner)
{
set_caption("__CAMPO_MENU__");
set_scroll_max(0, 0); // Get rid of that useless scrollbars
}
///////////////////////////////////////////////////////////
// TCampo_field
///////////////////////////////////////////////////////////
class TCampo_field : public TWindowed_field
{
protected:
virtual TField_window* create_window(int x, int y, int dx, int dy, WINDOW parent);
public:
void create(short dlg, int x, int y, int dx, int dy, WINDOW parent);
TCampo_field(TMask* m) : TWindowed_field(m) {}
};
TField_window* TCampo_field::create_window(int x, int y, int dx, int dy, WINDOW parent)
{
return new TCampo_window(x, y, dx, dy, parent, this);
}
void TCampo_field::create(short dlg, int x, int y, int dx, int dy, WINDOW parent)
{
_dlg = dlg;
_win = create_window(x, y, dx, dy, parent);
}
///////////////////////////////////////////////////////////
// TOutlook_mask
///////////////////////////////////////////////////////////
bool TOutlook_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
{
case DLG_TREE:
if (e == fe_modify)
{
const TMenuitem& mi = _tree.curr_item();
if (mi.enabled())
{
if (mi.is_submenu())
{
if (!_tree.expanded())
mi.perform();
}
else
{
mi.perform();
if (installing())
stop_run(K_FORCE_CLOSE);
}
}
}
break;
case DLG_LOOK:
if (e == fe_modify)
{
const int sel = atoi(o.get());
_tree.goto_root();
for (int i = 0; i < sel; i++)
_tree.goto_rbrother();
synchronize_tree_field(tfield(DLG_TREE));
}
break;
default: break;
}
return true;
}
TOutlook_mask::TOutlook_mask(TMenu& menu) : _tree(menu)
{
xvtil_statbar_destroy(); // Ammazza status bar inutile
RCT rct; xvt_vobj_get_client_rect(TASK_WIN, &rct);
xvt_vobj_move(win(), &rct); // Resiza la maschera in modo da occupare lo spazio liberato
menu.set_mask_mode(3); // Outlook mode
TTree_field& trifola = add_tree(DLG_TREE, 0, 0, 0, 28, 0);
trifola.set_tree(&_tree);
const int w = trifola.win().columns();
const int h = trifola.win().rows() / 2;
TOutlook_field* of = new TOutlook_field(this);
of->create(DLG_LOOK, 0, h, w, h, win());
add_field(of);
TCampo_field* cf = new TCampo_field(this);
cf->create(DLG_MAIN, w, 0, 0, 0, win());
add_field(cf);
TString caption;
for (bool ok = _tree.goto_root(); ok; ok = _tree.goto_rbrother())
{
_tree.get_description(caption);
const TMenuitem& mi = _tree.curr_item();
const int ico = mi.enabled() ? mi.icon() : 10203;
of->add_item(ico, caption, 0);
}
xvt_win_add_pane(win(), dlg2win(DLG_TREE), "Menu", 1, 0); // Left upper pane
xvt_win_add_pane(win(), dlg2win(DLG_LOOK), "Bar", 1, 0); // Left lower pane
xvt_win_add_pane(win(), dlg2win(DLG_MAIN), "Main", 0, 0); // Main pane
set_handlers();
}
TOutlook_mask::~TOutlook_mask()
{
// Ricostruisci status bar tornata utile
xvtil_create_statbar();
}

29
ba/ba0103.h Executable file
View File

@ -0,0 +1,29 @@
#ifndef __BA0103_H
#define __BA0103_H
#ifndef TMenu_tree
#include "ba0102.h"
#endif
#ifndef __EXECP_H
#include <execp.h>
#endif
///////////////////////////////////////////////////////////
// TOutlook_mask
///////////////////////////////////////////////////////////
class TOutlook_mask : public TSpidey_mask
{
TMenu_tree _tree;
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
enum { DLG_TREE = 101, DLG_LOOK = 102, DLG_MAIN = 103 };
public:
TOutlook_mask(TMenu& menu);
~TOutlook_mask();
};
#endif

View File

@ -8,6 +8,7 @@ BEGIN
ITEM " |Normale"
ITEM "1|Albero"
ITEM "2|Explorer"
ITEM "3|Outlook"
END
SPREADSHEET F_PREF_SHEET 63 -3

View File

@ -5,6 +5,7 @@
#include <relapp.h>
#include <utility.h>
#include <tree.h>
#include <treectrl.h>
#include <urldefid.h>
#include "ba1.h"

View File

@ -1608,7 +1608,7 @@ bool TCreadischi_mask::import_export_handler(TMask_field& f, KEY k)
fm.build_export_path(path);
FILE_SPEC fs;
xvt_fsys_convert_str_to_dir(path.get_buffer(), &fs.dir);
xvt_fsys_convert_str_to_dir(path, &fs.dir);
path.add(module); path << "inst.ini"; path.lower();
strcpy(fs.type, "ini");
strcpy(fs.name, path.name());

View File

@ -9,7 +9,7 @@
#include <prefix.h>
#include <relation.h>
#include <sheet.h>
#include <tree.h>
#include <treectrl.h>
#include <utility.h>
#include <xml.h>

View File

@ -10,6 +10,7 @@
#include <prefix.h>
#include <printer.h>
#include <reprint.h>
#include <treectrl.h>
#include <utility.h>
#include "ba8300.h"