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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "splitter.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/string.h"
30 #include "wx/dcscreen.h"
32 #include "wx/window.h"
33 #include "wx/dialog.h"
36 #include "wx/settings.h"
40 #include "wx/mac/private.h"
43 #include "wx/renderer.h"
45 #include "wx/splitter.h"
49 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
)
50 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
)
51 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
)
52 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_UNSPLIT
)
54 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow
, wxWindow
)
65 IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent
, wxNotifyEvent
)
67 BEGIN_EVENT_TABLE(wxSplitterWindow
, wxWindow
)
68 EVT_PAINT(wxSplitterWindow::OnPaint
)
69 EVT_SIZE(wxSplitterWindow::OnSize
)
70 EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent
)
72 #if defined( __WXMSW__ ) || defined( __WXMAC__)
73 EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor
)
76 WX_EVENT_TABLE_CONTROL_CONTAINER(wxSplitterWindow
)
79 WX_DELEGATE_TO_CONTROL_CONTAINER(wxSplitterWindow
);
81 bool wxSplitterWindow::Create(wxWindow
*parent
, wxWindowID id
,
87 // allow TABbing from one window to the other
88 style
|= wxTAB_TRAVERSAL
;
90 // we draw our border ourselves to blend the sash with it
91 style
&= ~wxBORDER_MASK
;
92 style
|= wxBORDER_NONE
;
94 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
97 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
99 // FIXME: with this line the background is not erased at all under GTK1,
100 // so temporary avoid it there
101 #if !defined(__WXGTK__) || defined(__WXGTK20__)
102 // don't erase the splitter background, it's pointless as we overwrite it
104 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
110 void wxSplitterWindow::Init()
112 m_container
.SetContainerWindow(this);
114 m_splitMode
= wxSPLIT_VERTICAL
;
115 m_permitUnsplitAlways
= true;
116 m_windowOne
= (wxWindow
*) NULL
;
117 m_windowTwo
= (wxWindow
*) NULL
;
118 m_dragMode
= wxSPLIT_DRAG_NONE
;
123 m_sashPosition
= m_requestedSashPosition
= 0;
125 m_lastSize
= wxSize(0,0);
126 m_checkRequestedSashPosition
= false;
127 m_minimumPaneSize
= 0;
128 m_sashCursorWE
= wxCursor(wxCURSOR_SIZEWE
);
129 m_sashCursorNS
= wxCursor(wxCURSOR_SIZENS
);
130 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
132 m_needUpdating
= false;
136 wxSplitterWindow::~wxSplitterWindow()
138 delete m_sashTrackerPen
;
141 // ----------------------------------------------------------------------------
142 // entering/leaving sash
143 // ----------------------------------------------------------------------------
145 void wxSplitterWindow::RedrawIfHotSensitive(bool isHot
)
147 if ( wxRendererNative::Get().GetSplitterParams(this).isHotSensitive
)
154 //else: we don't change our appearance, don't redraw to avoid flicker
157 void wxSplitterWindow::OnEnterSash()
161 RedrawIfHotSensitive(true);
164 void wxSplitterWindow::OnLeaveSash()
166 SetCursor(*wxSTANDARD_CURSOR
);
168 RedrawIfHotSensitive(false);
171 void wxSplitterWindow::SetResizeCursor()
173 SetCursor(m_splitMode
== wxSPLIT_VERTICAL
? m_sashCursorWE
177 // ----------------------------------------------------------------------------
178 // other event handlers
179 // ----------------------------------------------------------------------------
181 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
188 void wxSplitterWindow::OnInternalIdle()
190 wxWindow::OnInternalIdle();
192 // if this is the first idle time after a sash position has potentially
193 // been set, allow SizeWindows to check for a requested size.
194 if (!m_checkRequestedSashPosition
)
196 m_checkRequestedSashPosition
= true;
198 return; // it won't needUpdating in this case
205 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
207 int x
= (int)event
.GetX(),
208 y
= (int)event
.GetY();
210 if (GetWindowStyle() & wxSP_NOSASH
)
213 // with wxSP_LIVE_UPDATE style the splitter windows are always resized
214 // following the mouse movement while it drags the sash, without it we only
215 // draw the sash at the new position but only resize the windows when the
216 // dragging is finished
217 #if defined( __WXMAC__ ) && TARGET_API_MAC_OSX == 1
220 bool isLive
= (GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) != 0;
222 if (event
.LeftDown())
224 if ( SashHitTest(x
, y
) )
226 // Start the drag now
227 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
229 // Capture mouse and set the cursor
235 // remember the initial sash position and draw the initial
237 m_sashPositionCurrent
= m_sashPosition
;
239 DrawSashTracker(x
, y
);
249 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
251 // We can stop dragging now and see what we've got.
252 m_dragMode
= wxSPLIT_DRAG_NONE
;
254 // Release mouse and unset the cursor
256 SetCursor(* wxSTANDARD_CURSOR
);
258 // exit if unsplit after doubleclick
267 DrawSashTracker(m_oldX
, m_oldY
);
270 // the position of the click doesn't exactly correspond to
271 // m_sashPosition, rather it changes it by the distance by which the
273 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
275 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
276 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
277 if ( posSashNew
== -1 )
279 // change not allowed
283 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
285 // Deal with possible unsplit scenarios
286 if ( posSashNew
== 0 )
288 // We remove the first window from the view
289 wxWindow
*removedWindow
= m_windowOne
;
290 m_windowOne
= m_windowTwo
;
291 m_windowTwo
= (wxWindow
*) NULL
;
292 OnUnsplit(removedWindow
);
293 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
294 event
.m_data
.win
= removedWindow
;
295 (void)DoSendEvent(event
);
296 SetSashPositionAndNotify(0);
298 else if ( posSashNew
== GetWindowSize() )
300 // We remove the second window from the view
301 wxWindow
*removedWindow
= m_windowTwo
;
302 m_windowTwo
= (wxWindow
*) NULL
;
303 OnUnsplit(removedWindow
);
304 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
305 event
.m_data
.win
= removedWindow
;
306 (void)DoSendEvent(event
);
307 SetSashPositionAndNotify(0);
311 SetSashPositionAndNotify(posSashNew
);
316 SetSashPositionAndNotify(posSashNew
);
320 } // left up && dragging
321 else if ((event
.Moving() || event
.Leaving() || event
.Entering()) && (m_dragMode
== wxSPLIT_DRAG_NONE
))
323 if ( event
.Leaving() || !SashHitTest(x
, y
) )
328 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
330 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
333 // nothing to do, mouse didn't really move far enough
337 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
338 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
339 if ( posSashNew
== -1 )
341 // change not allowed
345 if ( posSashNew
== m_sashPosition
)
351 DrawSashTracker(m_oldX
, m_oldY
);
354 if (m_splitMode
== wxSPLIT_VERTICAL
)
359 // Remember old positions
364 // As we captured the mouse, we may get the mouse events from outside
365 // our window - for example, negative values in x, y. This has a weird
366 // consequence under MSW where we use unsigned values sometimes and
367 // signed ones other times: the coordinates turn as big positive
368 // numbers and so the sash is drawn on the *right* side of the window
369 // instead of the left (or bottom instead of top). Correct this.
370 if ( (short)m_oldX
< 0 )
372 if ( (short)m_oldY
< 0 )
379 m_sashPositionCurrent
= posSashNew
;
381 DrawSashTracker(m_oldX
, m_oldY
);
385 SetSashPositionAndNotify(posSashNew
);
386 m_needUpdating
= true;
389 else if ( event
.LeftDClick() && m_windowTwo
)
391 OnDoubleClickSash(x
, y
);
395 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
397 // only process this message if we're not iconized - otherwise iconizing
398 // and restoring a window containing the splitter has a funny side effect
399 // of changing the splitter position!
400 wxWindow
*parent
= wxGetTopLevelParent(this);
403 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
406 iconized
= winTop
->IsIconized();
410 wxFAIL_MSG(wxT("should have a top level parent!"));
417 m_lastSize
= wxSize(0,0);
427 GetClientSize(&w
, &h
);
429 int size
= m_splitMode
== wxSPLIT_VERTICAL
? w
: h
;
431 int old_size
= m_splitMode
== wxSPLIT_VERTICAL
? m_lastSize
.x
: m_lastSize
.y
;
434 int delta
= (int) ( (size
- old_size
)*m_sashGravity
);
437 int newPosition
= m_sashPosition
+ delta
;
438 if( newPosition
< m_minimumPaneSize
)
439 newPosition
= m_minimumPaneSize
;
440 SetSashPositionAndNotify(newPosition
);
444 if ( m_sashPosition
>= size
- 5 )
445 SetSashPositionAndNotify(wxMax(10, size
- 40));
446 m_lastSize
= wxSize(w
,h
);
452 void wxSplitterWindow::SetSashGravity(double gravity
)
454 wxCHECK_RET( gravity
>= 0. && gravity
<= 1.,
455 _T("invalid gravity value") );
457 m_sashGravity
= gravity
;
460 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
462 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
463 return false; // No sash
465 int z
= m_splitMode
== wxSPLIT_VERTICAL
? x
: y
;
466 int hitMin
= m_sashPosition
- tolerance
;
467 int hitMax
= m_sashPosition
+ GetSashSize() + tolerance
;
469 return z
>= hitMin
&& z
<= hitMax
;
472 int wxSplitterWindow::GetSashSize() const
474 return wxRendererNative::Get().GetSplitterParams(this).widthSash
;
477 int wxSplitterWindow::GetBorderSize() const
479 return wxRendererNative::Get().GetSplitterParams(this).border
;
483 void wxSplitterWindow::DrawSash(wxDC
& dc
)
485 if (HasFlag(wxSP_3DBORDER
))
486 wxRendererNative::Get().DrawSplitterBorder
493 // don't draw sash if we're not split
494 if ( m_sashPosition
== 0 || !m_windowTwo
)
497 // nor if we're configured to not show it
498 if ( HasFlag(wxSP_NOSASH
) )
501 wxRendererNative::Get().DrawSplitterSash
507 m_splitMode
== wxSPLIT_VERTICAL
? wxVERTICAL
509 m_isHot
? (int)wxCONTROL_CURRENT
: 0
513 // Draw the sash tracker (for whilst moving the sash)
514 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
517 GetClientSize(&w
, &h
);
523 if ( m_splitMode
== wxSPLIT_VERTICAL
)
554 ClientToScreen(&x1
, &y1
);
555 ClientToScreen(&x2
, &y2
);
557 screenDC
.SetLogicalFunction(wxINVERT
);
558 screenDC
.SetPen(*m_sashTrackerPen
);
559 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
561 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
563 screenDC
.SetLogicalFunction(wxCOPY
);
566 int wxSplitterWindow::GetWindowSize() const
568 wxSize size
= GetClientSize();
570 return m_splitMode
== wxSPLIT_VERTICAL
? size
.x
: size
.y
;
573 int wxSplitterWindow::AdjustSashPosition(int sashPos
) const
575 int window_size
= GetWindowSize();
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
= window_size
- minSize
- GetBorderSize() - GetSashSize();
606 if ( 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 if ( DoSetSashPosition(sashPos
) )
635 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
, this);
636 event
.m_data
.pos
= m_sashPosition
;
638 (void)DoSendEvent(event
);
642 // Position and size subwindows.
643 // Note that the border size applies to each subwindow, not
644 // including the edges next to the sash.
645 void wxSplitterWindow::SizeWindows()
647 // check if we have delayed setting the real sash position
648 if ( m_checkRequestedSashPosition
&& m_requestedSashPosition
!= INT_MAX
)
650 int newSashPosition
= ConvertSashPosition(m_requestedSashPosition
);
651 if ( newSashPosition
!= m_sashPosition
)
653 DoSetSashPosition(newSashPosition
);
656 if ( newSashPosition
<= m_sashPosition
657 && newSashPosition
>= m_sashPosition
- GetBorderSize() )
659 // don't update it any more
660 m_requestedSashPosition
= INT_MAX
;
665 GetClientSize(&w
, &h
);
667 if ( GetWindow1() && !GetWindow2() )
669 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
670 w
- 2*GetBorderSize(), h
- 2*GetBorderSize());
672 else if ( GetWindow1() && GetWindow2() )
674 const int border
= GetBorderSize(),
675 sash
= GetSashSize();
677 int size1
= GetSashPosition() - border
,
678 size2
= GetSashPosition() + sash
;
680 int x2
, y2
, w1
, h1
, w2
, h2
;
681 if ( GetSplitMode() == wxSPLIT_VERTICAL
)
684 w2
= w
- 2*border
- sash
- w1
;
690 else // horz splitter
695 h2
= h
- 2*border
- sash
- h1
;
700 GetWindow1()->SetSize(border
, border
, w1
, h1
);
701 GetWindow2()->SetSize(x2
, y2
, w2
, h2
);
707 SetNeedUpdating(false);
710 // Set pane for unsplit window
711 void wxSplitterWindow::Initialize(wxWindow
*window
)
713 wxASSERT_MSG( (!window
|| (window
&& window
->GetParent() == this)),
714 _T("windows in the splitter should have it as parent!") );
716 if (! window
->IsShown())
719 m_windowOne
= window
;
720 m_windowTwo
= (wxWindow
*) NULL
;
721 DoSetSashPosition(0);
724 // Associates the given window with window 2, drawing the appropriate sash
725 // and changing the split mode.
726 // Does nothing and returns false if the window is already split.
727 bool wxSplitterWindow::DoSplit(wxSplitMode mode
,
728 wxWindow
*window1
, wxWindow
*window2
,
734 wxCHECK_MSG( window1
&& window2
, false,
735 _T("can not split with NULL window(s)") );
737 wxCHECK_MSG( window1
->GetParent() == this && window2
->GetParent() == this, false,
738 _T("windows in the splitter should have it as parent!") );
740 if (! window1
->IsShown())
742 if (! window2
->IsShown())
746 m_windowOne
= window1
;
747 m_windowTwo
= window2
;
749 // remember the sash position we want to set for later if we can't set it
750 // right now (e.g. because the window is too small)
751 m_requestedSashPosition
= sashPosition
;
752 m_checkRequestedSashPosition
= false;
754 DoSetSashPosition(ConvertSashPosition(sashPosition
));
761 int wxSplitterWindow::ConvertSashPosition(int sashPosition
) const
763 if ( sashPosition
> 0 )
767 else if ( sashPosition
< 0 )
769 // It's negative so adding is subtracting
770 return GetWindowSize() + sashPosition
;
772 else // sashPosition == 0
774 // default, put it in the centre
775 return GetWindowSize() / 2;
779 // Remove the specified (or second) window from the view
780 // Doesn't actually delete the window.
781 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
787 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
790 m_windowTwo
= (wxWindow
*) NULL
;
792 else if ( toRemove
== m_windowOne
)
795 m_windowOne
= m_windowTwo
;
796 m_windowTwo
= (wxWindow
*) NULL
;
800 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
806 DoSetSashPosition(0);
812 // Replace a window with another one
813 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
815 wxCHECK_MSG( winOld
, false, wxT("use one of Split() functions instead") );
816 wxCHECK_MSG( winNew
, false, wxT("use Unsplit() functions instead") );
818 if ( winOld
== m_windowTwo
)
820 m_windowTwo
= winNew
;
822 else if ( winOld
== m_windowOne
)
824 m_windowOne
= winNew
;
828 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
838 void wxSplitterWindow::SetMinimumPaneSize(int min
)
840 m_minimumPaneSize
= min
;
841 int pos
= m_requestedSashPosition
!= INT_MAX
? m_requestedSashPosition
: m_sashPosition
;
842 SetSashPosition(pos
); // re-check limits
845 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
847 // remember the sash position we want to set for later if we can't set it
848 // right now (e.g. because the window is too small)
849 m_requestedSashPosition
= position
;
850 m_checkRequestedSashPosition
= false;
852 DoSetSashPosition(ConvertSashPosition(position
));
860 // Make sure the child window sizes are updated. This is useful
861 // for reducing flicker by updating the sizes before a
862 // window is shown, if you know the overall size is correct.
863 void wxSplitterWindow::UpdateSize()
865 m_checkRequestedSashPosition
= true;
867 m_checkRequestedSashPosition
= false;
870 bool wxSplitterWindow::DoSendEvent(wxSplitterEvent
& event
)
872 return !GetEventHandler()->ProcessEvent(event
) || event
.IsAllowed();
875 wxSize
wxSplitterWindow::DoGetBestSize() const
877 // get best sizes of subwindows
880 size1
= m_windowOne
->GetAdjustedBestSize();
882 size2
= m_windowTwo
->GetAdjustedBestSize();
886 // pSash points to the size component to which sash size must be added
889 if ( m_splitMode
== wxSPLIT_VERTICAL
)
891 sizeBest
.y
= wxMax(size1
.y
, size2
.y
);
892 sizeBest
.x
= wxMax(size1
.x
, m_minimumPaneSize
) +
893 wxMax(size2
.x
, m_minimumPaneSize
);
897 else // wxSPLIT_HORIZONTAL
899 sizeBest
.x
= wxMax(size1
.x
, size2
.x
);
900 sizeBest
.y
= wxMax(size1
.y
, m_minimumPaneSize
) +
901 wxMax(size2
.y
, m_minimumPaneSize
);
906 // account for the border and the sash
907 int border
= 2*GetBorderSize();
908 *pSash
+= GetSashSize();
909 sizeBest
.x
+= border
;
910 sizeBest
.y
+= border
;
915 // ---------------------------------------------------------------------------
916 // wxSplitterWindow virtual functions: they now just generate the events
917 // ---------------------------------------------------------------------------
919 bool wxSplitterWindow::OnSashPositionChange(int WXUNUSED(newSashPosition
))
921 // always allow by default
925 int wxSplitterWindow::OnSashPositionChanging(int newSashPosition
)
927 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
928 const int UNSPLIT_THRESHOLD
= 4;
930 // first of all, check if OnSashPositionChange() doesn't forbid this change
931 if ( !OnSashPositionChange(newSashPosition
) )
937 // Obtain relevant window dimension for bottom / right threshold check
938 int window_size
= GetWindowSize();
940 bool unsplit_scenario
= false;
941 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
943 // Do edge detection if unsplit premitted
944 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
946 // threshold top / left check
948 unsplit_scenario
= true;
950 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
952 // threshold bottom/right check
953 newSashPosition
= window_size
;
954 unsplit_scenario
= true;
958 if ( !unsplit_scenario
)
960 // If resultant pane would be too small, enlarge it
961 newSashPosition
= AdjustSashPosition(newSashPosition
);
964 // If the result is out of bounds it means minimum size is too big,
965 // so split window in half as best compromise.
966 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
967 newSashPosition
= window_size
/ 2;
969 // now let the event handler have it
971 // FIXME: shouldn't we do it before the adjustments above so as to ensure
972 // that the sash position is always reasonable?
973 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
, this);
974 event
.m_data
.pos
= newSashPosition
;
976 if ( !DoSendEvent(event
) )
978 // the event handler vetoed the change
979 newSashPosition
= -1;
983 // it could have been changed by it
984 newSashPosition
= event
.GetSashPosition();
987 return newSashPosition
;
990 // Called when the sash is double-clicked. The default behaviour is to remove
991 // the sash if the minimum pane size is zero.
992 void wxSplitterWindow::OnDoubleClickSash(int x
, int y
)
994 wxCHECK_RET(m_windowTwo
, wxT("splitter: no window to remove"));
996 // new code should handle events instead of using the virtual functions
997 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
, this);
998 event
.m_data
.pt
.x
= x
;
999 event
.m_data
.pt
.y
= y
;
1000 if ( DoSendEvent(event
) )
1002 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
1004 wxWindow
* win
= m_windowTwo
;
1007 wxSplitterEvent
unsplitEvent(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
1008 unsplitEvent
.m_data
.win
= win
;
1009 (void)DoSendEvent(unsplitEvent
);
1013 //else: blocked by user
1016 void wxSplitterWindow::OnUnsplit(wxWindow
*winRemoved
)
1018 // call this before calling the event handler which may delete the window
1019 winRemoved
->Show(false);
1022 #if defined( __WXMSW__ ) || defined( __WXMAC__)
1024 // this is currently called (and needed) under MSW only...
1025 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& event
)
1027 // if we don't do it, the resizing cursor might be set for child window:
1028 // and like this we explicitly say that our cursor should not be used for
1029 // children windows which overlap us
1031 if ( SashHitTest(event
.GetX(), event
.GetY(), 0) )
1033 // default processing is ok
1036 //else: do nothing, in particular, don't call Skip()
1039 #endif // wxMSW || wxMac
1041 #endif // wxUSE_SPLITTER