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/dcclient.h"
27 #include "wx/dcscreen.h"
29 #include "wx/window.h"
30 #include "wx/dialog.h"
33 #include "wx/settings.h"
37 #include "wx/mac/private.h"
40 #include "wx/renderer.h"
42 #include "wx/splitter.h"
46 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
)
47 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
)
48 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
)
49 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_UNSPLIT
)
51 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow
, wxWindow
)
62 IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent
, wxNotifyEvent
)
64 BEGIN_EVENT_TABLE(wxSplitterWindow
, wxWindow
)
65 EVT_PAINT(wxSplitterWindow::OnPaint
)
66 EVT_SIZE(wxSplitterWindow::OnSize
)
67 EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent
)
69 #if defined( __WXMSW__ ) || defined( __WXMAC__)
70 EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor
)
73 WX_EVENT_TABLE_CONTROL_CONTAINER(wxSplitterWindow
)
76 WX_DELEGATE_TO_CONTROL_CONTAINER(wxSplitterWindow
)
78 bool wxSplitterWindow::Create(wxWindow
*parent
, wxWindowID id
,
84 // allow TABbing from one window to the other
85 style
|= wxTAB_TRAVERSAL
;
87 // we draw our border ourselves to blend the sash with it
88 style
&= ~wxBORDER_MASK
;
89 style
|= wxBORDER_NONE
;
91 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
95 m_lastSize
.x
= size
.x
;
97 m_lastSize
.y
= size
.y
;
99 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
101 // FIXME: with this line the background is not erased at all under GTK1,
102 // so temporary avoid it there
103 #if !defined(__WXGTK__) || defined(__WXGTK20__)
104 // don't erase the splitter background, it's pointless as we overwrite it
106 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
112 void wxSplitterWindow::Init()
114 m_container
.SetContainerWindow(this);
116 m_splitMode
= wxSPLIT_VERTICAL
;
117 m_permitUnsplitAlways
= true;
118 m_windowOne
= (wxWindow
*) NULL
;
119 m_windowTwo
= (wxWindow
*) NULL
;
120 m_dragMode
= wxSPLIT_DRAG_NONE
;
125 m_sashPosition
= m_requestedSashPosition
= 0;
127 m_sashSize
= -1; // -1 means use the native sash size
128 m_lastSize
= wxSize(0,0);
129 m_checkRequestedSashPosition
= false;
130 m_minimumPaneSize
= 0;
131 m_sashCursorWE
= wxCursor(wxCURSOR_SIZEWE
);
132 m_sashCursorNS
= wxCursor(wxCURSOR_SIZENS
);
133 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
135 m_needUpdating
= false;
139 wxSplitterWindow::~wxSplitterWindow()
141 delete m_sashTrackerPen
;
144 // ----------------------------------------------------------------------------
145 // entering/leaving sash
146 // ----------------------------------------------------------------------------
148 void wxSplitterWindow::RedrawIfHotSensitive(bool isHot
)
150 if ( wxRendererNative::Get().GetSplitterParams(this).isHotSensitive
)
157 //else: we don't change our appearance, don't redraw to avoid flicker
160 void wxSplitterWindow::OnEnterSash()
164 RedrawIfHotSensitive(true);
167 void wxSplitterWindow::OnLeaveSash()
169 SetCursor(*wxSTANDARD_CURSOR
);
171 RedrawIfHotSensitive(false);
174 void wxSplitterWindow::SetResizeCursor()
176 SetCursor(m_splitMode
== wxSPLIT_VERTICAL
? m_sashCursorWE
180 // ----------------------------------------------------------------------------
181 // other event handlers
182 // ----------------------------------------------------------------------------
184 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
191 void wxSplitterWindow::OnInternalIdle()
193 wxWindow::OnInternalIdle();
195 // if this is the first idle time after a sash position has potentially
196 // been set, allow SizeWindows to check for a requested size.
197 if (!m_checkRequestedSashPosition
)
199 m_checkRequestedSashPosition
= true;
201 return; // it won't needUpdating in this case
208 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
210 int x
= (int)event
.GetX(),
211 y
= (int)event
.GetY();
213 if (GetWindowStyle() & wxSP_NOSASH
)
216 // with wxSP_LIVE_UPDATE style the splitter windows are always resized
217 // following the mouse movement while it drags the sash, without it we only
218 // draw the sash at the new position but only resize the windows when the
219 // dragging is finished
220 #if defined( __WXMAC__ ) && TARGET_API_MAC_OSX == 1
223 bool isLive
= (GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) != 0;
225 if (event
.LeftDown())
227 if ( SashHitTest(x
, y
) )
229 // Start the drag now
230 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
232 // Capture mouse and set the cursor
238 // remember the initial sash position and draw the initial
240 m_sashPositionCurrent
= m_sashPosition
;
242 DrawSashTracker(x
, y
);
252 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
254 // We can stop dragging now and see what we've got.
255 m_dragMode
= wxSPLIT_DRAG_NONE
;
257 // Release mouse and unset the cursor
259 SetCursor(* wxSTANDARD_CURSOR
);
261 // exit if unsplit after doubleclick
270 DrawSashTracker(m_oldX
, m_oldY
);
273 // the position of the click doesn't exactly correspond to
274 // m_sashPosition, rather it changes it by the distance by which the
276 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
278 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
279 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
280 if ( posSashNew
== -1 )
282 // change not allowed
286 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
288 // Deal with possible unsplit scenarios
289 if ( posSashNew
== 0 )
291 // We remove the first window from the view
292 wxWindow
*removedWindow
= m_windowOne
;
293 m_windowOne
= m_windowTwo
;
294 m_windowTwo
= (wxWindow
*) NULL
;
295 OnUnsplit(removedWindow
);
296 wxSplitterEvent
eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
297 eventUnsplit
.m_data
.win
= removedWindow
;
298 (void)DoSendEvent(eventUnsplit
);
299 SetSashPositionAndNotify(0);
301 else if ( posSashNew
== GetWindowSize() )
303 // We remove the second window from the view
304 wxWindow
*removedWindow
= m_windowTwo
;
305 m_windowTwo
= (wxWindow
*) NULL
;
306 OnUnsplit(removedWindow
);
307 wxSplitterEvent
eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
308 eventUnsplit
.m_data
.win
= removedWindow
;
309 (void)DoSendEvent(eventUnsplit
);
310 SetSashPositionAndNotify(0);
314 SetSashPositionAndNotify(posSashNew
);
319 SetSashPositionAndNotify(posSashNew
);
323 } // left up && dragging
324 else if ((event
.Moving() || event
.Leaving() || event
.Entering()) && (m_dragMode
== wxSPLIT_DRAG_NONE
))
326 if ( event
.Leaving() || !SashHitTest(x
, y
) )
331 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
333 int diff
= m_splitMode
== wxSPLIT_VERTICAL
? x
- m_oldX
: y
- m_oldY
;
336 // nothing to do, mouse didn't really move far enough
340 int posSashOld
= isLive
? m_sashPosition
: m_sashPositionCurrent
;
341 int posSashNew
= OnSashPositionChanging(posSashOld
+ diff
);
342 if ( posSashNew
== -1 )
344 // change not allowed
348 if ( posSashNew
== m_sashPosition
)
354 DrawSashTracker(m_oldX
, m_oldY
);
357 if (m_splitMode
== wxSPLIT_VERTICAL
)
362 // Remember old positions
367 // As we captured the mouse, we may get the mouse events from outside
368 // our window - for example, negative values in x, y. This has a weird
369 // consequence under MSW where we use unsigned values sometimes and
370 // signed ones other times: the coordinates turn as big positive
371 // numbers and so the sash is drawn on the *right* side of the window
372 // instead of the left (or bottom instead of top). Correct this.
373 if ( (short)m_oldX
< 0 )
375 if ( (short)m_oldY
< 0 )
382 m_sashPositionCurrent
= posSashNew
;
384 DrawSashTracker(m_oldX
, m_oldY
);
388 DoSetSashPosition(posSashNew
);
389 m_needUpdating
= true;
392 else if ( event
.LeftDClick() && m_windowTwo
)
394 OnDoubleClickSash(x
, y
);
398 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
400 // only process this message if we're not iconized - otherwise iconizing
401 // and restoring a window containing the splitter has a funny side effect
402 // of changing the splitter position!
403 wxWindow
*parent
= wxGetTopLevelParent(this);
406 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
409 iconized
= winTop
->IsIconized();
413 wxFAIL_MSG(wxT("should have a top level parent!"));
420 m_lastSize
= wxSize(0,0);
430 GetClientSize(&w
, &h
);
432 int size
= m_splitMode
== wxSPLIT_VERTICAL
? w
: h
;
434 int old_size
= m_splitMode
== wxSPLIT_VERTICAL
? m_lastSize
.x
: m_lastSize
.y
;
437 int delta
= (int) ( (size
- old_size
)*m_sashGravity
);
440 int newPosition
= m_sashPosition
+ delta
;
441 if( newPosition
< m_minimumPaneSize
)
442 newPosition
= m_minimumPaneSize
;
443 SetSashPositionAndNotify(newPosition
);
447 if ( m_sashPosition
>= size
- 5 )
448 SetSashPositionAndNotify(wxMax(10, size
- 40));
449 m_lastSize
= wxSize(w
,h
);
455 void wxSplitterWindow::SetSashGravity(double gravity
)
457 wxCHECK_RET( gravity
>= 0. && gravity
<= 1.,
458 _T("invalid gravity value") );
460 m_sashGravity
= gravity
;
463 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
465 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
466 return false; // No sash
468 int z
= m_splitMode
== wxSPLIT_VERTICAL
? x
: y
;
469 int hitMin
= m_sashPosition
- tolerance
;
470 int hitMax
= m_sashPosition
+ GetSashSize() + tolerance
;
472 return z
>= hitMin
&& z
<= hitMax
;
475 int wxSplitterWindow::GetSashSize() const
477 return m_sashSize
> -1 ? m_sashSize
: wxRendererNative::Get().GetSplitterParams(this).widthSash
;
480 int wxSplitterWindow::GetBorderSize() const
482 return wxRendererNative::Get().GetSplitterParams(this).border
;
486 void wxSplitterWindow::DrawSash(wxDC
& dc
)
488 if (HasFlag(wxSP_3DBORDER
))
489 wxRendererNative::Get().DrawSplitterBorder
496 // don't draw sash if we're not split
497 if ( m_sashPosition
== 0 || !m_windowTwo
)
500 // nor if we're configured to not show it
501 if ( HasFlag(wxSP_NOSASH
) )
504 wxRendererNative::Get().DrawSplitterSash
510 m_splitMode
== wxSPLIT_VERTICAL
? wxVERTICAL
512 m_isHot
? (int)wxCONTROL_CURRENT
: 0
516 // Draw the sash tracker (for whilst moving the sash)
517 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
520 GetClientSize(&w
, &h
);
526 if ( m_splitMode
== wxSPLIT_VERTICAL
)
557 ClientToScreen(&x1
, &y1
);
558 ClientToScreen(&x2
, &y2
);
560 screenDC
.SetLogicalFunction(wxINVERT
);
561 screenDC
.SetPen(*m_sashTrackerPen
);
562 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
564 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
566 screenDC
.SetLogicalFunction(wxCOPY
);
569 int wxSplitterWindow::GetWindowSize() const
571 wxSize size
= GetClientSize();
573 return m_splitMode
== wxSPLIT_VERTICAL
? size
.x
: size
.y
;
576 int wxSplitterWindow::AdjustSashPosition(int sashPos
) const
583 // the window shouldn't be smaller than its own minimal size nor
584 // smaller than the minimual pane size specified for this splitter
585 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
586 : win
->GetMinHeight();
588 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
589 minSize
= m_minimumPaneSize
;
591 minSize
+= GetBorderSize();
593 if ( sashPos
< minSize
)
600 int minSize
= m_splitMode
== wxSPLIT_VERTICAL
? win
->GetMinWidth()
601 : win
->GetMinHeight();
603 if ( minSize
== -1 || m_minimumPaneSize
> minSize
)
604 minSize
= m_minimumPaneSize
;
606 int maxSize
= GetWindowSize() - minSize
- GetBorderSize() - GetSashSize();
607 if ( maxSize
> 0 && sashPos
> maxSize
)
614 bool wxSplitterWindow::DoSetSashPosition(int sashPos
)
616 int newSashPosition
= AdjustSashPosition(sashPos
);
618 if ( newSashPosition
== m_sashPosition
)
621 m_sashPosition
= newSashPosition
;
626 void wxSplitterWindow::SetSashPositionAndNotify(int sashPos
)
628 // we must reset the request here, otherwise the sash would be stuck at
629 // old position if the user attempted to move the sash after invalid
630 // (e.g. smaller than minsize) sash position was requested using
631 // SetSashPosition():
632 m_requestedSashPosition
= INT_MAX
;
634 // note that we must send the event in any case, i.e. even if the sash
635 // position hasn't changed and DoSetSashPosition() returns false because we
636 // must generate a CHANGED event at the end of resizing
637 DoSetSashPosition(sashPos
);
639 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
, this);
640 event
.m_data
.pos
= m_sashPosition
;
642 (void)DoSendEvent(event
);
645 // Position and size subwindows.
646 // Note that the border size applies to each subwindow, not
647 // including the edges next to the sash.
648 void wxSplitterWindow::SizeWindows()
650 // check if we have delayed setting the real sash position
651 if ( m_checkRequestedSashPosition
&& m_requestedSashPosition
!= INT_MAX
)
653 int newSashPosition
= ConvertSashPosition(m_requestedSashPosition
);
654 if ( newSashPosition
!= m_sashPosition
)
656 DoSetSashPosition(newSashPosition
);
659 if ( newSashPosition
<= m_sashPosition
660 && newSashPosition
>= m_sashPosition
- GetBorderSize() )
662 // don't update it any more
663 m_requestedSashPosition
= INT_MAX
;
668 GetClientSize(&w
, &h
);
670 if ( GetWindow1() && !GetWindow2() )
672 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
673 w
- 2*GetBorderSize(), h
- 2*GetBorderSize());
675 else if ( GetWindow1() && GetWindow2() )
677 const int border
= GetBorderSize(),
678 sash
= GetSashSize();
680 int size1
= GetSashPosition() - border
,
681 size2
= GetSashPosition() + sash
;
683 int x2
, y2
, w1
, h1
, w2
, h2
;
684 if ( GetSplitMode() == wxSPLIT_VERTICAL
)
687 w2
= w
- 2*border
- sash
- w1
;
693 else // horz splitter
698 h2
= h
- 2*border
- sash
- h1
;
703 GetWindow2()->SetSize(x2
, y2
, w2
, h2
);
704 GetWindow1()->SetSize(border
, border
, w1
, h1
);
710 SetNeedUpdating(false);
713 // Set pane for unsplit window
714 void wxSplitterWindow::Initialize(wxWindow
*window
)
716 wxASSERT_MSG( (!window
|| (window
&& window
->GetParent() == this)),
717 _T("windows in the splitter should have it as parent!") );
719 if (window
&& !window
->IsShown())
722 m_windowOne
= window
;
723 m_windowTwo
= (wxWindow
*) NULL
;
724 DoSetSashPosition(0);
727 // Associates the given window with window 2, drawing the appropriate sash
728 // and changing the split mode.
729 // Does nothing and returns false if the window is already split.
730 bool wxSplitterWindow::DoSplit(wxSplitMode mode
,
731 wxWindow
*window1
, wxWindow
*window2
,
737 wxCHECK_MSG( window1
&& window2
, false,
738 _T("can not split with NULL window(s)") );
740 wxCHECK_MSG( window1
->GetParent() == this && window2
->GetParent() == this, false,
741 _T("windows in the splitter should have it as parent!") );
743 if (! window1
->IsShown())
745 if (! window2
->IsShown())
749 m_windowOne
= window1
;
750 m_windowTwo
= window2
;
752 // remember the sash position we want to set for later if we can't set it
753 // right now (e.g. because the window is too small)
754 m_requestedSashPosition
= sashPosition
;
755 m_checkRequestedSashPosition
= false;
757 DoSetSashPosition(ConvertSashPosition(sashPosition
));
764 int wxSplitterWindow::ConvertSashPosition(int sashPosition
) const
766 if ( sashPosition
> 0 )
770 else if ( sashPosition
< 0 )
772 // It's negative so adding is subtracting
773 return GetWindowSize() + sashPosition
;
775 else // sashPosition == 0
777 // default, put it in the centre
778 return GetWindowSize() / 2;
782 // Remove the specified (or second) window from the view
783 // Doesn't actually delete the window.
784 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
790 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
793 m_windowTwo
= (wxWindow
*) NULL
;
795 else if ( toRemove
== m_windowOne
)
798 m_windowOne
= m_windowTwo
;
799 m_windowTwo
= (wxWindow
*) NULL
;
803 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
809 DoSetSashPosition(0);
815 // Replace a window with another one
816 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
818 wxCHECK_MSG( winOld
, false, wxT("use one of Split() functions instead") );
819 wxCHECK_MSG( winNew
, false, wxT("use Unsplit() functions instead") );
821 if ( winOld
== m_windowTwo
)
823 m_windowTwo
= winNew
;
825 else if ( winOld
== m_windowOne
)
827 m_windowOne
= winNew
;
831 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
841 void wxSplitterWindow::SetMinimumPaneSize(int min
)
843 m_minimumPaneSize
= min
;
844 int pos
= m_requestedSashPosition
!= INT_MAX
? m_requestedSashPosition
: m_sashPosition
;
845 SetSashPosition(pos
); // re-check limits
848 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
850 // remember the sash position we want to set for later if we can't set it
851 // right now (e.g. because the window is too small)
852 m_requestedSashPosition
= position
;
853 m_checkRequestedSashPosition
= false;
855 DoSetSashPosition(ConvertSashPosition(position
));
863 // Make sure the child window sizes are updated. This is useful
864 // for reducing flicker by updating the sizes before a
865 // window is shown, if you know the overall size is correct.
866 void wxSplitterWindow::UpdateSize()
868 m_checkRequestedSashPosition
= true;
870 m_checkRequestedSashPosition
= false;
873 bool wxSplitterWindow::DoSendEvent(wxSplitterEvent
& event
)
875 return !GetEventHandler()->ProcessEvent(event
) || event
.IsAllowed();
878 wxSize
wxSplitterWindow::DoGetBestSize() const
880 // get best sizes of subwindows
883 size1
= m_windowOne
->GetAdjustedBestSize();
885 size2
= m_windowTwo
->GetAdjustedBestSize();
889 // pSash points to the size component to which sash size must be added
892 if ( m_splitMode
== wxSPLIT_VERTICAL
)
894 sizeBest
.y
= wxMax(size1
.y
, size2
.y
);
895 sizeBest
.x
= wxMax(size1
.x
, m_minimumPaneSize
) +
896 wxMax(size2
.x
, m_minimumPaneSize
);
900 else // wxSPLIT_HORIZONTAL
902 sizeBest
.x
= wxMax(size1
.x
, size2
.x
);
903 sizeBest
.y
= wxMax(size1
.y
, m_minimumPaneSize
) +
904 wxMax(size2
.y
, m_minimumPaneSize
);
909 // account for the border and the sash
910 int border
= 2*GetBorderSize();
911 *pSash
+= GetSashSize();
912 sizeBest
.x
+= border
;
913 sizeBest
.y
+= border
;
918 // ---------------------------------------------------------------------------
919 // wxSplitterWindow virtual functions: they now just generate the events
920 // ---------------------------------------------------------------------------
922 bool wxSplitterWindow::OnSashPositionChange(int WXUNUSED(newSashPosition
))
924 // always allow by default
928 int wxSplitterWindow::OnSashPositionChanging(int newSashPosition
)
930 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
931 const int UNSPLIT_THRESHOLD
= 4;
933 // first of all, check if OnSashPositionChange() doesn't forbid this change
934 if ( !OnSashPositionChange(newSashPosition
) )
940 // Obtain relevant window dimension for bottom / right threshold check
941 int window_size
= GetWindowSize();
943 bool unsplit_scenario
= false;
944 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
946 // Do edge detection if unsplit premitted
947 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
949 // threshold top / left check
951 unsplit_scenario
= true;
953 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
955 // threshold bottom/right check
956 newSashPosition
= window_size
;
957 unsplit_scenario
= true;
961 if ( !unsplit_scenario
)
963 // If resultant pane would be too small, enlarge it
964 newSashPosition
= AdjustSashPosition(newSashPosition
);
967 // If the result is out of bounds it means minimum size is too big,
968 // so split window in half as best compromise.
969 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
970 newSashPosition
= window_size
/ 2;
972 // now let the event handler have it
974 // FIXME: shouldn't we do it before the adjustments above so as to ensure
975 // that the sash position is always reasonable?
976 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
, this);
977 event
.m_data
.pos
= newSashPosition
;
979 if ( !DoSendEvent(event
) )
981 // the event handler vetoed the change
982 newSashPosition
= -1;
986 // it could have been changed by it
987 newSashPosition
= event
.GetSashPosition();
990 return newSashPosition
;
993 // Called when the sash is double-clicked. The default behaviour is to remove
994 // the sash if the minimum pane size is zero.
995 void wxSplitterWindow::OnDoubleClickSash(int x
, int y
)
997 wxCHECK_RET(m_windowTwo
, wxT("splitter: no window to remove"));
999 // new code should handle events instead of using the virtual functions
1000 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
, this);
1001 event
.m_data
.pt
.x
= x
;
1002 event
.m_data
.pt
.y
= y
;
1003 if ( DoSendEvent(event
) )
1005 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
1007 wxWindow
* win
= m_windowTwo
;
1010 wxSplitterEvent
unsplitEvent(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
1011 unsplitEvent
.m_data
.win
= win
;
1012 (void)DoSendEvent(unsplitEvent
);
1016 //else: blocked by user
1019 void wxSplitterWindow::OnUnsplit(wxWindow
*winRemoved
)
1021 // call this before calling the event handler which may delete the window
1022 winRemoved
->Show(false);
1025 #if defined( __WXMSW__ ) || defined( __WXMAC__)
1027 // this is currently called (and needed) under MSW only...
1028 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& event
)
1030 // if we don't do it, the resizing cursor might be set for child window:
1031 // and like this we explicitly say that our cursor should not be used for
1032 // children windows which overlap us
1034 if ( SashHitTest(event
.GetX(), event
.GetY(), 0) )
1036 // default processing is ok
1039 //else: do nothing, in particular, don't call Skip()
1042 #endif // wxMSW || wxMac
1044 #endif // wxUSE_SPLITTER