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