| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: wx/generic/tabmdi.h |
| 3 | // Purpose: Generic MDI (Multiple Document Interface) classes |
| 4 | // Author: Hans Van Leemputten |
| 5 | // Modified by: Benjamin I. Williams / Kirix Corporation |
| 6 | // Created: 29/07/2002 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) Hans Van Leemputten |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #ifndef _WX_AUITABMDI_H_ |
| 13 | #define _WX_AUITABMDI_H_ |
| 14 | |
| 15 | #if wxUSE_AUI |
| 16 | |
| 17 | // ---------------------------------------------------------------------------- |
| 18 | // headers |
| 19 | // ---------------------------------------------------------------------------- |
| 20 | |
| 21 | #include "wx/frame.h" |
| 22 | #include "wx/panel.h" |
| 23 | #include "wx/notebook.h" |
| 24 | #include "wx/icon.h" |
| 25 | #include "wx/aui/auibook.h" |
| 26 | |
| 27 | //----------------------------------------------------------------------------- |
| 28 | // classes |
| 29 | //----------------------------------------------------------------------------- |
| 30 | |
| 31 | class WXDLLIMPEXP_FWD_AUI wxAuiMDIParentFrame; |
| 32 | class WXDLLIMPEXP_FWD_AUI wxAuiMDIClientWindow; |
| 33 | class WXDLLIMPEXP_FWD_AUI wxAuiMDIChildFrame; |
| 34 | |
| 35 | //----------------------------------------------------------------------------- |
| 36 | // wxAuiMDIParentFrame |
| 37 | //----------------------------------------------------------------------------- |
| 38 | |
| 39 | class WXDLLIMPEXP_AUI wxAuiMDIParentFrame : public wxFrame |
| 40 | { |
| 41 | public: |
| 42 | wxAuiMDIParentFrame(); |
| 43 | wxAuiMDIParentFrame(wxWindow *parent, |
| 44 | wxWindowID winid, |
| 45 | const wxString& title, |
| 46 | const wxPoint& pos = wxDefaultPosition, |
| 47 | const wxSize& size = wxDefaultSize, |
| 48 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, |
| 49 | const wxString& name = wxFrameNameStr); |
| 50 | |
| 51 | ~wxAuiMDIParentFrame(); |
| 52 | |
| 53 | bool Create(wxWindow *parent, |
| 54 | wxWindowID winid, |
| 55 | const wxString& title, |
| 56 | const wxPoint& pos = wxDefaultPosition, |
| 57 | const wxSize& size = wxDefaultSize, |
| 58 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, |
| 59 | const wxString& name = wxFrameNameStr ); |
| 60 | |
| 61 | void SetArtProvider(wxAuiTabArt* provider); |
| 62 | wxAuiTabArt* GetArtProvider(); |
| 63 | wxAuiNotebook* GetNotebook() const; |
| 64 | |
| 65 | #if wxUSE_MENUS |
| 66 | wxMenu* GetWindowMenu() const { return m_pWindowMenu; } |
| 67 | void SetWindowMenu(wxMenu* pMenu); |
| 68 | |
| 69 | virtual void SetMenuBar(wxMenuBar *pMenuBar); |
| 70 | #endif // wxUSE_MENUS |
| 71 | |
| 72 | void SetChildMenuBar(wxAuiMDIChildFrame *pChild); |
| 73 | |
| 74 | virtual bool ProcessEvent(wxEvent& event); |
| 75 | |
| 76 | wxAuiMDIChildFrame *GetActiveChild() const; |
| 77 | void SetActiveChild(wxAuiMDIChildFrame* pChildFrame); |
| 78 | |
| 79 | wxAuiMDIClientWindow *GetClientWindow() const; |
| 80 | virtual wxAuiMDIClientWindow *OnCreateClient(); |
| 81 | |
| 82 | virtual void Cascade() { /* Has no effect */ } |
| 83 | virtual void Tile(wxOrientation orient = wxHORIZONTAL); |
| 84 | virtual void ArrangeIcons() { /* Has no effect */ } |
| 85 | virtual void ActivateNext(); |
| 86 | virtual void ActivatePrevious(); |
| 87 | |
| 88 | protected: |
| 89 | wxAuiMDIClientWindow* m_pClientWindow; |
| 90 | wxAuiMDIChildFrame* m_pActiveChild; |
| 91 | wxEvent* m_pLastEvt; |
| 92 | |
| 93 | #if wxUSE_MENUS |
| 94 | wxMenu *m_pWindowMenu; |
| 95 | wxMenuBar *m_pMyMenuBar; |
| 96 | #endif // wxUSE_MENUS |
| 97 | |
| 98 | protected: |
| 99 | void Init(); |
| 100 | |
| 101 | #if wxUSE_MENUS |
| 102 | void RemoveWindowMenu(wxMenuBar *pMenuBar); |
| 103 | void AddWindowMenu(wxMenuBar *pMenuBar); |
| 104 | |
| 105 | void DoHandleMenu(wxCommandEvent &event); |
| 106 | #endif // wxUSE_MENUS |
| 107 | |
| 108 | virtual void DoGetClientSize(int *width, int *height) const; |
| 109 | |
| 110 | private: |
| 111 | DECLARE_EVENT_TABLE() |
| 112 | DECLARE_DYNAMIC_CLASS(wxAuiMDIParentFrame) |
| 113 | }; |
| 114 | |
| 115 | //----------------------------------------------------------------------------- |
| 116 | // wxAuiMDIChildFrame |
| 117 | //----------------------------------------------------------------------------- |
| 118 | |
| 119 | class WXDLLIMPEXP_AUI wxAuiMDIChildFrame : public wxPanel |
| 120 | { |
| 121 | public: |
| 122 | wxAuiMDIChildFrame(); |
| 123 | wxAuiMDIChildFrame(wxAuiMDIParentFrame *parent, |
| 124 | wxWindowID winid, |
| 125 | const wxString& title, |
| 126 | const wxPoint& pos = wxDefaultPosition, |
| 127 | const wxSize& size = wxDefaultSize, |
| 128 | long style = wxDEFAULT_FRAME_STYLE, |
| 129 | const wxString& name = wxFrameNameStr); |
| 130 | |
| 131 | virtual ~wxAuiMDIChildFrame(); |
| 132 | bool Create(wxAuiMDIParentFrame *parent, |
| 133 | wxWindowID winid, |
| 134 | const wxString& title, |
| 135 | const wxPoint& pos = wxDefaultPosition, |
| 136 | const wxSize& size = wxDefaultSize, |
| 137 | long style = wxDEFAULT_FRAME_STYLE, |
| 138 | const wxString& name = wxFrameNameStr); |
| 139 | |
| 140 | #if wxUSE_MENUS |
| 141 | virtual void SetMenuBar(wxMenuBar *menu_bar); |
| 142 | virtual wxMenuBar *GetMenuBar() const; |
| 143 | #endif // wxUSE_MENUS |
| 144 | |
| 145 | virtual void SetTitle(const wxString& title); |
| 146 | virtual wxString GetTitle() const; |
| 147 | |
| 148 | virtual void SetIcons(const wxIconBundle& icons); |
| 149 | virtual const wxIconBundle& GetIcons() const; |
| 150 | |
| 151 | virtual void SetIcon(const wxIcon& icon); |
| 152 | virtual const wxIcon& GetIcon() const; |
| 153 | |
| 154 | virtual void Activate(); |
| 155 | virtual bool Destroy(); |
| 156 | |
| 157 | virtual bool Show(bool show = true); |
| 158 | |
| 159 | #if wxUSE_STATUSBAR |
| 160 | // no status bars |
| 161 | virtual wxStatusBar* CreateStatusBar(int WXUNUSED(number) = 1, |
| 162 | long WXUNUSED(style) = 1, |
| 163 | wxWindowID WXUNUSED(winid) = 1, |
| 164 | const wxString& WXUNUSED(name) = wxEmptyString) |
| 165 | { return (wxStatusBar*)NULL; } |
| 166 | |
| 167 | virtual wxStatusBar *GetStatusBar() const { return (wxStatusBar*)NULL; } |
| 168 | virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number)=0 ) {} |
| 169 | virtual void SetStatusWidths( int WXUNUSED(n), const int WXUNUSED(widths_field)[] ) {} |
| 170 | #endif |
| 171 | |
| 172 | #if wxUSE_TOOLBAR |
| 173 | // no toolbar bars |
| 174 | virtual wxToolBar* CreateToolBar(long WXUNUSED(style), |
| 175 | wxWindowID WXUNUSED(winid), |
| 176 | const wxString& WXUNUSED(name)) |
| 177 | { return (wxToolBar*)NULL; } |
| 178 | virtual wxToolBar *GetToolBar() const { return (wxToolBar*)NULL; } |
| 179 | #endif |
| 180 | |
| 181 | |
| 182 | // no maximize etc |
| 183 | virtual void Maximize(bool WXUNUSED(maximize) = true) { /* Has no effect */ } |
| 184 | virtual void Restore() { /* Has no effect */ } |
| 185 | virtual void Iconize(bool WXUNUSED(iconize) = true) { /* Has no effect */ } |
| 186 | virtual bool IsMaximized() const { return true; } |
| 187 | virtual bool IsIconized() const { return false; } |
| 188 | virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style)) { return false; } |
| 189 | virtual bool IsFullScreen() const { return false; } |
| 190 | |
| 191 | virtual bool IsTopLevel() const { return false; } |
| 192 | |
| 193 | void OnMenuHighlight(wxMenuEvent& evt); |
| 194 | void OnActivate(wxActivateEvent& evt); |
| 195 | void OnCloseWindow(wxCloseEvent& evt); |
| 196 | |
| 197 | void SetMDIParentFrame(wxAuiMDIParentFrame* parent); |
| 198 | wxAuiMDIParentFrame* GetMDIParentFrame() const; |
| 199 | |
| 200 | protected: |
| 201 | void Init(); |
| 202 | virtual void DoSetSize(int x, int y, int width, int height, int size_flags); |
| 203 | virtual void DoMoveWindow(int x, int y, int width, int height); |
| 204 | |
| 205 | // no size hints |
| 206 | virtual void DoSetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), |
| 207 | int WXUNUSED(maxW), int WXUNUSED(maxH), |
| 208 | int WXUNUSED(incW), int WXUNUSED(incH)) {} |
| 209 | public: |
| 210 | // This function needs to be called when a size change is confirmed, |
| 211 | // we needed this function to prevent anybody from the outside |
| 212 | // changing the panel... it messes the UI layout when we would allow it. |
| 213 | void ApplyMDIChildFrameRect(); |
| 214 | void DoShow(bool show); |
| 215 | |
| 216 | protected: |
| 217 | wxAuiMDIParentFrame* m_pMDIParentFrame; |
| 218 | wxRect m_mdi_newrect; |
| 219 | wxRect m_mdi_currect; |
| 220 | wxString m_title; |
| 221 | wxIcon m_icon; |
| 222 | wxIconBundle m_icon_bundle; |
| 223 | bool m_activate_on_create; |
| 224 | |
| 225 | #if wxUSE_MENUS |
| 226 | wxMenuBar* m_pMenuBar; |
| 227 | #endif // wxUSE_MENUS |
| 228 | |
| 229 | |
| 230 | |
| 231 | private: |
| 232 | DECLARE_DYNAMIC_CLASS(wxAuiMDIChildFrame) |
| 233 | DECLARE_EVENT_TABLE() |
| 234 | |
| 235 | friend class wxAuiMDIClientWindow; |
| 236 | }; |
| 237 | |
| 238 | //----------------------------------------------------------------------------- |
| 239 | // wxAuiMDIClientWindow |
| 240 | //----------------------------------------------------------------------------- |
| 241 | |
| 242 | class WXDLLIMPEXP_AUI wxAuiMDIClientWindow : public wxAuiNotebook |
| 243 | { |
| 244 | public: |
| 245 | wxAuiMDIClientWindow(); |
| 246 | wxAuiMDIClientWindow(wxAuiMDIParentFrame *parent, long style = 0); |
| 247 | ~wxAuiMDIClientWindow(); |
| 248 | |
| 249 | virtual bool CreateClient(wxAuiMDIParentFrame *parent, |
| 250 | long style = wxVSCROLL | wxHSCROLL); |
| 251 | |
| 252 | virtual int SetSelection(size_t page); |
| 253 | |
| 254 | protected: |
| 255 | |
| 256 | void PageChanged(int old_selection, int new_selection); |
| 257 | void OnPageClose(wxAuiNotebookEvent& evt); |
| 258 | void OnPageChanged(wxAuiNotebookEvent& evt); |
| 259 | void OnSize(wxSizeEvent& evt); |
| 260 | |
| 261 | private: |
| 262 | DECLARE_DYNAMIC_CLASS(wxAuiMDIClientWindow) |
| 263 | DECLARE_EVENT_TABLE() |
| 264 | }; |
| 265 | #endif // wxUSE_AUI |
| 266 | |
| 267 | #endif // _WX_AUITABMDI_H_ |