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"
29 #include "wx/string.h"
30 #include "wx/splitter.h"
31 #include "wx/dcscreen.h"
33 #if !USE_SHARED_LIBRARY
34 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow
, wxWindow
)
35 IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent
, wxCommandEvent
)
37 BEGIN_EVENT_TABLE(wxSplitterWindow
, wxWindow
)
38 EVT_PAINT(wxSplitterWindow::OnPaint
)
39 EVT_SIZE(wxSplitterWindow::OnSize
)
40 EVT_IDLE(wxSplitterWindow::OnIdle
)
41 EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent
)
43 EVT_SPLITTER_SASH_POS_CHANGED(-1, wxSplitterWindow::OnSashPosChanged
)
44 // NB: we borrow OnSashPosChanged for purposes of
45 // EVT_SPLITTER_SASH_POS_CHANGING since default implementation is identical
46 EVT_SPLITTER_SASH_POS_CHANGING(-1, wxSplitterWindow::OnSashPosChanged
)
47 EVT_SPLITTER_DCLICK(-1, wxSplitterWindow::OnDoubleClick
)
48 EVT_SPLITTER_UNSPLIT(-1, wxSplitterWindow::OnUnsplitEvent
)
52 wxSplitterWindow::wxSplitterWindow()
54 m_splitMode
= wxSPLIT_VERTICAL
;
55 m_permitUnsplitAlways
= FALSE
;
56 m_windowOne
= (wxWindow
*) NULL
;
57 m_windowTwo
= (wxWindow
*) NULL
;
58 m_dragMode
= wxSPLIT_DRAG_NONE
;
66 m_sashCursorWE
= (wxCursor
*) NULL
;
67 m_sashCursorNS
= (wxCursor
*) NULL
;
68 m_sashTrackerPen
= (wxPen
*) NULL
;
69 m_lightShadowPen
= (wxPen
*) NULL
;
70 m_mediumShadowPen
= (wxPen
*) NULL
;
71 m_darkShadowPen
= (wxPen
*) NULL
;
72 m_faceBrush
= (wxBrush
*) NULL
;
73 m_facePen
= (wxPen
*) NULL
;
74 m_hilightPen
= (wxPen
*) NULL
;
75 m_minimumPaneSize
= 0;
76 m_needUpdating
= FALSE
;
79 wxSplitterWindow::wxSplitterWindow(wxWindow
*parent
, wxWindowID id
,
84 : wxWindow(parent
, id
, pos
, size
, style
, name
)
86 m_splitMode
= wxSPLIT_VERTICAL
;
87 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
88 m_windowOne
= (wxWindow
*) NULL
;
89 m_windowTwo
= (wxWindow
*) NULL
;
90 m_dragMode
= wxSPLIT_DRAG_NONE
;
98 m_minimumPaneSize
= 0;
99 m_sashCursorWE
= new wxCursor(wxCURSOR_SIZEWE
);
100 m_sashCursorNS
= new wxCursor(wxCURSOR_SIZENS
);
101 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
102 m_lightShadowPen
= (wxPen
*) NULL
;
103 m_mediumShadowPen
= (wxPen
*) NULL
;
104 m_darkShadowPen
= (wxPen
*) NULL
;
105 m_faceBrush
= (wxBrush
*) NULL
;
106 m_facePen
= (wxPen
*) NULL
;
107 m_hilightPen
= (wxPen
*) NULL
;
109 if ( style
& wxSP_3D
)
114 else if ( style
& wxSP_BORDER
)
125 // Eventually, we'll respond to colour change messages
128 // For debugging purposes, to see the background.
129 // SetBackground(wxBLUE_BRUSH);
131 m_needUpdating
= FALSE
;
134 wxSplitterWindow::~wxSplitterWindow()
136 delete m_sashCursorWE
;
137 delete m_sashCursorNS
;
138 delete m_sashTrackerPen
;
139 delete m_lightShadowPen
;
140 delete m_darkShadowPen
;
141 delete m_mediumShadowPen
;
147 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
151 if ( m_borderSize
> 0 )
156 void wxSplitterWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
))
162 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
164 long x
= event
.GetX();
165 long y
= event
.GetY();
169 SetCursor(* wxSTANDARD_CURSOR
);
172 SetCursor(wxCursor());
176 if (event
.LeftDown())
178 if ( SashHitTest(x
, y
) )
182 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
184 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
186 DrawSashTracker(x
, y
);
194 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
196 // We can stop dragging now and see what we've got.
197 m_dragMode
= wxSPLIT_DRAG_NONE
;
201 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
203 DrawSashTracker(m_oldX
, m_oldY
);
206 // Obtain window size. We are only interested in the dimension the sash
209 GetClientSize(&w
, &h
);
210 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
? w
: h
);
211 int new_sash_position
=
212 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
214 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
,
216 eventSplitter
.m_data
.pos
= new_sash_position
;
217 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
219 new_sash_position
= eventSplitter
.GetSashPosition();
220 if ( new_sash_position
== -1 )
222 // change not allowed
227 if ( m_permitUnsplitAlways
228 || m_minimumPaneSize
== 0 )
230 // Deal with possible unsplit scenarios
231 if ( new_sash_position
== 0 )
233 // We remove the first window from the view
234 wxWindow
*removedWindow
= m_windowOne
;
235 m_windowOne
= m_windowTwo
;
236 m_windowTwo
= (wxWindow
*) NULL
;
237 SendUnsplitEvent(removedWindow
);
240 else if ( new_sash_position
== window_size
)
242 // We remove the second window from the view
243 wxWindow
*removedWindow
= m_windowTwo
;
244 m_windowTwo
= (wxWindow
*) NULL
;
245 SendUnsplitEvent(removedWindow
);
250 m_sashPosition
= new_sash_position
;
255 m_sashPosition
= new_sash_position
;
259 } // left up && dragging
260 else if (event
.Moving() && !event
.Dragging())
262 // Just change the cursor if required
263 if ( SashHitTest(x
, y
) )
265 if ( m_splitMode
== wxSPLIT_VERTICAL
)
267 SetCursor(*m_sashCursorWE
);
271 SetCursor(*m_sashCursorNS
);
277 // where else do we unset the cursor?
278 SetCursor(* wxSTANDARD_CURSOR
);
282 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
284 // Obtain window size. We are only interested in the dimension the sash
286 int new_sash_position
=
287 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
289 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
,
291 eventSplitter
.m_data
.pos
= new_sash_position
;
292 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
294 new_sash_position
= eventSplitter
.GetSashPosition();
295 if ( new_sash_position
== -1 )
297 // change not allowed
303 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
305 DrawSashTracker(m_oldX
, m_oldY
);
308 if (m_splitMode
== wxSPLIT_VERTICAL
)
309 x
= new_sash_position
;
311 y
= new_sash_position
;
313 if (new_sash_position
!= -1)
315 // Only modify if permitted
321 // As we captured the mouse, we may get the mouse events from outside
322 // our window - for example, negative values in x, y. This has a weird
323 // consequence under MSW where we use unsigned values sometimes and
324 // signed ones other times: the coordinates turn as big positive
325 // numbers and so the sash is drawn on the *right* side of the window
326 // instead of the left (or bottom instead of top). Correct this.
327 if ( (short)m_oldX
< 0 )
329 if ( (short)m_oldY
< 0 )
334 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
336 DrawSashTracker(m_oldX
, m_oldY
);
340 m_sashPosition
= new_sash_position
;
341 m_needUpdating
= TRUE
;
344 else if ( event
.LeftDClick() )
346 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
,
348 eventSplitter
.m_data
.pt
.x
= x
;
349 eventSplitter
.m_data
.pt
.y
= y
;
351 (void)GetEventHandler()->ProcessEvent(eventSplitter
);
355 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
357 // only process this message if we're not iconized - otherwise iconizing
358 // and restoring a window containing the splitter has a funny side effect
359 // of changing the splitter position!
360 wxWindow
*parent
= GetParent();
361 while ( parent
&& !parent
->IsTopLevel() )
363 parent
= parent
->GetParent();
366 bool iconized
= FALSE
;
367 wxFrame
*frame
= wxDynamicCast(parent
, wxFrame
);
369 iconized
= frame
->IsIconized();
372 wxDialog
*dialog
= wxDynamicCast(parent
, wxDialog
);
374 iconized
= dialog
->IsIconized();
376 wxFAIL_MSG(_T("should have a top level frame or dialog parent!"));
386 GetClientSize( &cw
, &ch
);
389 if ( m_splitMode
== wxSPLIT_VERTICAL
)
391 if ( m_sashPosition
>= (cw
- 5) )
392 m_sashPosition
= wxMax(10, cw
- 40);
394 if ( m_splitMode
== wxSPLIT_HORIZONTAL
)
396 if ( m_sashPosition
>= (ch
- 5) )
397 m_sashPosition
= wxMax(10, ch
- 40);
405 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
407 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
408 return FALSE
; // No sash
410 if ( m_splitMode
== wxSPLIT_VERTICAL
)
412 if ( (x
>= m_sashPosition
- tolerance
) && (x
<= m_sashPosition
+ m_sashSize
+ tolerance
) )
419 if ( (y
>= (m_sashPosition
- tolerance
)) && (y
<= (m_sashPosition
+ m_sashSize
+ tolerance
)) )
428 // Draw 3D effect borders
429 void wxSplitterWindow::DrawBorders(wxDC
& dc
)
432 GetClientSize(&w
, &h
);
434 if ( GetWindowStyleFlag() & wxSP_3D
)
437 dc
.SetPen(*m_facePen
);
438 dc
.SetBrush(*m_faceBrush
);
439 dc
.DrawRectangle(1, 1 , w
-1, m_borderSize
-2 ); //high
440 dc
.DrawRectangle(1, m_borderSize
-2 , m_borderSize
-2, h
-1 ); // left
441 dc
.DrawRectangle(w
-m_borderSize
+2, m_borderSize
-2 , w
-1, h
-1 ); // right
442 dc
.DrawRectangle(m_borderSize
-2, h
-m_borderSize
+2 , w
-m_borderSize
+2, h
-1 ); //bottom
444 dc
.SetPen(*m_mediumShadowPen
);
445 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, w
-m_borderSize
+1, m_borderSize
-2);
446 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, m_borderSize
-2, h
-m_borderSize
+1);
448 dc
.SetPen(*m_darkShadowPen
);
449 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, w
-m_borderSize
, m_borderSize
-1);
450 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, m_borderSize
-1, h
-m_borderSize
);
452 dc
.SetPen(*m_hilightPen
);
453 dc
.DrawLine(m_borderSize
- 2, h
-m_borderSize
+1, w
-m_borderSize
+1, h
-m_borderSize
+1);
454 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.
455 /// Anyway, h is required for MSW.
457 dc
.SetPen(*m_lightShadowPen
);
458 dc
.DrawLine(w
-m_borderSize
, m_borderSize
-1, w
-m_borderSize
, h
-m_borderSize
); // Right hand side
459 dc
.DrawLine(m_borderSize
-1, h
-m_borderSize
, w
-m_borderSize
+1, h
-m_borderSize
); // Bottom
461 else if ( GetWindowStyleFlag() & wxSP_BORDER
)
463 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
464 dc
.SetPen(*wxBLACK_PEN
);
465 dc
.DrawRectangle(0, 0, w
-1, h
-1);
468 dc
.SetPen(wxNullPen
);
469 dc
.SetBrush(wxNullBrush
);
473 void wxSplitterWindow::DrawSash(wxDC
& dc
)
475 if ( m_sashPosition
== 0 || !m_windowTwo
)
479 GetClientSize(&w
, &h
);
481 if ( GetWindowStyleFlag() & wxSP_3D
)
483 if ( m_splitMode
== wxSPLIT_VERTICAL
)
485 dc
.SetPen(*m_facePen
);
486 dc
.SetBrush(*m_faceBrush
);
487 dc
.DrawRectangle(m_sashPosition
+ 2, 0 , m_sashSize
- 4, h
);
489 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
491 dc
.SetPen(*m_lightShadowPen
);
492 int xShadow
= m_borderSize
? m_borderSize
- 1 : 0 ;
493 dc
.DrawLine(m_sashPosition
, xShadow
, m_sashPosition
, h
-m_borderSize
);
495 dc
.SetPen(*m_hilightPen
);
496 dc
.DrawLine(m_sashPosition
+1, m_borderSize
- 2, m_sashPosition
+1, h
- m_borderSize
+2);
498 dc
.SetPen(*m_mediumShadowPen
);
499 int yMedium
= m_borderSize
? h
-m_borderSize
+1 : h
;
500 dc
.DrawLine(m_sashPosition
+m_sashSize
-2, xShadow
, m_sashPosition
+m_sashSize
-2, yMedium
);
502 dc
.SetPen(*m_darkShadowPen
);
503 dc
.DrawLine(m_sashPosition
+m_sashSize
-1, m_borderSize
, m_sashPosition
+m_sashSize
-1, h
-m_borderSize
);
507 dc
.SetPen(*m_facePen
);
508 dc
.SetBrush(*m_faceBrush
);
509 dc
.DrawRectangle( m_borderSize
-2, m_sashPosition
+ 2, w
-m_borderSize
+2, m_sashSize
- 4);
511 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
513 dc
.SetPen(*m_lightShadowPen
);
514 dc
.DrawLine(m_borderSize
-1, m_sashPosition
, w
-m_borderSize
, m_sashPosition
);
516 dc
.SetPen(*m_hilightPen
);
517 dc
.DrawLine(m_borderSize
-2, m_sashPosition
+1, w
-m_borderSize
+1, m_sashPosition
+1);
519 dc
.SetPen(*m_mediumShadowPen
);
520 dc
.DrawLine(m_borderSize
-1, m_sashPosition
+m_sashSize
-2, w
-m_borderSize
+1, m_sashPosition
+m_sashSize
-2);
522 dc
.SetPen(*m_darkShadowPen
);
523 dc
.DrawLine(m_borderSize
, m_sashPosition
+m_sashSize
-1, w
-m_borderSize
, m_sashPosition
+m_sashSize
-1);
528 if ( m_splitMode
== wxSPLIT_VERTICAL
)
530 dc
.SetPen(*wxBLACK_PEN
);
531 dc
.SetBrush(*wxBLACK_BRUSH
);
533 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
534 h1
+= 1; // Not sure why this is necessary...
535 dc
.DrawRectangle(m_sashPosition
, 0, m_sashSize
, h1
);
539 dc
.SetPen(*wxBLACK_PEN
);
540 dc
.SetBrush(*wxBLACK_BRUSH
);
542 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
545 dc
.DrawRectangle(0, m_sashPosition
, w1
, m_sashSize
);
550 dc
.SetPen(wxNullPen
);
551 dc
.SetBrush(wxNullBrush
);
554 // Draw the sash tracker (for whilst moving the sash)
555 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
558 GetClientSize(&w
, &h
);
564 if ( m_splitMode
== wxSPLIT_VERTICAL
)
595 ClientToScreen(&x1
, &y1
);
596 ClientToScreen(&x2
, &y2
);
598 screenDC
.SetLogicalFunction(wxINVERT
);
599 screenDC
.SetPen(*m_sashTrackerPen
);
600 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
602 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
604 screenDC
.SetLogicalFunction(wxCOPY
);
606 screenDC
.SetPen(wxNullPen
);
607 screenDC
.SetBrush(wxNullBrush
);
610 // Position and size subwindows.
611 // Note that the border size applies to each subwindow, not
612 // including the edges next to the sash.
613 void wxSplitterWindow::SizeWindows()
616 GetClientSize(&w
, &h
);
618 if ( m_windowOne
&& !m_windowTwo
)
620 m_windowOne
->SetSize(m_borderSize
, m_borderSize
, w
- 2*m_borderSize
, h
- 2*m_borderSize
);
622 if (m_windowOne
->GetAutoLayout())
623 m_windowOne
->Layout();
625 else if ( m_windowOne
&& m_windowTwo
)
627 if (m_splitMode
== wxSPLIT_VERTICAL
)
629 int x1
= m_borderSize
;
630 int y1
= m_borderSize
;
631 int w1
= m_sashPosition
- m_borderSize
;
632 int h1
= h
- 2*m_borderSize
;
634 int x2
= m_sashPosition
+ m_sashSize
;
635 int y2
= m_borderSize
;
636 int w2
= w
- 2*m_borderSize
- m_sashSize
- w1
;
637 int h2
= h
- 2*m_borderSize
;
639 m_windowOne
->SetSize(x1
, y1
, w1
, h1
);
640 m_windowTwo
->SetSize(x2
, y2
, w2
, h2
);
642 if (m_windowOne
->GetAutoLayout())
643 m_windowOne
->Layout();
644 if (m_windowTwo
->GetAutoLayout())
645 m_windowTwo
->Layout();
649 m_windowOne
->SetSize(m_borderSize
, m_borderSize
,
650 w
- 2*m_borderSize
, m_sashPosition
- m_borderSize
);
651 m_windowTwo
->SetSize(m_borderSize
, m_sashPosition
+ m_sashSize
,
652 w
- 2*m_borderSize
, h
- 2*m_borderSize
- m_sashSize
- (m_sashPosition
- m_borderSize
));
654 if (m_windowOne
->GetAutoLayout())
655 m_windowOne
->Layout();
656 if (m_windowTwo
->GetAutoLayout())
657 m_windowTwo
->Layout();
661 if ( m_borderSize
> 0 )
666 // Set pane for unsplit window
667 void wxSplitterWindow::Initialize(wxWindow
*window
)
669 m_windowOne
= window
;
670 m_windowTwo
= (wxWindow
*) NULL
;
674 // Associates the given window with window 2, drawing the appropriate sash
675 // and changing the split mode.
676 // Does nothing and returns FALSE if the window is already split.
677 bool wxSplitterWindow::SplitVertically(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
683 GetClientSize(&w
, &h
);
685 m_splitMode
= wxSPLIT_VERTICAL
;
686 m_windowOne
= window1
;
687 m_windowTwo
= window2
;
688 if ( sashPosition
> 0 )
689 m_sashPosition
= sashPosition
;
690 else if ( sashPosition
< 0 )
691 m_sashPosition
= w
- sashPosition
;
693 m_sashPosition
= w
/2;
700 bool wxSplitterWindow::SplitHorizontally(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
706 GetClientSize(&w
, &h
);
708 m_splitMode
= wxSPLIT_HORIZONTAL
;
709 m_windowOne
= window1
;
710 m_windowTwo
= window2
;
711 if ( sashPosition
> 0 )
712 m_sashPosition
= sashPosition
;
713 else if ( sashPosition
< 0 )
714 m_sashPosition
= h
- sashPosition
;
716 m_sashPosition
= h
/2;
724 // Remove the specified (or second) window from the view
725 // Doesn't actually delete the window.
726 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
731 wxWindow
*win
= NULL
;
732 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
735 m_windowTwo
= (wxWindow
*) NULL
;
737 else if ( toRemove
== m_windowOne
)
740 m_windowOne
= m_windowTwo
;
741 m_windowTwo
= (wxWindow
*) NULL
;
745 wxFAIL_MSG(_T("splitter: attempt to remove a non-existent window"));
750 SendUnsplitEvent(win
);
757 // Replace a window with another one
758 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
760 wxCHECK_MSG( winOld
, FALSE
, _T("use one of Split() functions instead") );
761 wxCHECK_MSG( winNew
, FALSE
, _T("use Unsplit() functions instead") );
763 if ( winOld
== m_windowTwo
)
765 m_windowTwo
= winNew
;
767 else if ( winOld
== m_windowOne
)
769 m_windowOne
= winNew
;
773 wxFAIL_MSG(_T("splitter: attempt to replace a non-existent window"));
783 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
785 m_sashPosition
= position
;
793 // Initialize colours
794 void wxSplitterWindow::InitColours()
796 wxDELETE( m_facePen
);
797 wxDELETE( m_faceBrush
);
798 wxDELETE( m_mediumShadowPen
);
799 wxDELETE( m_darkShadowPen
);
800 wxDELETE( m_lightShadowPen
);
801 wxDELETE( m_hilightPen
);
804 #if defined(__WIN95__)
805 wxColour
faceColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
806 m_facePen
= new wxPen(faceColour
, 1, wxSOLID
);
807 m_faceBrush
= new wxBrush(faceColour
, wxSOLID
);
809 wxColour
mediumShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW
));
810 m_mediumShadowPen
= new wxPen(mediumShadowColour
, 1, wxSOLID
);
812 wxColour
darkShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW
));
813 m_darkShadowPen
= new wxPen(darkShadowColour
, 1, wxSOLID
);
815 wxColour
lightShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT
));
816 m_lightShadowPen
= new wxPen(lightShadowColour
, 1, wxSOLID
);
818 wxColour
hilightColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT
));
819 m_hilightPen
= new wxPen(hilightColour
, 1, wxSOLID
);
821 m_facePen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
822 m_faceBrush
= new wxBrush("LIGHT GREY", wxSOLID
);
823 m_mediumShadowPen
= new wxPen("GREY", 1, wxSOLID
);
824 m_darkShadowPen
= new wxPen("BLACK", 1, wxSOLID
);
825 m_lightShadowPen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
826 m_hilightPen
= new wxPen("WHITE", 1, wxSOLID
);
827 #endif // Win32/!Win32
830 void wxSplitterWindow::SendUnsplitEvent(wxWindow
*winRemoved
)
832 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
833 event
.m_data
.win
= winRemoved
;
835 (void)GetEventHandler()->ProcessEvent(event
);
838 // ---------------------------------------------------------------------------
839 // splitter event handlers
840 // ---------------------------------------------------------------------------
842 void wxSplitterWindow::OnSashPosChanged(wxSplitterEvent
& event
)
844 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
845 const int UNSPLIT_THRESHOLD
= 4;
847 int newSashPosition
= event
.GetSashPosition();
849 // Obtain relevant window dimension for bottom / right threshold check
851 GetClientSize(&w
, &h
);
852 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
) ? w
: h
;
854 bool unsplit_scenario
= FALSE
;
855 if ( m_permitUnsplitAlways
856 || m_minimumPaneSize
== 0 )
858 // Do edge detection if unsplit premitted
859 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
861 // threshold top / left check
863 unsplit_scenario
= TRUE
;
865 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
867 // threshold bottom/right check
868 newSashPosition
= window_size
;
869 unsplit_scenario
= TRUE
;
873 if ( !unsplit_scenario
)
875 // If resultant pane would be too small, enlarge it
876 if ( newSashPosition
< m_minimumPaneSize
)
877 newSashPosition
= m_minimumPaneSize
;
878 if ( newSashPosition
> window_size
- m_minimumPaneSize
)
879 newSashPosition
= window_size
- m_minimumPaneSize
;
882 // If the result is out of bounds it means minimum size is too big,
883 // so split window in half as best compromise.
884 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
885 newSashPosition
= window_size
/ 2;
887 // for compatibility, call the virtual function
888 if ( !OnSashPositionChange(newSashPosition
) )
890 newSashPosition
= -1;
893 event
.SetSashPosition(newSashPosition
);
896 // Called when the sash is double-clicked. The default behaviour is to remove
897 // the sash if the minimum pane size is zero.
898 void wxSplitterWindow::OnDoubleClick(wxSplitterEvent
& event
)
900 // for compatibility, call the virtual function
901 OnDoubleClickSash(event
.GetX(), event
.GetY());
903 if ( GetMinimumPaneSize() == 0
904 || m_permitUnsplitAlways
)
910 void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent
& event
)
912 wxWindow
*win
= event
.GetWindowBeingRemoved();
914 // for compatibility, call the virtual function