]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/laywin.h
readded wxEVT_HELP inadvertently deleted the last time
[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
82a5f02c
RR
26extern const int wxEVT_QUERY_LAYOUT_INFO;
27extern const int wxEVT_CALCULATE_LAYOUT;
a6d70308 28
88ac883a
VZ
29enum wxLayoutOrientation
30{
a6d70308
JS
31 wxLAYOUT_HORIZONTAL,
32 wxLAYOUT_VERTICAL
33};
34
88ac883a
VZ
35enum wxLayoutAlignment
36{
a6d70308
JS
37 wxLAYOUT_NONE,
38 wxLAYOUT_TOP,
39 wxLAYOUT_LEFT,
40 wxLAYOUT_RIGHT,
afce4c03 41 wxLAYOUT_BOTTOM
a6d70308
JS
42};
43
44// Not sure this is necessary
45// Tell window which dimension we're sizing on
46#define wxLAYOUT_LENGTH_Y 0x0008
47#define wxLAYOUT_LENGTH_X 0x0000
48
49// Use most recently used length
50#define wxLAYOUT_MRU_LENGTH 0x0010
51
52// Only a query, so don't actually move it.
53#define wxLAYOUT_QUERY 0x0100
54
55/*
56 * This event is used to get information about window alignment,
57 * orientation and size.
58 */
59
937cf827 60class WXDLLEXPORT wxQueryLayoutInfoEvent: public wxEvent
a6d70308
JS
61{
62DECLARE_DYNAMIC_CLASS(wxQueryLayoutInfoEvent)
63public:
64
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
a6d70308
JS
92protected:
93 int m_flags;
94 int m_requestedLength;
95 wxSize m_size;
96 wxLayoutOrientation m_orientation;
97 wxLayoutAlignment m_alignment;
98
99};
100
101typedef void (wxEvtHandler::*wxQueryLayoutInfoEventFunction)(wxQueryLayoutInfoEvent&);
102
82a5f02c
RR
103#define EVT_QUERY_LAYOUT_INFO(func) \
104 wxEventTableEntry( wxEVT_QUERY_LAYOUT_INFO, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxQueryLayoutInfoEventFunction) & func, NULL ),
a6d70308
JS
105
106/*
107 * This event is used to take a bite out of the available client area.
108 */
109
937cf827 110class WXDLLEXPORT wxCalculateLayoutEvent: public wxEvent
a6d70308
JS
111{
112DECLARE_DYNAMIC_CLASS(wxCalculateLayoutEvent)
113public:
114 wxCalculateLayoutEvent(wxWindowID id = 0)
115 {
116 SetEventType(wxEVT_CALCULATE_LAYOUT);
117 m_flags = 0;
afce4c03 118 m_id = id;
a6d70308
JS
119 }
120// Read by the app
121 inline void SetFlags(int flags) { m_flags = flags; }
122 inline int GetFlags() const { return m_flags; }
123
124// Set by the app
125 inline void SetRect(const wxRect& rect) { m_rect = rect; }
126 inline wxRect GetRect() const { return m_rect; }
127protected:
128 int m_flags;
129 wxRect m_rect;
130};
131
132typedef void (wxEvtHandler::*wxCalculateLayoutEventFunction)(wxCalculateLayoutEvent&);
133
82a5f02c
RR
134#define EVT_CALCULATE_LAYOUT(func) \
135 wxEventTableEntry( wxEVT_CALCULATE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCalculateLayoutEventFunction) & func, NULL ),
a6d70308 136
88ac883a
VZ
137#if wxUSE_SASH
138
a6d70308
JS
139// This is window that can remember alignment/orientation, does its own layout,
140// and can provide sashes too. Useful for implementing docked windows with sashes in
141// an IDE-style interface.
937cf827 142class WXDLLEXPORT wxSashLayoutWindow: public wxSashWindow
a6d70308
JS
143{
144 DECLARE_CLASS(wxSashLayoutWindow)
145public:
f6bcfd97
BP
146 wxSashLayoutWindow()
147 {
148 Init();
149 }
150
a6d70308 151 wxSashLayoutWindow(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
f6bcfd97
BP
152 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = "layoutWindow")
153 {
154 Create(parent, id, pos, size, style, name);
155 }
156
157 bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
a6d70308
JS
158 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = "layoutWindow");
159
160// Accessors
161 inline wxLayoutAlignment GetAlignment() const { return m_alignment; };
162 inline wxLayoutOrientation GetOrientation() const { return m_orientation; };
163
164 inline void SetAlignment(wxLayoutAlignment align) { m_alignment = align; };
165 inline void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; };
166
167 // Give the window default dimensions
168 inline void SetDefaultSize(const wxSize& size) { m_defaultSize = size; }
169
170// Event handlers
171 // Called by layout algorithm to allow window to take a bit out of the
172 // client rectangle, and size itself if not in wxLAYOUT_QUERY mode.
173 void OnCalculateLayout(wxCalculateLayoutEvent& event);
174
175 // Called by layout algorithm to retrieve information about the window.
176 void OnQueryLayoutInfo(wxQueryLayoutInfoEvent& event);
f6bcfd97
BP
177
178private:
179 void Init();
180
a6d70308
JS
181 wxLayoutAlignment m_alignment;
182 wxLayoutOrientation m_orientation;
183 wxSize m_defaultSize;
184
185DECLARE_EVENT_TABLE()
186};
187
88ac883a
VZ
188#endif // wxUSE_SASH
189
a6d70308
JS
190class WXDLLEXPORT wxMDIParentFrame;
191class WXDLLEXPORT wxFrame;
192
193// This class implements the layout algorithm
937cf827 194class WXDLLEXPORT wxLayoutAlgorithm: public wxObject
a6d70308
JS
195{
196public:
197 wxLayoutAlgorithm() {}
198
199 // The MDI client window is sized to whatever's left over.
2243eed5 200 bool LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* rect = (wxRect*) NULL);
a6d70308 201
f9b1708c
JS
202 // mainWindow is sized to whatever's left over. This function for backward
203 // compatibility; use LayoutWindow.
204 bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = (wxWindow*) NULL)
205 {
206 return LayoutWindow(frame, mainWindow);
207 }
208
f6bcfd97 209 // mainWindow is sized to whatever's left over.
f9b1708c 210 bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = (wxWindow*) NULL);
a6d70308
JS
211};
212
213#endif
214 // _WX_LAYWIN_H_G_