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"
22 #include "wx/string.h"
26 #include "wx/dcscreen.h"
28 #include "wx/window.h"
29 #include "wx/dialog.h"
32 #include "wx/settings.h"
36 #include "wx/mac/private.h"
39 #include "wx/renderer.h"
41 #include "wx/splitter.h"
45 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
)
46 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
)
47 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
)
48 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_UNSPLIT
)
50 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow
, wxWindow
)
61 IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent
, wxNotifyEvent
)
63 BEGIN_EVENT_TABLE(wxSplitterWindow
, wxWindow
)
64 EVT_PAINT(wxSplitterWindow::OnPaint
)
65 EVT_SIZE(wxSplitterWindow::OnSize
)
66 EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent
)
68 #if defined( __WXMSW__ ) || defined( __WXMAC__)
69 EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor
)
72 WX_EVENT_TABLE_CONTROL_CONTAINER(wxSplitterWindow
)
75 WX_DELEGATE_TO_CONTROL_CONTAINER(wxSplitterWindow
)
77 bool wxSplitterWindow::Create(wxWindow
*parent
, wxWindowID id
,
83 // allow TABbing from one window to the other
84 style
|= wxTAB_TRAVERSAL
;
86 // we draw our border ourselves to blend the sash with it
87 style
&= ~wxBORDER_MASK
;
88 style
|= wxBORDER_NONE
;
90 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
94 m_lastSize
.x
= size
.x
;
96 m_lastSize
.y
= size
.y
;
98 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
100 // FIXME: with this line the background is not erased at all under GTK1,
101 // so temporary avoid it there
102 #if !defined(__WXGTK__) || defined(__WXGTK20__)
103 // don't erase the splitter background, it's pointless as we overwrite it
105 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
111 void wxSplitterWindow::Init()
113 m_container
.SetContainerWindow(this);
115 m_splitMode
= wxSPLIT_VERTICAL
;
116 m_permitUnsplitAlways
= true;
117 m_windowOne
= (wxWindow
*) NULL
;
118 m_windowTwo
= (wxWindow
*) NULL
;
119 m_dragMode
= wxSPLIT_DRAG_NONE
;
124 m_sashPosition
= m_requestedSashPosition
= 0;
126 m_sashSize
= -1; // -1 means use the native sash size
127 m_lastSize
= wxSize(0,0);
128 m_checkRequestedSashPosition
= false;
129 m_minimumPaneSize
= 0;
130 m_sashCursorWE
= wxCursor(wxCURSOR_SIZEWE
);
131 m_sashCursorNS
= wxCursor(wxCURSOR_SIZENS
);
132 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
134 m_needUpdating
= false;
138 wxSplitterWindow::~wxSplitterWindow()
140 delete m_sashTrackerPen
;
143 // ----------------------------------------------------------------------------
144 // entering/leaving sash
145 // ----------------------------------------------------------------------------
147 void wxSplitterWindow::RedrawIfHotSensitive(bool isHot
)
149 if ( wxRendererNative::Get().GetSplitterParams(this).isHotSensitive
)
156 //else: we don't change our appearance, don't redraw to avoid flicker
159 void wxSplitterWindow::OnEnterSash()
163 RedrawIfHotSensitive(true);
166 void wxSplitterWindow::OnLeaveSash()
168 SetCursor(*wxSTANDARD_CURSOR
);
170 RedrawIfHotSensitive(false);
173 void wxSplitterWindow::SetResizeCursor()
175 SetCursor(m_splitMode
== wxSPLIT_VERTICAL
? m_sashCursorWE
179 // ----------------------------------------------------------------------------
180 // other event handlers
181 // ----------------------------------------------------------------------------
183 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
190 void wxSplitterWindow::OnInternalIdle()
192 wxWindow::OnInternalIdle();
194 // if this is the first idle time after a sash position has potentially
195 // been set, allow SizeWindows to check for a requested size.
196 if (!m_checkRequestedSashPosition
)
198 m_checkRequestedSashPosition
= true;
200 return; // it won't needUpdating in this case
207 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
209 int x
= (int)event
.GetX(),
210 y
= (int)event
.GetY();
212 if (GetWindowStyle() & wxSP_NOSASH
)
215 // with wxSP_LIVE_UPDATE style the splitter windows are always resized
216 // following the mouse movement while it drags the sash, without it we only
217 // draw the sash at the new position but only resize the windows when the
218 // dragging is finished
219 #if defined( __WXMAC__ ) && TARGET_API_MAC_OSX == 1
222 bool isLive
= (GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) != 0;
224 if (event
.LeftDown())
226 if ( SashHitTest(x
, y
) )
228 // Start the drag now
229 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
231 // Capture mouse and set the cursor
237 // remember the initial sash position and draw the initial
239 m_sashPositionCurrent
= m_sashPosition
;
241 DrawSashTracker(x
, y
);
251 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
253 // We can stop dragging now and see what we've got.
254 m_dragMode
= wxSPLIT_DRAG_NONE
;
256 // Release mouse and unset the cursor
258 SetCursor(* wxSTANDARD_CURSOR
);
260 // exit if unsplit after doubleclick
269 DrawSashTracker(m_oldX
, m_oldY
);
272 // the position of the click doesn't exactly correspond to
273 // m_sashPosition, rather it changes it by the distance by which the
275 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
277 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
278 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
279 if ( posSashNew
== -1 )
281 // change not allowed
285 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
287 // Deal with possible unsplit scenarios
288 if ( posSashNew
== 0 )
290 // We remove the first window from the view
291 wxWindow
*removedWindow
= m_windowOne
;
292 m_windowOne
= m_windowTwo
;
293 m_windowTwo
= (wxWindow
*) NULL
;
294 OnUnsplit(removedWindow
);
295 wxSplitterEvent
eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
296 eventUnsplit
.m_data
.win
= removedWindow
;
297 (void)DoSendEvent(eventUnsplit
);
298 SetSashPositionAndNotify(0);
300 else if ( posSashNew
== GetWindowSize() )
302 // We remove the second window from the view
303 wxWindow
*removedWindow
= m_windowTwo
;
304 m_windowTwo
= (wxWindow
*) NULL
;
305 OnUnsplit(removedWindow
);
306 wxSplitterEvent
eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
307 eventUnsplit
.m_data
.win
= removedWindow
;
308 (void)DoSendEvent(eventUnsplit
);
309 SetSashPositionAndNotify(0);
313 SetSashPositionAndNotify(posSashNew
);
318 SetSashPositionAndNotify(posSashNew
);
322 } // left up && dragging
323 else if ((event
.Moving() || event
.Leaving() || event
.Entering()) && (m_dragMode
== wxSPLIT_DRAG_NONE
))
325 if ( event
.Leaving() || !SashHitTest(x
, y
) )
330 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
332 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
335 // nothing to do, mouse didn't really move far enough
339 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
340 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
341 if ( posSashNew
== -1 )
343 // change not allowed
347 if ( posSashNew
== m_sashPosition
)
353 DrawSashTracker(m_oldX
, m_oldY
);
356 if (m_splitMode
== wxSPLIT_VERTICAL
)
361 // Remember old positions
366 // As we captured the mouse, we may get the mouse events from outside
367 // our window - for example, negative values in x, y. This has a weird
368 // consequence under MSW where we use unsigned values sometimes and
369 // signed ones other times: the coordinates turn as big positive
370 // numbers and so the sash is drawn on the *right* side of the window
371 // instead of the left (or bottom instead of top). Correct this.
372 if ( (short)m_oldX
< 0 )
374 if ( (short)m_oldY
< 0 )
381 m_sashPositionCurrent
= posSashNew
;
383 DrawSashTracker(m_oldX
, m_oldY
);
387 DoSetSashPosition(posSashNew
);
388 m_needUpdating
= true;
391 else if ( event
.LeftDClick() && m_windowTwo
)
393 OnDoubleClickSash(x
, y
);
397 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
399 // only process this message if we're not iconized - otherwise iconizing
400 // and restoring a window containing the splitter has a funny side effect
401 // of changing the splitter position!
402 wxWindow
*parent
= wxGetTopLevelParent(this);
405 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
408 iconized
= winTop
->IsIconized();
412 wxFAIL_MSG(wxT("should have a top level parent!"));
419 m_lastSize
= wxSize(0,0);
429 GetClientSize(&w
, &h
);
431 int size
= m_splitMode
== wxSPLIT_VERTICAL
? w
: h
;
433 int old_size
= m_splitMode
== wxSPLIT_VERTICAL
? m_lastSize
.x
: m_lastSize
.y
;
436 int delta
= (int) ( (size
- old_size
)*m_sashGravity
);
439 int newPosition
= m_sashPosition
+ delta
;
440 if( newPosition
< m_minimumPaneSize
)
441 newPosition
= m_minimumPaneSize
;
442 SetSashPositionAndNotify(newPosition
);
446 if ( m_sashPosition
>= size
- 5 )
447 SetSashPositionAndNotify(wxMax(10, size
- 40));
448 m_lastSize
= wxSize(w
,h
);
454 void wxSplitterWindow::SetSashGravity(double gravity
)
456 wxCHECK_RET( gravity
>= 0. && gravity
<= 1.,
457 _T("invalid gravity value") );
459 m_sashGravity
= gravity
;
462 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
464 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
465 return false; // No sash
467 int z
= m_splitMode
== wxSPLIT_VERTICAL
? x
: y
;
468 int hitMin
= m_sashPosition
- tolerance
;
469 int hitMax
= m_sashPosition
+ GetSashSize() + tolerance
;
471 return z
>= hitMin
&& z
<= hitMax
;
474 int wxSplitterWindow::GetSashSize() const
476 return m_sashSize
> -1 ? m_sashSize
: wxRendererNative::Get().GetSplitterParams(this).widthSash
;
479 int wxSplitterWindow::GetBorderSize() const
481 return wxRendererNative::Get().GetSplitterParams(this).border
;
485 void wxSplitterWindow::DrawSash(wxDC
& dc
)
487 if (HasFlag(wxSP_3DBORDER
))
488 wxRendererNative::Get().DrawSplitterBorder
495 // don't draw sash if we're not split
496 if ( m_sashPosition
== 0 || !m_windowTwo
)
499 // nor if we're configured to not show it
500 if ( HasFlag(wxSP_NOSASH
) )
503 wxRendererNative::Get().DrawSplitterSash
509 m_splitMode
== wxSPLIT_VERTICAL
? wxVERTICAL
511 m_isHot
? (int)wxCONTROL_CURRENT
: 0
515 // Draw the sash tracker (for whilst moving the sash)
516 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
519 GetClientSize(&w
, &h
);
525 if ( m_splitMode
== wxSPLIT_VERTICAL
)
556 ClientToScreen(&x1
, &y1
);
557 ClientToScreen(&x2
, &y2
);
559 screenDC
.SetLogicalFunction(wxINVERT
);
560 screenDC
.SetPen(*m_sashTrackerPen
);
561 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
563 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
565 screenDC
.SetLogicalFunction(wxCOPY
);
568 int wxSplitterWindow::GetWindowSize() const
570 wxSize size
= GetClientSize();
572 return m_splitMode
== wxSPLIT_VERTICAL
? size
.x
: size
.y
;
575 int wxSplitterWindow::AdjustSashPosition(int sashPos
) const
582 // the window shouldn't be smaller than its own minimal size nor
583 // smaller than the minimual pane size specified for this splitter
584 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
585 : win
->GetMinHeight();
587 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
588 minSize
= m_minimumPaneSize
;
590 minSize
+= GetBorderSize();
592 if ( sashPos
< minSize
)
599 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
600 : win
->GetMinHeight();
602 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
603 minSize
= m_minimumPaneSize
;
605 int maxSize
= GetWindowSize() - minSize
- GetBorderSize() - GetSashSize();
606 if ( maxSize
> 0 && sashPos
> maxSize
)
613 bool wxSplitterWindow::DoSetSashPosition(int sashPos
)
615 int newSashPosition
= AdjustSashPosition(sashPos
);
617 if ( newSashPosition
== m_sashPosition
)
620 m_sashPosition
= newSashPosition
;
625 void wxSplitterWindow::SetSashPositionAndNotify(int sashPos
)
627 // we must reset the request here, otherwise the sash would be stuck at
628 // old position if the user attempted to move the sash after invalid
629 // (e.g. smaller than minsize) sash position was requested using
630 // SetSashPosition():
631 m_requestedSashPosition
= INT_MAX
;
633 // note that we must send the event in any case, i.e. even if the sash
634 // position hasn't changed and DoSetSashPosition() returns false because we
635 // must generate a CHANGED event at the end of resizing
636 DoSetSashPosition(sashPos
);
638 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
, this);
639 event
.m_data
.pos
= m_sashPosition
;
641 (void)DoSendEvent(event
);
644 // Position and size subwindows.
645 // Note that the border size applies to each subwindow, not
646 // including the edges next to the sash.
647 void wxSplitterWindow::SizeWindows()
649 // check if we have delayed setting the real sash position
650 if ( m_checkRequestedSashPosition
&& m_requestedSashPosition
!= INT_MAX
)
652 int newSashPosition
= ConvertSashPosition(m_requestedSashPosition
);
653 if ( newSashPosition
!= m_sashPosition
)
655 DoSetSashPosition(newSashPosition
);
658 if ( newSashPosition
<= m_sashPosition
659 && newSashPosition
>= m_sashPosition
- GetBorderSize() )
661 // don't update it any more
662 m_requestedSashPosition
= INT_MAX
;
667 GetClientSize(&w
, &h
);
669 if ( GetWindow1() && !GetWindow2() )
671 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
672 w
- 2*GetBorderSize(), h
- 2*GetBorderSize());
674 else if ( GetWindow1() && GetWindow2() )
676 const int border
= GetBorderSize(),
677 sash
= GetSashSize();
679 int size1
= GetSashPosition() - border
,
680 size2
= GetSashPosition() + sash
;
682 int x2
, y2
, w1
, h1
, w2
, h2
;
683 if ( GetSplitMode() == wxSPLIT_VERTICAL
)
686 w2
= w
- 2*border
- sash
- w1
;
692 else // horz splitter
697 h2
= h
- 2*border
- sash
- h1
;
702 GetWindow2()->SetSize(x2
, y2
, w2
, h2
);
703 GetWindow1()->SetSize(border
, border
, w1
, h1
);
709 SetNeedUpdating(false);
712 // Set pane for unsplit window
713 void wxSplitterWindow::Initialize(wxWindow
*window
)
715 wxASSERT_MSG( (!window
|| (window
&& window
->GetParent() == this)),
716 _T("windows in the splitter should have it as parent!") );
718 if (window
&& !window
->IsShown())
721 m_windowOne
= window
;
722 m_windowTwo
= (wxWindow
*) NULL
;
723 DoSetSashPosition(0);
726 // Associates the given window with window 2, drawing the appropriate sash
727 // and changing the split mode.
728 // Does nothing and returns false if the window is already split.
729 bool wxSplitterWindow::DoSplit(wxSplitMode mode
,
730 wxWindow
*window1
, wxWindow
*window2
,
736 wxCHECK_MSG( window1
&& window2
, false,
737 _T("can not split with NULL window(s)") );
739 wxCHECK_MSG( window1
->GetParent() == this && window2
->GetParent() == this, false,
740 _T("windows in the splitter should have it as parent!") );
742 if (! window1
->IsShown())
744 if (! window2
->IsShown())
748 m_windowOne
= window1
;
749 m_windowTwo
= window2
;
751 // remember the sash position we want to set for later if we can't set it
752 // right now (e.g. because the window is too small)
753 m_requestedSashPosition
= sashPosition
;
754 m_checkRequestedSashPosition
= false;
756 DoSetSashPosition(ConvertSashPosition(sashPosition
));
763 int wxSplitterWindow::ConvertSashPosition(int sashPosition
) const
765 if ( sashPosition
> 0 )
769 else if ( sashPosition
< 0 )
771 // It's negative so adding is subtracting
772 return GetWindowSize() + sashPosition
;
774 else // sashPosition == 0
776 // default, put it in the centre
777 return GetWindowSize() / 2;
781 // Remove the specified (or second) window from the view
782 // Doesn't actually delete the window.
783 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
789 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
792 m_windowTwo
= (wxWindow
*) NULL
;
794 else if ( toRemove
== m_windowOne
)
797 m_windowOne
= m_windowTwo
;
798 m_windowTwo
= (wxWindow
*) NULL
;
802 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
808 DoSetSashPosition(0);
814 // Replace a window with another one
815 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
817 wxCHECK_MSG( winOld
, false, wxT("use one of Split() functions instead") );
818 wxCHECK_MSG( winNew
, false, wxT("use Unsplit() functions instead") );
820 if ( winOld
== m_windowTwo
)
822 m_windowTwo
= winNew
;
824 else if ( winOld
== m_windowOne
)
826 m_windowOne
= winNew
;
830 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
840 void wxSplitterWindow::SetMinimumPaneSize(int min
)
842 m_minimumPaneSize
= min
;
843 int pos
= m_requestedSashPosition
!= INT_MAX
? m_requestedSashPosition
: m_sashPosition
;
844 SetSashPosition(pos
); // re-check limits
847 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
849 // remember the sash position we want to set for later if we can't set it
850 // right now (e.g. because the window is too small)
851 m_requestedSashPosition
= position
;
852 m_checkRequestedSashPosition
= false;
854 DoSetSashPosition(ConvertSashPosition(position
));
862 // Make sure the child window sizes are updated. This is useful
863 // for reducing flicker by updating the sizes before a
864 // window is shown, if you know the overall size is correct.
865 void wxSplitterWindow::UpdateSize()
867 m_checkRequestedSashPosition
= true;
869 m_checkRequestedSashPosition
= false;
872 bool wxSplitterWindow::DoSendEvent(wxSplitterEvent
& event
)
874 return !GetEventHandler()->ProcessEvent(event
) || event
.IsAllowed();
877 wxSize
wxSplitterWindow::DoGetBestSize() const
879 // get best sizes of subwindows
882 size1
= m_windowOne
->GetAdjustedBestSize();
884 size2
= m_windowTwo
->GetAdjustedBestSize();
888 // pSash points to the size component to which sash size must be added
891 if ( m_splitMode
== wxSPLIT_VERTICAL
)
893 sizeBest
.y
= wxMax(size1
.y
, size2
.y
);
894 sizeBest
.x
= wxMax(size1
.x
, m_minimumPaneSize
) +
895 wxMax(size2
.x
, m_minimumPaneSize
);
899 else // wxSPLIT_HORIZONTAL
901 sizeBest
.x
= wxMax(size1
.x
, size2
.x
);
902 sizeBest
.y
= wxMax(size1
.y
, m_minimumPaneSize
) +
903 wxMax(size2
.y
, m_minimumPaneSize
);
908 // account for the border and the sash
909 int border
= 2*GetBorderSize();
910 *pSash
+= GetSashSize();
911 sizeBest
.x
+= border
;
912 sizeBest
.y
+= border
;
917 // ---------------------------------------------------------------------------
918 // wxSplitterWindow virtual functions: they now just generate the events
919 // ---------------------------------------------------------------------------
921 bool wxSplitterWindow::OnSashPositionChange(int WXUNUSED(newSashPosition
))
923 // always allow by default
927 int wxSplitterWindow::OnSashPositionChanging(int newSashPosition
)
929 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
930 const int UNSPLIT_THRESHOLD
= 4;
932 // first of all, check if OnSashPositionChange() doesn't forbid this change
933 if ( !OnSashPositionChange(newSashPosition
) )
939 // Obtain relevant window dimension for bottom / right threshold check
940 int window_size
= GetWindowSize();
942 bool unsplit_scenario
= false;
943 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
945 // Do edge detection if unsplit premitted
946 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
948 // threshold top / left check
950 unsplit_scenario
= true;
952 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
954 // threshold bottom/right check
955 newSashPosition
= window_size
;
956 unsplit_scenario
= true;
960 if ( !unsplit_scenario
)
962 // If resultant pane would be too small, enlarge it
963 newSashPosition
= AdjustSashPosition(newSashPosition
);
966 // If the result is out of bounds it means minimum size is too big,
967 // so split window in half as best compromise.
968 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
969 newSashPosition
= window_size
/ 2;
971 // now let the event handler have it
973 // FIXME: shouldn't we do it before the adjustments above so as to ensure
974 // that the sash position is always reasonable?
975 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
, this);
976 event
.m_data
.pos
= newSashPosition
;
978 if ( !DoSendEvent(event
) )
980 // the event handler vetoed the change
981 newSashPosition
= -1;
985 // it could have been changed by it
986 newSashPosition
= event
.GetSashPosition();
989 return newSashPosition
;
992 // Called when the sash is double-clicked. The default behaviour is to remove
993 // the sash if the minimum pane size is zero.
994 void wxSplitterWindow::OnDoubleClickSash(int x
, int y
)
996 wxCHECK_RET(m_windowTwo
, wxT("splitter: no window to remove"));
998 // new code should handle events instead of using the virtual functions
999 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
, this);
1000 event
.m_data
.pt
.x
= x
;
1001 event
.m_data
.pt
.y
= y
;
1002 if ( DoSendEvent(event
) )
1004 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
1006 wxWindow
* win
= m_windowTwo
;
1009 wxSplitterEvent
unsplitEvent(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
1010 unsplitEvent
.m_data
.win
= win
;
1011 (void)DoSendEvent(unsplitEvent
);
1015 //else: blocked by user
1018 void wxSplitterWindow::OnUnsplit(wxWindow
*winRemoved
)
1020 // call this before calling the event handler which may delete the window
1021 winRemoved
->Show(false);
1024 #if defined( __WXMSW__ ) || defined( __WXMAC__)
1026 // this is currently called (and needed) under MSW only...
1027 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& event
)
1029 // if we don't do it, the resizing cursor might be set for child window:
1030 // and like this we explicitly say that our cursor should not be used for
1031 // children windows which overlap us
1033 if ( SashHitTest(event
.GetX(), event
.GetY(), 0) )
1035 // default processing is ok
1038 //else: do nothing, in particular, don't call Skip()
1041 #endif // wxMSW || wxMac
1043 #endif // wxUSE_SPLITTER