]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/laywin.h
Fix missing documentation for several GDI functions.
[wxWidgets.git] / include / wx / generic / laywin.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/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 wxUSE_SASH
19 #include "wx/sashwin.h"
20#endif // wxUSE_SASH
21
22#include "wx/event.h"
23
24class WXDLLIMPEXP_FWD_ADV wxQueryLayoutInfoEvent;
25class WXDLLIMPEXP_FWD_ADV wxCalculateLayoutEvent;
26
27wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_QUERY_LAYOUT_INFO, wxQueryLayoutInfoEvent );
28wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALCULATE_LAYOUT, wxCalculateLayoutEvent );
29
30enum wxLayoutOrientation
31{
32 wxLAYOUT_HORIZONTAL,
33 wxLAYOUT_VERTICAL
34};
35
36enum wxLayoutAlignment
37{
38 wxLAYOUT_NONE,
39 wxLAYOUT_TOP,
40 wxLAYOUT_LEFT,
41 wxLAYOUT_RIGHT,
42 wxLAYOUT_BOTTOM
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
61class WXDLLIMPEXP_ADV wxQueryLayoutInfoEvent: public wxEvent
62{
63public:
64 wxQueryLayoutInfoEvent(wxWindowID id = 0)
65 {
66 SetEventType(wxEVT_QUERY_LAYOUT_INFO);
67 m_requestedLength = 0;
68 m_flags = 0;
69 m_id = id;
70 m_alignment = wxLAYOUT_TOP;
71 m_orientation = wxLAYOUT_HORIZONTAL;
72 }
73
74 // Read by the app
75 void SetRequestedLength(int length) { m_requestedLength = length; }
76 int GetRequestedLength() const { return m_requestedLength; }
77
78 void SetFlags(int flags) { m_flags = flags; }
79 int GetFlags() const { return m_flags; }
80
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; }
90
91 virtual wxEvent *Clone() const { return new wxQueryLayoutInfoEvent(*this); }
92
93protected:
94 int m_flags;
95 int m_requestedLength;
96 wxSize m_size;
97 wxLayoutOrientation m_orientation;
98 wxLayoutAlignment m_alignment;
99
100private:
101 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryLayoutInfoEvent)
102};
103
104typedef void (wxEvtHandler::*wxQueryLayoutInfoEventFunction)(wxQueryLayoutInfoEvent&);
105
106#define wxQueryLayoutInfoEventHandler( func ) \
107 wxEVENT_HANDLER_CAST( wxQueryLayoutInfoEventFunction, func )
108
109#define EVT_QUERY_LAYOUT_INFO(func) \
110 wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_QUERY_LAYOUT_INFO, wxID_ANY, wxID_ANY, wxQueryLayoutInfoEventHandler( func ), NULL ),
111
112/*
113 * This event is used to take a bite out of the available client area.
114 */
115
116class WXDLLIMPEXP_ADV wxCalculateLayoutEvent: public wxEvent
117{
118public:
119 wxCalculateLayoutEvent(wxWindowID id = 0)
120 {
121 SetEventType(wxEVT_CALCULATE_LAYOUT);
122 m_flags = 0;
123 m_id = id;
124 }
125
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
136protected:
137 int m_flags;
138 wxRect m_rect;
139
140private:
141 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCalculateLayoutEvent)
142};
143
144typedef void (wxEvtHandler::*wxCalculateLayoutEventFunction)(wxCalculateLayoutEvent&);
145
146#define wxCalculateLayoutEventHandler( func ) wxEVENT_HANDLER_CAST(wxCalculateLayoutEventFunction, func)
147
148#define EVT_CALCULATE_LAYOUT(func) \
149 wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_CALCULATE_LAYOUT, wxID_ANY, wxID_ANY, wxCalculateLayoutEventHandler( func ), NULL ),
150
151#if wxUSE_SASH
152
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.
156class WXDLLIMPEXP_ADV wxSashLayoutWindow: public wxSashWindow
157{
158public:
159 wxSashLayoutWindow()
160 {
161 Init();
162 }
163
164 wxSashLayoutWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
165 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow"))
166 {
167 Create(parent, id, pos, size, style, name);
168 }
169
170 bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
171 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow"));
172
173// Accessors
174 inline wxLayoutAlignment GetAlignment() const { return m_alignment; }
175 inline wxLayoutOrientation GetOrientation() const { return m_orientation; }
176
177 inline void SetAlignment(wxLayoutAlignment align) { m_alignment = align; }
178 inline void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; }
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);
190
191private:
192 void Init();
193
194 wxLayoutAlignment m_alignment;
195 wxLayoutOrientation m_orientation;
196 wxSize m_defaultSize;
197
198private:
199 DECLARE_DYNAMIC_CLASS_NO_COPY(wxSashLayoutWindow)
200 DECLARE_EVENT_TABLE()
201};
202
203#endif // wxUSE_SASH
204
205class WXDLLIMPEXP_FWD_CORE wxMDIParentFrame;
206class WXDLLIMPEXP_FWD_CORE wxFrame;
207
208// This class implements the layout algorithm
209class WXDLLIMPEXP_ADV wxLayoutAlgorithm: public wxObject
210{
211public:
212 wxLayoutAlgorithm() {}
213
214#if wxUSE_MDI_ARCHITECTURE
215 // The MDI client window is sized to whatever's left over.
216 bool LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* rect = NULL);
217#endif // wxUSE_MDI_ARCHITECTURE
218
219 // mainWindow is sized to whatever's left over. This function for backward
220 // compatibility; use LayoutWindow.
221 bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = NULL);
222
223 // mainWindow is sized to whatever's left over.
224 bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = NULL);
225};
226
227#endif
228 // _WX_LAYWIN_H_G_