]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/sashwin.h
added wxDynamicLibrary::GetSymbolAorW()
[wxWidgets.git] / include / wx / generic / sashwin.h
CommitLineData
a6d70308
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: sashwin.h
3// Purpose: wxSashWindow implementation. A sash window has an optional
4// sash on each edge, allowing it to be dragged. An event
5// is generated when the sash is released.
6// Author: Julian Smart
7// Modified by:
8// Created: 01/02/97
9// RCS-ID: $Id$
10// Copyright: (c) Julian Smart
65571936 11// Licence: wxWindows licence
a6d70308
JS
12/////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_SASHWIN_H_G_
15#define _WX_SASHWIN_H_G_
16
12028905 17#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
a6d70308
JS
18#pragma interface "sashwin.h"
19#endif
20
88ac883a
VZ
21#if wxUSE_SASH
22
a6d70308
JS
23#include "wx/defs.h"
24#include "wx/window.h"
25#include "wx/string.h"
26
27#define wxSASH_DRAG_NONE 0
28#define wxSASH_DRAG_DRAGGING 1
29#define wxSASH_DRAG_LEFT_DOWN 2
30
31enum wxSashEdgePosition {
32 wxSASH_TOP = 0,
33 wxSASH_RIGHT,
34 wxSASH_BOTTOM,
35 wxSASH_LEFT,
36 wxSASH_NONE = 100
37};
38
39/*
40 * wxSashEdge represents one of the four edges of a window.
41 */
42
12f190b0 43class WXDLLIMPEXP_ADV wxSashEdge
a6d70308
JS
44{
45public:
ca65c044 46 wxSashEdge() { m_show = false; m_border = false; m_margin = 0; }
a6d70308
JS
47
48 bool m_show; // Is the sash showing?
49 bool m_border; // Do we draw a border?
50 int m_margin; // The margin size
51};
52
53/*
54 * wxSashWindow flags
55 */
56
448af9a4 57#define wxSW_NOBORDER 0x0000
f6bcfd97 58//#define wxSW_3D 0x0010
448af9a4 59#define wxSW_BORDER 0x0020
f6bcfd97
BP
60#define wxSW_3DSASH 0x0040
61#define wxSW_3DBORDER 0x0080
62#define wxSW_3D (wxSW_3DSASH | wxSW_3DBORDER)
a6d70308
JS
63
64/*
65 * wxSashWindow allows any of its edges to have a sash which can be dragged
66 * to resize the window. The actual content window will be created as a child
67 * of wxSashWindow.
68 */
69
12f190b0 70class WXDLLIMPEXP_ADV wxSashWindow: public wxWindow
a6d70308 71{
a6d70308 72public:
a6d70308 73 // Default constructor
f6bcfd97
BP
74 wxSashWindow()
75 {
76 Init();
77 }
a6d70308
JS
78
79 // Normal constructor
ca65c044 80 wxSashWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
2b5f62a0 81 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow"))
f6bcfd97
BP
82 {
83 Init();
84 Create(parent, id, pos, size, style, name);
85 }
86
a6d70308
JS
87 ~wxSashWindow();
88
ca65c044 89 bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
2b5f62a0 90 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow"));
f6bcfd97 91
a6d70308
JS
92 // Set whether there's a sash in this position
93 void SetSashVisible(wxSashEdgePosition edge, bool sash);
94
95 // Get whether there's a sash in this position
40717c90 96 bool GetSashVisible(wxSashEdgePosition edge) const { return m_sashes[edge].m_show; }
a6d70308
JS
97
98 // Set whether there's a border in this position
40717c90 99 void SetSashBorder(wxSashEdgePosition edge, bool border) { m_sashes[edge].m_border = border; }
a6d70308
JS
100
101 // Get whether there's a border in this position
40717c90 102 bool HasBorder(wxSashEdgePosition edge) const { return m_sashes[edge].m_border; }
a6d70308
JS
103
104 // Get border size
40717c90 105 int GetEdgeMargin(wxSashEdgePosition edge) const { return m_sashes[edge].m_margin; }
a6d70308
JS
106
107 // Sets the default sash border size
40717c90 108 void SetDefaultBorderSize(int width) { m_borderSize = width; }
a6d70308
JS
109
110 // Gets the default sash border size
40717c90 111 int GetDefaultBorderSize() const { return m_borderSize; }
a6d70308
JS
112
113 // Sets the addition border size between child and sash window
40717c90 114 void SetExtraBorderSize(int width) { m_extraBorderSize = width; }
a6d70308
JS
115
116 // Gets the addition border size between child and sash window
40717c90 117 int GetExtraBorderSize() const { return m_extraBorderSize; }
a6d70308
JS
118
119 virtual void SetMinimumSizeX(int min) { m_minimumPaneSizeX = min; }
120 virtual void SetMinimumSizeY(int min) { m_minimumPaneSizeY = min; }
121 virtual int GetMinimumSizeX() const { return m_minimumPaneSizeX; }
122 virtual int GetMinimumSizeY() const { return m_minimumPaneSizeY; }
123
124 virtual void SetMaximumSizeX(int max) { m_maximumPaneSizeX = max; }
125 virtual void SetMaximumSizeY(int max) { m_maximumPaneSizeY = max; }
126 virtual int GetMaximumSizeX() const { return m_maximumPaneSizeX; }
127 virtual int GetMaximumSizeY() const { return m_maximumPaneSizeY; }
128
129////////////////////////////////////////////////////////////////////////////
130// Implementation
131
132 // Paints the border and sash
133 void OnPaint(wxPaintEvent& event);
134
135 // Handles mouse events
136 void OnMouseEvent(wxMouseEvent& ev);
137
138 // Adjusts the panes
139 void OnSize(wxSizeEvent& event);
140
91ce04cf 141#if defined(__WXMSW__) || defined(__WXMAC__)
2b5f62a0
VZ
142 // Handle cursor correctly
143 void OnSetCursor(wxSetCursorEvent& event);
144#endif // wxMSW
145
a6d70308
JS
146 // Draws borders
147 void DrawBorders(wxDC& dc);
148
149 // Draws the sashes
150 void DrawSash(wxSashEdgePosition edge, wxDC& dc);
151
152 // Draws the sashes
153 void DrawSashes(wxDC& dc);
154
155 // Draws the sash tracker (for whilst moving the sash)
156 void DrawSashTracker(wxSashEdgePosition edge, int x, int y);
157
158 // Tests for x, y over sash
159 wxSashEdgePosition SashHitTest(int x, int y, int tolerance = 2);
160
161 // Resizes subwindows
162 void SizeWindows();
163
164 // Initialize colours
165 void InitColours();
166
f6bcfd97
BP
167private:
168 void Init();
169
a6d70308
JS
170 wxSashEdge m_sashes[4];
171 int m_dragMode;
172 wxSashEdgePosition m_draggingEdge;
173 int m_oldX;
174 int m_oldY;
175 int m_borderSize;
176 int m_extraBorderSize;
177 int m_firstX;
178 int m_firstY;
179 int m_minimumPaneSizeX;
180 int m_minimumPaneSizeY;
181 int m_maximumPaneSizeX;
182 int m_maximumPaneSizeY;
183 wxCursor* m_sashCursorWE;
184 wxCursor* m_sashCursorNS;
185 wxColour m_lightShadowColour;
186 wxColour m_mediumShadowColour;
187 wxColour m_darkShadowColour;
188 wxColour m_hilightColour;
189 wxColour m_faceColour;
621f9767 190 bool m_mouseCaptured;
2b5f62a0 191 wxCursor* m_currentCursor;
a6d70308 192
2b5f62a0
VZ
193private:
194 DECLARE_DYNAMIC_CLASS(wxSashWindow)
195 DECLARE_EVENT_TABLE()
22f3361e 196 DECLARE_NO_COPY_CLASS(wxSashWindow)
a6d70308
JS
197};
198
32956769 199BEGIN_DECLARE_EVENT_TYPES()
12f190b0
VS
200 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV,
201 wxEVT_SASH_DRAGGED, wxEVT_FIRST + 1200)
32956769
JS
202END_DECLARE_EVENT_TYPES()
203
a6d70308
JS
204enum wxSashDragStatus
205{
206 wxSASH_STATUS_OK,
207 wxSASH_STATUS_OUT_OF_RANGE
208};
209
12f190b0 210class WXDLLIMPEXP_ADV wxSashEvent: public wxCommandEvent
a6d70308 211{
2b5f62a0 212public:
40717c90
VZ
213 wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE)
214 {
215 m_eventType = (wxEventType) wxEVT_SASH_DRAGGED;
216 m_id = id;
217 m_edge = edge;
218 }
a6d70308 219
40717c90
VZ
220 void SetEdge(wxSashEdgePosition edge) { m_edge = edge; }
221 wxSashEdgePosition GetEdge() const { return m_edge; }
a6d70308
JS
222
223 //// The rectangle formed by the drag operation
40717c90
VZ
224 void SetDragRect(const wxRect& rect) { m_dragRect = rect; }
225 wxRect GetDragRect() const { return m_dragRect; }
a6d70308
JS
226
227 //// Whether the drag caused the rectangle to be reversed (e.g.
228 //// dragging the top below the bottom)
40717c90
VZ
229 void SetDragStatus(wxSashDragStatus status) { m_dragStatus = status; }
230 wxSashDragStatus GetDragStatus() const { return m_dragStatus; }
ca65c044 231
2b5f62a0 232private:
a6d70308
JS
233 wxSashEdgePosition m_edge;
234 wxRect m_dragRect;
235 wxSashDragStatus m_dragStatus;
2b5f62a0
VZ
236
237private:
2eb10e2a 238 DECLARE_DYNAMIC_CLASS_NO_COPY(wxSashEvent)
a6d70308
JS
239};
240
241typedef void (wxEvtHandler::*wxSashEventFunction)(wxSashEvent&);
242
40717c90
VZ
243#define wxSashEventHandler(func) \
244 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSashEventFunction, &func)
245
82a5f02c 246#define EVT_SASH_DRAGGED(id, fn) \
40717c90 247 wx__DECLARE_EVT1(wxEVT_SASH_DRAGGED, id, wxSashEventHandler(fn))
82a5f02c 248#define EVT_SASH_DRAGGED_RANGE(id1, id2, fn) \
40717c90 249 wx__DECLARE_EVT2(wxEVT_SASH_DRAGGED, id1, id2, wxSashEventHandler(fn))
a6d70308 250
88ac883a
VZ
251#endif // wxUSE_SASH
252
a6d70308
JS
253#endif
254 // _WX_SASHWIN_H_G_