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"
36 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow
, wxWindow
)
37 IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent
, wxCommandEvent
)
39 BEGIN_EVENT_TABLE(wxSplitterWindow
, wxWindow
)
40 EVT_PAINT(wxSplitterWindow::OnPaint
)
41 EVT_SIZE(wxSplitterWindow::OnSize
)
42 EVT_IDLE(wxSplitterWindow::OnIdle
)
43 EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent
)
45 EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor
)
47 EVT_SPLITTER_SASH_POS_CHANGED(-1, wxSplitterWindow::OnSashPosChanged
)
48 // NB: we borrow OnSashPosChanged for purposes of
49 // EVT_SPLITTER_SASH_POS_CHANGING since default implementation is identical
50 EVT_SPLITTER_SASH_POS_CHANGING(-1, wxSplitterWindow::OnSashPosChanged
)
51 EVT_SPLITTER_DCLICK(-1, wxSplitterWindow::OnDoubleClick
)
52 EVT_SPLITTER_UNSPLIT(-1, wxSplitterWindow::OnUnsplitEvent
)
55 wxSplitterWindow::wxSplitterWindow()
57 m_splitMode
= wxSPLIT_VERTICAL
;
58 m_permitUnsplitAlways
= FALSE
;
59 m_windowOne
= (wxWindow
*) NULL
;
60 m_windowTwo
= (wxWindow
*) NULL
;
61 m_dragMode
= wxSPLIT_DRAG_NONE
;
69 m_sashCursorWE
= (wxCursor
*) NULL
;
70 m_sashCursorNS
= (wxCursor
*) NULL
;
71 m_sashTrackerPen
= (wxPen
*) NULL
;
72 m_lightShadowPen
= (wxPen
*) NULL
;
73 m_mediumShadowPen
= (wxPen
*) NULL
;
74 m_darkShadowPen
= (wxPen
*) NULL
;
75 m_faceBrush
= (wxBrush
*) NULL
;
76 m_facePen
= (wxPen
*) NULL
;
77 m_hilightPen
= (wxPen
*) NULL
;
78 m_minimumPaneSize
= 0;
79 m_needUpdating
= FALSE
;
82 wxSplitterWindow::wxSplitterWindow(wxWindow
*parent
, wxWindowID id
,
87 : wxWindow(parent
, id
, pos
, size
, style
, name
)
89 m_splitMode
= wxSPLIT_VERTICAL
;
90 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
91 m_windowOne
= (wxWindow
*) NULL
;
92 m_windowTwo
= (wxWindow
*) NULL
;
93 m_dragMode
= wxSPLIT_DRAG_NONE
;
101 m_minimumPaneSize
= 0;
102 m_sashCursorWE
= new wxCursor(wxCURSOR_SIZEWE
);
103 m_sashCursorNS
= new wxCursor(wxCURSOR_SIZENS
);
104 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
105 m_lightShadowPen
= (wxPen
*) NULL
;
106 m_mediumShadowPen
= (wxPen
*) NULL
;
107 m_darkShadowPen
= (wxPen
*) NULL
;
108 m_faceBrush
= (wxBrush
*) NULL
;
109 m_facePen
= (wxPen
*) NULL
;
110 m_hilightPen
= (wxPen
*) NULL
;
112 if ( style
& wxSP_3D
)
117 else if ( style
& wxSP_BORDER
)
128 // Eventually, we'll respond to colour change messages
131 // For debugging purposes, to see the background.
132 // SetBackground(wxBLUE_BRUSH);
134 m_needUpdating
= FALSE
;
137 wxSplitterWindow::~wxSplitterWindow()
139 delete m_sashCursorWE
;
140 delete m_sashCursorNS
;
141 delete m_sashTrackerPen
;
142 delete m_lightShadowPen
;
143 delete m_darkShadowPen
;
144 delete m_mediumShadowPen
;
150 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
154 if ( m_borderSize
> 0 )
159 void wxSplitterWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
))
165 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
167 wxCoord x
= (wxCoord
)event
.GetX(),
168 y
= (wxCoord
)event
.GetY();
172 SetCursor(* wxSTANDARD_CURSOR
);
175 SetCursor(wxCursor());
179 if (event
.LeftDown())
181 if ( SashHitTest(x
, y
) )
185 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
187 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
189 DrawSashTracker(x
, y
);
195 if ( m_splitMode
== wxSPLIT_VERTICAL
)
197 SetCursor(*m_sashCursorWE
);
201 SetCursor(*m_sashCursorNS
);
206 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
208 // We can stop dragging now and see what we've got.
209 m_dragMode
= wxSPLIT_DRAG_NONE
;
213 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
215 DrawSashTracker(m_oldX
, m_oldY
);
218 // Obtain window size. We are only interested in the dimension the sash
221 GetClientSize(&w
, &h
);
222 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
? w
: h
);
223 int new_sash_position
=
224 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
226 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
,
228 eventSplitter
.m_data
.pos
= new_sash_position
;
229 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
231 new_sash_position
= eventSplitter
.GetSashPosition();
232 if ( new_sash_position
== -1 )
234 // change not allowed
239 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
241 // Deal with possible unsplit scenarios
242 if ( new_sash_position
== 0 )
244 // We remove the first window from the view
245 wxWindow
*removedWindow
= m_windowOne
;
246 m_windowOne
= m_windowTwo
;
247 m_windowTwo
= (wxWindow
*) NULL
;
248 SendUnsplitEvent(removedWindow
);
251 else if ( new_sash_position
== window_size
)
253 // We remove the second window from the view
254 wxWindow
*removedWindow
= m_windowTwo
;
255 m_windowTwo
= (wxWindow
*) NULL
;
256 SendUnsplitEvent(removedWindow
);
261 m_sashPosition
= new_sash_position
;
266 m_sashPosition
= new_sash_position
;
270 m_needUpdating
= FALSE
;
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
);
289 // where else do we unset the cursor?
290 SetCursor(* wxSTANDARD_CURSOR
);
294 m_needUpdating
= FALSE
;
296 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
299 // Otherwise, the cursor sometimes reverts to the normal cursor
301 if ( m_splitMode
== wxSPLIT_VERTICAL
)
303 SetCursor(*m_sashCursorWE
);
307 SetCursor(*m_sashCursorNS
);
311 // Obtain window size. We are only interested in the dimension the sash
313 int new_sash_position
=
314 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
316 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
,
318 eventSplitter
.m_data
.pos
= new_sash_position
;
319 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
321 new_sash_position
= eventSplitter
.GetSashPosition();
322 if ( new_sash_position
== -1 )
324 // change not allowed
330 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
332 DrawSashTracker(m_oldX
, m_oldY
);
335 if (m_splitMode
== wxSPLIT_VERTICAL
)
336 x
= new_sash_position
;
338 y
= new_sash_position
;
340 if (new_sash_position
!= -1)
342 // Only modify if permitted
348 // As we captured the mouse, we may get the mouse events from outside
349 // our window - for example, negative values in x, y. This has a weird
350 // consequence under MSW where we use unsigned values sometimes and
351 // signed ones other times: the coordinates turn as big positive
352 // numbers and so the sash is drawn on the *right* side of the window
353 // instead of the left (or bottom instead of top). Correct this.
354 if ( (short)m_oldX
< 0 )
356 if ( (short)m_oldY
< 0 )
361 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
363 DrawSashTracker(m_oldX
, m_oldY
);
367 m_sashPosition
= new_sash_position
;
368 m_needUpdating
= TRUE
;
371 else if ( event
.LeftDClick() )
373 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
,
375 eventSplitter
.m_data
.pt
.x
= x
;
376 eventSplitter
.m_data
.pt
.y
= y
;
378 (void)GetEventHandler()->ProcessEvent(eventSplitter
);
382 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
384 // only process this message if we're not iconized - otherwise iconizing
385 // and restoring a window containing the splitter has a funny side effect
386 // of changing the splitter position!
387 wxWindow
*parent
= GetParent();
388 while ( parent
&& !parent
->IsTopLevel() )
390 parent
= parent
->GetParent();
393 bool iconized
= FALSE
;
394 wxFrame
*frame
= wxDynamicCast(parent
, wxFrame
);
396 iconized
= frame
->IsIconized();
399 wxDialog
*dialog
= wxDynamicCast(parent
, wxDialog
);
401 iconized
= dialog
->IsIconized();
403 wxFAIL_MSG(wxT("should have a top level frame or dialog parent!"));
413 GetClientSize( &cw
, &ch
);
416 if ( m_splitMode
== wxSPLIT_VERTICAL
)
418 if ( m_sashPosition
>= (cw
- 5) )
419 m_sashPosition
= wxMax(10, cw
- 40);
421 if ( m_splitMode
== wxSPLIT_HORIZONTAL
)
423 if ( m_sashPosition
>= (ch
- 5) )
424 m_sashPosition
= wxMax(10, ch
- 40);
432 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
434 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
435 return FALSE
; // No sash
437 if ( m_splitMode
== wxSPLIT_VERTICAL
)
439 if ( (x
>= m_sashPosition
- tolerance
) && (x
<= m_sashPosition
+ m_sashSize
+ tolerance
) )
446 if ( (y
>= (m_sashPosition
- tolerance
)) && (y
<= (m_sashPosition
+ m_sashSize
+ tolerance
)) )
453 // Draw 3D effect borders
454 void wxSplitterWindow::DrawBorders(wxDC
& dc
)
457 GetClientSize(&w
, &h
);
459 if ( GetWindowStyleFlag() & wxSP_3D
)
462 dc
.SetPen(*m_facePen
);
463 dc
.SetBrush(*m_faceBrush
);
464 dc
.DrawRectangle(1, 1 , w
-1, m_borderSize
-2 ); //high
465 dc
.DrawRectangle(1, m_borderSize
-2 , m_borderSize
-2, h
-1 ); // left
466 dc
.DrawRectangle(w
-m_borderSize
+2, m_borderSize
-2 , w
-1, h
-1 ); // right
467 dc
.DrawRectangle(m_borderSize
-2, h
-m_borderSize
+2 , w
-m_borderSize
+2, h
-1 ); //bottom
469 dc
.SetPen(*m_mediumShadowPen
);
470 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, w
-m_borderSize
+1, m_borderSize
-2);
471 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, m_borderSize
-2, h
-m_borderSize
+1);
473 dc
.SetPen(*m_darkShadowPen
);
474 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, w
-m_borderSize
, m_borderSize
-1);
475 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, m_borderSize
-1, h
-m_borderSize
);
477 dc
.SetPen(*m_hilightPen
);
478 dc
.DrawLine(m_borderSize
- 2, h
-m_borderSize
+1, w
-m_borderSize
+1, h
-m_borderSize
+1);
479 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.
480 /// Anyway, h is required for MSW.
482 dc
.SetPen(*m_lightShadowPen
);
483 dc
.DrawLine(w
-m_borderSize
, m_borderSize
-1, w
-m_borderSize
, h
-m_borderSize
); // Right hand side
484 dc
.DrawLine(m_borderSize
-1, h
-m_borderSize
, w
-m_borderSize
+1, h
-m_borderSize
); // Bottom
486 else if ( GetWindowStyleFlag() & wxSP_BORDER
)
488 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
489 dc
.SetPen(*wxBLACK_PEN
);
490 dc
.DrawRectangle(0, 0, w
-1, h
-1);
493 dc
.SetPen(wxNullPen
);
494 dc
.SetBrush(wxNullBrush
);
498 void wxSplitterWindow::DrawSash(wxDC
& dc
)
500 if ( m_sashPosition
== 0 || !m_windowTwo
)
504 GetClientSize(&w
, &h
);
506 if ( GetWindowStyleFlag() & wxSP_3D
)
508 if ( m_splitMode
== wxSPLIT_VERTICAL
)
510 dc
.SetPen(*m_facePen
);
511 dc
.SetBrush(*m_faceBrush
);
512 dc
.DrawRectangle(m_sashPosition
+ 2, 0 , m_sashSize
- 4, h
);
514 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
516 dc
.SetPen(*m_lightShadowPen
);
517 int xShadow
= m_borderSize
? m_borderSize
- 1 : 0 ;
518 dc
.DrawLine(m_sashPosition
, xShadow
, m_sashPosition
, h
-m_borderSize
);
520 dc
.SetPen(*m_hilightPen
);
521 dc
.DrawLine(m_sashPosition
+1, m_borderSize
- 2, m_sashPosition
+1, h
- m_borderSize
+2);
523 dc
.SetPen(*m_mediumShadowPen
);
524 int yMedium
= m_borderSize
? h
-m_borderSize
+1 : h
;
525 dc
.DrawLine(m_sashPosition
+m_sashSize
-2, xShadow
, m_sashPosition
+m_sashSize
-2, yMedium
);
527 dc
.SetPen(*m_darkShadowPen
);
528 dc
.DrawLine(m_sashPosition
+m_sashSize
-1, m_borderSize
, m_sashPosition
+m_sashSize
-1, h
-m_borderSize
);
532 dc
.SetPen(*m_facePen
);
533 dc
.SetBrush(*m_faceBrush
);
534 dc
.DrawRectangle( m_borderSize
-2, m_sashPosition
+ 2, w
-m_borderSize
+2, m_sashSize
- 4);
536 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
538 dc
.SetPen(*m_lightShadowPen
);
539 dc
.DrawLine(m_borderSize
-1, m_sashPosition
, w
-m_borderSize
, m_sashPosition
);
541 dc
.SetPen(*m_hilightPen
);
542 dc
.DrawLine(m_borderSize
-2, m_sashPosition
+1, w
-m_borderSize
+1, m_sashPosition
+1);
544 dc
.SetPen(*m_mediumShadowPen
);
545 dc
.DrawLine(m_borderSize
-1, m_sashPosition
+m_sashSize
-2, w
-m_borderSize
+1, m_sashPosition
+m_sashSize
-2);
547 dc
.SetPen(*m_darkShadowPen
);
548 dc
.DrawLine(m_borderSize
, m_sashPosition
+m_sashSize
-1, w
-m_borderSize
, m_sashPosition
+m_sashSize
-1);
553 if ( m_splitMode
== wxSPLIT_VERTICAL
)
555 dc
.SetPen(*wxBLACK_PEN
);
556 dc
.SetBrush(*wxBLACK_BRUSH
);
558 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
559 h1
+= 1; // Not sure why this is necessary...
560 dc
.DrawRectangle(m_sashPosition
, 0, m_sashSize
, h1
);
564 dc
.SetPen(*wxBLACK_PEN
);
565 dc
.SetBrush(*wxBLACK_BRUSH
);
567 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
570 dc
.DrawRectangle(0, m_sashPosition
, w1
, m_sashSize
);
575 dc
.SetPen(wxNullPen
);
576 dc
.SetBrush(wxNullBrush
);
579 // Draw the sash tracker (for whilst moving the sash)
580 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
583 GetClientSize(&w
, &h
);
589 if ( m_splitMode
== wxSPLIT_VERTICAL
)
620 ClientToScreen(&x1
, &y1
);
621 ClientToScreen(&x2
, &y2
);
623 screenDC
.SetLogicalFunction(wxINVERT
);
624 screenDC
.SetPen(*m_sashTrackerPen
);
625 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
627 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
629 screenDC
.SetLogicalFunction(wxCOPY
);
631 screenDC
.SetPen(wxNullPen
);
632 screenDC
.SetBrush(wxNullBrush
);
635 // Position and size subwindows.
636 // Note that the border size applies to each subwindow, not
637 // including the edges next to the sash.
638 void wxSplitterWindow::SizeWindows()
641 GetClientSize(&w
, &h
);
643 if ( m_windowOne
&& !m_windowTwo
)
645 m_windowOne
->SetSize(m_borderSize
, m_borderSize
, w
- 2*m_borderSize
, h
- 2*m_borderSize
);
648 else if ( m_windowOne
&& m_windowTwo
)
650 if (m_splitMode
== wxSPLIT_VERTICAL
)
652 int x1
= m_borderSize
;
653 int y1
= m_borderSize
;
654 int w1
= m_sashPosition
- m_borderSize
;
655 int h1
= h
- 2*m_borderSize
;
657 int x2
= m_sashPosition
+ m_sashSize
;
658 int y2
= m_borderSize
;
659 int w2
= w
- 2*m_borderSize
- m_sashSize
- w1
;
660 int h2
= h
- 2*m_borderSize
;
662 m_windowOne
->SetSize(x1
, y1
, w1
, h1
);
663 m_windowTwo
->SetSize(x2
, y2
, w2
, h2
);
668 m_windowOne
->SetSize(m_borderSize
, m_borderSize
,
669 w
- 2*m_borderSize
, m_sashPosition
- m_borderSize
);
670 m_windowTwo
->SetSize(m_borderSize
, m_sashPosition
+ m_sashSize
,
671 w
- 2*m_borderSize
, h
- 2*m_borderSize
- m_sashSize
- (m_sashPosition
- m_borderSize
));
676 if ( m_borderSize
> 0 )
681 // Set pane for unsplit window
682 void wxSplitterWindow::Initialize(wxWindow
*window
)
684 m_windowOne
= window
;
685 m_windowTwo
= (wxWindow
*) NULL
;
689 // Associates the given window with window 2, drawing the appropriate sash
690 // and changing the split mode.
691 // Does nothing and returns FALSE if the window is already split.
692 bool wxSplitterWindow::SplitVertically(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
698 GetClientSize(&w
, &h
);
700 m_splitMode
= wxSPLIT_VERTICAL
;
701 m_windowOne
= window1
;
702 m_windowTwo
= window2
;
703 if ( sashPosition
> 0 )
704 m_sashPosition
= sashPosition
;
705 else if ( sashPosition
< 0 )
706 m_sashPosition
= w
- sashPosition
;
708 m_sashPosition
= w
/2;
715 bool wxSplitterWindow::SplitHorizontally(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
721 GetClientSize(&w
, &h
);
723 m_splitMode
= wxSPLIT_HORIZONTAL
;
724 m_windowOne
= window1
;
725 m_windowTwo
= window2
;
726 if ( sashPosition
> 0 )
727 m_sashPosition
= sashPosition
;
728 else if ( sashPosition
< 0 )
729 m_sashPosition
= h
- sashPosition
;
731 m_sashPosition
= h
/2;
739 // Remove the specified (or second) window from the view
740 // Doesn't actually delete the window.
741 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
746 wxWindow
*win
= NULL
;
747 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
750 m_windowTwo
= (wxWindow
*) NULL
;
752 else if ( toRemove
== m_windowOne
)
755 m_windowOne
= m_windowTwo
;
756 m_windowTwo
= (wxWindow
*) NULL
;
760 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
765 SendUnsplitEvent(win
);
772 // Replace a window with another one
773 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
775 wxCHECK_MSG( winOld
, FALSE
, wxT("use one of Split() functions instead") );
776 wxCHECK_MSG( winNew
, FALSE
, wxT("use Unsplit() functions instead") );
778 if ( winOld
== m_windowTwo
)
780 m_windowTwo
= winNew
;
782 else if ( winOld
== m_windowOne
)
784 m_windowOne
= winNew
;
788 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
798 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
800 m_sashPosition
= position
;
808 // Initialize colours
809 void wxSplitterWindow::InitColours()
811 wxDELETE( m_facePen
);
812 wxDELETE( m_faceBrush
);
813 wxDELETE( m_mediumShadowPen
);
814 wxDELETE( m_darkShadowPen
);
815 wxDELETE( m_lightShadowPen
);
816 wxDELETE( m_hilightPen
);
819 #if defined(__WIN95__)
820 wxColour
faceColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
821 m_facePen
= new wxPen(faceColour
, 1, wxSOLID
);
822 m_faceBrush
= new wxBrush(faceColour
, wxSOLID
);
824 wxColour
mediumShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW
));
825 m_mediumShadowPen
= new wxPen(mediumShadowColour
, 1, wxSOLID
);
827 wxColour
darkShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW
));
828 m_darkShadowPen
= new wxPen(darkShadowColour
, 1, wxSOLID
);
830 wxColour
lightShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT
));
831 m_lightShadowPen
= new wxPen(lightShadowColour
, 1, wxSOLID
);
833 wxColour
hilightColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT
));
834 m_hilightPen
= new wxPen(hilightColour
, 1, wxSOLID
);
836 m_facePen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
837 m_faceBrush
= new wxBrush("LIGHT GREY", wxSOLID
);
838 m_mediumShadowPen
= new wxPen("GREY", 1, wxSOLID
);
839 m_darkShadowPen
= new wxPen("BLACK", 1, wxSOLID
);
840 m_lightShadowPen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
841 m_hilightPen
= new wxPen("WHITE", 1, wxSOLID
);
842 #endif // Win32/!Win32
845 void wxSplitterWindow::SendUnsplitEvent(wxWindow
*winRemoved
)
847 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
848 event
.m_data
.win
= winRemoved
;
850 (void)GetEventHandler()->ProcessEvent(event
);
853 // ---------------------------------------------------------------------------
854 // splitter event handlers
855 // ---------------------------------------------------------------------------
857 void wxSplitterWindow::OnSashPosChanged(wxSplitterEvent
& event
)
859 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
860 const int UNSPLIT_THRESHOLD
= 4;
862 int newSashPosition
= event
.GetSashPosition();
864 // Obtain relevant window dimension for bottom / right threshold check
866 GetClientSize(&w
, &h
);
867 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
) ? w
: h
;
869 bool unsplit_scenario
= FALSE
;
870 if ( m_permitUnsplitAlways
871 || m_minimumPaneSize
== 0 )
873 // Do edge detection if unsplit premitted
874 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
876 // threshold top / left check
878 unsplit_scenario
= TRUE
;
880 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
882 // threshold bottom/right check
883 newSashPosition
= window_size
;
884 unsplit_scenario
= TRUE
;
888 if ( !unsplit_scenario
)
890 // If resultant pane would be too small, enlarge it
891 if ( newSashPosition
< m_minimumPaneSize
)
892 newSashPosition
= m_minimumPaneSize
;
893 if ( newSashPosition
> window_size
- m_minimumPaneSize
)
894 newSashPosition
= window_size
- m_minimumPaneSize
;
897 // If the result is out of bounds it means minimum size is too big,
898 // so split window in half as best compromise.
899 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
900 newSashPosition
= window_size
/ 2;
902 // for compatibility, call the virtual function
903 if ( !OnSashPositionChange(newSashPosition
) )
905 newSashPosition
= -1;
908 event
.SetSashPosition(newSashPosition
);
911 // Called when the sash is double-clicked. The default behaviour is to remove
912 // the sash if the minimum pane size is zero.
913 void wxSplitterWindow::OnDoubleClick(wxSplitterEvent
& event
)
915 // for compatibility, call the virtual function
916 OnDoubleClickSash(event
.GetX(), event
.GetY());
918 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
924 void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent
& event
)
926 wxWindow
*win
= event
.GetWindowBeingRemoved();
928 // do it before calling OnUnsplit() which may delete the window
931 // for compatibility, call the virtual function
935 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& event
)
937 // this is currently called (and needed) under MSW only...
940 // if we don't do it, the resizing cursor might be set for child window:
941 // and like this we explicitly say that our cursor should not be used for
942 // children windows which overlap us
944 if ( SashHitTest(event
.GetX(), event
.GetY()) )
946 // default processing is ok
949 //else: do nothing, in particular, don't call Skip()