]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/mdi.h
tentative fix for BestSize problems (non-native toolbar)
[wxWidgets.git] / include / wx / mac / carbon / mdi.h
CommitLineData
8cf73271
SC
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
65571936 11// Licence: wxWindows licence
8cf73271
SC
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
23WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
24WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
25
26class WXDLLEXPORT wxMDIClientWindow;
27class WXDLLEXPORT wxMDIChildFrame;
28
29class WXDLLEXPORT wxMDIParentFrame: public wxFrame
30{
31 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
32
33public:
34
a57ac1c4
VZ
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)
8cf73271 43 {
a57ac1c4 44 Init();
8cf73271
SC
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
77ffb593 61 // wxWidgets activate event
8cf73271
SC
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; };
0bba37f5
DE
72 // Get rect to be used to center top-level children
73 virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h);
8cf73271
SC
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();
0d97c090 81 virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL);
8cf73271
SC
82 virtual void ArrangeIcons();
83 virtual void ActivateNext();
84 virtual void ActivatePrevious();
85
29e92efb
VZ
86 virtual bool Show( bool show = true );
87
a57ac1c4
VZ
88 // overridden base clas virtuals
89 virtual void AddChild(wxWindowBase *child);
90 virtual void RemoveChild(wxWindowBase *child);
91
8cf73271 92protected:
a57ac1c4
VZ
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;
8cf73271 99
8cf73271 100
a57ac1c4
VZ
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
8cf73271
SC
107 bool m_parentFrameActive;
108
a57ac1c4
VZ
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
8cf73271
SC
113private:
114 friend class WXDLLEXPORT wxMDIChildFrame;
a57ac1c4 115 DECLARE_EVENT_TABLE()
8cf73271
SC
116};
117
118class WXDLLEXPORT wxMDIChildFrame: public wxFrame
119{
120DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
121public:
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();
157protected:
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
170class 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
194protected:
195
196DECLARE_EVENT_TABLE()
197};
198
199#endif
200 // _WX_MDI_H_