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 // don't erase the splitter background, it's pointless as we overwrite it
101 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
106 void wxSplitterWindow::Init()
108 m_container
.SetContainerWindow(this);
110 m_splitMode
= wxSPLIT_VERTICAL
;
111 m_permitUnsplitAlways
= true;
112 m_windowOne
= (wxWindow
*) NULL
;
113 m_windowTwo
= (wxWindow
*) NULL
;
114 m_dragMode
= wxSPLIT_DRAG_NONE
;
119 m_sashPosition
= m_requestedSashPosition
= 0;
121 m_lastSize
= wxSize(0,0);
122 m_checkRequestedSashPosition
= false;
123 m_minimumPaneSize
= 0;
124 m_sashCursorWE
= wxCursor(wxCURSOR_SIZEWE
);
125 m_sashCursorNS
= wxCursor(wxCURSOR_SIZENS
);
126 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
128 m_needUpdating
= false;
132 wxSplitterWindow::~wxSplitterWindow()
134 delete m_sashTrackerPen
;
137 // ----------------------------------------------------------------------------
138 // entering/leaving sash
139 // ----------------------------------------------------------------------------
141 void wxSplitterWindow::RedrawIfHotSensitive(bool isHot
)
143 if ( wxRendererNative::Get().GetSplitterParams(this).isHotSensitive
)
150 //else: we don't change our appearance, don't redraw to avoid flicker
153 void wxSplitterWindow::OnEnterSash()
157 RedrawIfHotSensitive(true);
160 void wxSplitterWindow::OnLeaveSash()
162 SetCursor(*wxSTANDARD_CURSOR
);
164 RedrawIfHotSensitive(false);
167 void wxSplitterWindow::SetResizeCursor()
169 SetCursor(m_splitMode
== wxSPLIT_VERTICAL
? m_sashCursorWE
173 // ----------------------------------------------------------------------------
174 // other event handlers
175 // ----------------------------------------------------------------------------
177 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
184 void wxSplitterWindow::OnInternalIdle()
186 wxWindow::OnInternalIdle();
188 // if this is the first idle time after a sash position has potentially
189 // been set, allow SizeWindows to check for a requested size.
190 if (!m_checkRequestedSashPosition
)
192 m_checkRequestedSashPosition
= true;
194 return; // it won't needUpdating in this case
201 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
203 int x
= (int)event
.GetX(),
204 y
= (int)event
.GetY();
206 if (GetWindowStyle() & wxSP_NOSASH
)
209 // with wxSP_LIVE_UPDATE style the splitter windows are always resized
210 // following the mouse movement while it drags the sash, without it we only
211 // draw the sash at the new position but only resize the windows when the
212 // dragging is finished
213 #if defined( __WXMAC__ ) && TARGET_API_MAC_OSX == 1
216 bool isLive
= (GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) != 0;
218 if (event
.LeftDown())
220 if ( SashHitTest(x
, y
) )
222 // Start the drag now
223 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
225 // Capture mouse and set the cursor
231 // remember the initial sash position and draw the initial
233 m_sashPositionCurrent
= m_sashPosition
;
235 DrawSashTracker(x
, y
);
245 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
247 // We can stop dragging now and see what we've got.
248 m_dragMode
= wxSPLIT_DRAG_NONE
;
250 // Release mouse and unset the cursor
252 SetCursor(* wxSTANDARD_CURSOR
);
254 // exit if unsplit after doubleclick
263 DrawSashTracker(m_oldX
, m_oldY
);
266 // the position of the click doesn't exactly correspond to
267 // m_sashPosition, rather it changes it by the distance by which the
269 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
271 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
272 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
273 if ( posSashNew
== -1 )
275 // change not allowed
279 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
281 // Deal with possible unsplit scenarios
282 if ( posSashNew
== 0 )
284 // We remove the first window from the view
285 wxWindow
*removedWindow
= m_windowOne
;
286 m_windowOne
= m_windowTwo
;
287 m_windowTwo
= (wxWindow
*) NULL
;
288 OnUnsplit(removedWindow
);
289 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
290 event
.m_data
.win
= removedWindow
;
291 (void)DoSendEvent(event
);
292 SetSashPositionAndNotify(0);
294 else if ( posSashNew
== GetWindowSize() )
296 // We remove the second window from the view
297 wxWindow
*removedWindow
= m_windowTwo
;
298 m_windowTwo
= (wxWindow
*) NULL
;
299 OnUnsplit(removedWindow
);
300 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
301 event
.m_data
.win
= removedWindow
;
302 (void)DoSendEvent(event
);
303 SetSashPositionAndNotify(0);
307 SetSashPositionAndNotify(posSashNew
);
312 SetSashPositionAndNotify(posSashNew
);
316 } // left up && dragging
317 else if ((event
.Moving() || event
.Leaving() || event
.Entering()) && (m_dragMode
== wxSPLIT_DRAG_NONE
))
319 if ( event
.Leaving() || !SashHitTest(x
, y
) )
324 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
326 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
329 // nothing to do, mouse didn't really move far enough
333 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
334 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
335 if ( posSashNew
== -1 )
337 // change not allowed
341 if ( posSashNew
== m_sashPosition
)
347 DrawSashTracker(m_oldX
, m_oldY
);
350 if (m_splitMode
== wxSPLIT_VERTICAL
)
355 // Remember old positions
360 // As we captured the mouse, we may get the mouse events from outside
361 // our window - for example, negative values in x, y. This has a weird
362 // consequence under MSW where we use unsigned values sometimes and
363 // signed ones other times: the coordinates turn as big positive
364 // numbers and so the sash is drawn on the *right* side of the window
365 // instead of the left (or bottom instead of top). Correct this.
366 if ( (short)m_oldX
< 0 )
368 if ( (short)m_oldY
< 0 )
375 m_sashPositionCurrent
= posSashNew
;
377 DrawSashTracker(m_oldX
, m_oldY
);
381 SetSashPositionAndNotify(posSashNew
);
382 m_needUpdating
= true;
385 else if ( event
.LeftDClick() && m_windowTwo
)
387 OnDoubleClickSash(x
, y
);
391 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
393 // only process this message if we're not iconized - otherwise iconizing
394 // and restoring a window containing the splitter has a funny side effect
395 // of changing the splitter position!
396 wxWindow
*parent
= wxGetTopLevelParent(this);
399 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
402 iconized
= winTop
->IsIconized();
406 wxFAIL_MSG(wxT("should have a top level parent!"));
413 m_lastSize
= wxSize(0,0);
423 GetClientSize(&w
, &h
);
425 int size
= m_splitMode
== wxSPLIT_VERTICAL
? w
: h
;
427 int old_size
= m_splitMode
== wxSPLIT_VERTICAL
? m_lastSize
.x
: m_lastSize
.y
;
430 int delta
= (int) ( (size
- old_size
)*m_sashGravity
);
433 int newPosition
= m_sashPosition
+ delta
;
434 if( newPosition
< m_minimumPaneSize
)
435 newPosition
= m_minimumPaneSize
;
436 SetSashPositionAndNotify(newPosition
);
440 if ( m_sashPosition
>= size
- 5 )
441 SetSashPositionAndNotify(wxMax(10, size
- 40));
442 m_lastSize
= wxSize(w
,h
);
448 void wxSplitterWindow::SetSashGravity(double gravity
)
450 wxCHECK_RET( gravity
>= 0. && gravity
<= 1.,
451 _T("invalid gravity value") );
453 m_sashGravity
= gravity
;
456 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
458 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
459 return false; // No sash
461 int z
= m_splitMode
== wxSPLIT_VERTICAL
? x
: y
;
462 int hitMin
= m_sashPosition
- tolerance
;
463 int hitMax
= m_sashPosition
+ GetSashSize() + tolerance
;
465 return z
>= hitMin
&& z
<= hitMax
;
468 int wxSplitterWindow::GetSashSize() const
470 return wxRendererNative::Get().GetSplitterParams(this).widthSash
;
473 int wxSplitterWindow::GetBorderSize() const
475 return wxRendererNative::Get().GetSplitterParams(this).border
;
479 void wxSplitterWindow::DrawSash(wxDC
& dc
)
481 if (HasFlag(wxSP_3DBORDER
))
482 wxRendererNative::Get().DrawSplitterBorder
489 // don't draw sash if we're not split
490 if ( m_sashPosition
== 0 || !m_windowTwo
)
493 // nor if we're configured to not show it
494 if ( HasFlag(wxSP_NOSASH
) )
497 wxRendererNative::Get().DrawSplitterSash
503 m_splitMode
== wxSPLIT_VERTICAL
? wxVERTICAL
505 m_isHot
? wxCONTROL_CURRENT
: 0
509 // Draw the sash tracker (for whilst moving the sash)
510 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
513 GetClientSize(&w
, &h
);
519 if ( m_splitMode
== wxSPLIT_VERTICAL
)
550 ClientToScreen(&x1
, &y1
);
551 ClientToScreen(&x2
, &y2
);
553 screenDC
.SetLogicalFunction(wxINVERT
);
554 screenDC
.SetPen(*m_sashTrackerPen
);
555 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
557 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
559 screenDC
.SetLogicalFunction(wxCOPY
);
562 int wxSplitterWindow::GetWindowSize() const
564 wxSize size
= GetClientSize();
566 return m_splitMode
== wxSPLIT_VERTICAL
? size
.x
: size
.y
;
569 int wxSplitterWindow::AdjustSashPosition(int sashPos
) const
571 int window_size
= GetWindowSize();
578 // the window shouldn't be smaller than its own minimal size nor
579 // smaller than the minimual pane size specified for this splitter
580 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
581 : win
->GetMinHeight();
583 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
584 minSize
= m_minimumPaneSize
;
586 minSize
+= GetBorderSize();
588 if ( sashPos
< minSize
)
595 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
596 : win
->GetMinHeight();
598 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
599 minSize
= m_minimumPaneSize
;
601 int maxSize
= window_size
- minSize
- GetBorderSize() - GetSashSize();
602 if ( sashPos
> maxSize
)
609 bool wxSplitterWindow::DoSetSashPosition(int sashPos
)
611 int newSashPosition
= AdjustSashPosition(sashPos
);
613 if ( newSashPosition
== m_sashPosition
)
616 m_sashPosition
= newSashPosition
;
621 void wxSplitterWindow::SetSashPositionAndNotify(int sashPos
)
623 // we must reset the request here, otherwise the sash would be stuck at
624 // old position if the user attempted to move the sash after invalid
625 // (e.g. smaller than minsize) sash position was requested using
626 // SetSashPosition():
627 m_requestedSashPosition
= INT_MAX
;
629 if ( DoSetSashPosition(sashPos
) )
631 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
, this);
632 event
.m_data
.pos
= m_sashPosition
;
634 (void)DoSendEvent(event
);
638 // Position and size subwindows.
639 // Note that the border size applies to each subwindow, not
640 // including the edges next to the sash.
641 void wxSplitterWindow::SizeWindows()
643 // check if we have delayed setting the real sash position
644 if ( m_checkRequestedSashPosition
&& m_requestedSashPosition
!= INT_MAX
)
646 int newSashPosition
= ConvertSashPosition(m_requestedSashPosition
);
647 if ( newSashPosition
!= m_sashPosition
)
649 DoSetSashPosition(newSashPosition
);
652 if ( newSashPosition
<= m_sashPosition
653 && newSashPosition
>= m_sashPosition
- GetBorderSize() )
655 // don't update it any more
656 m_requestedSashPosition
= INT_MAX
;
661 GetClientSize(&w
, &h
);
663 if ( GetWindow1() && !GetWindow2() )
665 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
666 w
- 2*GetBorderSize(), h
- 2*GetBorderSize());
668 else if ( GetWindow1() && GetWindow2() )
670 const int border
= GetBorderSize(),
671 sash
= GetSashSize();
673 int size1
= GetSashPosition() - border
,
674 size2
= GetSashPosition() + sash
;
676 int x2
, y2
, w1
, h1
, w2
, h2
;
677 if ( GetSplitMode() == wxSPLIT_VERTICAL
)
680 w2
= w
- 2*border
- sash
- w1
;
686 else // horz splitter
691 h2
= h
- 2*border
- sash
- h1
;
696 GetWindow1()->SetSize(border
, border
, w1
, h1
);
697 GetWindow2()->SetSize(x2
, y2
, w2
, h2
);
703 SetNeedUpdating(false);
706 // Set pane for unsplit window
707 void wxSplitterWindow::Initialize(wxWindow
*window
)
709 wxASSERT_MSG( (!window
|| (window
&& window
->GetParent() == this)),
710 _T("windows in the splitter should have it as parent!") );
712 if (! window
->IsShown())
715 m_windowOne
= window
;
716 m_windowTwo
= (wxWindow
*) NULL
;
717 DoSetSashPosition(0);
720 // Associates the given window with window 2, drawing the appropriate sash
721 // and changing the split mode.
722 // Does nothing and returns false if the window is already split.
723 bool wxSplitterWindow::DoSplit(wxSplitMode mode
,
724 wxWindow
*window1
, wxWindow
*window2
,
730 wxCHECK_MSG( window1
&& window2
, false,
731 _T("can not split with NULL window(s)") );
733 wxCHECK_MSG( window1
->GetParent() == this && window2
->GetParent() == this, false,
734 _T("windows in the splitter should have it as parent!") );
736 if (! window1
->IsShown())
738 if (! window2
->IsShown())
742 m_windowOne
= window1
;
743 m_windowTwo
= window2
;
745 // remember the sash position we want to set for later if we can't set it
746 // right now (e.g. because the window is too small)
747 m_requestedSashPosition
= sashPosition
;
748 m_checkRequestedSashPosition
= false;
750 DoSetSashPosition(ConvertSashPosition(sashPosition
));
757 int wxSplitterWindow::ConvertSashPosition(int sashPosition
) const
759 if ( sashPosition
> 0 )
763 else if ( sashPosition
< 0 )
765 // It's negative so adding is subtracting
766 return GetWindowSize() + sashPosition
;
768 else // sashPosition == 0
770 // default, put it in the centre
771 return GetWindowSize() / 2;
775 // Remove the specified (or second) window from the view
776 // Doesn't actually delete the window.
777 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
783 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
786 m_windowTwo
= (wxWindow
*) NULL
;
788 else if ( toRemove
== m_windowOne
)
791 m_windowOne
= m_windowTwo
;
792 m_windowTwo
= (wxWindow
*) NULL
;
796 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
802 DoSetSashPosition(0);
808 // Replace a window with another one
809 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
811 wxCHECK_MSG( winOld
, false, wxT("use one of Split() functions instead") );
812 wxCHECK_MSG( winNew
, false, wxT("use Unsplit() functions instead") );
814 if ( winOld
== m_windowTwo
)
816 m_windowTwo
= winNew
;
818 else if ( winOld
== m_windowOne
)
820 m_windowOne
= winNew
;
824 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
834 void wxSplitterWindow::SetMinimumPaneSize(int min
)
836 m_minimumPaneSize
= min
;
837 int pos
= m_requestedSashPosition
!= INT_MAX
? m_requestedSashPosition
: m_sashPosition
;
838 SetSashPosition(pos
); // re-check limits
841 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
843 // remember the sash position we want to set for later if we can't set it
844 // right now (e.g. because the window is too small)
845 m_requestedSashPosition
= position
;
846 m_checkRequestedSashPosition
= false;
848 DoSetSashPosition(ConvertSashPosition(position
));
856 // Make sure the child window sizes are updated. This is useful
857 // for reducing flicker by updating the sizes before a
858 // window is shown, if you know the overall size is correct.
859 void wxSplitterWindow::UpdateSize()
861 m_checkRequestedSashPosition
= true;
863 m_checkRequestedSashPosition
= false;
866 bool wxSplitterWindow::DoSendEvent(wxSplitterEvent
& event
)
868 return !GetEventHandler()->ProcessEvent(event
) || event
.IsAllowed();
871 wxSize
wxSplitterWindow::DoGetBestSize() const
873 // get best sizes of subwindows
876 size1
= m_windowOne
->GetBestSize();
878 size2
= m_windowTwo
->GetBestSize();
882 // pSash points to the size component to which sash size must be added
885 if ( m_splitMode
== wxSPLIT_VERTICAL
)
887 sizeBest
.y
= wxMax(size1
.y
, size2
.y
);
888 sizeBest
.x
= wxMax(size1
.x
, m_minimumPaneSize
) +
889 wxMax(size2
.x
, m_minimumPaneSize
);
893 else // wxSPLIT_HORIZONTAL
895 sizeBest
.x
= wxMax(size1
.x
, size2
.x
);
896 sizeBest
.y
= wxMax(size1
.y
, m_minimumPaneSize
) +
897 wxMax(size2
.y
, m_minimumPaneSize
);
902 // account for the border and the sash
903 int border
= 2*GetBorderSize();
904 *pSash
+= GetSashSize();
905 sizeBest
.x
+= border
;
906 sizeBest
.y
+= border
;
911 // ---------------------------------------------------------------------------
912 // wxSplitterWindow virtual functions: they now just generate the events
913 // ---------------------------------------------------------------------------
915 bool wxSplitterWindow::OnSashPositionChange(int WXUNUSED(newSashPosition
))
917 // always allow by default
921 int wxSplitterWindow::OnSashPositionChanging(int newSashPosition
)
923 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
924 const int UNSPLIT_THRESHOLD
= 4;
926 // first of all, check if OnSashPositionChange() doesn't forbid this change
927 if ( !OnSashPositionChange(newSashPosition
) )
933 // Obtain relevant window dimension for bottom / right threshold check
934 int window_size
= GetWindowSize();
936 bool unsplit_scenario
= false;
937 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
939 // Do edge detection if unsplit premitted
940 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
942 // threshold top / left check
944 unsplit_scenario
= true;
946 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
948 // threshold bottom/right check
949 newSashPosition
= window_size
;
950 unsplit_scenario
= true;
954 if ( !unsplit_scenario
)
956 // If resultant pane would be too small, enlarge it
957 newSashPosition
= AdjustSashPosition(newSashPosition
);
960 // If the result is out of bounds it means minimum size is too big,
961 // so split window in half as best compromise.
962 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
963 newSashPosition
= window_size
/ 2;
965 // now let the event handler have it
967 // FIXME: shouldn't we do it before the adjustments above so as to ensure
968 // that the sash position is always reasonable?
969 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
, this);
970 event
.m_data
.pos
= newSashPosition
;
972 if ( !DoSendEvent(event
) )
974 // the event handler vetoed the change
975 newSashPosition
= -1;
979 // it could have been changed by it
980 newSashPosition
= event
.GetSashPosition();
983 return newSashPosition
;
986 // Called when the sash is double-clicked. The default behaviour is to remove
987 // the sash if the minimum pane size is zero.
988 void wxSplitterWindow::OnDoubleClickSash(int x
, int y
)
990 wxCHECK_RET(m_windowTwo
, wxT("splitter: no window to remove"));
992 // new code should handle events instead of using the virtual functions
993 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
, this);
994 event
.m_data
.pt
.x
= x
;
995 event
.m_data
.pt
.y
= y
;
996 if ( DoSendEvent(event
) )
998 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
1000 wxWindow
* win
= m_windowTwo
;
1003 wxSplitterEvent
unsplitEvent(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
1004 unsplitEvent
.m_data
.win
= win
;
1005 (void)DoSendEvent(unsplitEvent
);
1009 //else: blocked by user
1012 void wxSplitterWindow::OnUnsplit(wxWindow
*winRemoved
)
1014 // call this before calling the event handler which may delete the window
1015 winRemoved
->Show(false);
1018 #if defined( __WXMSW__ ) || defined( __WXMAC__)
1020 // this is currently called (and needed) under MSW only...
1021 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& event
)
1023 // if we don't do it, the resizing cursor might be set for child window:
1024 // and like this we explicitly say that our cursor should not be used for
1025 // children windows which overlap us
1027 if ( SashHitTest(event
.GetX(), event
.GetY(), 0) )
1029 // default processing is ok
1032 //else: do nothing, in particular, don't call Skip()
1035 #endif // wxMSW || wxMac
1037 #endif // wxUSE_SPLITTER