]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/sashwin.h
Fix for VA 4.0
[wxWidgets.git] / include / wx / generic / sashwin.h
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
11 // Licence: wxWindows license
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
21 #if wxUSE_SASH
22
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
31 enum 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
43 class WXDLLEXPORT wxSashEdge
44 {
45 public:
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
57 #define wxSW_NOBORDER 0x0000
58 #define wxSW_3D 0x0010
59 #define wxSW_BORDER 0x0020
60
61 /*
62 * wxSashWindow allows any of its edges to have a sash which can be dragged
63 * to resize the window. The actual content window will be created as a child
64 * of wxSashWindow.
65 */
66
67 class WXDLLEXPORT wxSashWindow: public wxWindow
68 {
69 DECLARE_DYNAMIC_CLASS(wxSashWindow)
70
71 public:
72
73 ////////////////////////////////////////////////////////////////////////////
74 // Public API
75
76 // Default constructor
77 wxSashWindow();
78
79 // Normal constructor
80 wxSashWindow(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
81 const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = "sashWindow");
82 ~wxSashWindow();
83
84 // Set whether there's a sash in this position
85 void SetSashVisible(wxSashEdgePosition edge, bool sash);
86
87 // Get whether there's a sash in this position
88 inline bool GetSashVisible(wxSashEdgePosition edge) const { return m_sashes[edge].m_show; }
89
90 // Set whether there's a border in this position
91 inline void SetSashBorder(wxSashEdgePosition edge, bool border) { m_sashes[edge].m_border = border; }
92
93 // Get whether there's a border in this position
94 inline bool HasBorder(wxSashEdgePosition edge) const { return m_sashes[edge].m_border; }
95
96 // Get border size
97 inline int GetEdgeMargin(wxSashEdgePosition edge) const { return m_sashes[edge].m_margin; }
98
99 // Sets the default sash border size
100 inline void SetDefaultBorderSize(int width) { m_borderSize = width; }
101
102 // Gets the default sash border size
103 inline int GetDefaultBorderSize() const { return m_borderSize; }
104
105 // Sets the addition border size between child and sash window
106 inline void SetExtraBorderSize(int width) { m_extraBorderSize = width; }
107
108 // Gets the addition border size between child and sash window
109 inline int GetExtraBorderSize() const { return m_extraBorderSize; }
110
111 virtual void SetMinimumSizeX(int min) { m_minimumPaneSizeX = min; }
112 virtual void SetMinimumSizeY(int min) { m_minimumPaneSizeY = min; }
113 virtual int GetMinimumSizeX() const { return m_minimumPaneSizeX; }
114 virtual int GetMinimumSizeY() const { return m_minimumPaneSizeY; }
115
116 virtual void SetMaximumSizeX(int max) { m_maximumPaneSizeX = max; }
117 virtual void SetMaximumSizeY(int max) { m_maximumPaneSizeY = max; }
118 virtual int GetMaximumSizeX() const { return m_maximumPaneSizeX; }
119 virtual int GetMaximumSizeY() const { return m_maximumPaneSizeY; }
120
121 ////////////////////////////////////////////////////////////////////////////
122 // Implementation
123
124 // Paints the border and sash
125 void OnPaint(wxPaintEvent& event);
126
127 // Handles mouse events
128 void OnMouseEvent(wxMouseEvent& ev);
129
130 // Adjusts the panes
131 void OnSize(wxSizeEvent& event);
132
133 // Draws borders
134 void DrawBorders(wxDC& dc);
135
136 // Draws the sashes
137 void DrawSash(wxSashEdgePosition edge, wxDC& dc);
138
139 // Draws the sashes
140 void DrawSashes(wxDC& dc);
141
142 // Draws the sash tracker (for whilst moving the sash)
143 void DrawSashTracker(wxSashEdgePosition edge, int x, int y);
144
145 // Tests for x, y over sash
146 wxSashEdgePosition SashHitTest(int x, int y, int tolerance = 2);
147
148 // Resizes subwindows
149 void SizeWindows();
150
151 // Initialize colours
152 void InitColours();
153
154 protected:
155 wxSashEdge m_sashes[4];
156 int m_dragMode;
157 wxSashEdgePosition m_draggingEdge;
158 int m_oldX;
159 int m_oldY;
160 int m_borderSize;
161 int m_extraBorderSize;
162 int m_firstX;
163 int m_firstY;
164 int m_minimumPaneSizeX;
165 int m_minimumPaneSizeY;
166 int m_maximumPaneSizeX;
167 int m_maximumPaneSizeY;
168 wxCursor* m_sashCursorWE;
169 wxCursor* m_sashCursorNS;
170 wxColour m_lightShadowColour;
171 wxColour m_mediumShadowColour;
172 wxColour m_darkShadowColour;
173 wxColour m_hilightColour;
174 wxColour m_faceColour;
175
176 DECLARE_EVENT_TABLE()
177 };
178
179 #define wxEVT_SASH_DRAGGED (wxEVT_FIRST + 1200)
180
181 enum wxSashDragStatus
182 {
183 wxSASH_STATUS_OK,
184 wxSASH_STATUS_OUT_OF_RANGE
185 };
186
187 class WXDLLEXPORT wxSashEvent: public wxCommandEvent
188 {
189 DECLARE_DYNAMIC_CLASS(wxSashEvent)
190
191 public:
192 inline wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE) {
193 m_eventType = (wxEventType) wxEVT_SASH_DRAGGED; m_id = id; m_edge = edge; }
194
195 inline void SetEdge(wxSashEdgePosition edge) { m_edge = edge; }
196 inline wxSashEdgePosition GetEdge() const { return m_edge; }
197
198 //// The rectangle formed by the drag operation
199 inline void SetDragRect(const wxRect& rect) { m_dragRect = rect; }
200 inline wxRect GetDragRect() const { return m_dragRect; }
201
202 //// Whether the drag caused the rectangle to be reversed (e.g.
203 //// dragging the top below the bottom)
204 inline void SetDragStatus(wxSashDragStatus status) { m_dragStatus = status; }
205 inline wxSashDragStatus GetDragStatus() const { return m_dragStatus; }
206 private:
207 wxSashEdgePosition m_edge;
208 wxRect m_dragRect;
209 wxSashDragStatus m_dragStatus;
210 };
211
212 typedef void (wxEvtHandler::*wxSashEventFunction)(wxSashEvent&);
213
214 #define EVT_SASH_DRAGGED(id, fn) { wxEVT_SASH_DRAGGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSashEventFunction) & fn, NULL },
215 #define EVT_SASH_DRAGGED_RANGE(id1, id2, fn) { wxEVT_SASH_DRAGGED, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxSashEventFunction) & fn, NULL },
216
217 #endif // wxUSE_SASH
218
219 #endif
220 // _WX_SASHWIN_H_G_