00001
00012 #ifndef _DEFINTERFACE_H_
00013 #define _DEFINTERFACE_H_
00014
00015 #include "plugin.h"
00016 #include "events.h"
00017
00018 #include <wx/frame.h>
00019 #include <wx/bitmap.h>
00020 #include <wx/pen.h>
00021 #include <wx/brush.h>
00022
00023
00024
00025
00026 #define IFM_FLOATING_FRAME_STYLE wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCLOSE_BOX
00027
00028 #define IFM_CAPTION_PAD 1
00029
00030 #define IFM_COMPONENT_BUTTON_X 10
00031 #define IFM_COMPONENT_BUTTON_Y 11
00032 #define IFM_COMPONENT_BUTTON_PAD 2
00033
00035 #define IFM_COMPONENT_ID_CLOSE 0
00036 #define IFM_COMPONENT_ID_MAXIMIZE 1
00037 #define IFM_COMPONENT_ID_MINIMIZE 2
00038
00039 #define IFM_CONTAINER_GRIPPER_WIDTH 0
00040
00041 class wxIFMDefaultInterfacePlugin;
00042 class wxIFMFloatingFrame;
00043 class wxIFMDefaultContainerPlugin;
00044 class wxIFMDefaultPanelPlugin;
00045 class wxIFMContainerData;
00046 class wxIFMPanelTabData;
00047 class wxIFMAddTopContainerEvent;
00048 class wxIFMRemoveTopContainerEvent;
00049 class wxIFMSelectTabEvent;
00050 class wxIFMComponentButton;
00051 class wxIFMComponentButtonManager;
00052 class wxIFMComponentButtonEvent;
00053 class wxIFMTab;
00054
00055
00056 WX_DECLARE_LIST(wxIFMComponent, wxIFMComponentList);
00057
00058
00059 WX_DEFINE_ARRAY(wxIFMComponentButton *, wxIFMComponentButtonArray);
00060 WX_DEFINE_ARRAY(wxIFMTab *, wxIFMTabArray);
00061
00062
00063 DECLARE_IFM_DATA_KEY(IFM_CONTAINER_DATA_KEY)
00064 DECLARE_IFM_DATA_KEY(IFM_PANEL_DATA_KEY)
00065 DECLARE_IFM_DATA_KEY(IFM_TABBED_PANEL_DATA_KEY)
00066
00067 #define IFM_ORIENTATION_DEFAULT -1
00068 #define IFM_ORIENTATION_NONE 0
00069 #define IFM_ORIENTATION_TOP 1
00070 #define IFM_ORIENTATION_BOTTOM 2
00071 #define IFM_ORIENTATION_LEFT 3
00072 #define IFM_ORIENTATION_RIGHT 4
00073 #define IFM_ORIENTATION_FLOAT 5
00074 #define IFM_ORIENTATION_DOCKED 6
00075
00076 DECLARE_IFM_COMPONENT_TYPE(IFM_COMPONENT_CONTAINER)
00077 DECLARE_IFM_COMPONENT_TYPE(IFM_COMPONENT_PANEL_TAB)
00078 DECLARE_IFM_COMPONENT_TYPE(IFM_COMPONENT_PANEL)
00079
00080 DECLARE_EVENT_TYPE(wxEVT_IFM_ADDTOPCONTAINER, 0);
00081 DECLARE_EVENT_TYPE(wxEVT_IFM_REMOVETOPCONTAINER, 0);
00082 DECLARE_EVENT_TYPE(wxEVT_IFM_SELECTTAB, 0);
00083 DECLARE_EVENT_TYPE(wxEVT_IFM_COMPONENTBUTTONCLICK, 0);
00084
00085 #if IFM_CANFLOAT
00086
00090 class wxIFMFloatingFrame : public wxIFMFloatingWindowBase
00091 {
00092 public:
00093
00094 wxIFMFloatingFrame(wxIFMInterfacePluginBase *ip,
00095 wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition,
00096 const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE,
00097 const wxString& name = wxFrameNameStr);
00098
00099 ~wxIFMFloatingFrame() {}
00100
00101 void OnClose(wxCloseEvent &event);
00102
00103 DECLARE_EVENT_TABLE()
00104 };
00105
00106 #endif
00107
00111 class wxIFMDefaultInterfacePlugin : public wxIFMInterfacePluginBase
00112 {
00113 public:
00114
00115 wxIFMDefaultInterfacePlugin();
00116 ~wxIFMDefaultInterfacePlugin();
00117
00121 bool Initialize(wxInterfaceManager *manager);
00122
00126 const wxIFMComponentList &GetTopContainerList() const;
00127
00128 bool ProcessPluginEvent(wxIFMPluginEvent &event);
00129
00134 wxIFMComponent *GetContainer(int orientation);
00135
00136 wxIFMComponent *GetComponentByPos(const wxPoint &pos, wxIFMComponent *component = NULL, bool floating = false);
00137
00138 private:
00139
00140 wxIFMComponentList m_containers;
00141
00142 void OnDeleteComponent(wxIFMDeleteComponentEvent &event);
00143 void OnAddChild(wxIFMAddChildEvent &event);
00144 void OnUpdate(wxIFMUpdateEvent &event);
00145 void OnPaint(wxIFMPaintInterfaceEvent &event);
00146 void OnGetContentRect(wxIFMRectEvent &event);
00147
00148 void OnAddTopContainer(wxIFMAddTopContainerEvent &event);
00149 void OnRemoveTopContainer(wxIFMRemoveTopContainerEvent &event);
00150
00151 #if IFM_CANFLOAT
00152 void OnCreateFloatingWindow(wxIFMCreateFloatingWindowEvent &event);
00153 void OnDestroyFloatingWindow(wxIFMDestroyFloatingWindowEvent &event);
00154 void OnFloat(wxIFMFloatEvent &event);
00155 #endif
00156
00157 DECLARE_EVENT_TABLE()
00158
00159 #if IFM_USE_WX_RTTI
00160 DECLARE_DYNAMIC_CLASS_NO_COPY(wxIFMDefaultInterfacePlugin)
00161 #endif
00162 };
00163
00167 class wxIFMDefaultContainerPlugin : public wxIFMExtensionPluginBase
00168 {
00169 public:
00170
00171 wxIFMDefaultContainerPlugin();
00172
00173 private:
00174
00175
00176
00177
00178 void OnCreateComponent(wxIFMNewComponentEvent &event);
00179 void OnDock(wxIFMDockEvent &event);
00180 void OnUndock(wxIFMUndockEvent &event);
00181 void OnUpdate(wxIFMUpdateComponentEvent &event);
00182 void OnVisibilityChange(wxIFMComponentVisibilityChangedEvent &event);
00183 void OnShowComponent(wxIFMShowComponentEvent &event);
00184 void OnLeftDown(wxIFMMouseEvent &event);
00185
00186 #if IFM_CANFLOAT
00187 void OnFloatNotify(wxIFMFloatNotifyEvent &event);
00188 void UpdateFloatingCaption(wxIFMComponent *container);
00189 #endif
00190
00191 void OnGetDesiredSize(wxIFMRectEvent &event);
00192 void OnSetDesiredSize(wxIFMRectEvent &event);
00193 void OnGetRect(wxIFMRectEvent &event);
00194
00195 void OnPaintDecor(wxIFMPaintEvent &event);
00196
00197 void OnComponentButtonClick(wxIFMComponentButtonEvent &event);
00198
00206 bool HasVisibleChildren(wxIFMComponent *component);
00207
00211 bool HasNonCloseableChildren(wxIFMComponent *component);
00212
00216 int GetVisibleChildrenCount(wxIFMComponent *component);
00217
00218 DECLARE_EVENT_TABLE()
00219
00220 #if IFM_USE_WX_RTTI
00221 DECLARE_DYNAMIC_CLASS_NO_COPY(wxIFMDefaultContainerPlugin)
00222 #endif
00223 };
00224
00228 struct wxIFMTabConfig
00229 {
00230 wxFont font;
00231 wxColour font_color;
00232 int font_height;
00233 int row_height;
00234 int row_indent;
00235 int tab_height;
00236 int tab_padding;
00237 int tab_spacing;
00238 int rounding_factor;
00239
00240 wxPen tab_border_p;
00241
00242 wxBrush tab_active_bg_b;
00243 wxPen tab_active_bg_p;
00244
00245 wxBrush tab_inactive_bg_b;
00246 wxPen tab_inactive_bg_p;
00247
00248 wxBrush bg_brush;
00249 wxPen bg_pen;
00250 wxPen line_pen;
00251 };
00252
00256 struct wxIFMCaptionConfig
00257 {
00258 wxFont font;
00259 wxColour color;
00260 int font_height;
00261 int height;
00262 int padding;
00263 };
00264
00268 class wxIFMDefaultPanelPlugin : public wxIFMExtensionPluginBase
00269 {
00270 public:
00271
00272 wxIFMDefaultPanelPlugin() : wxIFMExtensionPluginBase() {}
00273 bool Initialize(wxIFMInterfacePluginBase *plugin);
00274
00275 private:
00276
00277 wxIFMCaptionConfig m_caption_config;
00278 wxIFMTabConfig m_tab_config;
00279
00280 void OnCreateComponent(wxIFMNewComponentEvent &event);
00281 void OnDestroyComponent(wxIFMDeleteComponentEvent &event);
00282 void OnSetChild(wxIFMSetChildEvent &event);
00283 void OnQueryChild(wxIFMQueryChildEvent &event);
00284 void OnUpdate(wxIFMUpdateComponentEvent &event);
00285 void OnVisibilityChanged(wxIFMComponentVisibilityChangedEvent &event);
00286 void OnShowComponent(wxIFMShowComponentEvent &event);
00287 void OnPaintDecor(wxIFMPaintEvent &event);
00288 void OnPaintBg(wxIFMPaintEvent &event);
00289 void OnLeftDown(wxIFMMouseEvent &event);
00290 void OnLeftUp(wxIFMMouseEvent &event);
00291 void OnMouseMove(wxIFMMouseEvent &event);
00292 void OnDock(wxIFMDockEvent &event);
00293 void OnUndock(wxIFMUndockEvent &event);
00294 void OnComponentButtonClick(wxIFMComponentButtonEvent &event);
00295
00296 void OnSelectTab(wxIFMSelectTabEvent &event);
00297 void OnGetDesiredSize(wxIFMRectEvent &event);
00298 void OnSetDesiredSize(wxIFMRectEvent &event);
00299 void OnGetMinSize(wxIFMRectEvent &event);
00300 void OnGetMaxSize(wxIFMRectEvent &event);
00301
00302 void DrawTabs(wxDC &dc, wxIFMComponent *component, const wxRegion ®ion, const wxIFMTabArray &tabs);
00303
00304 #if IFM_CANFLOAT
00305 void OnFloatNotify(wxIFMFloatNotifyEvent &event);
00306 #endif
00307
00308 DECLARE_EVENT_TABLE()
00309
00310 #if IFM_USE_WX_RTTI
00311 DECLARE_DYNAMIC_CLASS_NO_COPY(wxIFMDefaultPanelPlugin)
00312 #endif
00313 };
00314
00321 class wxIFMComponentButtonManager
00322 {
00323 private:
00324 wxPoint m_pos;
00325 int m_height;
00326 wxIFMInterfacePluginBase *m_ip;
00327 wxIFMComponent *m_component;
00328 bool m_hidden;
00329
00330 public:
00331
00332 wxIFMComponentButtonArray m_buttons;
00333
00334 wxIFMComponentButtonManager(wxIFMInterfacePluginBase *ip, wxIFMComponent *component);
00335 ~wxIFMComponentButtonManager();
00336
00337 wxIFMInterfacePluginBase *GetIP();
00338 wxIFMComponent *GetComponent();
00339
00346 wxIFMComponentButton *AddButton(int id);
00347
00353 void RemoveButton(int id);
00354
00358 wxIFMComponentButton *GetButton(int id);
00359
00363 const wxRect GetRect() const;
00364
00368 const wxPoint &GetPosition() const;
00369
00373 void SetPosition(const wxPoint& pos);
00374
00380 void SetHeight(int height);
00381
00385 void Show(bool show = true);
00386 void Hide();
00387
00392 void Show(bool show, int id);
00393
00397 void SetParent(wxWindow *parent);
00398
00402 void Layout();
00403 };
00404
00405 class wxIFMComponentButton : public wxWindow
00406 {
00407 private:
00408
00409 int m_id;
00410
00411 wxIFMComponentButtonManager *m_manager;
00412
00413 bool m_hover, m_pressed, m_leftDown;
00414
00415 wxIFMInterfacePluginBase *GetIP();
00416
00417 public:
00418 wxBitmap *m_bmp, *m_bmpH, *m_bmpP;
00419
00420 wxIFMComponentButton(wxIFMComponentButtonManager *manager, int id, wxWindow *parent);
00421 int GetID() const;
00422
00426 void SetHover(bool h);
00427 bool GetHover() const;
00428
00432 void SetPressed(bool p);
00433 bool GetPressed() const;
00434
00435 void OnPaint(wxPaintEvent &event);
00436 void OnEraseBg(wxEraseEvent &event);
00437 void OnEnterWindow(wxMouseEvent &event);
00438 void OnLeaveWindow(wxMouseEvent &event);
00439 void OnLeftDown(wxMouseEvent &event);
00440 void OnLeftUp(wxMouseEvent &event);
00441 void OnMouseMove(wxMouseEvent &event);
00442
00443 DECLARE_EVENT_TABLE()
00444 };
00445
00449 class wxIFMDefaultChildData : public wxIFMChildDataBase
00450 {
00451 public:
00452
00453 int m_orientation;
00468 int m_index;
00473 bool m_newRow;
00479 bool m_tabify;
00485 wxBitmap m_bitmap;
00490 wxPoint m_pos;
00496 wxIFMDefaultChildData();
00497
00498
00499 wxIFMDefaultChildData(wxWindow *child, int type, const wxString &name = IFM_DEFAULT_COMPONENT_NAME,
00500 wxSize size = IFM_DEFAULT_SIZE, bool hidden = false,
00501 int orientation = IFM_ORIENTATION_DEFAULT, int index = IFM_DEFAULT_INDEX,
00502 bool newRow = false, bool tabify = false, const wxBitmap &bmp = wxNullBitmap);
00503
00504
00505 wxIFMDefaultChildData(wxWindow *child, int type, wxPoint pos, wxSize size, bool hidden = false,
00506 const wxString &name = IFM_DEFAULT_COMPONENT_NAME);
00507
00508
00509 wxIFMDefaultChildData(const wxIFMDefaultChildData &data);
00510 wxIFMDefaultChildData(const wxIFMChildDataBase &data);
00511
00512 #if IFM_USE_WX_RTTI
00513 DECLARE_DYNAMIC_CLASS(wxIFMDefaultChildData)
00514 #endif
00515 };
00516
00520 class wxIFMContainerData : public wxIFMExtensionDataBase
00521 {
00522 public:
00523
00524 #if IFM_USE_WX_RTTI
00525 wxIFMContainerData();
00526 #endif
00527
00528 wxIFMContainerData(wxIFMInterfacePluginBase *ip, wxIFMComponent *c);
00529
00530
00531
00532 int m_orientation;
00533 wxRect m_tray_rect;
00534
00535 wxIFMComponentDataKeyType GetDataKey() const;
00536 static wxIFMComponentDataKeyType DataKey();
00537
00538 #if IFM_USE_WX_RTTI
00539 DECLARE_DYNAMIC_CLASS(wxIFMContainerData)
00540 #endif
00541 };
00542
00546 class wxIFMPanelTabData : public wxIFMExtensionDataBase
00547 {
00548 public:
00549
00550 wxBitmap m_bitmap;
00551
00552 #if IFM_USE_WX_RTTI
00553 wxIFMPanelTabData();
00554 #endif
00555
00556 wxIFMComponentDataKeyType GetDataKey() const;
00557 static wxIFMComponentDataKeyType DataKey();
00558
00559 #if IFM_USE_WX_RTTI
00560 DECLARE_DYNAMIC_CLASS(wxIFMPanelTabData)
00561 #endif
00562 };
00563
00567 class wxIFMTab
00568 {
00569 public:
00570 wxIFMTab()
00571 : m_active(false),
00572 m_visible(true),
00573 m_tab(NULL),
00574 m_name_width(0)
00575 { }
00576
00577 bool m_active, m_visible;
00578 wxRect m_rect;
00579 wxIFMComponent *m_tab;
00580 int m_name_width;
00581 };
00582
00586 class wxIFMPanelData : public wxIFMExtensionDataBase
00587 {
00588 public:
00589
00590 #ifdef IFM_USE_WX_RTTI
00591 wxIFMPanelData()
00592 : m_button_manager(0,0)
00593 { }
00594 #endif
00595
00596 wxIFMPanelData(wxIFMInterfacePluginBase *ip, wxIFMComponent *c);
00597 ~wxIFMPanelData();
00598
00599 wxIFMComponentButtonManager m_button_manager;
00600
00601 int m_active_tab_index;
00602 wxIFMTab *m_active_tab;
00603 wxRect m_caption;
00604 wxPoint m_titlePos;
00605
00612 bool m_dont_hide_tab;
00613
00614 wxIFMTabArray m_tabs;
00615
00616 wxIFMComponentDataKeyType GetDataKey() const;
00617 static wxIFMComponentDataKeyType DataKey();
00618
00619 #if IFM_USE_WX_RTTI
00620 DECLARE_DYNAMIC_CLASS(wxIFMPanelData)
00621 #endif
00622 };
00623
00630 class wxIFMAddTopContainerEvent : public wxIFMPluginEvent
00631 {
00632 private:
00633 int m_index;
00634 wxIFMComponent *m_indexContainer;
00635
00636 public:
00637
00638 wxIFMAddTopContainerEvent(wxIFMComponent *container, int index)
00639 : wxIFMPluginEvent(wxEVT_IFM_ADDTOPCONTAINER, container),
00640 m_index(index),
00641 m_indexContainer(NULL)
00642 { }
00643
00644
00645
00646 wxIFMAddTopContainerEvent(wxIFMComponent *container, wxIFMComponent *index_container, bool before)
00647 : wxIFMPluginEvent(wxEVT_IFM_ADDTOPCONTAINER, container),
00648 m_index(before ? 1 : 0),
00649 m_indexContainer(index_container)
00650 { }
00651
00652 virtual wxEvent *Clone() const { return new wxIFMAddTopContainerEvent(*this); }
00653
00657 bool GetIndexMode() const { return m_indexContainer == NULL; }
00658
00665 int GetIndex() const { return m_index; }
00666
00667 wxIFMComponent *GetIndexContainer() const { return m_indexContainer; }
00668 };
00669
00675 class wxIFMRemoveTopContainerEvent : public wxIFMPluginEvent
00676 {
00677 public:
00678 wxIFMRemoveTopContainerEvent(wxIFMComponent *container)
00679 : wxIFMPluginEvent(wxEVT_IFM_REMOVETOPCONTAINER, container)
00680 { }
00681
00682 wxIFMRemoveTopContainerEvent(const wxIFMRemoveTopContainerEvent &event)
00683 : wxIFMPluginEvent(event)
00684 { }
00685
00686 virtual wxEvent *Clone() const { return new wxIFMRemoveTopContainerEvent(*this); }
00687 };
00688
00692 class wxIFMSelectTabEvent : public wxIFMPluginEvent
00693 {
00694 private:
00695 wxIFMTab *m_tab;
00696 bool m_update;
00697
00698 public:
00699 wxIFMSelectTabEvent(wxIFMComponent *panel, wxIFMTab *tab, bool update)
00700 : wxIFMPluginEvent(wxEVT_IFM_SELECTTAB, panel),
00701 m_tab(tab),
00702 m_update(update)
00703 { }
00704
00705 wxIFMSelectTabEvent(const wxIFMSelectTabEvent &event)
00706 : wxIFMPluginEvent(event),
00707 m_tab(event.m_tab),
00708 m_update(event.m_update)
00709 { }
00710
00711 virtual wxEvent *Clone() const { return new wxIFMSelectTabEvent(*this); }
00712
00716 wxIFMTab *GetTab() { return m_tab; }
00717
00721 bool GetUpdate() { return m_update; }
00722 };
00723
00727 class wxIFMComponentButtonEvent : public wxIFMPluginEvent
00728 {
00729 private:
00730 wxIFMComponentButton *m_button;
00731
00732 public:
00733 wxIFMComponentButtonEvent(wxEventType type, wxIFMComponent *component, wxIFMComponentButton *button)
00734 : wxIFMPluginEvent(type, component),
00735 m_button(button)
00736 { }
00737
00741 wxIFMComponentButton *GetButton() const { return m_button; }
00742 };
00743
00744 typedef void (wxEvtHandler::*wxIFMAddTopContainerEventFunction)(wxIFMAddTopContainerEvent&);
00745 typedef void (wxEvtHandler::*wxIFMRemoveTopContainerEventFunction)(wxIFMRemoveTopContainerEvent&);
00746 typedef void (wxEvtHandler::*wxIFMSelectTabEventFunction)(wxIFMSelectTabEvent&);
00747 typedef void (wxEvtHandler::*wxIFMComponentButtonEventFunction)(wxIFMComponentButtonEvent&);
00748
00749 #define wxIFMAddTopContainerEventFunctionHandler(func) \
00750 (wxObjectEventFunction)wxStaticCastEvent(wxIFMAddTopContainerEventFunction, &func)
00751 #define wxIFMRemoveTopContainerEventFunctionHandler(func) \
00752 (wxObjectEventFunction)wxStaticCastEvent(wxIFMRemoveTopContainerEventFunction, &func)
00753 #define wxIFMSelectTabEventFunctionHandler(func) \
00754 (wxObjectEventFunction)wxStaticCastEvent(wxIFMSelectTabEventFunction, &func)
00755 #define wxIFMComponentButtonEventFunctionHandler(func) \
00756 (wxObjectEventFunction)wxStaticCastEvent(wxIFMComponentButtonEventFunction, &func)
00757
00758 #define EVT_IFM_ADDTOPCONTAINER(func) wx__DECLARE_EVT0(wxEVT_IFM_ADDTOPCONTAINER, wxIFMAddTopContainerEventFunctionHandler(func))
00759 #define EVT_IFM_REMOVETOPCONTAINER(func) wx__DECLARE_EVT0(wxEVT_IFM_REMOVETOPCONTAINER, wxIFMRemoveTopContainerEventFunctionHandler(func))
00760 #define EVT_IFM_SELECTTAB(func) wx__DECLARE_EVT0(wxEVT_IFM_SELECTTAB, wxIFMSelectTabEventFunctionHandler(func))
00761 #define EVT_IFM_COMPONENTBUTTONCLICK(func) wx__DECLARE_EVT0(wxEVT_IFM_COMPONENTBUTTONCLICK, wxIFMComponentButtonEventFunctionHandler(func))
00762
00763 #endif // _DEFINTERFACE_H_