]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/laywin.h
Use the OOR typemap for wxTreeCtrls too.
[wxWidgets.git] / include / wx / generic / laywin.h
CommitLineData
a6d70308
JS
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
afce4c03 12// Licence: wxWindows licence
a6d70308
JS
13/////////////////////////////////////////////////////////////////////////////
14
15#ifndef _WX_LAYWIN_H_G_
16#define _WX_LAYWIN_H_G_
17
18#ifdef __GNUG__
19#pragma interface "laywin.h"
20#endif
21
88ac883a
VZ
22#if wxUSE_SASH
23 #include "wx/sashwin.h"
24#endif // wxUSE_SASH
a6d70308 25
2e4df4bf
VZ
26BEGIN_DECLARE_EVENT_TYPES()
27 DECLARE_EVENT_TYPE(wxEVT_QUERY_LAYOUT_INFO, 1500)
28 DECLARE_EVENT_TYPE(wxEVT_CALCULATE_LAYOUT, 1501)
29END_DECLARE_EVENT_TYPES()
a6d70308 30
88ac883a
VZ
31enum wxLayoutOrientation
32{
a6d70308
JS
33 wxLAYOUT_HORIZONTAL,
34 wxLAYOUT_VERTICAL
35};
36
88ac883a
VZ
37enum wxLayoutAlignment
38{
a6d70308
JS
39 wxLAYOUT_NONE,
40 wxLAYOUT_TOP,
41 wxLAYOUT_LEFT,
42 wxLAYOUT_RIGHT,
afce4c03 43 wxLAYOUT_BOTTOM
a6d70308
JS
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
937cf827 62class WXDLLEXPORT wxQueryLayoutInfoEvent: public wxEvent
a6d70308
JS
63{
64DECLARE_DYNAMIC_CLASS(wxQueryLayoutInfoEvent)
65public:
66
67 wxQueryLayoutInfoEvent(wxWindowID id = 0)
68 {
69 SetEventType(wxEVT_QUERY_LAYOUT_INFO);
70 m_requestedLength = 0;
71 m_flags = 0;
8cb50e4b 72 m_id = id;
a6d70308
JS
73 m_alignment = wxLAYOUT_TOP;
74 m_orientation = wxLAYOUT_HORIZONTAL;
75 }
a6d70308 76
bfc6fde4
VZ
77 // Read by the app
78 void SetRequestedLength(int length) { m_requestedLength = length; }
79 int GetRequestedLength() const { return m_requestedLength; }
a6d70308 80
bfc6fde4
VZ
81 void SetFlags(int flags) { m_flags = flags; }
82 int GetFlags() const { return m_flags; }
a6d70308 83
bfc6fde4
VZ
84 // Set by the app
85 void SetSize(const wxSize& size) { m_size = size; }
86 wxSize GetSize() const { return m_size; }
87
88 void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; }
89 wxLayoutOrientation GetOrientation() const { return m_orientation; }
90
91 void SetAlignment(wxLayoutAlignment align) { m_alignment = align; }
92 wxLayoutAlignment GetAlignment() const { return m_alignment; }
a6d70308 93
acd15a3f
VZ
94 virtual wxEvent *Clone() const { return new wxQueryLayoutInfoEvent(*this); }
95
a6d70308
JS
96protected:
97 int m_flags;
98 int m_requestedLength;
99 wxSize m_size;
100 wxLayoutOrientation m_orientation;
101 wxLayoutAlignment m_alignment;
102
103};
104
105typedef void (wxEvtHandler::*wxQueryLayoutInfoEventFunction)(wxQueryLayoutInfoEvent&);
106
82a5f02c 107#define EVT_QUERY_LAYOUT_INFO(func) \
2e4df4bf 108 DECLARE_EVENT_TABLE_ENTRY( wxEVT_QUERY_LAYOUT_INFO, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxQueryLayoutInfoEventFunction) & func, NULL ),
a6d70308
JS
109
110/*
111 * This event is used to take a bite out of the available client area.
112 */
113
937cf827 114class WXDLLEXPORT wxCalculateLayoutEvent: public wxEvent
a6d70308
JS
115{
116DECLARE_DYNAMIC_CLASS(wxCalculateLayoutEvent)
117public:
118 wxCalculateLayoutEvent(wxWindowID id = 0)
119 {
120 SetEventType(wxEVT_CALCULATE_LAYOUT);
121 m_flags = 0;
afce4c03 122 m_id = id;
a6d70308 123 }
a6d70308 124
acd15a3f
VZ
125 // Read by the app
126 void SetFlags(int flags) { m_flags = flags; }
127 int GetFlags() const { return m_flags; }
128
129 // Set by the app
130 void SetRect(const wxRect& rect) { m_rect = rect; }
131 wxRect GetRect() const { return m_rect; }
132
133 virtual wxEvent *Clone() const { return new wxCalculateLayoutEvent(*this); }
134
a6d70308
JS
135protected:
136 int m_flags;
137 wxRect m_rect;
138};
139
140typedef void (wxEvtHandler::*wxCalculateLayoutEventFunction)(wxCalculateLayoutEvent&);
141
82a5f02c 142#define EVT_CALCULATE_LAYOUT(func) \
2e4df4bf 143 DECLARE_EVENT_TABLE_ENTRY( wxEVT_CALCULATE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCalculateLayoutEventFunction) & func, NULL ),
a6d70308 144
88ac883a
VZ
145#if wxUSE_SASH
146
a6d70308
JS
147// This is window that can remember alignment/orientation, does its own layout,
148// and can provide sashes too. Useful for implementing docked windows with sashes in
149// an IDE-style interface.
937cf827 150class WXDLLEXPORT wxSashLayoutWindow: public wxSashWindow
a6d70308
JS
151{
152 DECLARE_CLASS(wxSashLayoutWindow)
153public:
f6bcfd97
BP
154 wxSashLayoutWindow()
155 {
156 Init();
157 }
158
a6d70308 159 wxSashLayoutWindow(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
f6bcfd97
BP
160 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = "layoutWindow")
161 {
162 Create(parent, id, pos, size, style, name);
163 }
164
165 bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
a6d70308
JS
166 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = "layoutWindow");
167
168// Accessors
169 inline wxLayoutAlignment GetAlignment() const { return m_alignment; };
170 inline wxLayoutOrientation GetOrientation() const { return m_orientation; };
171
172 inline void SetAlignment(wxLayoutAlignment align) { m_alignment = align; };
173 inline void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; };
174
175 // Give the window default dimensions
176 inline void SetDefaultSize(const wxSize& size) { m_defaultSize = size; }
177
178// Event handlers
179 // Called by layout algorithm to allow window to take a bit out of the
180 // client rectangle, and size itself if not in wxLAYOUT_QUERY mode.
181 void OnCalculateLayout(wxCalculateLayoutEvent& event);
182
183 // Called by layout algorithm to retrieve information about the window.
184 void OnQueryLayoutInfo(wxQueryLayoutInfoEvent& event);
f6bcfd97
BP
185
186private:
187 void Init();
188
a6d70308
JS
189 wxLayoutAlignment m_alignment;
190 wxLayoutOrientation m_orientation;
191 wxSize m_defaultSize;
192
193DECLARE_EVENT_TABLE()
194};
195
88ac883a
VZ
196#endif // wxUSE_SASH
197
a6d70308
JS
198class WXDLLEXPORT wxMDIParentFrame;
199class WXDLLEXPORT wxFrame;
200
201// This class implements the layout algorithm
937cf827 202class WXDLLEXPORT wxLayoutAlgorithm: public wxObject
a6d70308
JS
203{
204public:
205 wxLayoutAlgorithm() {}
206
1e6feb95 207#if wxUSE_MDI_ARCHITECTURE
a6d70308 208 // The MDI client window is sized to whatever's left over.
2243eed5 209 bool LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* rect = (wxRect*) NULL);
1e6feb95 210#endif // wxUSE_MDI_ARCHITECTURE
a6d70308 211
f9b1708c
JS
212 // mainWindow is sized to whatever's left over. This function for backward
213 // compatibility; use LayoutWindow.
04dbb646 214 bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = (wxWindow*) NULL);
f9b1708c 215
f6bcfd97 216 // mainWindow is sized to whatever's left over.
f9b1708c 217 bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = (wxWindow*) NULL);
a6d70308
JS
218};
219
220#endif
221 // _WX_LAYWIN_H_G_