]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/sashwin.h
moved the rest of XPMs to /art
[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
88ac883a 11// Licence: wxWindows license
a6d70308
JS
12/////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_SASHWIN_H_G_
15#define _WX_SASHWIN_H_G_
16
17#ifdef __GNUG__
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
43class WXDLLEXPORT wxSashEdge
44{
45public:
46 wxSashEdge() { m_show = FALSE; m_border = FALSE; m_margin = 0; }
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
70class WXDLLEXPORT wxSashWindow: public wxWindow
71{
72 DECLARE_DYNAMIC_CLASS(wxSashWindow)
73
74public:
75
76////////////////////////////////////////////////////////////////////////////
77// Public API
78
79 // Default constructor
f6bcfd97
BP
80 wxSashWindow()
81 {
82 Init();
83 }
a6d70308
JS
84
85 // Normal constructor
86 wxSashWindow(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
f6bcfd97
BP
87 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = "sashWindow")
88 {
89 Init();
90 Create(parent, id, pos, size, style, name);
91 }
92
a6d70308
JS
93 ~wxSashWindow();
94
f6bcfd97
BP
95 bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
96 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = "sashWindow");
97
a6d70308
JS
98 // Set whether there's a sash in this position
99 void SetSashVisible(wxSashEdgePosition edge, bool sash);
100
101 // Get whether there's a sash in this position
2243eed5 102 inline bool GetSashVisible(wxSashEdgePosition edge) const { return m_sashes[edge].m_show; }
a6d70308
JS
103
104 // Set whether there's a border in this position
105 inline void SetSashBorder(wxSashEdgePosition edge, bool border) { m_sashes[edge].m_border = border; }
106
107 // Get whether there's a border in this position
2243eed5 108 inline bool HasBorder(wxSashEdgePosition edge) const { return m_sashes[edge].m_border; }
a6d70308
JS
109
110 // Get border size
2243eed5 111 inline int GetEdgeMargin(wxSashEdgePosition edge) const { return m_sashes[edge].m_margin; }
a6d70308
JS
112
113 // Sets the default sash border size
114 inline void SetDefaultBorderSize(int width) { m_borderSize = width; }
115
116 // Gets the default sash border size
117 inline int GetDefaultBorderSize() const { return m_borderSize; }
118
119 // Sets the addition border size between child and sash window
120 inline void SetExtraBorderSize(int width) { m_extraBorderSize = width; }
121
122 // Gets the addition border size between child and sash window
123 inline int GetExtraBorderSize() const { return m_extraBorderSize; }
124
125 virtual void SetMinimumSizeX(int min) { m_minimumPaneSizeX = min; }
126 virtual void SetMinimumSizeY(int min) { m_minimumPaneSizeY = min; }
127 virtual int GetMinimumSizeX() const { return m_minimumPaneSizeX; }
128 virtual int GetMinimumSizeY() const { return m_minimumPaneSizeY; }
129
130 virtual void SetMaximumSizeX(int max) { m_maximumPaneSizeX = max; }
131 virtual void SetMaximumSizeY(int max) { m_maximumPaneSizeY = max; }
132 virtual int GetMaximumSizeX() const { return m_maximumPaneSizeX; }
133 virtual int GetMaximumSizeY() const { return m_maximumPaneSizeY; }
134
135////////////////////////////////////////////////////////////////////////////
136// Implementation
137
138 // Paints the border and sash
139 void OnPaint(wxPaintEvent& event);
140
141 // Handles mouse events
142 void OnMouseEvent(wxMouseEvent& ev);
143
144 // Adjusts the panes
145 void OnSize(wxSizeEvent& event);
146
147 // Draws borders
148 void DrawBorders(wxDC& dc);
149
150 // Draws the sashes
151 void DrawSash(wxSashEdgePosition edge, wxDC& dc);
152
153 // Draws the sashes
154 void DrawSashes(wxDC& dc);
155
156 // Draws the sash tracker (for whilst moving the sash)
157 void DrawSashTracker(wxSashEdgePosition edge, int x, int y);
158
159 // Tests for x, y over sash
160 wxSashEdgePosition SashHitTest(int x, int y, int tolerance = 2);
161
162 // Resizes subwindows
163 void SizeWindows();
164
165 // Initialize colours
166 void InitColours();
167
f6bcfd97
BP
168private:
169 void Init();
170
a6d70308
JS
171 wxSashEdge m_sashes[4];
172 int m_dragMode;
173 wxSashEdgePosition m_draggingEdge;
174 int m_oldX;
175 int m_oldY;
176 int m_borderSize;
177 int m_extraBorderSize;
178 int m_firstX;
179 int m_firstY;
180 int m_minimumPaneSizeX;
181 int m_minimumPaneSizeY;
182 int m_maximumPaneSizeX;
183 int m_maximumPaneSizeY;
184 wxCursor* m_sashCursorWE;
185 wxCursor* m_sashCursorNS;
186 wxColour m_lightShadowColour;
187 wxColour m_mediumShadowColour;
188 wxColour m_darkShadowColour;
189 wxColour m_hilightColour;
190 wxColour m_faceColour;
621f9767 191 bool m_mouseCaptured;
a6d70308
JS
192
193DECLARE_EVENT_TABLE()
194};
195
32956769
JS
196BEGIN_DECLARE_EVENT_TYPES()
197 DECLARE_EVENT_TYPE(wxEVT_SASH_DRAGGED, wxEVT_FIRST + 1200)
198END_DECLARE_EVENT_TYPES()
199
200// #define wxEVT_SASH_DRAGGED (wxEVT_FIRST + 1200)
a6d70308
JS
201
202enum wxSashDragStatus
203{
204 wxSASH_STATUS_OK,
205 wxSASH_STATUS_OUT_OF_RANGE
206};
207
208class WXDLLEXPORT wxSashEvent: public wxCommandEvent
209{
210 DECLARE_DYNAMIC_CLASS(wxSashEvent)
211
212 public:
213 inline wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE) {
214 m_eventType = (wxEventType) wxEVT_SASH_DRAGGED; m_id = id; m_edge = edge; }
215
216 inline void SetEdge(wxSashEdgePosition edge) { m_edge = edge; }
217 inline wxSashEdgePosition GetEdge() const { return m_edge; }
218
219 //// The rectangle formed by the drag operation
220 inline void SetDragRect(const wxRect& rect) { m_dragRect = rect; }
221 inline wxRect GetDragRect() const { return m_dragRect; }
222
223 //// Whether the drag caused the rectangle to be reversed (e.g.
224 //// dragging the top below the bottom)
225 inline void SetDragStatus(wxSashDragStatus status) { m_dragStatus = status; }
226 inline wxSashDragStatus GetDragStatus() const { return m_dragStatus; }
227 private:
228 wxSashEdgePosition m_edge;
229 wxRect m_dragRect;
230 wxSashDragStatus m_dragStatus;
231};
232
233typedef void (wxEvtHandler::*wxSashEventFunction)(wxSashEvent&);
234
82a5f02c 235#define EVT_SASH_DRAGGED(id, fn) \
2e4df4bf 236 DECLARE_EVENT_TABLE_ENTRY( wxEVT_SASH_DRAGGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSashEventFunction) & fn, NULL ),
82a5f02c 237#define EVT_SASH_DRAGGED_RANGE(id1, id2, fn) \
2e4df4bf 238 DECLARE_EVENT_TABLE_ENTRY( wxEVT_SASH_DRAGGED, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxSashEventFunction) & fn, NULL ),
a6d70308 239
88ac883a
VZ
240#endif // wxUSE_SASH
241
a6d70308
JS
242#endif
243 // _WX_SASHWIN_H_G_