1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/splitter.cpp
3 // Purpose: wxSplitterWindow implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/splitter.h"
24 #include "wx/string.h"
28 #include "wx/dcclient.h"
29 #include "wx/dcscreen.h"
31 #include "wx/window.h"
32 #include "wx/dialog.h"
35 #include "wx/settings.h"
38 #include "wx/renderer.h"
42 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
)
43 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
)
44 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
)
45 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_UNSPLIT
)
47 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow
, wxWindow
)
58 IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent
, wxNotifyEvent
)
60 BEGIN_EVENT_TABLE(wxSplitterWindow
, wxWindow
)
61 EVT_PAINT(wxSplitterWindow::OnPaint
)
62 EVT_SIZE(wxSplitterWindow::OnSize
)
63 EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent
)
65 #if defined( __WXMSW__ ) || defined( __WXMAC__)
66 EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor
)
69 WX_EVENT_TABLE_CONTROL_CONTAINER(wxSplitterWindow
)
72 WX_DELEGATE_TO_CONTROL_CONTAINER(wxSplitterWindow
, wxWindow
)
74 bool wxSplitterWindow::Create(wxWindow
*parent
, wxWindowID id
,
80 // allow TABbing from one window to the other
81 style
|= wxTAB_TRAVERSAL
;
83 // we draw our border ourselves to blend the sash with it
84 style
&= ~wxBORDER_MASK
;
85 style
|= wxBORDER_NONE
;
87 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
91 m_lastSize
.x
= size
.x
;
93 m_lastSize
.y
= size
.y
;
95 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
97 // FIXME: with this line the background is not erased at all under GTK1,
98 // so temporary avoid it there
99 #if !defined(__WXGTK__) || defined(__WXGTK20__)
100 // don't erase the splitter background, it's pointless as we overwrite it
102 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
108 void wxSplitterWindow::Init()
110 WX_INIT_CONTROL_CONTAINER();
112 m_splitMode
= wxSPLIT_VERTICAL
;
113 m_permitUnsplitAlways
= true;
114 m_windowOne
= (wxWindow
*) NULL
;
115 m_windowTwo
= (wxWindow
*) NULL
;
116 m_dragMode
= wxSPLIT_DRAG_NONE
;
121 m_sashPosition
= m_requestedSashPosition
= 0;
123 m_sashSize
= -1; // -1 means use the native sash size
124 m_lastSize
= wxSize(0,0);
125 m_checkRequestedSashPosition
= false;
126 m_minimumPaneSize
= 0;
127 m_sashCursorWE
= wxCursor(wxCURSOR_SIZEWE
);
128 m_sashCursorNS
= wxCursor(wxCURSOR_SIZENS
);
129 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
131 m_needUpdating
= false;
135 wxSplitterWindow::~wxSplitterWindow()
137 delete m_sashTrackerPen
;
140 // ----------------------------------------------------------------------------
141 // entering/leaving sash
142 // ----------------------------------------------------------------------------
144 void wxSplitterWindow::RedrawIfHotSensitive(bool isHot
)
146 if ( wxRendererNative::Get().GetSplitterParams(this).isHotSensitive
)
153 //else: we don't change our appearance, don't redraw to avoid flicker
156 void wxSplitterWindow::OnEnterSash()
160 RedrawIfHotSensitive(true);
163 void wxSplitterWindow::OnLeaveSash()
165 SetCursor(*wxSTANDARD_CURSOR
);
167 RedrawIfHotSensitive(false);
170 void wxSplitterWindow::SetResizeCursor()
172 SetCursor(m_splitMode
== wxSPLIT_VERTICAL
? m_sashCursorWE
176 // ----------------------------------------------------------------------------
177 // other event handlers
178 // ----------------------------------------------------------------------------
180 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
187 void wxSplitterWindow::OnInternalIdle()
189 wxWindow::OnInternalIdle();
191 // if this is the first idle time after a sash position has potentially
192 // been set, allow SizeWindows to check for a requested size.
193 if (!m_checkRequestedSashPosition
)
195 m_checkRequestedSashPosition
= true;
197 return; // it won't needUpdating in this case
204 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
206 int x
= (int)event
.GetX(),
207 y
= (int)event
.GetY();
209 if (GetWindowStyle() & wxSP_NOSASH
)
212 // with wxSP_LIVE_UPDATE style the splitter windows are always resized
213 // following the mouse movement while it drags the sash, without it we only
214 // draw the sash at the new position but only resize the windows when the
215 // dragging is finished
216 #if defined( __WXMAC__ )
217 // FIXME : this should be usable also with no live update, but then this
218 // currently is not visible
221 bool isLive
= HasFlag(wxSP_LIVE_UPDATE
);
223 if (event
.LeftDown())
225 if ( SashHitTest(x
, y
) )
227 // Start the drag now
228 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
230 // Capture mouse and set the cursor
236 // remember the initial sash position and draw the initial
238 m_sashPositionCurrent
= m_sashPosition
;
240 DrawSashTracker(x
, y
);
250 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
252 // We can stop dragging now and see what we've got.
253 m_dragMode
= wxSPLIT_DRAG_NONE
;
255 // Release mouse and unset the cursor
257 SetCursor(* wxSTANDARD_CURSOR
);
259 // exit if unsplit after doubleclick
268 DrawSashTracker(m_oldX
, m_oldY
);
271 // the position of the click doesn't exactly correspond to
272 // m_sashPosition, rather it changes it by the distance by which the
274 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
276 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
277 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
278 if ( posSashNew
== -1 )
280 // change not allowed
284 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
286 // Deal with possible unsplit scenarios
287 if ( posSashNew
== 0 )
289 // We remove the first window from the view
290 wxWindow
*removedWindow
= m_windowOne
;
291 m_windowOne
= m_windowTwo
;
292 m_windowTwo
= (wxWindow
*) NULL
;
293 OnUnsplit(removedWindow
);
294 wxSplitterEvent
eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
295 eventUnsplit
.m_data
.win
= removedWindow
;
296 (void)DoSendEvent(eventUnsplit
);
297 SetSashPositionAndNotify(0);
299 else if ( posSashNew
== GetWindowSize() )
301 // We remove the second window from the view
302 wxWindow
*removedWindow
= m_windowTwo
;
303 m_windowTwo
= (wxWindow
*) NULL
;
304 OnUnsplit(removedWindow
);
305 wxSplitterEvent
eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
306 eventUnsplit
.m_data
.win
= removedWindow
;
307 (void)DoSendEvent(eventUnsplit
);
308 SetSashPositionAndNotify(0);
312 SetSashPositionAndNotify(posSashNew
);
317 SetSashPositionAndNotify(posSashNew
);
321 } // left up && dragging
322 else if ((event
.Moving() || event
.Leaving() || event
.Entering()) && (m_dragMode
== wxSPLIT_DRAG_NONE
))
324 if ( event
.Leaving() || !SashHitTest(x
, y
) )
329 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
331 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
334 // nothing to do, mouse didn't really move far enough
338 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
339 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
340 if ( posSashNew
== -1 )
342 // change not allowed
346 if ( posSashNew
== m_sashPosition
)
352 DrawSashTracker(m_oldX
, m_oldY
);
355 if (m_splitMode
== wxSPLIT_VERTICAL
)
360 // Remember old positions
365 // As we captured the mouse, we may get the mouse events from outside
366 // our window - for example, negative values in x, y. This has a weird
367 // consequence under MSW where we use unsigned values sometimes and
368 // signed ones other times: the coordinates turn as big positive
369 // numbers and so the sash is drawn on the *right* side of the window
370 // instead of the left (or bottom instead of top). Correct this.
371 if ( (short)m_oldX
< 0 )
373 if ( (short)m_oldY
< 0 )
380 m_sashPositionCurrent
= posSashNew
;
382 DrawSashTracker(m_oldX
, m_oldY
);
386 DoSetSashPosition(posSashNew
);
387 m_needUpdating
= true;
390 else if ( event
.LeftDClick() && m_windowTwo
)
392 OnDoubleClickSash(x
, y
);
396 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
398 // only process this message if we're not iconized - otherwise iconizing
399 // and restoring a window containing the splitter has a funny side effect
400 // of changing the splitter position!
401 wxWindow
*parent
= wxGetTopLevelParent(this);
404 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
407 iconized
= winTop
->IsIconized();
411 wxFAIL_MSG(wxT("should have a top level parent!"));
418 m_lastSize
= wxSize(0,0);
428 GetClientSize(&w
, &h
);
430 int size
= m_splitMode
== wxSPLIT_VERTICAL
? w
: h
;
432 int old_size
= m_splitMode
== wxSPLIT_VERTICAL
? m_lastSize
.x
: m_lastSize
.y
;
435 int delta
= (int) ( (size
- old_size
)*m_sashGravity
);
438 int newPosition
= m_sashPosition
+ delta
;
439 if( newPosition
< m_minimumPaneSize
)
440 newPosition
= m_minimumPaneSize
;
441 SetSashPositionAndNotify(newPosition
);
445 if ( m_sashPosition
>= size
- 5 )
446 SetSashPositionAndNotify(wxMax(10, size
- 40));
447 m_lastSize
= wxSize(w
,h
);
453 void wxSplitterWindow::SetSashGravity(double gravity
)
455 wxCHECK_RET( gravity
>= 0. && gravity
<= 1.,
456 _T("invalid gravity value") );
458 m_sashGravity
= gravity
;
461 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
463 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
464 return false; // No sash
466 int z
= m_splitMode
== wxSPLIT_VERTICAL
? x
: y
;
467 int hitMin
= m_sashPosition
- tolerance
;
468 int hitMax
= m_sashPosition
+ GetSashSize() + tolerance
;
470 return z
>= hitMin
&& z
<= hitMax
;
473 int wxSplitterWindow::GetSashSize() const
475 return m_sashSize
> -1 ? m_sashSize
: wxRendererNative::Get().GetSplitterParams(this).widthSash
;
478 int wxSplitterWindow::GetBorderSize() const
480 return wxRendererNative::Get().GetSplitterParams(this).border
;
484 void wxSplitterWindow::DrawSash(wxDC
& dc
)
486 if (HasFlag(wxSP_3DBORDER
))
487 wxRendererNative::Get().DrawSplitterBorder
494 // don't draw sash if we're not split
495 if ( m_sashPosition
== 0 || !m_windowTwo
)
498 // nor if we're configured to not show it
499 if ( HasFlag(wxSP_NOSASH
) )
502 wxRendererNative::Get().DrawSplitterSash
508 m_splitMode
== wxSPLIT_VERTICAL
? wxVERTICAL
510 m_isHot
? (int)wxCONTROL_CURRENT
: 0
514 // Draw the sash tracker (for whilst moving the sash)
515 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
518 GetClientSize(&w
, &h
);
524 if ( m_splitMode
== wxSPLIT_VERTICAL
)
555 ClientToScreen(&x1
, &y1
);
556 ClientToScreen(&x2
, &y2
);
558 screenDC
.SetLogicalFunction(wxINVERT
);
559 screenDC
.SetPen(*m_sashTrackerPen
);
560 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
562 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
564 screenDC
.SetLogicalFunction(wxCOPY
);
567 int wxSplitterWindow::GetWindowSize() const
569 wxSize size
= GetClientSize();
571 return m_splitMode
== wxSPLIT_VERTICAL
? size
.x
: size
.y
;
574 int wxSplitterWindow::AdjustSashPosition(int sashPos
) const
581 // the window shouldn't be smaller than its own minimal size nor
582 // smaller than the minimual pane size specified for this splitter
583 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
584 : win
->GetMinHeight();
586 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
587 minSize
= m_minimumPaneSize
;
589 minSize
+= GetBorderSize();
591 if ( sashPos
< minSize
)
598 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
599 : win
->GetMinHeight();
601 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
602 minSize
= m_minimumPaneSize
;
604 int maxSize
= GetWindowSize() - minSize
- GetBorderSize() - GetSashSize();
605 if ( maxSize
> 0 && sashPos
> maxSize
)
612 bool wxSplitterWindow::DoSetSashPosition(int sashPos
)
614 int newSashPosition
= AdjustSashPosition(sashPos
);
616 if ( newSashPosition
== m_sashPosition
)
619 m_sashPosition
= newSashPosition
;
624 void wxSplitterWindow::SetSashPositionAndNotify(int sashPos
)
626 // we must reset the request here, otherwise the sash would be stuck at
627 // old position if the user attempted to move the sash after invalid
628 // (e.g. smaller than minsize) sash position was requested using
629 // SetSashPosition():
630 m_requestedSashPosition
= INT_MAX
;
632 // note that we must send the event in any case, i.e. even if the sash
633 // position hasn't changed and DoSetSashPosition() returns false because we
634 // must generate a CHANGED event at the end of resizing
635 DoSetSashPosition(sashPos
);
637 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
, this);
638 event
.m_data
.pos
= m_sashPosition
;
640 (void)DoSendEvent(event
);
643 // Position and size subwindows.
644 // Note that the border size applies to each subwindow, not
645 // including the edges next to the sash.
646 void wxSplitterWindow::SizeWindows()
648 // check if we have delayed setting the real sash position
649 if ( m_checkRequestedSashPosition
&& m_requestedSashPosition
!= INT_MAX
)
651 int newSashPosition
= ConvertSashPosition(m_requestedSashPosition
);
652 if ( newSashPosition
!= m_sashPosition
)
654 DoSetSashPosition(newSashPosition
);
657 if ( newSashPosition
<= m_sashPosition
658 && newSashPosition
>= m_sashPosition
- GetBorderSize() )
660 // don't update it any more
661 m_requestedSashPosition
= INT_MAX
;
666 GetClientSize(&w
, &h
);
668 if ( GetWindow1() && !GetWindow2() )
670 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
671 w
- 2*GetBorderSize(), h
- 2*GetBorderSize());
673 else if ( GetWindow1() && GetWindow2() )
675 const int border
= GetBorderSize(),
676 sash
= GetSashSize();
678 int size1
= GetSashPosition() - border
,
679 size2
= GetSashPosition() + sash
;
681 int x2
, y2
, w1
, h1
, w2
, h2
;
682 if ( GetSplitMode() == wxSPLIT_VERTICAL
)
685 w2
= w
- 2*border
- sash
- w1
;
695 else // horz splitter
702 h2
= h
- 2*border
- sash
- h1
;
709 GetWindow2()->SetSize(x2
, y2
, w2
, h2
);
710 GetWindow1()->SetSize(border
, border
, w1
, h1
);
716 SetNeedUpdating(false);
719 // Set pane for unsplit window
720 void wxSplitterWindow::Initialize(wxWindow
*window
)
722 wxASSERT_MSG( (!window
|| (window
&& window
->GetParent() == this)),
723 _T("windows in the splitter should have it as parent!") );
725 if (window
&& !window
->IsShown())
728 m_windowOne
= window
;
729 m_windowTwo
= (wxWindow
*) NULL
;
730 DoSetSashPosition(0);
733 // Associates the given window with window 2, drawing the appropriate sash
734 // and changing the split mode.
735 // Does nothing and returns false if the window is already split.
736 bool wxSplitterWindow::DoSplit(wxSplitMode mode
,
737 wxWindow
*window1
, wxWindow
*window2
,
743 wxCHECK_MSG( window1
&& window2
, false,
744 _T("can not split with NULL window(s)") );
746 wxCHECK_MSG( window1
->GetParent() == this && window2
->GetParent() == this, false,
747 _T("windows in the splitter should have it as parent!") );
749 if (! window1
->IsShown())
751 if (! window2
->IsShown())
755 m_windowOne
= window1
;
756 m_windowTwo
= window2
;
758 // remember the sash position we want to set for later if we can't set it
759 // right now (e.g. because the window is too small)
760 m_requestedSashPosition
= sashPosition
;
761 m_checkRequestedSashPosition
= false;
763 DoSetSashPosition(ConvertSashPosition(sashPosition
));
770 int wxSplitterWindow::ConvertSashPosition(int sashPosition
) const
772 if ( sashPosition
> 0 )
776 else if ( sashPosition
< 0 )
778 // It's negative so adding is subtracting
779 return GetWindowSize() + sashPosition
;
781 else // sashPosition == 0
783 // default, put it in the centre
784 return GetWindowSize() / 2;
788 // Remove the specified (or second) window from the view
789 // Doesn't actually delete the window.
790 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
796 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
799 m_windowTwo
= (wxWindow
*) NULL
;
801 else if ( toRemove
== m_windowOne
)
804 m_windowOne
= m_windowTwo
;
805 m_windowTwo
= (wxWindow
*) NULL
;
809 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
815 DoSetSashPosition(0);
821 // Replace a window with another one
822 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
824 wxCHECK_MSG( winOld
, false, wxT("use one of Split() functions instead") );
825 wxCHECK_MSG( winNew
, false, wxT("use Unsplit() functions instead") );
827 if ( winOld
== m_windowTwo
)
829 m_windowTwo
= winNew
;
831 else if ( winOld
== m_windowOne
)
833 m_windowOne
= winNew
;
837 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
847 void wxSplitterWindow::SetMinimumPaneSize(int min
)
849 m_minimumPaneSize
= min
;
850 int pos
= m_requestedSashPosition
!= INT_MAX
? m_requestedSashPosition
: m_sashPosition
;
851 SetSashPosition(pos
); // re-check limits
854 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
856 // remember the sash position we want to set for later if we can't set it
857 // right now (e.g. because the window is too small)
858 m_requestedSashPosition
= position
;
859 m_checkRequestedSashPosition
= false;
861 DoSetSashPosition(ConvertSashPosition(position
));
869 // Make sure the child window sizes are updated. This is useful
870 // for reducing flicker by updating the sizes before a
871 // window is shown, if you know the overall size is correct.
872 void wxSplitterWindow::UpdateSize()
874 m_checkRequestedSashPosition
= true;
876 m_checkRequestedSashPosition
= false;
879 bool wxSplitterWindow::DoSendEvent(wxSplitterEvent
& event
)
881 return !GetEventHandler()->ProcessEvent(event
) || event
.IsAllowed();
884 wxSize
wxSplitterWindow::DoGetBestSize() const
886 // get best sizes of subwindows
889 size1
= m_windowOne
->GetEffectiveMinSize();
891 size2
= m_windowTwo
->GetEffectiveMinSize();
895 // pSash points to the size component to which sash size must be added
898 if ( m_splitMode
== wxSPLIT_VERTICAL
)
900 sizeBest
.y
= wxMax(size1
.y
, size2
.y
);
901 sizeBest
.x
= wxMax(size1
.x
, m_minimumPaneSize
) +
902 wxMax(size2
.x
, m_minimumPaneSize
);
906 else // wxSPLIT_HORIZONTAL
908 sizeBest
.x
= wxMax(size1
.x
, size2
.x
);
909 sizeBest
.y
= wxMax(size1
.y
, m_minimumPaneSize
) +
910 wxMax(size2
.y
, m_minimumPaneSize
);
915 // account for the border and the sash
916 int border
= 2*GetBorderSize();
917 *pSash
+= GetSashSize();
918 sizeBest
.x
+= border
;
919 sizeBest
.y
+= border
;
924 // ---------------------------------------------------------------------------
925 // wxSplitterWindow virtual functions: they now just generate the events
926 // ---------------------------------------------------------------------------
928 bool wxSplitterWindow::OnSashPositionChange(int WXUNUSED(newSashPosition
))
930 // always allow by default
934 int wxSplitterWindow::OnSashPositionChanging(int newSashPosition
)
936 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
937 const int UNSPLIT_THRESHOLD
= 4;
939 // first of all, check if OnSashPositionChange() doesn't forbid this change
940 if ( !OnSashPositionChange(newSashPosition
) )
946 // Obtain relevant window dimension for bottom / right threshold check
947 int window_size
= GetWindowSize();
949 bool unsplit_scenario
= false;
950 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
952 // Do edge detection if unsplit premitted
953 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
955 // threshold top / left check
957 unsplit_scenario
= true;
959 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
961 // threshold bottom/right check
962 newSashPosition
= window_size
;
963 unsplit_scenario
= true;
967 if ( !unsplit_scenario
)
969 // If resultant pane would be too small, enlarge it
970 newSashPosition
= AdjustSashPosition(newSashPosition
);
973 // If the result is out of bounds it means minimum size is too big,
974 // so split window in half as best compromise.
975 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
976 newSashPosition
= window_size
/ 2;
978 // now let the event handler have it
980 // FIXME: shouldn't we do it before the adjustments above so as to ensure
981 // that the sash position is always reasonable?
982 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
, this);
983 event
.m_data
.pos
= newSashPosition
;
985 if ( !DoSendEvent(event
) )
987 // the event handler vetoed the change
988 newSashPosition
= -1;
992 // it could have been changed by it
993 newSashPosition
= event
.GetSashPosition();
996 return newSashPosition
;
999 // Called when the sash is double-clicked. The default behaviour is to remove
1000 // the sash if the minimum pane size is zero.
1001 void wxSplitterWindow::OnDoubleClickSash(int x
, int y
)
1003 wxCHECK_RET(m_windowTwo
, wxT("splitter: no window to remove"));
1005 // new code should handle events instead of using the virtual functions
1006 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
, this);
1007 event
.m_data
.pt
.x
= x
;
1008 event
.m_data
.pt
.y
= y
;
1009 if ( DoSendEvent(event
) )
1011 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
1013 wxWindow
* win
= m_windowTwo
;
1016 wxSplitterEvent
unsplitEvent(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
1017 unsplitEvent
.m_data
.win
= win
;
1018 (void)DoSendEvent(unsplitEvent
);
1022 //else: blocked by user
1025 void wxSplitterWindow::OnUnsplit(wxWindow
*winRemoved
)
1027 // call this before calling the event handler which may delete the window
1028 winRemoved
->Show(false);
1031 #if defined( __WXMSW__ ) || defined( __WXMAC__)
1033 // this is currently called (and needed) under MSW only...
1034 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& event
)
1036 // if we don't do it, the resizing cursor might be set for child window:
1037 // and like this we explicitly say that our cursor should not be used for
1038 // children windows which overlap us
1040 if ( SashHitTest(event
.GetX(), event
.GetY(), 0) )
1042 // default processing is ok
1045 //else: do nothing, in particular, don't call Skip()
1048 #endif // wxMSW || wxMac
1050 #endif // wxUSE_SPLITTER