]>
Commit | Line | Data |
---|---|---|
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/aui/auibook.h" | |
25 | ||
26 | //----------------------------------------------------------------------------- | |
27 | // classes | |
28 | //----------------------------------------------------------------------------- | |
29 | ||
30 | class WXDLLIMPEXP_AUI wxAuiMDIParentFrame; | |
31 | class WXDLLIMPEXP_AUI wxAuiMDIClientWindow; | |
32 | class WXDLLIMPEXP_AUI wxAuiMDIChildFrame; | |
33 | ||
34 | //----------------------------------------------------------------------------- | |
35 | // wxAuiMDIParentFrame | |
36 | //----------------------------------------------------------------------------- | |
37 | ||
38 | class WXDLLIMPEXP_AUI wxAuiMDIParentFrame : public wxFrame | |
39 | { | |
40 | public: | |
41 | wxAuiMDIParentFrame(); | |
42 | wxAuiMDIParentFrame(wxWindow *parent, | |
43 | wxWindowID winid, | |
44 | const wxString& title, | |
45 | const wxPoint& pos = wxDefaultPosition, | |
46 | const wxSize& size = wxDefaultSize, | |
47 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
48 | const wxString& name = wxFrameNameStr); | |
49 | ||
50 | ~wxAuiMDIParentFrame(); | |
51 | ||
52 | bool Create(wxWindow *parent, | |
53 | wxWindowID winid, | |
54 | const wxString& title, | |
55 | const wxPoint& pos = wxDefaultPosition, | |
56 | const wxSize& size = wxDefaultSize, | |
57 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
58 | const wxString& name = wxFrameNameStr ); | |
59 | ||
60 | void SetArtProvider(wxAuiTabArt* provider); | |
61 | wxAuiTabArt* GetArtProvider(); | |
62 | wxAuiNotebook* GetNotebook() const; | |
63 | ||
64 | #if wxUSE_MENUS | |
65 | wxMenu* GetWindowMenu() const { return m_pWindowMenu; }; | |
66 | void SetWindowMenu(wxMenu* pMenu); | |
67 | ||
68 | virtual void SetMenuBar(wxMenuBar *pMenuBar); | |
69 | #endif // wxUSE_MENUS | |
70 | ||
71 | void SetChildMenuBar(wxAuiMDIChildFrame *pChild); | |
72 | ||
73 | virtual bool ProcessEvent(wxEvent& event); | |
74 | ||
75 | wxAuiMDIChildFrame *GetActiveChild() const; | |
76 | inline void SetActiveChild(wxAuiMDIChildFrame* pChildFrame); | |
77 | ||
78 | wxAuiMDIClientWindow *GetClientWindow() const; | |
79 | virtual wxAuiMDIClientWindow *OnCreateClient(); | |
80 | ||
81 | virtual void Cascade() { /* Has no effect */ } | |
82 | virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL) { } | |
83 | virtual void ArrangeIcons() { /* Has no effect */ } | |
84 | virtual void ActivateNext(); | |
85 | virtual void ActivatePrevious(); | |
86 | ||
87 | protected: | |
88 | wxAuiMDIClientWindow* m_pClientWindow; | |
89 | wxAuiMDIChildFrame* m_pActiveChild; | |
90 | wxEvent* m_pLastEvt; | |
91 | ||
92 | #if wxUSE_MENUS | |
93 | wxMenu *m_pWindowMenu; | |
94 | wxMenuBar *m_pMyMenuBar; | |
95 | #endif // wxUSE_MENUS | |
96 | ||
97 | protected: | |
98 | void Init(); | |
99 | ||
100 | #if wxUSE_MENUS | |
101 | void RemoveWindowMenu(wxMenuBar *pMenuBar); | |
102 | void AddWindowMenu(wxMenuBar *pMenuBar); | |
103 | ||
104 | void DoHandleMenu(wxCommandEvent &event); | |
105 | #endif // wxUSE_MENUS | |
106 | ||
107 | virtual void DoGetClientSize(int *width, int *height) const; | |
108 | ||
109 | private: | |
110 | DECLARE_EVENT_TABLE() | |
111 | DECLARE_DYNAMIC_CLASS(wxAuiMDIParentFrame) | |
112 | }; | |
113 | ||
114 | //----------------------------------------------------------------------------- | |
115 | // wxAuiMDIChildFrame | |
116 | //----------------------------------------------------------------------------- | |
117 | ||
118 | class WXDLLIMPEXP_AUI wxAuiMDIChildFrame : public wxPanel | |
119 | { | |
120 | public: | |
121 | wxAuiMDIChildFrame(); | |
122 | wxAuiMDIChildFrame(wxAuiMDIParentFrame *parent, | |
123 | wxWindowID winid, | |
124 | const wxString& title, | |
125 | const wxPoint& pos = wxDefaultPosition, | |
126 | const wxSize& size = wxDefaultSize, | |
127 | long style = wxDEFAULT_FRAME_STYLE, | |
128 | const wxString& name = wxFrameNameStr); | |
129 | ||
130 | virtual ~wxAuiMDIChildFrame(); | |
131 | bool Create(wxAuiMDIParentFrame *parent, | |
132 | wxWindowID winid, | |
133 | const wxString& title, | |
134 | const wxPoint& pos = wxDefaultPosition, | |
135 | const wxSize& size = wxDefaultSize, | |
136 | long style = wxDEFAULT_FRAME_STYLE, | |
137 | const wxString& name = wxFrameNameStr); | |
138 | ||
139 | #if wxUSE_MENUS | |
140 | virtual void SetMenuBar(wxMenuBar *menu_bar); | |
141 | virtual wxMenuBar *GetMenuBar() const; | |
142 | #endif // wxUSE_MENUS | |
143 | ||
144 | virtual void SetTitle(const wxString& title); | |
145 | virtual wxString GetTitle() const; | |
146 | ||
147 | virtual void SetIcons(const wxIconBundle& icons); | |
148 | virtual const wxIconBundle& GetIcons() const; | |
149 | ||
150 | virtual void SetIcon(const wxIcon& icon); | |
151 | virtual const wxIcon& GetIcon() const; | |
152 | ||
153 | virtual void Activate(); | |
154 | virtual bool Destroy(); | |
155 | ||
156 | #if wxUSE_STATUSBAR | |
157 | // no status bars | |
158 | virtual wxStatusBar* CreateStatusBar(int WXUNUSED(number) = 1, | |
159 | long WXUNUSED(style) = 1, | |
160 | wxWindowID WXUNUSED(winid) = 1, | |
161 | const wxString& WXUNUSED(name) = wxEmptyString) | |
162 | { return (wxStatusBar*)NULL; } | |
163 | ||
164 | virtual wxStatusBar *GetStatusBar() const { return (wxStatusBar*)NULL; } | |
165 | virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number)=0 ) {} | |
166 | virtual void SetStatusWidths( int WXUNUSED(n), const int WXUNUSED(widths_field)[] ) {} | |
167 | #endif | |
168 | ||
169 | // no size hints | |
170 | virtual void DoSetSizeHints(int WXUNUSED(minW), | |
171 | int WXUNUSED(minH), | |
172 | int WXUNUSED(maxW) = wxDefaultCoord, | |
173 | int WXUNUSED(maxH) = wxDefaultCoord, | |
174 | int WXUNUSED(incW) = wxDefaultCoord, | |
175 | int WXUNUSED(incH) = wxDefaultCoord) {} | |
176 | #if wxUSE_TOOLBAR | |
177 | // no toolbar bars | |
178 | virtual wxToolBar* CreateToolBar(long WXUNUSED(style), | |
179 | wxWindowID WXUNUSED(winid), | |
180 | const wxString& WXUNUSED(name)) | |
181 | { return (wxToolBar*)NULL; } | |
182 | virtual wxToolBar *GetToolBar() const { return (wxToolBar*)NULL; } | |
183 | #endif | |
184 | ||
185 | ||
186 | // no maximize etc | |
187 | virtual void Maximize(bool WXUNUSED(maximize) = true) { /* Has no effect */ } | |
188 | virtual void Restore() { /* Has no effect */ } | |
189 | virtual void Iconize(bool WXUNUSED(iconize) = true) { /* Has no effect */ } | |
190 | virtual bool IsMaximized() const { return true; } | |
191 | virtual bool IsIconized() const { return false; } | |
192 | virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style)) { return false; } | |
193 | virtual bool IsFullScreen() const { return false; } | |
194 | ||
195 | virtual bool IsTopLevel() const { return false; } | |
196 | ||
197 | void OnMenuHighlight(wxMenuEvent& evt); | |
198 | void OnActivate(wxActivateEvent& evt); | |
199 | void OnCloseWindow(wxCloseEvent& evt); | |
200 | ||
201 | void SetMDIParentFrame(wxAuiMDIParentFrame* parent); | |
202 | wxAuiMDIParentFrame* GetMDIParentFrame() const; | |
203 | ||
204 | protected: | |
205 | void Init(); | |
206 | virtual bool Show(bool show = true); | |
207 | virtual void DoSetSize(int x, int y, int width, int height, int size_flags); | |
208 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
209 | ||
210 | public: | |
211 | // This function needs to be called when a size change is confirmed, | |
212 | // we needed this function to prevent anybody from the outside | |
213 | // changing the panel... it messes the UI layout when we would allow it. | |
214 | void ApplyMDIChildFrameRect(); | |
215 | void DoShow(bool show); | |
216 | ||
217 | protected: | |
218 | wxAuiMDIParentFrame* m_pMDIParentFrame; | |
219 | wxRect m_mdi_newrect; | |
220 | wxRect m_mdi_currect; | |
221 | wxString m_title; | |
222 | wxIcon m_icon; | |
223 | wxIconBundle m_icon_bundle; | |
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 OnPageChanged(wxAuiNotebookEvent& event); | |
258 | void OnSize(wxSizeEvent& evt); | |
259 | ||
260 | private: | |
261 | DECLARE_DYNAMIC_CLASS(wxAuiMDIClientWindow) | |
262 | DECLARE_EVENT_TABLE() | |
263 | }; | |
264 | #endif // wxUSE_AUI | |
265 | ||
266 | #endif // _WX_AUITABMDI_H_ |