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