#include "ba0103.h" #include #include /////////////////////////////////////////////////////////// // TCampo_window /////////////////////////////////////////////////////////// class TCampo_window : public TField_window { TImage _logo; 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) { if (_logo.ok()) { RCT rcti = _logo.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); _logo.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), _logo("logo.gif") { set_caption("__CAMPO_MENU__"); set_scroll_max(0, 0); // Get rid of that useless scrollbars if (_logo.ok() && can_be_transparent(_logo)) _logo.convert_transparent_color(NORMAL_BACK_COLOR); } 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(); }