]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/laywin.h
simplifications and corrections to background drawing:
[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
65571936 12// Licence: wxWindows licence
a6d70308
JS
13/////////////////////////////////////////////////////////////////////////////
14
15#ifndef _WX_LAYWIN_H_G_
16#define _WX_LAYWIN_H_G_
17
12028905 18#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
a6d70308
JS
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 26BEGIN_DECLARE_EVENT_TYPES()
12f190b0
VS
27 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_QUERY_LAYOUT_INFO, 1500)
28 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALCULATE_LAYOUT, 1501)
2e4df4bf 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
12f190b0 62class WXDLLIMPEXP_ADV wxQueryLayoutInfoEvent: public wxEvent
a6d70308 63{
a6d70308 64public:
a6d70308
JS
65 wxQueryLayoutInfoEvent(wxWindowID id = 0)
66 {
67 SetEventType(wxEVT_QUERY_LAYOUT_INFO);
68 m_requestedLength = 0;
69 m_flags = 0;
8cb50e4b 70 m_id = id;
a6d70308
JS
71 m_alignment = wxLAYOUT_TOP;
72 m_orientation = wxLAYOUT_HORIZONTAL;
73 }
a6d70308 74
bfc6fde4
VZ
75 // Read by the app
76 void SetRequestedLength(int length) { m_requestedLength = length; }
77 int GetRequestedLength() const { return m_requestedLength; }
a6d70308 78
bfc6fde4
VZ
79 void SetFlags(int flags) { m_flags = flags; }
80 int GetFlags() const { return m_flags; }
a6d70308 81
bfc6fde4
VZ
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; }
a6d70308 91
acd15a3f
VZ
92 virtual wxEvent *Clone() const { return new wxQueryLayoutInfoEvent(*this); }
93
a6d70308
JS
94protected:
95 int m_flags;
96 int m_requestedLength;
97 wxSize m_size;
98 wxLayoutOrientation m_orientation;
99 wxLayoutAlignment m_alignment;
ca65c044 100
2b5f62a0 101private:
a6cbc4db 102 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryLayoutInfoEvent)
a6d70308
JS
103};
104
105typedef void (wxEvtHandler::*wxQueryLayoutInfoEventFunction)(wxQueryLayoutInfoEvent&);
106
82a5f02c 107#define EVT_QUERY_LAYOUT_INFO(func) \
ca65c044 108 DECLARE_EVENT_TABLE_ENTRY( wxEVT_QUERY_LAYOUT_INFO, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxQueryLayoutInfoEventFunction, & func ), NULL ),
a6d70308
JS
109
110/*
111 * This event is used to take a bite out of the available client area.
112 */
113
12f190b0 114class WXDLLIMPEXP_ADV wxCalculateLayoutEvent: public wxEvent
a6d70308 115{
a6d70308
JS
116public:
117 wxCalculateLayoutEvent(wxWindowID id = 0)
118 {
119 SetEventType(wxEVT_CALCULATE_LAYOUT);
120 m_flags = 0;
afce4c03 121 m_id = id;
a6d70308 122 }
a6d70308 123
acd15a3f
VZ
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
a6d70308
JS
134protected:
135 int m_flags;
136 wxRect m_rect;
ca65c044 137
2b5f62a0 138private:
a6cbc4db 139 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCalculateLayoutEvent)
a6d70308
JS
140};
141
142typedef void (wxEvtHandler::*wxCalculateLayoutEventFunction)(wxCalculateLayoutEvent&);
143
82a5f02c 144#define EVT_CALCULATE_LAYOUT(func) \
ca65c044 145 DECLARE_EVENT_TABLE_ENTRY( wxEVT_CALCULATE_LAYOUT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxCalculateLayoutEventFunction, & func ), NULL ),
a6d70308 146
88ac883a
VZ
147#if wxUSE_SASH
148
a6d70308
JS
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.
12f190b0 152class WXDLLIMPEXP_ADV wxSashLayoutWindow: public wxSashWindow
a6d70308 153{
a6d70308 154public:
f6bcfd97
BP
155 wxSashLayoutWindow()
156 {
157 Init();
158 }
159
ca65c044 160 wxSashLayoutWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
2b5f62a0 161 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow"))
f6bcfd97
BP
162 {
163 Create(parent, id, pos, size, style, name);
164 }
165
ca65c044 166 bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
2b5f62a0 167 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow"));
a6d70308
JS
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);
f6bcfd97
BP
186
187private:
188 void Init();
189
a6d70308
JS
190 wxLayoutAlignment m_alignment;
191 wxLayoutOrientation m_orientation;
192 wxSize m_defaultSize;
193
2b5f62a0 194private:
2eb10e2a 195 DECLARE_DYNAMIC_CLASS_NO_COPY(wxSashLayoutWindow)
2b5f62a0 196 DECLARE_EVENT_TABLE()
a6d70308
JS
197};
198
88ac883a
VZ
199#endif // wxUSE_SASH
200
a6d70308
JS
201class WXDLLEXPORT wxMDIParentFrame;
202class WXDLLEXPORT wxFrame;
203
204// This class implements the layout algorithm
12f190b0 205class WXDLLIMPEXP_ADV wxLayoutAlgorithm: public wxObject
a6d70308
JS
206{
207public:
208 wxLayoutAlgorithm() {}
209
1e6feb95 210#if wxUSE_MDI_ARCHITECTURE
a6d70308 211 // The MDI client window is sized to whatever's left over.
2243eed5 212 bool LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* rect = (wxRect*) NULL);
1e6feb95 213#endif // wxUSE_MDI_ARCHITECTURE
a6d70308 214
f9b1708c
JS
215 // mainWindow is sized to whatever's left over. This function for backward
216 // compatibility; use LayoutWindow.
04dbb646 217 bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = (wxWindow*) NULL);
f9b1708c 218
f6bcfd97 219 // mainWindow is sized to whatever's left over.
f9b1708c 220 bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = (wxWindow*) NULL);
a6d70308
JS
221};
222
223#endif
224 // _WX_LAYWIN_H_G_