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 wxDEFINE_EVENT( wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
, wxSplitterEvent
)
43 wxDEFINE_EVENT( wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
, wxSplitterEvent
)
44 wxDEFINE_EVENT( wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
, wxSplitterEvent
)
45 wxDEFINE_EVENT( wxEVT_COMMAND_SPLITTER_UNSPLIT
, wxSplitterEvent
)
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
;
88 // CoreGraphics can't paint sash feedback
89 style
|= wxSP_LIVE_UPDATE
;
92 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
96 m_lastSize
.x
= size
.x
;
98 m_lastSize
.y
= size
.y
;
100 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
102 // FIXME: with this line the background is not erased at all under GTK1,
103 // so temporary avoid it there
104 #if !defined(__WXGTK__) || defined(__WXGTK20__)
105 // don't erase the splitter background, it's pointless as we overwrite it
107 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
113 void wxSplitterWindow::Init()
115 WX_INIT_CONTROL_CONTAINER();
117 m_splitMode
= wxSPLIT_VERTICAL
;
118 m_permitUnsplitAlways
= true;
121 m_dragMode
= wxSPLIT_DRAG_NONE
;
126 m_sashPosition
= m_requestedSashPosition
= 0;
128 m_sashSize
= -1; // -1 means use the native sash size
129 m_lastSize
= wxSize(0,0);
130 m_checkRequestedSashPosition
= false;
131 m_minimumPaneSize
= 0;
132 m_sashCursorWE
= wxCursor(wxCURSOR_SIZEWE
);
133 m_sashCursorNS
= wxCursor(wxCURSOR_SIZENS
);
134 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxPENSTYLE_SOLID
);
136 m_needUpdating
= false;
140 wxSplitterWindow::~wxSplitterWindow()
142 delete m_sashTrackerPen
;
145 // ----------------------------------------------------------------------------
146 // entering/leaving sash
147 // ----------------------------------------------------------------------------
149 void wxSplitterWindow::RedrawIfHotSensitive(bool isHot
)
151 if ( wxRendererNative::Get().GetSplitterParams(this).isHotSensitive
)
158 //else: we don't change our appearance, don't redraw to avoid flicker
161 void wxSplitterWindow::OnEnterSash()
165 RedrawIfHotSensitive(true);
168 void wxSplitterWindow::OnLeaveSash()
170 SetCursor(*wxSTANDARD_CURSOR
);
172 RedrawIfHotSensitive(false);
175 void wxSplitterWindow::SetResizeCursor()
177 SetCursor(m_splitMode
== wxSPLIT_VERTICAL
? m_sashCursorWE
181 // ----------------------------------------------------------------------------
182 // other event handlers
183 // ----------------------------------------------------------------------------
185 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
192 void wxSplitterWindow::OnInternalIdle()
194 wxWindow::OnInternalIdle();
196 // if this is the first idle time after a sash position has potentially
197 // been set, allow SizeWindows to check for a requested size.
198 if (!m_checkRequestedSashPosition
)
200 m_checkRequestedSashPosition
= true;
202 return; // it won't needUpdating in this case
209 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
211 int x
= (int)event
.GetX(),
212 y
= (int)event
.GetY();
214 if ( GetWindowStyle() & wxSP_NOSASH
)
220 // with wxSP_LIVE_UPDATE style the splitter windows are always resized
221 // following the mouse movement while it drags the sash, without it we only
222 // draw the sash at the new position but only resize the windows when the
223 // dragging is finished
224 #if defined( __WXMAC__ )
225 // FIXME : this should be usable also with no live update, but then this
226 // currently is not visible
229 bool isLive
= HasFlag(wxSP_LIVE_UPDATE
);
231 if (event
.LeftDown())
233 if ( SashHitTest(x
, y
) )
235 // Start the drag now
236 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
238 // Capture mouse and set the cursor
244 // remember the initial sash position and draw the initial
246 m_sashPositionCurrent
= m_sashPosition
;
248 DrawSashTracker(x
, y
);
258 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
260 // We can stop dragging now and see what we've got.
261 m_dragMode
= wxSPLIT_DRAG_NONE
;
263 // Release mouse and unset the cursor
265 SetCursor(* wxSTANDARD_CURSOR
);
267 // exit if unsplit after doubleclick
276 DrawSashTracker(m_oldX
, m_oldY
);
279 // the position of the click doesn't exactly correspond to
280 // m_sashPosition, rather it changes it by the distance by which the
282 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
284 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
285 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
286 if ( posSashNew
== -1 )
288 // change not allowed
292 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
294 // Deal with possible unsplit scenarios
295 if ( posSashNew
== 0 )
297 // We remove the first window from the view
298 wxWindow
*removedWindow
= m_windowOne
;
299 m_windowOne
= m_windowTwo
;
301 OnUnsplit(removedWindow
);
302 wxSplitterEvent
eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
303 eventUnsplit
.m_data
.win
= removedWindow
;
304 (void)DoSendEvent(eventUnsplit
);
305 SetSashPositionAndNotify(0);
307 else if ( posSashNew
== GetWindowSize() )
309 // We remove the second window from the view
310 wxWindow
*removedWindow
= m_windowTwo
;
312 OnUnsplit(removedWindow
);
313 wxSplitterEvent
eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
314 eventUnsplit
.m_data
.win
= removedWindow
;
315 (void)DoSendEvent(eventUnsplit
);
316 SetSashPositionAndNotify(0);
320 SetSashPositionAndNotify(posSashNew
);
325 SetSashPositionAndNotify(posSashNew
);
329 } // left up && dragging
330 else if ((event
.Moving() || event
.Leaving() || event
.Entering()) && (m_dragMode
== wxSPLIT_DRAG_NONE
))
332 if ( event
.Leaving() || !SashHitTest(x
, y
) )
337 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
339 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
342 // nothing to do, mouse didn't really move far enough
346 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
347 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
348 if ( posSashNew
== -1 )
350 // change not allowed
354 if ( posSashNew
== m_sashPosition
)
360 DrawSashTracker(m_oldX
, m_oldY
);
363 if (m_splitMode
== wxSPLIT_VERTICAL
)
368 // Remember old positions
373 // As we captured the mouse, we may get the mouse events from outside
374 // our window - for example, negative values in x, y. This has a weird
375 // consequence under MSW where we use unsigned values sometimes and
376 // signed ones other times: the coordinates turn as big positive
377 // numbers and so the sash is drawn on the *right* side of the window
378 // instead of the left (or bottom instead of top). Correct this.
379 if ( (short)m_oldX
< 0 )
381 if ( (short)m_oldY
< 0 )
388 m_sashPositionCurrent
= posSashNew
;
390 DrawSashTracker(m_oldX
, m_oldY
);
394 DoSetSashPosition(posSashNew
);
395 m_needUpdating
= true;
398 else if ( event
.LeftDClick() && m_windowTwo
)
400 OnDoubleClickSash(x
, y
);
408 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
410 // only process this message if we're not iconized - otherwise iconizing
411 // and restoring a window containing the splitter has a funny side effect
412 // of changing the splitter position!
413 wxWindow
*parent
= wxGetTopLevelParent(this);
416 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
419 iconized
= winTop
->IsIconized();
423 wxFAIL_MSG(wxT("should have a top level parent!"));
430 m_lastSize
= wxSize(0,0);
440 GetClientSize(&w
, &h
);
442 int size
= m_splitMode
== wxSPLIT_VERTICAL
? w
: h
;
444 int old_size
= m_splitMode
== wxSPLIT_VERTICAL
? m_lastSize
.x
: m_lastSize
.y
;
447 int delta
= (int) ( (size
- old_size
)*m_sashGravity
);
450 int newPosition
= m_sashPosition
+ delta
;
451 if( newPosition
< m_minimumPaneSize
)
452 newPosition
= m_minimumPaneSize
;
453 SetSashPositionAndNotify(newPosition
);
457 if ( m_sashPosition
>= size
- 5 )
458 SetSashPositionAndNotify(wxMax(10, size
- 40));
459 m_lastSize
= wxSize(w
,h
);
465 void wxSplitterWindow::SetSashGravity(double gravity
)
467 wxCHECK_RET( gravity
>= 0. && gravity
<= 1.,
468 _T("invalid gravity value") );
470 m_sashGravity
= gravity
;
473 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
475 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
476 return false; // No sash
478 int z
= m_splitMode
== wxSPLIT_VERTICAL
? x
: y
;
479 int hitMin
= m_sashPosition
- tolerance
;
480 int hitMax
= m_sashPosition
+ GetSashSize() + tolerance
;
482 return z
>= hitMin
&& z
<= hitMax
;
485 int wxSplitterWindow::GetSashSize() const
487 return m_sashSize
> -1 ? m_sashSize
: wxRendererNative::Get().GetSplitterParams(this).widthSash
;
490 int wxSplitterWindow::GetBorderSize() const
492 return wxRendererNative::Get().GetSplitterParams(this).border
;
496 void wxSplitterWindow::DrawSash(wxDC
& dc
)
498 if (HasFlag(wxSP_3DBORDER
))
499 wxRendererNative::Get().DrawSplitterBorder
506 // don't draw sash if we're not split
507 if ( m_sashPosition
== 0 || !m_windowTwo
)
510 // nor if we're configured to not show it
511 if ( HasFlag(wxSP_NOSASH
) )
514 wxRendererNative::Get().DrawSplitterSash
520 m_splitMode
== wxSPLIT_VERTICAL
? wxVERTICAL
522 m_isHot
? (int)wxCONTROL_CURRENT
: 0
526 // Draw the sash tracker (for whilst moving the sash)
527 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
530 GetClientSize(&w
, &h
);
536 if ( m_splitMode
== wxSPLIT_VERTICAL
)
567 ClientToScreen(&x1
, &y1
);
568 ClientToScreen(&x2
, &y2
);
570 screenDC
.SetLogicalFunction(wxINVERT
);
571 screenDC
.SetPen(*m_sashTrackerPen
);
572 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
574 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
576 screenDC
.SetLogicalFunction(wxCOPY
);
579 int wxSplitterWindow::GetWindowSize() const
581 wxSize size
= GetClientSize();
583 return m_splitMode
== wxSPLIT_VERTICAL
? size
.x
: size
.y
;
586 int wxSplitterWindow::AdjustSashPosition(int sashPos
) const
593 // the window shouldn't be smaller than its own minimal size nor
594 // smaller than the minimual pane size specified for this splitter
595 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
596 : win
->GetMinHeight();
598 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
599 minSize
= m_minimumPaneSize
;
601 minSize
+= GetBorderSize();
603 if ( sashPos
< minSize
)
610 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
611 : win
->GetMinHeight();
613 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
614 minSize
= m_minimumPaneSize
;
616 int maxSize
= GetWindowSize() - minSize
- GetBorderSize() - GetSashSize();
617 if ( maxSize
> 0 && sashPos
> maxSize
)
624 bool wxSplitterWindow::DoSetSashPosition(int sashPos
)
626 int newSashPosition
= AdjustSashPosition(sashPos
);
628 if ( newSashPosition
== m_sashPosition
)
631 m_sashPosition
= newSashPosition
;
636 void wxSplitterWindow::SetSashPositionAndNotify(int sashPos
)
638 // we must reset the request here, otherwise the sash would be stuck at
639 // old position if the user attempted to move the sash after invalid
640 // (e.g. smaller than minsize) sash position was requested using
641 // SetSashPosition():
642 m_requestedSashPosition
= INT_MAX
;
644 // note that we must send the event in any case, i.e. even if the sash
645 // position hasn't changed and DoSetSashPosition() returns false because we
646 // must generate a CHANGED event at the end of resizing
647 DoSetSashPosition(sashPos
);
649 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
, this);
650 event
.m_data
.pos
= m_sashPosition
;
652 (void)DoSendEvent(event
);
655 // Position and size subwindows.
656 // Note that the border size applies to each subwindow, not
657 // including the edges next to the sash.
658 void wxSplitterWindow::SizeWindows()
660 // check if we have delayed setting the real sash position
661 if ( m_checkRequestedSashPosition
&& m_requestedSashPosition
!= INT_MAX
)
663 int newSashPosition
= ConvertSashPosition(m_requestedSashPosition
);
664 if ( newSashPosition
!= m_sashPosition
)
666 DoSetSashPosition(newSashPosition
);
669 if ( newSashPosition
<= m_sashPosition
670 && newSashPosition
>= m_sashPosition
- GetBorderSize() )
672 // don't update it any more
673 m_requestedSashPosition
= INT_MAX
;
678 GetClientSize(&w
, &h
);
680 if ( GetWindow1() && !GetWindow2() )
682 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
683 w
- 2*GetBorderSize(), h
- 2*GetBorderSize());
685 else if ( GetWindow1() && GetWindow2() )
687 const int border
= GetBorderSize(),
688 sash
= GetSashSize();
690 int size1
= GetSashPosition() - border
,
691 size2
= GetSashPosition() + sash
;
693 int x2
, y2
, w1
, h1
, w2
, h2
;
694 if ( GetSplitMode() == wxSPLIT_VERTICAL
)
697 w2
= w
- 2*border
- sash
- w1
;
707 else // horz splitter
714 h2
= h
- 2*border
- sash
- h1
;
721 GetWindow2()->SetSize(x2
, y2
, w2
, h2
);
722 GetWindow1()->SetSize(border
, border
, w1
, h1
);
728 SetNeedUpdating(false);
731 // Set pane for unsplit window
732 void wxSplitterWindow::Initialize(wxWindow
*window
)
734 wxASSERT_MSG( (!window
|| window
->GetParent() == this),
735 _T("windows in the splitter should have it as parent!") );
737 if (window
&& !window
->IsShown())
740 m_windowOne
= window
;
742 DoSetSashPosition(0);
745 // Associates the given window with window 2, drawing the appropriate sash
746 // and changing the split mode.
747 // Does nothing and returns false if the window is already split.
748 bool wxSplitterWindow::DoSplit(wxSplitMode mode
,
749 wxWindow
*window1
, wxWindow
*window2
,
755 wxCHECK_MSG( window1
&& window2
, false,
756 _T("can not split with NULL window(s)") );
758 wxCHECK_MSG( window1
->GetParent() == this && window2
->GetParent() == this, false,
759 _T("windows in the splitter should have it as parent!") );
761 if (! window1
->IsShown())
763 if (! window2
->IsShown())
767 m_windowOne
= window1
;
768 m_windowTwo
= window2
;
770 // remember the sash position we want to set for later if we can't set it
771 // right now (e.g. because the window is too small)
772 m_requestedSashPosition
= sashPosition
;
773 m_checkRequestedSashPosition
= false;
775 DoSetSashPosition(ConvertSashPosition(sashPosition
));
782 int wxSplitterWindow::ConvertSashPosition(int sashPosition
) const
784 if ( sashPosition
> 0 )
788 else if ( sashPosition
< 0 )
790 // It's negative so adding is subtracting
791 return GetWindowSize() + sashPosition
;
793 else // sashPosition == 0
795 // default, put it in the centre
796 return GetWindowSize() / 2;
800 // Remove the specified (or second) window from the view
801 // Doesn't actually delete the window.
802 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
808 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
813 else if ( toRemove
== m_windowOne
)
816 m_windowOne
= m_windowTwo
;
821 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
827 DoSetSashPosition(0);
833 // Replace a window with another one
834 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
836 wxCHECK_MSG( winOld
, false, wxT("use one of Split() functions instead") );
837 wxCHECK_MSG( winNew
, false, wxT("use Unsplit() functions instead") );
839 if ( winOld
== m_windowTwo
)
841 m_windowTwo
= winNew
;
843 else if ( winOld
== m_windowOne
)
845 m_windowOne
= winNew
;
849 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
859 void wxSplitterWindow::SetMinimumPaneSize(int min
)
861 m_minimumPaneSize
= min
;
862 int pos
= m_requestedSashPosition
!= INT_MAX
? m_requestedSashPosition
: m_sashPosition
;
863 SetSashPosition(pos
); // re-check limits
866 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
868 // remember the sash position we want to set for later if we can't set it
869 // right now (e.g. because the window is too small)
870 m_requestedSashPosition
= position
;
871 m_checkRequestedSashPosition
= false;
873 DoSetSashPosition(ConvertSashPosition(position
));
881 // Make sure the child window sizes are updated. This is useful
882 // for reducing flicker by updating the sizes before a
883 // window is shown, if you know the overall size is correct.
884 void wxSplitterWindow::UpdateSize()
886 m_checkRequestedSashPosition
= true;
888 m_checkRequestedSashPosition
= false;
891 bool wxSplitterWindow::DoSendEvent(wxSplitterEvent
& event
)
893 return !GetEventHandler()->ProcessEvent(event
) || event
.IsAllowed();
896 wxSize
wxSplitterWindow::DoGetBestSize() const
898 // get best sizes of subwindows
901 size1
= m_windowOne
->GetEffectiveMinSize();
903 size2
= m_windowTwo
->GetEffectiveMinSize();
907 // pSash points to the size component to which sash size must be added
910 if ( m_splitMode
== wxSPLIT_VERTICAL
)
912 sizeBest
.y
= wxMax(size1
.y
, size2
.y
);
913 sizeBest
.x
= wxMax(size1
.x
, m_minimumPaneSize
) +
914 wxMax(size2
.x
, m_minimumPaneSize
);
918 else // wxSPLIT_HORIZONTAL
920 sizeBest
.x
= wxMax(size1
.x
, size2
.x
);
921 sizeBest
.y
= wxMax(size1
.y
, m_minimumPaneSize
) +
922 wxMax(size2
.y
, m_minimumPaneSize
);
927 // account for the border and the sash
928 int border
= 2*GetBorderSize();
929 *pSash
+= GetSashSize();
930 sizeBest
.x
+= border
;
931 sizeBest
.y
+= border
;
936 // ---------------------------------------------------------------------------
937 // wxSplitterWindow virtual functions: they now just generate the events
938 // ---------------------------------------------------------------------------
940 bool wxSplitterWindow::OnSashPositionChange(int WXUNUSED(newSashPosition
))
942 // always allow by default
946 int wxSplitterWindow::OnSashPositionChanging(int newSashPosition
)
948 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
949 const int UNSPLIT_THRESHOLD
= 4;
951 // first of all, check if OnSashPositionChange() doesn't forbid this change
952 if ( !OnSashPositionChange(newSashPosition
) )
958 // Obtain relevant window dimension for bottom / right threshold check
959 int window_size
= GetWindowSize();
961 bool unsplit_scenario
= false;
962 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
964 // Do edge detection if unsplit premitted
965 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
967 // threshold top / left check
969 unsplit_scenario
= true;
971 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
973 // threshold bottom/right check
974 newSashPosition
= window_size
;
975 unsplit_scenario
= true;
979 if ( !unsplit_scenario
)
981 // If resultant pane would be too small, enlarge it
982 newSashPosition
= AdjustSashPosition(newSashPosition
);
985 // If the result is out of bounds it means minimum size is too big,
986 // so split window in half as best compromise.
987 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
988 newSashPosition
= window_size
/ 2;
990 // now let the event handler have it
992 // FIXME: shouldn't we do it before the adjustments above so as to ensure
993 // that the sash position is always reasonable?
994 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
, this);
995 event
.m_data
.pos
= newSashPosition
;
997 if ( !DoSendEvent(event
) )
999 // the event handler vetoed the change
1000 newSashPosition
= -1;
1004 // it could have been changed by it
1005 newSashPosition
= event
.GetSashPosition();
1008 return newSashPosition
;
1011 // Called when the sash is double-clicked. The default behaviour is to remove
1012 // the sash if the minimum pane size is zero.
1013 void wxSplitterWindow::OnDoubleClickSash(int x
, int y
)
1015 wxCHECK_RET(m_windowTwo
, wxT("splitter: no window to remove"));
1017 // new code should handle events instead of using the virtual functions
1018 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
, this);
1019 event
.m_data
.pt
.x
= x
;
1020 event
.m_data
.pt
.y
= y
;
1021 if ( DoSendEvent(event
) )
1023 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
1025 wxWindow
* win
= m_windowTwo
;
1028 wxSplitterEvent
unsplitEvent(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
1029 unsplitEvent
.m_data
.win
= win
;
1030 (void)DoSendEvent(unsplitEvent
);
1034 //else: blocked by user
1037 void wxSplitterWindow::OnUnsplit(wxWindow
*winRemoved
)
1039 // call this before calling the event handler which may delete the window
1040 winRemoved
->Show(false);
1043 #if defined( __WXMSW__ ) || defined( __WXMAC__)
1045 // this is currently called (and needed) under MSW only...
1046 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& event
)
1048 // if we don't do it, the resizing cursor might be set for child window:
1049 // and like this we explicitly say that our cursor should not be used for
1050 // children windows which overlap us
1052 if ( SashHitTest(event
.GetX(), event
.GetY(), 0) )
1054 // default processing is ok
1057 //else: do nothing, in particular, don't call Skip()
1060 #endif // wxMSW || wxMac
1062 #endif // wxUSE_SPLITTER