1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSplitterWindow implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "splitter.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
24 #include "wx/window.h"
25 #include "wx/dialog.h"
31 #include "wx/string.h"
32 #include "wx/splitter.h"
33 #include "wx/dcscreen.h"
34 #include "wx/settings.h"
37 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow
, wxWindow
)
38 IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent
, wxCommandEvent
)
40 BEGIN_EVENT_TABLE(wxSplitterWindow
, wxWindow
)
41 EVT_PAINT(wxSplitterWindow::OnPaint
)
42 EVT_SIZE(wxSplitterWindow::OnSize
)
43 EVT_IDLE(wxSplitterWindow::OnIdle
)
44 EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent
)
46 EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor
)
48 EVT_SPLITTER_SASH_POS_CHANGED(-1, wxSplitterWindow::OnSashPosChanged
)
49 // NB: we borrow OnSashPosChanged for purposes of
50 // EVT_SPLITTER_SASH_POS_CHANGING since default implementation is identical
51 EVT_SPLITTER_SASH_POS_CHANGING(-1, wxSplitterWindow::OnSashPosChanged
)
52 EVT_SPLITTER_DCLICK(-1, wxSplitterWindow::OnDoubleClick
)
53 EVT_SPLITTER_UNSPLIT(-1, wxSplitterWindow::OnUnsplitEvent
)
56 bool wxSplitterWindow::Create(wxWindow
*parent
, wxWindowID id
,
62 if (!wxWindow::Create(parent
, id
, pos
, size
, style
, name
))
65 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
67 if ( style
& wxSP_3DSASH
)
72 if ( style
& wxSP_3DBORDER
)
74 else if ( style
& wxSP_BORDER
)
82 void wxSplitterWindow::Init()
84 m_splitMode
= wxSPLIT_VERTICAL
;
85 m_permitUnsplitAlways
= TRUE
;
86 m_windowOne
= (wxWindow
*) NULL
;
87 m_windowTwo
= (wxWindow
*) NULL
;
88 m_dragMode
= wxSPLIT_DRAG_NONE
;
96 m_minimumPaneSize
= 0;
97 m_sashCursorWE
= new wxCursor(wxCURSOR_SIZEWE
);
98 m_sashCursorNS
= new wxCursor(wxCURSOR_SIZENS
);
99 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
100 m_lightShadowPen
= (wxPen
*) NULL
;
101 m_mediumShadowPen
= (wxPen
*) NULL
;
102 m_darkShadowPen
= (wxPen
*) NULL
;
103 m_faceBrush
= (wxBrush
*) NULL
;
104 m_facePen
= (wxPen
*) NULL
;
105 m_hilightPen
= (wxPen
*) NULL
;
112 m_needUpdating
= FALSE
;
115 wxSplitterWindow::~wxSplitterWindow()
117 delete m_sashCursorWE
;
118 delete m_sashCursorNS
;
119 delete m_sashTrackerPen
;
120 delete m_lightShadowPen
;
121 delete m_darkShadowPen
;
122 delete m_mediumShadowPen
;
128 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
132 if ( m_borderSize
> 0 )
137 void wxSplitterWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
))
143 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
145 wxCoord x
= (wxCoord
)event
.GetX(),
146 y
= (wxCoord
)event
.GetY();
150 SetCursor(* wxSTANDARD_CURSOR
);
153 SetCursor(wxCursor());
156 if (GetWindowStyle() & wxSP_NOSASH
)
159 if (event
.LeftDown())
161 if ( SashHitTest(x
, y
) )
165 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
167 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
169 DrawSashTracker(x
, y
);
175 if ( m_splitMode
== wxSPLIT_VERTICAL
)
177 SetCursor(*m_sashCursorWE
);
181 SetCursor(*m_sashCursorNS
);
186 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
188 // We can stop dragging now and see what we've got.
189 m_dragMode
= wxSPLIT_DRAG_NONE
;
193 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
195 DrawSashTracker(m_oldX
, m_oldY
);
198 // Obtain window size. We are only interested in the dimension the sash
201 GetClientSize(&w
, &h
);
202 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
? w
: h
);
203 int new_sash_position
=
204 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
206 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
,
208 eventSplitter
.m_data
.pos
= new_sash_position
;
209 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
211 new_sash_position
= eventSplitter
.GetSashPosition();
212 if ( new_sash_position
== -1 )
214 // change not allowed
219 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
221 // Deal with possible unsplit scenarios
222 if ( new_sash_position
== 0 )
224 // We remove the first window from the view
225 wxWindow
*removedWindow
= m_windowOne
;
226 m_windowOne
= m_windowTwo
;
227 m_windowTwo
= (wxWindow
*) NULL
;
228 SendUnsplitEvent(removedWindow
);
231 else if ( new_sash_position
== window_size
)
233 // We remove the second window from the view
234 wxWindow
*removedWindow
= m_windowTwo
;
235 m_windowTwo
= (wxWindow
*) NULL
;
236 SendUnsplitEvent(removedWindow
);
241 m_sashPosition
= new_sash_position
;
246 m_sashPosition
= new_sash_position
;
250 } // left up && dragging
251 else if (event
.Moving() && !event
.Dragging())
253 // Just change the cursor if required
254 if ( SashHitTest(x
, y
) )
256 if ( m_splitMode
== wxSPLIT_VERTICAL
)
258 SetCursor(*m_sashCursorWE
);
262 SetCursor(*m_sashCursorNS
);
265 #if defined(__WXGTK__) || defined(__WXMSW__)
268 // We must set the normal cursor in MSW, because
269 // if the child window doesn't have a cursor, the
270 // parent's (splitter window) will be used, and this
271 // must be the standard cursor.
273 // where else do we unset the cursor?
274 SetCursor(* wxSTANDARD_CURSOR
);
278 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
281 // Otherwise, the cursor sometimes reverts to the normal cursor
283 if ( m_splitMode
== wxSPLIT_VERTICAL
)
285 SetCursor(*m_sashCursorWE
);
289 SetCursor(*m_sashCursorNS
);
293 // Obtain window size. We are only interested in the dimension the sash
295 int new_sash_position
=
296 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
298 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
,
300 eventSplitter
.m_data
.pos
= new_sash_position
;
301 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
303 new_sash_position
= eventSplitter
.GetSashPosition();
304 if ( new_sash_position
== -1 )
306 // change not allowed
311 if (new_sash_position
== m_sashPosition
)
315 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
317 DrawSashTracker(m_oldX
, m_oldY
);
320 if (m_splitMode
== wxSPLIT_VERTICAL
)
321 x
= new_sash_position
;
323 y
= new_sash_position
;
325 // Remember old positions
330 // As we captured the mouse, we may get the mouse events from outside
331 // our window - for example, negative values in x, y. This has a weird
332 // consequence under MSW where we use unsigned values sometimes and
333 // signed ones other times: the coordinates turn as big positive
334 // numbers and so the sash is drawn on the *right* side of the window
335 // instead of the left (or bottom instead of top). Correct this.
336 if ( (short)m_oldX
< 0 )
338 if ( (short)m_oldY
< 0 )
343 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
345 DrawSashTracker(m_oldX
, m_oldY
);
349 m_sashPosition
= new_sash_position
;
350 m_needUpdating
= TRUE
;
353 else if ( event
.LeftDClick() )
355 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
,
357 eventSplitter
.m_data
.pt
.x
= x
;
358 eventSplitter
.m_data
.pt
.y
= y
;
360 (void)GetEventHandler()->ProcessEvent(eventSplitter
);
364 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
366 // only process this message if we're not iconized - otherwise iconizing
367 // and restoring a window containing the splitter has a funny side effect
368 // of changing the splitter position!
369 wxWindow
*parent
= GetParent();
370 while ( parent
&& !parent
->IsTopLevel() )
372 parent
= parent
->GetParent();
375 bool iconized
= FALSE
;
376 wxFrame
*frame
= wxDynamicCast(parent
, wxFrame
);
378 iconized
= frame
->IsIconized();
381 wxDialog
*dialog
= wxDynamicCast(parent
, wxDialog
);
383 iconized
= dialog
->IsIconized();
385 wxFAIL_MSG(wxT("should have a top level frame or dialog parent!"));
395 GetClientSize( &cw
, &ch
);
398 if ( m_splitMode
== wxSPLIT_VERTICAL
)
400 if ( m_sashPosition
>= (cw
- 5) )
401 m_sashPosition
= wxMax(10, cw
- 40);
403 if ( m_splitMode
== wxSPLIT_HORIZONTAL
)
405 if ( m_sashPosition
>= (ch
- 5) )
406 m_sashPosition
= wxMax(10, ch
- 40);
414 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
416 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
417 return FALSE
; // No sash
419 if ( m_splitMode
== wxSPLIT_VERTICAL
)
421 if ( (x
>= m_sashPosition
- tolerance
) && (x
<= m_sashPosition
+ m_sashSize
+ tolerance
) )
428 if ( (y
>= (m_sashPosition
- tolerance
)) && (y
<= (m_sashPosition
+ m_sashSize
+ tolerance
)) )
435 // Draw 3D effect borders
436 void wxSplitterWindow::DrawBorders(wxDC
& dc
)
439 GetClientSize(&w
, &h
);
441 if ( GetWindowStyleFlag() & wxSP_3DBORDER
)
444 dc
.SetPen(*m_facePen
);
445 dc
.SetBrush(*m_faceBrush
);
446 dc
.DrawRectangle(1, 1 , w
-1, m_borderSize
-2 ); //high
447 dc
.DrawRectangle(1, m_borderSize
-2 , m_borderSize
-2, h
-1 ); // left
448 dc
.DrawRectangle(w
-m_borderSize
+2, m_borderSize
-2 , w
-1, h
-1 ); // right
449 dc
.DrawRectangle(m_borderSize
-2, h
-m_borderSize
+2 , w
-m_borderSize
+2, h
-1 ); //bottom
451 dc
.SetPen(*m_mediumShadowPen
);
452 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, w
-m_borderSize
+1, m_borderSize
-2);
453 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, m_borderSize
-2, h
-m_borderSize
+1);
455 dc
.SetPen(*m_darkShadowPen
);
456 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, w
-m_borderSize
, m_borderSize
-1);
457 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, m_borderSize
-1, h
-m_borderSize
);
459 dc
.SetPen(*m_hilightPen
);
460 dc
.DrawLine(m_borderSize
- 2, h
-m_borderSize
+1, w
-m_borderSize
+1, h
-m_borderSize
+1);
461 dc
.DrawLine(w
-m_borderSize
+1, m_borderSize
- 2, w
-m_borderSize
+1, h
-m_borderSize
+2); // Surely the maximum y pos. should be h - 1.
462 /// Anyway, h is required for MSW.
464 dc
.SetPen(*m_lightShadowPen
);
465 dc
.DrawLine(w
-m_borderSize
, m_borderSize
-1, w
-m_borderSize
, h
-m_borderSize
); // Right hand side
466 dc
.DrawLine(m_borderSize
-1, h
-m_borderSize
, w
-m_borderSize
+1, h
-m_borderSize
); // Bottom
468 else if ( GetWindowStyleFlag() & wxSP_BORDER
)
470 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
471 dc
.SetPen(*wxBLACK_PEN
);
472 dc
.DrawRectangle(0, 0, w
-1, h
-1);
475 dc
.SetPen(wxNullPen
);
476 dc
.SetBrush(wxNullBrush
);
480 void wxSplitterWindow::DrawSash(wxDC
& dc
)
482 if ( m_sashPosition
== 0 || !m_windowTwo
)
484 if (GetWindowStyle() & wxSP_NOSASH
)
488 GetClientSize(&w
, &h
);
490 if ( GetWindowStyleFlag() & wxSP_3DSASH
)
492 if ( m_splitMode
== wxSPLIT_VERTICAL
)
494 dc
.SetPen(*m_facePen
);
495 dc
.SetBrush(*m_faceBrush
);
496 dc
.DrawRectangle(m_sashPosition
+ 2, 0 , m_sashSize
- 4, h
);
498 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
500 dc
.SetPen(*m_lightShadowPen
);
501 int xShadow
= m_borderSize
? m_borderSize
- 1 : 0 ;
502 dc
.DrawLine(m_sashPosition
, xShadow
, m_sashPosition
, h
-m_borderSize
);
504 dc
.SetPen(*m_hilightPen
);
505 dc
.DrawLine(m_sashPosition
+1, m_borderSize
- 2, m_sashPosition
+1, h
- m_borderSize
+2);
507 dc
.SetPen(*m_mediumShadowPen
);
508 int yMedium
= m_borderSize
? h
-m_borderSize
+1 : h
;
509 dc
.DrawLine(m_sashPosition
+m_sashSize
-2, xShadow
, m_sashPosition
+m_sashSize
-2, yMedium
);
511 dc
.SetPen(*m_darkShadowPen
);
512 dc
.DrawLine(m_sashPosition
+m_sashSize
-1, m_borderSize
, m_sashPosition
+m_sashSize
-1, h
-m_borderSize
);
514 // Draw the top and bottom edges of the sash, if requested
515 if (GetWindowStyle() & wxSP_FULLSASH
)
518 dc
.SetPen(*m_hilightPen
);
519 dc
.DrawLine(m_sashPosition
+1, m_borderSize
, m_sashPosition
+m_sashSize
-1, m_borderSize
);
522 dc
.SetPen(*m_darkShadowPen
);
523 dc
.DrawLine(m_sashPosition
+1, h
-m_borderSize
-1, m_sashPosition
+m_sashSize
-1, h
-m_borderSize
-1);
528 dc
.SetPen(*m_facePen
);
529 dc
.SetBrush(*m_faceBrush
);
530 dc
.DrawRectangle( m_borderSize
-2, m_sashPosition
+ 2, w
-m_borderSize
+2, m_sashSize
- 4);
532 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
534 dc
.SetPen(*m_lightShadowPen
);
535 dc
.DrawLine(m_borderSize
-1, m_sashPosition
, w
-m_borderSize
, m_sashPosition
);
537 dc
.SetPen(*m_hilightPen
);
538 dc
.DrawLine(m_borderSize
-2, m_sashPosition
+1, w
-m_borderSize
+1, m_sashPosition
+1);
540 dc
.SetPen(*m_mediumShadowPen
);
541 dc
.DrawLine(m_borderSize
-1, m_sashPosition
+m_sashSize
-2, w
-m_borderSize
+1, m_sashPosition
+m_sashSize
-2);
543 dc
.SetPen(*m_darkShadowPen
);
544 dc
.DrawLine(m_borderSize
, m_sashPosition
+m_sashSize
-1, w
-m_borderSize
, m_sashPosition
+m_sashSize
-1);
546 // Draw the left and right edges of the sash, if requested
547 if (GetWindowStyle() & wxSP_FULLSASH
)
550 dc
.SetPen(*m_hilightPen
);
551 dc
.DrawLine(m_borderSize
, m_sashPosition
, m_borderSize
, m_sashPosition
+m_sashSize
);
554 dc
.SetPen(*m_darkShadowPen
);
555 dc
.DrawLine(w
-m_borderSize
-1, m_sashPosition
+1, w
-m_borderSize
-1, m_sashPosition
+m_sashSize
-1);
561 if ( m_splitMode
== wxSPLIT_VERTICAL
)
563 dc
.SetPen(*wxBLACK_PEN
);
564 dc
.SetBrush(*wxBLACK_BRUSH
);
567 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
&& (GetWindowStyleFlag() & wxSP_3DBORDER
) != wxSP_3DBORDER
)
568 h1
+= 1; // Not sure why this is necessary...
569 if ( (GetWindowStyleFlag() & wxSP_3DBORDER
) == wxSP_3DBORDER
)
573 dc
.DrawRectangle(m_sashPosition
, y1
, m_sashSize
, h1
);
577 dc
.SetPen(*wxBLACK_PEN
);
578 dc
.SetBrush(*wxBLACK_BRUSH
);
581 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
&& (GetWindowStyleFlag() & wxSP_3DBORDER
) != wxSP_3DBORDER
)
583 if ( (GetWindowStyleFlag() & wxSP_3DBORDER
) == wxSP_3DBORDER
)
587 dc
.DrawRectangle(x1
, m_sashPosition
, w1
, m_sashSize
);
592 dc
.SetPen(wxNullPen
);
593 dc
.SetBrush(wxNullBrush
);
596 // Draw the sash tracker (for whilst moving the sash)
597 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
600 GetClientSize(&w
, &h
);
606 if ( m_splitMode
== wxSPLIT_VERTICAL
)
637 ClientToScreen(&x1
, &y1
);
638 ClientToScreen(&x2
, &y2
);
640 screenDC
.SetLogicalFunction(wxINVERT
);
641 screenDC
.SetPen(*m_sashTrackerPen
);
642 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
644 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
646 screenDC
.SetLogicalFunction(wxCOPY
);
648 screenDC
.SetPen(wxNullPen
);
649 screenDC
.SetBrush(wxNullBrush
);
652 // Position and size subwindows.
653 // Note that the border size applies to each subwindow, not
654 // including the edges next to the sash.
655 void wxSplitterWindow::SizeWindows()
658 GetClientSize(&w
, &h
);
660 if ( GetWindow1() && !GetWindow2() )
662 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(), w
- 2*GetBorderSize(), h
- 2*GetBorderSize());
665 else if ( GetWindow1() && GetWindow2() )
667 if (GetSplitMode() == wxSPLIT_VERTICAL
)
669 int x1
= GetBorderSize();
670 int y1
= GetBorderSize();
671 int w1
= GetSashPosition() - GetBorderSize();
672 int h1
= h
- 2*GetBorderSize();
674 int x2
= GetSashPosition() + GetSashSize();
675 int y2
= GetBorderSize();
676 int w2
= w
- 2*GetBorderSize() - GetSashSize() - w1
;
677 int h2
= h
- 2*GetBorderSize();
679 GetWindow1()->SetSize(x1
, y1
, w1
, h1
);
680 GetWindow2()->SetSize(x2
, y2
, w2
, h2
);
684 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
685 w
- 2*GetBorderSize(), GetSashPosition() - GetBorderSize());
686 GetWindow2()->SetSize(GetBorderSize(), GetSashPosition() + GetSashSize(),
687 w
- 2*GetBorderSize(), h
- 2*GetBorderSize() - GetSashSize() - (GetSashPosition() - GetBorderSize()));
691 if ( GetBorderSize() > 0 )
695 SetNeedUpdating(FALSE
);
698 // Set pane for unsplit window
699 void wxSplitterWindow::Initialize(wxWindow
*window
)
701 m_windowOne
= window
;
702 m_windowTwo
= (wxWindow
*) NULL
;
706 // Associates the given window with window 2, drawing the appropriate sash
707 // and changing the split mode.
708 // Does nothing and returns FALSE if the window is already split.
709 bool wxSplitterWindow::SplitVertically(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
715 GetClientSize(&w
, &h
);
717 m_splitMode
= wxSPLIT_VERTICAL
;
718 m_windowOne
= window1
;
719 m_windowTwo
= window2
;
720 if ( sashPosition
> 0 )
721 m_sashPosition
= sashPosition
;
722 else if ( sashPosition
< 0 )
723 m_sashPosition
= w
- sashPosition
;
725 m_sashPosition
= w
/2;
732 bool wxSplitterWindow::SplitHorizontally(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
738 GetClientSize(&w
, &h
);
740 m_splitMode
= wxSPLIT_HORIZONTAL
;
741 m_windowOne
= window1
;
742 m_windowTwo
= window2
;
743 if ( sashPosition
> 0 )
744 m_sashPosition
= sashPosition
;
745 else if ( sashPosition
< 0 )
746 m_sashPosition
= h
- sashPosition
;
748 m_sashPosition
= h
/2;
756 // Remove the specified (or second) window from the view
757 // Doesn't actually delete the window.
758 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
763 wxWindow
*win
= NULL
;
764 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
767 m_windowTwo
= (wxWindow
*) NULL
;
769 else if ( toRemove
== m_windowOne
)
772 m_windowOne
= m_windowTwo
;
773 m_windowTwo
= (wxWindow
*) NULL
;
777 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
782 SendUnsplitEvent(win
);
789 // Replace a window with another one
790 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
792 wxCHECK_MSG( winOld
, FALSE
, wxT("use one of Split() functions instead") );
793 wxCHECK_MSG( winNew
, FALSE
, wxT("use Unsplit() functions instead") );
795 if ( winOld
== m_windowTwo
)
797 m_windowTwo
= winNew
;
799 else if ( winOld
== m_windowOne
)
801 m_windowOne
= winNew
;
805 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
815 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
817 m_sashPosition
= position
;
825 // Initialize colours
826 void wxSplitterWindow::InitColours()
828 wxDELETE( m_facePen
);
829 wxDELETE( m_faceBrush
);
830 wxDELETE( m_mediumShadowPen
);
831 wxDELETE( m_darkShadowPen
);
832 wxDELETE( m_lightShadowPen
);
833 wxDELETE( m_hilightPen
);
837 wxColour
faceColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
838 m_facePen
= new wxPen(faceColour
, 1, wxSOLID
);
839 m_faceBrush
= new wxBrush(faceColour
, wxSOLID
);
841 wxColour
mediumShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW
));
842 m_mediumShadowPen
= new wxPen(mediumShadowColour
, 1, wxSOLID
);
844 wxColour
darkShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW
));
845 m_darkShadowPen
= new wxPen(darkShadowColour
, 1, wxSOLID
);
847 wxColour
lightShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT
));
848 m_lightShadowPen
= new wxPen(lightShadowColour
, 1, wxSOLID
);
850 wxColour
hilightColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT
));
851 m_hilightPen
= new wxPen(hilightColour
, 1, wxSOLID
);
853 m_facePen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
854 m_faceBrush
= new wxBrush("LIGHT GREY", wxSOLID
);
855 m_mediumShadowPen
= new wxPen("GREY", 1, wxSOLID
);
856 m_darkShadowPen
= new wxPen("BLACK", 1, wxSOLID
);
857 m_lightShadowPen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
858 m_hilightPen
= new wxPen("WHITE", 1, wxSOLID
);
862 void wxSplitterWindow::SendUnsplitEvent(wxWindow
*winRemoved
)
864 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
865 event
.m_data
.win
= winRemoved
;
867 (void)GetEventHandler()->ProcessEvent(event
);
870 // ---------------------------------------------------------------------------
871 // splitter event handlers
872 // ---------------------------------------------------------------------------
874 void wxSplitterWindow::OnSashPosChanged(wxSplitterEvent
& event
)
876 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
877 const int UNSPLIT_THRESHOLD
= 4;
879 int newSashPosition
= event
.GetSashPosition();
881 // Obtain relevant window dimension for bottom / right threshold check
883 GetClientSize(&w
, &h
);
884 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
) ? w
: h
;
886 bool unsplit_scenario
= FALSE
;
887 if ( m_permitUnsplitAlways
888 || m_minimumPaneSize
== 0 )
890 // Do edge detection if unsplit premitted
891 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
893 // threshold top / left check
895 unsplit_scenario
= TRUE
;
897 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
899 // threshold bottom/right check
900 newSashPosition
= window_size
;
901 unsplit_scenario
= TRUE
;
905 if ( !unsplit_scenario
)
907 // If resultant pane would be too small, enlarge it
908 if ( newSashPosition
< m_minimumPaneSize
)
909 newSashPosition
= m_minimumPaneSize
;
910 if ( newSashPosition
> window_size
- m_minimumPaneSize
)
911 newSashPosition
= window_size
- m_minimumPaneSize
;
914 // If the result is out of bounds it means minimum size is too big,
915 // so split window in half as best compromise.
916 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
917 newSashPosition
= window_size
/ 2;
919 // for compatibility, call the virtual function
920 if ( !OnSashPositionChange(newSashPosition
) )
922 newSashPosition
= -1;
925 event
.SetSashPosition(newSashPosition
);
928 // Called when the sash is double-clicked. The default behaviour is to remove
929 // the sash if the minimum pane size is zero.
930 void wxSplitterWindow::OnDoubleClick(wxSplitterEvent
& event
)
932 // for compatibility, call the virtual function
933 OnDoubleClickSash(event
.GetX(), event
.GetY());
935 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
941 void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent
& event
)
943 wxWindow
*win
= event
.GetWindowBeingRemoved();
945 // do it before calling OnUnsplit() which may delete the window
948 // for compatibility, call the virtual function
952 #if defined(__WXMSW__)
953 #define WXUNUSED_UNLESS_MSW(identifier) identifier
955 #define WXUNUSED_UNLESS_MSW(identifier) WXUNUSED(identifier)
958 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& WXUNUSED_UNLESS_MSW(event
))
960 // this is currently called (and needed) under MSW only...
963 // if we don't do it, the resizing cursor might be set for child window:
964 // and like this we explicitly say that our cursor should not be used for
965 // children windows which overlap us
967 if ( SashHitTest(event
.GetX(), event
.GetY()) )
969 // default processing is ok
972 //else: do nothing, in particular, don't call Skip()