]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/mdi.h
927194c27d7bf657dbb94f2cd99509531631d744
[wxWidgets.git] / include / wx / mac / carbon / mdi.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mdi.h
3 // Purpose: MDI (Multiple Document Interface) classes.
4 // This doesn't have to be implemented just like Windows,
5 // it could be a tabbed design as in wxGTK.
6 // Author: Stefan Csomor
7 // Modified by:
8 // Created: 1998-01-01
9 // RCS-ID: $Id$
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
13
14 #ifndef _WX_MDI_H_
15 #define _WX_MDI_H_
16
17 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 #pragma interface "mdi.h"
19 #endif
20
21 #include "wx/frame.h"
22
23 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
24 WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
25
26 class WXDLLEXPORT wxMDIClientWindow;
27 class WXDLLEXPORT wxMDIChildFrame;
28
29 class WXDLLEXPORT wxMDIParentFrame: public wxFrame
30 {
31 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
32
33 public:
34
35 wxMDIParentFrame() { Init(); }
36 wxMDIParentFrame(wxWindow *parent,
37 wxWindowID id,
38 const wxString& title,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, // Scrolling refers to client window
42 const wxString& name = wxFrameNameStr)
43 {
44 Init();
45 Create(parent, id, title, pos, size, style, name);
46 }
47
48 ~wxMDIParentFrame();
49
50 bool Create(wxWindow *parent,
51 wxWindowID id,
52 const wxString& title,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
56 const wxString& name = wxFrameNameStr);
57
58 // Mac OS activate event
59 virtual void MacActivate(long timestamp, bool activating);
60
61 // wxWidgets activate event
62 void OnActivate(wxActivateEvent& event);
63 void OnSysColourChanged(wxSysColourChangedEvent& event);
64
65 void SetMenuBar(wxMenuBar *menu_bar);
66
67 // Get the active MDI child window (Windows only)
68 wxMDIChildFrame *GetActiveChild() const ;
69
70 // Get the client window
71 inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; };
72 // Get rect to be used to center top-level children
73 virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h);
74
75 // Create the client window class (don't Create the window,
76 // just return a new class)
77 virtual wxMDIClientWindow *OnCreateClient() ;
78
79 // MDI operations
80 virtual void Cascade();
81 virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL);
82 virtual void ArrangeIcons();
83 virtual void ActivateNext();
84 virtual void ActivatePrevious();
85
86 virtual bool Show( bool show = true );
87
88 // overridden base clas virtuals
89 virtual void AddChild(wxWindowBase *child);
90 virtual void RemoveChild(wxWindowBase *child);
91
92 protected:
93 // common part of all ctors
94 void Init();
95
96 // returns true if this frame has some contents and so should be visible,
97 // false if it's used solely as container for its children
98 bool ShouldBeVisible() const;
99
100
101 // TODO maybe have this member
102 wxMDIClientWindow *m_clientWindow;
103 wxMDIChildFrame *m_currentChild;
104 wxMenu *m_windowMenu;
105
106 // true if MDI Frame is intercepting commands, not child
107 bool m_parentFrameActive;
108
109 // true if the frame should be shown but is not because it is empty and
110 // useless otherwise than a container for its children
111 bool m_shouldBeShown;
112
113 private:
114 friend class WXDLLEXPORT wxMDIChildFrame;
115 DECLARE_EVENT_TABLE()
116 };
117
118 class WXDLLEXPORT wxMDIChildFrame: public wxFrame
119 {
120 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
121 public:
122
123 wxMDIChildFrame();
124 inline wxMDIChildFrame(wxMDIParentFrame *parent,
125 wxWindowID id,
126 const wxString& title,
127 const wxPoint& pos = wxDefaultPosition,
128 const wxSize& size = wxDefaultSize,
129 long style = wxDEFAULT_FRAME_STYLE,
130 const wxString& name = wxFrameNameStr)
131 {
132 Init() ;
133 Create(parent, id, title, pos, size, style, name);
134 }
135
136 ~wxMDIChildFrame();
137
138 bool Create(wxMDIParentFrame *parent,
139 wxWindowID id,
140 const wxString& title,
141 const wxPoint& pos = wxDefaultPosition,
142 const wxSize& size = wxDefaultSize,
143 long style = wxDEFAULT_FRAME_STYLE,
144 const wxString& name = wxFrameNameStr);
145
146 // Mac OS activate event
147 virtual void MacActivate(long timestamp, bool activating);
148
149 // Set menu bar
150 void SetMenuBar(wxMenuBar *menu_bar);
151
152 // MDI operations
153 virtual void Maximize();
154 virtual void Maximize( bool ){ Maximize() ; } // this one is inherited from wxFrame
155 virtual void Restore();
156 virtual void Activate();
157 protected:
158
159 // common part of all ctors
160 void Init();
161 };
162
163 /* The client window is a child of the parent MDI frame, and itself
164 * contains the child MDI frames.
165 * However, you create the MDI children as children of the MDI parent:
166 * only in the implementation does the client window become the parent
167 * of the children. Phew! So the children are sort of 'adopted'...
168 */
169
170 class WXDLLEXPORT wxMDIClientWindow: public wxWindow
171 {
172 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
173 public:
174
175 wxMDIClientWindow() ;
176 inline wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
177 {
178 CreateClient(parent, style);
179 }
180
181 ~wxMDIClientWindow();
182
183 // Note: this is virtual, to allow overridden behaviour.
184 virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL);
185
186 // Gets the size available for subwindows after menu size, toolbar size
187 // and status bar size have been subtracted. If you want to manage your own
188 // toolbar(s), don't call SetToolBar.
189 void DoGetClientSize(int *width, int *height) const;
190
191 // Explicitly call default scroll behaviour
192 void OnScroll(wxScrollEvent& event);
193
194 protected:
195
196 DECLARE_EVENT_TABLE()
197 };
198
199 #endif
200 // _WX_MDI_H_