campo-sirio/ba/ba0103.cpp
guy ab7990b69e Patch level : 10.0
Files correlati     : ba0
Ricompilazione Demo : [ ]
Commento            :
Aggiunta gestione sotto/processi


git-svn-id: svn://10.65.10.50/trunk@16084 c028cbd2-c16b-5b4b-a496-9718f37d4682
2008-02-01 16:39:41 +00:00

176 lines
4.4 KiB
C++
Executable File

#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);
~TCampo_window();
};
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_window::~TCampo_window()
{
xvt_sys_close_children(win());
}
///////////////////////////////////////////////////////////
// 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();
}