]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/splitter.h
"const" added to wxAccelTable ctor
[wxWidgets.git] / include / wx / generic / splitter.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: splitter.h
3// Purpose: wxSplitterWindow class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __SPLITTERH_G__
13#define __SPLITTERH_G__
14
15#ifdef __GNUG__
16#pragma interface "splitter.h"
17#endif
18
19#include "wx/defs.h"
20#include "wx/window.h"
21#include "wx/string.h"
22
23#define WXSPLITTER_VERSION 1.0
24
25#define wxSPLIT_HORIZONTAL 1
26#define wxSPLIT_VERTICAL 2
27
28#define wxSPLIT_DRAG_NONE 0
29#define wxSPLIT_DRAG_DRAGGING 1
30#define wxSPLIT_DRAG_LEFT_DOWN 2
31
32/*
33 * wxSplitterWindow maintains one or two panes, with
34 * an optional vertical or horizontal split which
35 * can be used with the mouse or programmatically.
36 */
37
38// TODO:
39// 1) Perhaps make the borders sensitive to dragging in order to create a split.
40// The MFC splitter window manages scrollbars as well so is able to
41// put sash buttons on the scrollbars, but we probably don't want to go down
42// this path.
43// 2) for wxWindows 2.0, we must find a way to set the WS_CLIPCHILDREN style
44// to prevent flickering. (WS_CLIPCHILDREN doesn't work in all cases so can't be
45// standard).
46
47class WXDLLEXPORT wxSplitterWindow: public wxWindow
48{
49 DECLARE_DYNAMIC_CLASS(wxSplitterWindow)
50
51 public:
52
53////////////////////////////////////////////////////////////////////////////
54// Public API
55
56 // Default constructor
57 wxSplitterWindow(void);
58
59 // Normal constructor
debe6624
JS
60 wxSplitterWindow(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize, long style = wxSP_3D|wxCLIP_CHILDREN, const wxString& name = "splitter");
c801d85f
KB
62 ~wxSplitterWindow(void);
63
64 // Gets the only or left/top pane
65 inline wxWindow *GetWindow1(void) { return m_windowOne; }
66
67 // Gets the right/bottom pane
68 inline wxWindow *GetWindow2(void) { return m_windowTwo; }
69
70 // Sets the split mode
debe6624 71 inline void SetSplitMode(int mode) { m_splitMode = mode; }
c801d85f
KB
72
73 // Gets the split mode
74 inline int GetSplitMode(void) const { return m_splitMode; };
75
76 // Initialize with one window
77 void Initialize(wxWindow *window);
78
79 // Associates the given window with window 2, drawing the appropriate sash
80 // and changing the split mode.
81 // Does nothing and returns FALSE if the window is already split.
82 // A sashPosition of -1 means choose a default sash position.
debe6624
JS
83 bool SplitVertically(wxWindow *window1, wxWindow *window2, int sashPosition = -1);
84 bool SplitHorizontally(wxWindow *window1, wxWindow *window2, int sashPosition = -1);
c801d85f
KB
85
86 // Removes the specified (or second) window from the view
87 // Doesn't actually delete the window.
c67daf87 88 bool Unsplit(wxWindow *toRemove = (wxWindow *) NULL);
c801d85f
KB
89
90 // Is the window split?
91 inline bool IsSplit(void) const { return (m_windowTwo != NULL); }
92
93 // Sets the sash size
debe6624 94 inline void SetSashSize(int width) { m_sashSize = width; }
c801d85f
KB
95
96 // Sets the border size
debe6624 97 inline void SetBorderSize(int width) { m_borderSize = width; }
c801d85f
KB
98
99 // Gets the sash size
100 inline int GetSashSize(void) const { return m_sashSize; }
101
102 // Gets the border size
103 inline int GetBorderSize(void) const { return m_borderSize; }
104
105 // Set the sash position
debe6624 106 void SetSashPosition(int position, bool redaw = TRUE);
c801d85f
KB
107
108 // Gets the sash position
109 inline int GetSashPosition(void) const { return m_sashPosition; }
110
111 // If this is zero, we can remove panes by dragging the sash.
debe6624 112 inline void SetMinimumPaneSize(int min) { m_minimumPaneSize = min; }
c801d85f
KB
113 inline int GetMinimumPaneSize(void) const { return m_minimumPaneSize; }
114
115 // If the sash is moved to an extreme position, a subwindow
116 // is removed from the splitter window, and the app is
117 // notified. The app should delete or hide the window.
118 virtual void OnUnsplit(wxWindow *removed) { removed->Show(FALSE); }
119
120 // Called when the sash is double-clicked.
121 // The default behaviour is to remove the sash if the
122 // minimum pane size is zero.
123 virtual void OnDoubleClickSash(int x, int y);
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
137 // Draws borders
138 void DrawBorders(wxDC& dc);
139
140 // Draws the sash
141 void DrawSash(wxDC& dc);
142
143 // Draws the sash tracker (for whilst moving the sash)
debe6624 144 void DrawSashTracker(int x, int y);
c801d85f
KB
145
146 // Tests for x, y over sash
debe6624 147 bool SashHitTest(int x, int y, int tolerance = 2);
c801d85f
KB
148
149 // Resizes subwindows
150 void SizeWindows(void);
151
152 // Initialize colours
153 void InitColours(void);
154
155 protected:
156 int m_splitMode;
157 wxWindow* m_windowOne;
158 wxWindow* m_windowTwo;
159 int m_dragMode;
160 int m_oldX;
161 int m_oldY;
162 int m_borderSize;
163 int m_sashSize; // Sash width or height
164 int m_sashPosition; // Number of pixels from left or top
165 int m_firstX;
166 int m_firstY;
167 int m_minimumPaneSize;
168 wxCursor* m_sashCursorWE;
169 wxCursor* m_sashCursorNS;
170 wxPen* m_sashTrackerPen;
171 wxPen* m_lightShadowPen;
172 wxPen* m_mediumShadowPen;
173 wxPen* m_darkShadowPen;
174 wxPen* m_hilightPen;
175 wxBrush* m_faceBrush;
176 wxPen* m_facePen;
177DECLARE_EVENT_TABLE()
178};
179
180#endif