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