]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/laywin.h
Removed overloaded DoMenuUpdates function since it duplicated
[wxWidgets.git] / include / wx / generic / laywin.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: laywin.h
3 // Purpose: Implements a simple layout algorithm, plus
4 // wxSashLayoutWindow which is an example of a window with
5 // layout-awareness (via event handlers). This is suited to
6 // IDE-style window layout.
7 // Author: Julian Smart
8 // Modified by:
9 // Created: 04/01/98
10 // RCS-ID: $Id$
11 // Copyright: (c) Julian Smart
12 // Licence: wxWindows licence
13 /////////////////////////////////////////////////////////////////////////////
14
15 #ifndef _WX_LAYWIN_H_G_
16 #define _WX_LAYWIN_H_G_
17
18 #if defined(__GNUG__) && !defined(__APPLE__)
19 #pragma interface "laywin.h"
20 #endif
21
22 #if wxUSE_SASH
23 #include "wx/sashwin.h"
24 #endif // wxUSE_SASH
25
26 BEGIN_DECLARE_EVENT_TYPES()
27 DECLARE_EVENT_TYPE(wxEVT_QUERY_LAYOUT_INFO, 1500)
28 DECLARE_EVENT_TYPE(wxEVT_CALCULATE_LAYOUT, 1501)
29 END_DECLARE_EVENT_TYPES()
30
31 enum wxLayoutOrientation
32 {
33 wxLAYOUT_HORIZONTAL,
34 wxLAYOUT_VERTICAL
35 };
36
37 enum wxLayoutAlignment
38 {
39 wxLAYOUT_NONE,
40 wxLAYOUT_TOP,
41 wxLAYOUT_LEFT,
42 wxLAYOUT_RIGHT,
43 wxLAYOUT_BOTTOM
44 };
45
46 // Not sure this is necessary
47 // Tell window which dimension we're sizing on
48 #define wxLAYOUT_LENGTH_Y 0x0008
49 #define wxLAYOUT_LENGTH_X 0x0000
50
51 // Use most recently used length
52 #define wxLAYOUT_MRU_LENGTH 0x0010
53
54 // Only a query, so don't actually move it.
55 #define wxLAYOUT_QUERY 0x0100
56
57 /*
58 * This event is used to get information about window alignment,
59 * orientation and size.
60 */
61
62 class WXDLLEXPORT wxQueryLayoutInfoEvent: public wxEvent
63 {
64 public:
65 wxQueryLayoutInfoEvent(wxWindowID id = 0)
66 {
67 SetEventType(wxEVT_QUERY_LAYOUT_INFO);
68 m_requestedLength = 0;
69 m_flags = 0;
70 m_id = id;
71 m_alignment = wxLAYOUT_TOP;
72 m_orientation = wxLAYOUT_HORIZONTAL;
73 }
74
75 // Read by the app
76 void SetRequestedLength(int length) { m_requestedLength = length; }
77 int GetRequestedLength() const { return m_requestedLength; }
78
79 void SetFlags(int flags) { m_flags = flags; }
80 int GetFlags() const { return m_flags; }
81
82 // Set by the app
83 void SetSize(const wxSize& size) { m_size = size; }
84 wxSize GetSize() const { return m_size; }
85
86 void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; }
87 wxLayoutOrientation GetOrientation() const { return m_orientation; }
88
89 void SetAlignment(wxLayoutAlignment align) { m_alignment = align; }
90 wxLayoutAlignment GetAlignment() const { return m_alignment; }
91
92 virtual wxEvent *Clone() const { return new wxQueryLayoutInfoEvent(*this); }
93
94 protected:
95 int m_flags;
96 int m_requestedLength;
97 wxSize m_size;
98 wxLayoutOrientation m_orientation;
99 wxLayoutAlignment m_alignment;
100
101 private:
102 DECLARE_DYNAMIC_CLASS(wxQueryLayoutInfoEvent)
103 };
104
105 typedef void (wxEvtHandler::*wxQueryLayoutInfoEventFunction)(wxQueryLayoutInfoEvent&);
106
107 #define EVT_QUERY_LAYOUT_INFO(func) \
108 DECLARE_EVENT_TABLE_ENTRY( wxEVT_QUERY_LAYOUT_INFO, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxQueryLayoutInfoEventFunction) & func, NULL ),
109
110 /*
111 * This event is used to take a bite out of the available client area.
112 */
113
114 class WXDLLEXPORT wxCalculateLayoutEvent: public wxEvent
115 {
116 public:
117 wxCalculateLayoutEvent(wxWindowID id = 0)
118 {
119 SetEventType(wxEVT_CALCULATE_LAYOUT);
120 m_flags = 0;
121 m_id = id;
122 }
123
124 // Read by the app
125 void SetFlags(int flags) { m_flags = flags; }
126 int GetFlags() const { return m_flags; }
127
128 // Set by the app
129 void SetRect(const wxRect& rect) { m_rect = rect; }
130 wxRect GetRect() const { return m_rect; }
131
132 virtual wxEvent *Clone() const { return new wxCalculateLayoutEvent(*this); }
133
134 protected:
135 int m_flags;
136 wxRect m_rect;
137
138 private:
139 DECLARE_DYNAMIC_CLASS(wxCalculateLayoutEvent)
140 };
141
142 typedef void (wxEvtHandler::*wxCalculateLayoutEventFunction)(wxCalculateLayoutEvent&);
143
144 #define EVT_CALCULATE_LAYOUT(func) \
145 DECLARE_EVENT_TABLE_ENTRY( wxEVT_CALCULATE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCalculateLayoutEventFunction) & func, NULL ),
146
147 #if wxUSE_SASH
148
149 // This is window that can remember alignment/orientation, does its own layout,
150 // and can provide sashes too. Useful for implementing docked windows with sashes in
151 // an IDE-style interface.
152 class WXDLLEXPORT wxSashLayoutWindow: public wxSashWindow
153 {
154 public:
155 wxSashLayoutWindow()
156 {
157 Init();
158 }
159
160 wxSashLayoutWindow(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
161 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow"))
162 {
163 Create(parent, id, pos, size, style, name);
164 }
165
166 bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
167 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow"));
168
169 // Accessors
170 inline wxLayoutAlignment GetAlignment() const { return m_alignment; };
171 inline wxLayoutOrientation GetOrientation() const { return m_orientation; };
172
173 inline void SetAlignment(wxLayoutAlignment align) { m_alignment = align; };
174 inline void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; };
175
176 // Give the window default dimensions
177 inline void SetDefaultSize(const wxSize& size) { m_defaultSize = size; }
178
179 // Event handlers
180 // Called by layout algorithm to allow window to take a bit out of the
181 // client rectangle, and size itself if not in wxLAYOUT_QUERY mode.
182 void OnCalculateLayout(wxCalculateLayoutEvent& event);
183
184 // Called by layout algorithm to retrieve information about the window.
185 void OnQueryLayoutInfo(wxQueryLayoutInfoEvent& event);
186
187 private:
188 void Init();
189
190 wxLayoutAlignment m_alignment;
191 wxLayoutOrientation m_orientation;
192 wxSize m_defaultSize;
193
194 private:
195 DECLARE_CLASS(wxSashLayoutWindow)
196 DECLARE_EVENT_TABLE()
197 };
198
199 #endif // wxUSE_SASH
200
201 class WXDLLEXPORT wxMDIParentFrame;
202 class WXDLLEXPORT wxFrame;
203
204 // This class implements the layout algorithm
205 class WXDLLEXPORT wxLayoutAlgorithm: public wxObject
206 {
207 public:
208 wxLayoutAlgorithm() {}
209
210 #if wxUSE_MDI_ARCHITECTURE
211 // The MDI client window is sized to whatever's left over.
212 bool LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* rect = (wxRect*) NULL);
213 #endif // wxUSE_MDI_ARCHITECTURE
214
215 // mainWindow is sized to whatever's left over. This function for backward
216 // compatibility; use LayoutWindow.
217 bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = (wxWindow*) NULL);
218
219 // mainWindow is sized to whatever's left over.
220 bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = (wxWindow*) NULL);
221 };
222
223 #endif
224 // _WX_LAYWIN_H_G_