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 wxSplitterWindow::wxSplitterWindow()
58 m_splitMode
= wxSPLIT_VERTICAL
;
59 m_permitUnsplitAlways
= FALSE
;
60 m_windowOne
= (wxWindow
*) NULL
;
61 m_windowTwo
= (wxWindow
*) NULL
;
62 m_dragMode
= wxSPLIT_DRAG_NONE
;
70 m_sashCursorWE
= (wxCursor
*) NULL
;
71 m_sashCursorNS
= (wxCursor
*) NULL
;
72 m_sashTrackerPen
= (wxPen
*) NULL
;
73 m_lightShadowPen
= (wxPen
*) NULL
;
74 m_mediumShadowPen
= (wxPen
*) NULL
;
75 m_darkShadowPen
= (wxPen
*) NULL
;
76 m_faceBrush
= (wxBrush
*) NULL
;
77 m_facePen
= (wxPen
*) NULL
;
78 m_hilightPen
= (wxPen
*) NULL
;
79 m_minimumPaneSize
= 0;
80 m_needUpdating
= FALSE
;
83 wxSplitterWindow::wxSplitterWindow(wxWindow
*parent
, wxWindowID id
,
88 : wxWindow(parent
, id
, pos
, size
, style
, name
)
90 m_splitMode
= wxSPLIT_VERTICAL
;
91 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
92 m_windowOne
= (wxWindow
*) NULL
;
93 m_windowTwo
= (wxWindow
*) NULL
;
94 m_dragMode
= wxSPLIT_DRAG_NONE
;
102 m_minimumPaneSize
= 0;
103 m_sashCursorWE
= new wxCursor(wxCURSOR_SIZEWE
);
104 m_sashCursorNS
= new wxCursor(wxCURSOR_SIZENS
);
105 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
106 m_lightShadowPen
= (wxPen
*) NULL
;
107 m_mediumShadowPen
= (wxPen
*) NULL
;
108 m_darkShadowPen
= (wxPen
*) NULL
;
109 m_faceBrush
= (wxBrush
*) NULL
;
110 m_facePen
= (wxPen
*) NULL
;
111 m_hilightPen
= (wxPen
*) NULL
;
113 if ( style
& wxSP_3D
)
118 else if ( style
& wxSP_BORDER
)
129 // Eventually, we'll respond to colour change messages
132 // For debugging purposes, to see the background.
133 // SetBackground(wxBLUE_BRUSH);
135 m_needUpdating
= FALSE
;
138 wxSplitterWindow::~wxSplitterWindow()
140 delete m_sashCursorWE
;
141 delete m_sashCursorNS
;
142 delete m_sashTrackerPen
;
143 delete m_lightShadowPen
;
144 delete m_darkShadowPen
;
145 delete m_mediumShadowPen
;
151 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
155 if ( m_borderSize
> 0 )
160 void wxSplitterWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
))
166 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
168 wxCoord x
= (wxCoord
)event
.GetX(),
169 y
= (wxCoord
)event
.GetY();
173 SetCursor(* wxSTANDARD_CURSOR
);
176 SetCursor(wxCursor());
180 if (event
.LeftDown())
182 if ( SashHitTest(x
, y
) )
186 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
188 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
190 DrawSashTracker(x
, y
);
196 if ( m_splitMode
== wxSPLIT_VERTICAL
)
198 SetCursor(*m_sashCursorWE
);
202 SetCursor(*m_sashCursorNS
);
207 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
209 // We can stop dragging now and see what we've got.
210 m_dragMode
= wxSPLIT_DRAG_NONE
;
214 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
216 DrawSashTracker(m_oldX
, m_oldY
);
219 // Obtain window size. We are only interested in the dimension the sash
222 GetClientSize(&w
, &h
);
223 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
? w
: h
);
224 int new_sash_position
=
225 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
227 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
,
229 eventSplitter
.m_data
.pos
= new_sash_position
;
230 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
232 new_sash_position
= eventSplitter
.GetSashPosition();
233 if ( new_sash_position
== -1 )
235 // change not allowed
240 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
242 // Deal with possible unsplit scenarios
243 if ( new_sash_position
== 0 )
245 // We remove the first window from the view
246 wxWindow
*removedWindow
= m_windowOne
;
247 m_windowOne
= m_windowTwo
;
248 m_windowTwo
= (wxWindow
*) NULL
;
249 SendUnsplitEvent(removedWindow
);
252 else if ( new_sash_position
== window_size
)
254 // We remove the second window from the view
255 wxWindow
*removedWindow
= m_windowTwo
;
256 m_windowTwo
= (wxWindow
*) NULL
;
257 SendUnsplitEvent(removedWindow
);
262 m_sashPosition
= new_sash_position
;
267 m_sashPosition
= new_sash_position
;
271 } // left up && dragging
272 else if (event
.Moving() && !event
.Dragging())
274 // Just change the cursor if required
275 if ( SashHitTest(x
, y
) )
277 if ( m_splitMode
== wxSPLIT_VERTICAL
)
279 SetCursor(*m_sashCursorWE
);
283 SetCursor(*m_sashCursorNS
);
286 #if defined(__WXGTK__) || defined(__WXMSW__)
289 // We must set the normal cursor in MSW, because
290 // if the child window doesn't have a cursor, the
291 // parent's (splitter window) will be used, and this
292 // must be the standard cursor.
294 // where else do we unset the cursor?
295 SetCursor(* wxSTANDARD_CURSOR
);
299 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
302 // Otherwise, the cursor sometimes reverts to the normal cursor
304 if ( m_splitMode
== wxSPLIT_VERTICAL
)
306 SetCursor(*m_sashCursorWE
);
310 SetCursor(*m_sashCursorNS
);
314 // Obtain window size. We are only interested in the dimension the sash
316 int new_sash_position
=
317 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
319 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
,
321 eventSplitter
.m_data
.pos
= new_sash_position
;
322 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
324 new_sash_position
= eventSplitter
.GetSashPosition();
325 if ( new_sash_position
== -1 )
327 // change not allowed
332 if (new_sash_position
== m_sashPosition
)
336 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
338 DrawSashTracker(m_oldX
, m_oldY
);
341 if (m_splitMode
== wxSPLIT_VERTICAL
)
342 x
= new_sash_position
;
344 y
= new_sash_position
;
346 // Remember old positions
351 // As we captured the mouse, we may get the mouse events from outside
352 // our window - for example, negative values in x, y. This has a weird
353 // consequence under MSW where we use unsigned values sometimes and
354 // signed ones other times: the coordinates turn as big positive
355 // numbers and so the sash is drawn on the *right* side of the window
356 // instead of the left (or bottom instead of top). Correct this.
357 if ( (short)m_oldX
< 0 )
359 if ( (short)m_oldY
< 0 )
364 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
366 DrawSashTracker(m_oldX
, m_oldY
);
370 m_sashPosition
= new_sash_position
;
371 m_needUpdating
= TRUE
;
374 else if ( event
.LeftDClick() )
376 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
,
378 eventSplitter
.m_data
.pt
.x
= x
;
379 eventSplitter
.m_data
.pt
.y
= y
;
381 (void)GetEventHandler()->ProcessEvent(eventSplitter
);
385 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
387 // only process this message if we're not iconized - otherwise iconizing
388 // and restoring a window containing the splitter has a funny side effect
389 // of changing the splitter position!
390 wxWindow
*parent
= GetParent();
391 while ( parent
&& !parent
->IsTopLevel() )
393 parent
= parent
->GetParent();
396 bool iconized
= FALSE
;
397 wxFrame
*frame
= wxDynamicCast(parent
, wxFrame
);
399 iconized
= frame
->IsIconized();
402 wxDialog
*dialog
= wxDynamicCast(parent
, wxDialog
);
404 iconized
= dialog
->IsIconized();
406 wxFAIL_MSG(wxT("should have a top level frame or dialog parent!"));
416 GetClientSize( &cw
, &ch
);
419 if ( m_splitMode
== wxSPLIT_VERTICAL
)
421 if ( m_sashPosition
>= (cw
- 5) )
422 m_sashPosition
= wxMax(10, cw
- 40);
424 if ( m_splitMode
== wxSPLIT_HORIZONTAL
)
426 if ( m_sashPosition
>= (ch
- 5) )
427 m_sashPosition
= wxMax(10, ch
- 40);
435 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
437 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
438 return FALSE
; // No sash
440 if ( m_splitMode
== wxSPLIT_VERTICAL
)
442 if ( (x
>= m_sashPosition
- tolerance
) && (x
<= m_sashPosition
+ m_sashSize
+ tolerance
) )
449 if ( (y
>= (m_sashPosition
- tolerance
)) && (y
<= (m_sashPosition
+ m_sashSize
+ tolerance
)) )
456 // Draw 3D effect borders
457 void wxSplitterWindow::DrawBorders(wxDC
& dc
)
460 GetClientSize(&w
, &h
);
462 if ( GetWindowStyleFlag() & wxSP_3D
)
465 dc
.SetPen(*m_facePen
);
466 dc
.SetBrush(*m_faceBrush
);
467 dc
.DrawRectangle(1, 1 , w
-1, m_borderSize
-2 ); //high
468 dc
.DrawRectangle(1, m_borderSize
-2 , m_borderSize
-2, h
-1 ); // left
469 dc
.DrawRectangle(w
-m_borderSize
+2, m_borderSize
-2 , w
-1, h
-1 ); // right
470 dc
.DrawRectangle(m_borderSize
-2, h
-m_borderSize
+2 , w
-m_borderSize
+2, h
-1 ); //bottom
472 dc
.SetPen(*m_mediumShadowPen
);
473 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, w
-m_borderSize
+1, m_borderSize
-2);
474 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, m_borderSize
-2, h
-m_borderSize
+1);
476 dc
.SetPen(*m_darkShadowPen
);
477 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, w
-m_borderSize
, m_borderSize
-1);
478 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, m_borderSize
-1, h
-m_borderSize
);
480 dc
.SetPen(*m_hilightPen
);
481 dc
.DrawLine(m_borderSize
- 2, h
-m_borderSize
+1, w
-m_borderSize
+1, h
-m_borderSize
+1);
482 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.
483 /// Anyway, h is required for MSW.
485 dc
.SetPen(*m_lightShadowPen
);
486 dc
.DrawLine(w
-m_borderSize
, m_borderSize
-1, w
-m_borderSize
, h
-m_borderSize
); // Right hand side
487 dc
.DrawLine(m_borderSize
-1, h
-m_borderSize
, w
-m_borderSize
+1, h
-m_borderSize
); // Bottom
489 else if ( GetWindowStyleFlag() & wxSP_BORDER
)
491 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
492 dc
.SetPen(*wxBLACK_PEN
);
493 dc
.DrawRectangle(0, 0, w
-1, h
-1);
496 dc
.SetPen(wxNullPen
);
497 dc
.SetBrush(wxNullBrush
);
501 void wxSplitterWindow::DrawSash(wxDC
& dc
)
503 if ( m_sashPosition
== 0 || !m_windowTwo
)
507 GetClientSize(&w
, &h
);
509 if ( GetWindowStyleFlag() & wxSP_3D
)
511 if ( m_splitMode
== wxSPLIT_VERTICAL
)
513 dc
.SetPen(*m_facePen
);
514 dc
.SetBrush(*m_faceBrush
);
515 dc
.DrawRectangle(m_sashPosition
+ 2, 0 , m_sashSize
- 4, h
);
517 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
519 dc
.SetPen(*m_lightShadowPen
);
520 int xShadow
= m_borderSize
? m_borderSize
- 1 : 0 ;
521 dc
.DrawLine(m_sashPosition
, xShadow
, m_sashPosition
, h
-m_borderSize
);
523 dc
.SetPen(*m_hilightPen
);
524 dc
.DrawLine(m_sashPosition
+1, m_borderSize
- 2, m_sashPosition
+1, h
- m_borderSize
+2);
526 dc
.SetPen(*m_mediumShadowPen
);
527 int yMedium
= m_borderSize
? h
-m_borderSize
+1 : h
;
528 dc
.DrawLine(m_sashPosition
+m_sashSize
-2, xShadow
, m_sashPosition
+m_sashSize
-2, yMedium
);
530 dc
.SetPen(*m_darkShadowPen
);
531 dc
.DrawLine(m_sashPosition
+m_sashSize
-1, m_borderSize
, m_sashPosition
+m_sashSize
-1, h
-m_borderSize
);
535 dc
.SetPen(*m_facePen
);
536 dc
.SetBrush(*m_faceBrush
);
537 dc
.DrawRectangle( m_borderSize
-2, m_sashPosition
+ 2, w
-m_borderSize
+2, m_sashSize
- 4);
539 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
541 dc
.SetPen(*m_lightShadowPen
);
542 dc
.DrawLine(m_borderSize
-1, m_sashPosition
, w
-m_borderSize
, m_sashPosition
);
544 dc
.SetPen(*m_hilightPen
);
545 dc
.DrawLine(m_borderSize
-2, m_sashPosition
+1, w
-m_borderSize
+1, m_sashPosition
+1);
547 dc
.SetPen(*m_mediumShadowPen
);
548 dc
.DrawLine(m_borderSize
-1, m_sashPosition
+m_sashSize
-2, w
-m_borderSize
+1, m_sashPosition
+m_sashSize
-2);
550 dc
.SetPen(*m_darkShadowPen
);
551 dc
.DrawLine(m_borderSize
, m_sashPosition
+m_sashSize
-1, w
-m_borderSize
, m_sashPosition
+m_sashSize
-1);
556 if ( m_splitMode
== wxSPLIT_VERTICAL
)
558 dc
.SetPen(*wxBLACK_PEN
);
559 dc
.SetBrush(*wxBLACK_BRUSH
);
561 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
562 h1
+= 1; // Not sure why this is necessary...
563 dc
.DrawRectangle(m_sashPosition
, 0, m_sashSize
, h1
);
567 dc
.SetPen(*wxBLACK_PEN
);
568 dc
.SetBrush(*wxBLACK_BRUSH
);
570 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
573 dc
.DrawRectangle(0, m_sashPosition
, w1
, m_sashSize
);
578 dc
.SetPen(wxNullPen
);
579 dc
.SetBrush(wxNullBrush
);
582 // Draw the sash tracker (for whilst moving the sash)
583 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
586 GetClientSize(&w
, &h
);
592 if ( m_splitMode
== wxSPLIT_VERTICAL
)
623 ClientToScreen(&x1
, &y1
);
624 ClientToScreen(&x2
, &y2
);
626 screenDC
.SetLogicalFunction(wxINVERT
);
627 screenDC
.SetPen(*m_sashTrackerPen
);
628 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
630 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
632 screenDC
.SetLogicalFunction(wxCOPY
);
634 screenDC
.SetPen(wxNullPen
);
635 screenDC
.SetBrush(wxNullBrush
);
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()
644 GetClientSize(&w
, &h
);
646 if ( m_windowOne
&& !m_windowTwo
)
648 m_windowOne
->SetSize(m_borderSize
, m_borderSize
, w
- 2*m_borderSize
, h
- 2*m_borderSize
);
651 else if ( m_windowOne
&& m_windowTwo
)
653 if (m_splitMode
== wxSPLIT_VERTICAL
)
655 int x1
= m_borderSize
;
656 int y1
= m_borderSize
;
657 int w1
= m_sashPosition
- m_borderSize
;
658 int h1
= h
- 2*m_borderSize
;
660 int x2
= m_sashPosition
+ m_sashSize
;
661 int y2
= m_borderSize
;
662 int w2
= w
- 2*m_borderSize
- m_sashSize
- w1
;
663 int h2
= h
- 2*m_borderSize
;
665 m_windowOne
->SetSize(x1
, y1
, w1
, h1
);
666 m_windowTwo
->SetSize(x2
, y2
, w2
, h2
);
671 m_windowOne
->SetSize(m_borderSize
, m_borderSize
,
672 w
- 2*m_borderSize
, m_sashPosition
- m_borderSize
);
673 m_windowTwo
->SetSize(m_borderSize
, m_sashPosition
+ m_sashSize
,
674 w
- 2*m_borderSize
, h
- 2*m_borderSize
- m_sashSize
- (m_sashPosition
- m_borderSize
));
679 if ( m_borderSize
> 0 )
683 m_needUpdating
= FALSE
;
686 // Set pane for unsplit window
687 void wxSplitterWindow::Initialize(wxWindow
*window
)
689 m_windowOne
= window
;
690 m_windowTwo
= (wxWindow
*) NULL
;
694 // Associates the given window with window 2, drawing the appropriate sash
695 // and changing the split mode.
696 // Does nothing and returns FALSE if the window is already split.
697 bool wxSplitterWindow::SplitVertically(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
703 GetClientSize(&w
, &h
);
705 m_splitMode
= wxSPLIT_VERTICAL
;
706 m_windowOne
= window1
;
707 m_windowTwo
= window2
;
708 if ( sashPosition
> 0 )
709 m_sashPosition
= sashPosition
;
710 else if ( sashPosition
< 0 )
711 m_sashPosition
= w
- sashPosition
;
713 m_sashPosition
= w
/2;
720 bool wxSplitterWindow::SplitHorizontally(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
726 GetClientSize(&w
, &h
);
728 m_splitMode
= wxSPLIT_HORIZONTAL
;
729 m_windowOne
= window1
;
730 m_windowTwo
= window2
;
731 if ( sashPosition
> 0 )
732 m_sashPosition
= sashPosition
;
733 else if ( sashPosition
< 0 )
734 m_sashPosition
= h
- sashPosition
;
736 m_sashPosition
= h
/2;
744 // Remove the specified (or second) window from the view
745 // Doesn't actually delete the window.
746 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
751 wxWindow
*win
= NULL
;
752 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
755 m_windowTwo
= (wxWindow
*) NULL
;
757 else if ( toRemove
== m_windowOne
)
760 m_windowOne
= m_windowTwo
;
761 m_windowTwo
= (wxWindow
*) NULL
;
765 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
770 SendUnsplitEvent(win
);
777 // Replace a window with another one
778 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
780 wxCHECK_MSG( winOld
, FALSE
, wxT("use one of Split() functions instead") );
781 wxCHECK_MSG( winNew
, FALSE
, wxT("use Unsplit() functions instead") );
783 if ( winOld
== m_windowTwo
)
785 m_windowTwo
= winNew
;
787 else if ( winOld
== m_windowOne
)
789 m_windowOne
= winNew
;
793 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
803 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
805 m_sashPosition
= position
;
813 // Initialize colours
814 void wxSplitterWindow::InitColours()
816 wxDELETE( m_facePen
);
817 wxDELETE( m_faceBrush
);
818 wxDELETE( m_mediumShadowPen
);
819 wxDELETE( m_darkShadowPen
);
820 wxDELETE( m_lightShadowPen
);
821 wxDELETE( m_hilightPen
);
824 #if defined(__WIN95__)
825 wxColour
faceColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
826 m_facePen
= new wxPen(faceColour
, 1, wxSOLID
);
827 m_faceBrush
= new wxBrush(faceColour
, wxSOLID
);
829 wxColour
mediumShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW
));
830 m_mediumShadowPen
= new wxPen(mediumShadowColour
, 1, wxSOLID
);
832 wxColour
darkShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW
));
833 m_darkShadowPen
= new wxPen(darkShadowColour
, 1, wxSOLID
);
835 wxColour
lightShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT
));
836 m_lightShadowPen
= new wxPen(lightShadowColour
, 1, wxSOLID
);
838 wxColour
hilightColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT
));
839 m_hilightPen
= new wxPen(hilightColour
, 1, wxSOLID
);
841 m_facePen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
842 m_faceBrush
= new wxBrush("LIGHT GREY", wxSOLID
);
843 m_mediumShadowPen
= new wxPen("GREY", 1, wxSOLID
);
844 m_darkShadowPen
= new wxPen("BLACK", 1, wxSOLID
);
845 m_lightShadowPen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
846 m_hilightPen
= new wxPen("WHITE", 1, wxSOLID
);
847 #endif // Win32/!Win32
850 void wxSplitterWindow::SendUnsplitEvent(wxWindow
*winRemoved
)
852 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
853 event
.m_data
.win
= winRemoved
;
855 (void)GetEventHandler()->ProcessEvent(event
);
858 // ---------------------------------------------------------------------------
859 // splitter event handlers
860 // ---------------------------------------------------------------------------
862 void wxSplitterWindow::OnSashPosChanged(wxSplitterEvent
& event
)
864 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
865 const int UNSPLIT_THRESHOLD
= 4;
867 int newSashPosition
= event
.GetSashPosition();
869 // Obtain relevant window dimension for bottom / right threshold check
871 GetClientSize(&w
, &h
);
872 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
) ? w
: h
;
874 bool unsplit_scenario
= FALSE
;
875 if ( m_permitUnsplitAlways
876 || m_minimumPaneSize
== 0 )
878 // Do edge detection if unsplit premitted
879 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
881 // threshold top / left check
883 unsplit_scenario
= TRUE
;
885 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
887 // threshold bottom/right check
888 newSashPosition
= window_size
;
889 unsplit_scenario
= TRUE
;
893 if ( !unsplit_scenario
)
895 // If resultant pane would be too small, enlarge it
896 if ( newSashPosition
< m_minimumPaneSize
)
897 newSashPosition
= m_minimumPaneSize
;
898 if ( newSashPosition
> window_size
- m_minimumPaneSize
)
899 newSashPosition
= window_size
- m_minimumPaneSize
;
902 // If the result is out of bounds it means minimum size is too big,
903 // so split window in half as best compromise.
904 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
905 newSashPosition
= window_size
/ 2;
907 // for compatibility, call the virtual function
908 if ( !OnSashPositionChange(newSashPosition
) )
910 newSashPosition
= -1;
913 event
.SetSashPosition(newSashPosition
);
916 // Called when the sash is double-clicked. The default behaviour is to remove
917 // the sash if the minimum pane size is zero.
918 void wxSplitterWindow::OnDoubleClick(wxSplitterEvent
& event
)
920 // for compatibility, call the virtual function
921 OnDoubleClickSash(event
.GetX(), event
.GetY());
923 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
929 void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent
& event
)
931 wxWindow
*win
= event
.GetWindowBeingRemoved();
933 // do it before calling OnUnsplit() which may delete the window
936 // for compatibility, call the virtual function
940 #if defined(__WXMSW__)
941 #define WXUNUSED_UNLESS_MSW(identifier) identifier
943 #define WXUNUSED_UNLESS_MSW(identifier) WXUNUSED(identifier)
946 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& WXUNUSED_UNLESS_MSW(event
))
948 // this is currently called (and needed) under MSW only...
951 // if we don't do it, the resizing cursor might be set for child window:
952 // and like this we explicitly say that our cursor should not be used for
953 // children windows which overlap us
955 if ( SashHitTest(event
.GetX(), event
.GetY()) )
957 // default processing is ok
960 //else: do nothing, in particular, don't call Skip()