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_SPLITTER_SASH_POS_CHANGED(-1, wxSplitterWindow::OnSashPosChanged
)
46 // NB: we borrow OnSashPosChanged for purposes of
47 // EVT_SPLITTER_SASH_POS_CHANGING since default implementation is identical
48 EVT_SPLITTER_SASH_POS_CHANGING(-1, wxSplitterWindow::OnSashPosChanged
)
49 EVT_SPLITTER_DCLICK(-1, wxSplitterWindow::OnDoubleClick
)
50 EVT_SPLITTER_UNSPLIT(-1, wxSplitterWindow::OnUnsplitEvent
)
53 wxSplitterWindow::wxSplitterWindow()
55 m_splitMode
= wxSPLIT_VERTICAL
;
56 m_permitUnsplitAlways
= FALSE
;
57 m_windowOne
= (wxWindow
*) NULL
;
58 m_windowTwo
= (wxWindow
*) NULL
;
59 m_dragMode
= wxSPLIT_DRAG_NONE
;
67 m_sashCursorWE
= (wxCursor
*) NULL
;
68 m_sashCursorNS
= (wxCursor
*) NULL
;
69 m_sashTrackerPen
= (wxPen
*) NULL
;
70 m_lightShadowPen
= (wxPen
*) NULL
;
71 m_mediumShadowPen
= (wxPen
*) NULL
;
72 m_darkShadowPen
= (wxPen
*) NULL
;
73 m_faceBrush
= (wxBrush
*) NULL
;
74 m_facePen
= (wxPen
*) NULL
;
75 m_hilightPen
= (wxPen
*) NULL
;
76 m_minimumPaneSize
= 0;
77 m_needUpdating
= FALSE
;
80 wxSplitterWindow::wxSplitterWindow(wxWindow
*parent
, wxWindowID id
,
85 : wxWindow(parent
, id
, pos
, size
, style
, name
)
87 m_splitMode
= wxSPLIT_VERTICAL
;
88 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
89 m_windowOne
= (wxWindow
*) NULL
;
90 m_windowTwo
= (wxWindow
*) NULL
;
91 m_dragMode
= wxSPLIT_DRAG_NONE
;
99 m_minimumPaneSize
= 0;
100 m_sashCursorWE
= new wxCursor(wxCURSOR_SIZEWE
);
101 m_sashCursorNS
= new wxCursor(wxCURSOR_SIZENS
);
102 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
103 m_lightShadowPen
= (wxPen
*) NULL
;
104 m_mediumShadowPen
= (wxPen
*) NULL
;
105 m_darkShadowPen
= (wxPen
*) NULL
;
106 m_faceBrush
= (wxBrush
*) NULL
;
107 m_facePen
= (wxPen
*) NULL
;
108 m_hilightPen
= (wxPen
*) NULL
;
110 if ( style
& wxSP_3D
)
115 else if ( style
& wxSP_BORDER
)
126 // Eventually, we'll respond to colour change messages
129 // For debugging purposes, to see the background.
130 // SetBackground(wxBLUE_BRUSH);
132 m_needUpdating
= FALSE
;
135 wxSplitterWindow::~wxSplitterWindow()
137 delete m_sashCursorWE
;
138 delete m_sashCursorNS
;
139 delete m_sashTrackerPen
;
140 delete m_lightShadowPen
;
141 delete m_darkShadowPen
;
142 delete m_mediumShadowPen
;
148 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
152 if ( m_borderSize
> 0 )
157 void wxSplitterWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
))
163 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
165 wxCoord x
= (wxCoord
)event
.GetX(),
166 y
= (wxCoord
)event
.GetY();
170 SetCursor(* wxSTANDARD_CURSOR
);
173 SetCursor(wxCursor());
177 if (event
.LeftDown())
179 if ( SashHitTest(x
, y
) )
183 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
185 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
187 DrawSashTracker(x
, y
);
193 if ( m_splitMode
== wxSPLIT_VERTICAL
)
195 SetCursor(*m_sashCursorWE
);
199 SetCursor(*m_sashCursorNS
);
204 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
206 // We can stop dragging now and see what we've got.
207 m_dragMode
= wxSPLIT_DRAG_NONE
;
211 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
213 DrawSashTracker(m_oldX
, m_oldY
);
216 // Obtain window size. We are only interested in the dimension the sash
219 GetClientSize(&w
, &h
);
220 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
? w
: h
);
221 int new_sash_position
=
222 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
224 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
,
226 eventSplitter
.m_data
.pos
= new_sash_position
;
227 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
229 new_sash_position
= eventSplitter
.GetSashPosition();
230 if ( new_sash_position
== -1 )
232 // change not allowed
237 if ( m_permitUnsplitAlways
238 || m_minimumPaneSize
== 0 )
240 // Deal with possible unsplit scenarios
241 if ( new_sash_position
== 0 )
243 // We remove the first window from the view
244 wxWindow
*removedWindow
= m_windowOne
;
245 m_windowOne
= m_windowTwo
;
246 m_windowTwo
= (wxWindow
*) NULL
;
247 SendUnsplitEvent(removedWindow
);
250 else if ( new_sash_position
== window_size
)
252 // We remove the second window from the view
253 wxWindow
*removedWindow
= m_windowTwo
;
254 m_windowTwo
= (wxWindow
*) NULL
;
255 SendUnsplitEvent(removedWindow
);
260 m_sashPosition
= new_sash_position
;
265 m_sashPosition
= new_sash_position
;
269 m_needUpdating
= FALSE
;
270 } // left up && dragging
271 else if (event
.Moving() && !event
.Dragging())
273 // Just change the cursor if required
274 if ( SashHitTest(x
, y
) )
276 if ( m_splitMode
== wxSPLIT_VERTICAL
)
278 SetCursor(*m_sashCursorWE
);
282 SetCursor(*m_sashCursorNS
);
288 // where else do we unset the cursor?
289 SetCursor(* wxSTANDARD_CURSOR
);
293 m_needUpdating
= FALSE
;
295 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
298 // Otherwise, the cursor sometimes reverts to the normal cursor
300 if ( m_splitMode
== wxSPLIT_VERTICAL
)
302 SetCursor(*m_sashCursorWE
);
306 SetCursor(*m_sashCursorNS
);
310 // Obtain window size. We are only interested in the dimension the sash
312 int new_sash_position
=
313 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
315 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
,
317 eventSplitter
.m_data
.pos
= new_sash_position
;
318 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
320 new_sash_position
= eventSplitter
.GetSashPosition();
321 if ( new_sash_position
== -1 )
323 // change not allowed
329 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
331 DrawSashTracker(m_oldX
, m_oldY
);
334 if (m_splitMode
== wxSPLIT_VERTICAL
)
335 x
= new_sash_position
;
337 y
= new_sash_position
;
339 if (new_sash_position
!= -1)
341 // Only modify if permitted
347 // As we captured the mouse, we may get the mouse events from outside
348 // our window - for example, negative values in x, y. This has a weird
349 // consequence under MSW where we use unsigned values sometimes and
350 // signed ones other times: the coordinates turn as big positive
351 // numbers and so the sash is drawn on the *right* side of the window
352 // instead of the left (or bottom instead of top). Correct this.
353 if ( (short)m_oldX
< 0 )
355 if ( (short)m_oldY
< 0 )
360 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
362 DrawSashTracker(m_oldX
, m_oldY
);
366 m_sashPosition
= new_sash_position
;
367 m_needUpdating
= TRUE
;
370 else if ( event
.LeftDClick() )
372 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
,
374 eventSplitter
.m_data
.pt
.x
= x
;
375 eventSplitter
.m_data
.pt
.y
= y
;
377 (void)GetEventHandler()->ProcessEvent(eventSplitter
);
381 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
383 // only process this message if we're not iconized - otherwise iconizing
384 // and restoring a window containing the splitter has a funny side effect
385 // of changing the splitter position!
386 wxWindow
*parent
= GetParent();
387 while ( parent
&& !parent
->IsTopLevel() )
389 parent
= parent
->GetParent();
392 bool iconized
= FALSE
;
393 wxFrame
*frame
= wxDynamicCast(parent
, wxFrame
);
395 iconized
= frame
->IsIconized();
398 wxDialog
*dialog
= wxDynamicCast(parent
, wxDialog
);
400 iconized
= dialog
->IsIconized();
402 wxFAIL_MSG(wxT("should have a top level frame or dialog parent!"));
412 GetClientSize( &cw
, &ch
);
415 if ( m_splitMode
== wxSPLIT_VERTICAL
)
417 if ( m_sashPosition
>= (cw
- 5) )
418 m_sashPosition
= wxMax(10, cw
- 40);
420 if ( m_splitMode
== wxSPLIT_HORIZONTAL
)
422 if ( m_sashPosition
>= (ch
- 5) )
423 m_sashPosition
= wxMax(10, ch
- 40);
431 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
433 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
434 return FALSE
; // No sash
436 if ( m_splitMode
== wxSPLIT_VERTICAL
)
438 if ( (x
>= m_sashPosition
- tolerance
) && (x
<= m_sashPosition
+ m_sashSize
+ tolerance
) )
445 if ( (y
>= (m_sashPosition
- tolerance
)) && (y
<= (m_sashPosition
+ m_sashSize
+ tolerance
)) )
452 // Draw 3D effect borders
453 void wxSplitterWindow::DrawBorders(wxDC
& dc
)
456 GetClientSize(&w
, &h
);
458 if ( GetWindowStyleFlag() & wxSP_3D
)
461 dc
.SetPen(*m_facePen
);
462 dc
.SetBrush(*m_faceBrush
);
463 dc
.DrawRectangle(1, 1 , w
-1, m_borderSize
-2 ); //high
464 dc
.DrawRectangle(1, m_borderSize
-2 , m_borderSize
-2, h
-1 ); // left
465 dc
.DrawRectangle(w
-m_borderSize
+2, m_borderSize
-2 , w
-1, h
-1 ); // right
466 dc
.DrawRectangle(m_borderSize
-2, h
-m_borderSize
+2 , w
-m_borderSize
+2, h
-1 ); //bottom
468 dc
.SetPen(*m_mediumShadowPen
);
469 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, w
-m_borderSize
+1, m_borderSize
-2);
470 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, m_borderSize
-2, h
-m_borderSize
+1);
472 dc
.SetPen(*m_darkShadowPen
);
473 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, w
-m_borderSize
, m_borderSize
-1);
474 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, m_borderSize
-1, h
-m_borderSize
);
476 dc
.SetPen(*m_hilightPen
);
477 dc
.DrawLine(m_borderSize
- 2, h
-m_borderSize
+1, w
-m_borderSize
+1, h
-m_borderSize
+1);
478 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.
479 /// Anyway, h is required for MSW.
481 dc
.SetPen(*m_lightShadowPen
);
482 dc
.DrawLine(w
-m_borderSize
, m_borderSize
-1, w
-m_borderSize
, h
-m_borderSize
); // Right hand side
483 dc
.DrawLine(m_borderSize
-1, h
-m_borderSize
, w
-m_borderSize
+1, h
-m_borderSize
); // Bottom
485 else if ( GetWindowStyleFlag() & wxSP_BORDER
)
487 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
488 dc
.SetPen(*wxBLACK_PEN
);
489 dc
.DrawRectangle(0, 0, w
-1, h
-1);
492 dc
.SetPen(wxNullPen
);
493 dc
.SetBrush(wxNullBrush
);
497 void wxSplitterWindow::DrawSash(wxDC
& dc
)
499 if ( m_sashPosition
== 0 || !m_windowTwo
)
503 GetClientSize(&w
, &h
);
505 if ( GetWindowStyleFlag() & wxSP_3D
)
507 if ( m_splitMode
== wxSPLIT_VERTICAL
)
509 dc
.SetPen(*m_facePen
);
510 dc
.SetBrush(*m_faceBrush
);
511 dc
.DrawRectangle(m_sashPosition
+ 2, 0 , m_sashSize
- 4, h
);
513 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
515 dc
.SetPen(*m_lightShadowPen
);
516 int xShadow
= m_borderSize
? m_borderSize
- 1 : 0 ;
517 dc
.DrawLine(m_sashPosition
, xShadow
, m_sashPosition
, h
-m_borderSize
);
519 dc
.SetPen(*m_hilightPen
);
520 dc
.DrawLine(m_sashPosition
+1, m_borderSize
- 2, m_sashPosition
+1, h
- m_borderSize
+2);
522 dc
.SetPen(*m_mediumShadowPen
);
523 int yMedium
= m_borderSize
? h
-m_borderSize
+1 : h
;
524 dc
.DrawLine(m_sashPosition
+m_sashSize
-2, xShadow
, m_sashPosition
+m_sashSize
-2, yMedium
);
526 dc
.SetPen(*m_darkShadowPen
);
527 dc
.DrawLine(m_sashPosition
+m_sashSize
-1, m_borderSize
, m_sashPosition
+m_sashSize
-1, h
-m_borderSize
);
531 dc
.SetPen(*m_facePen
);
532 dc
.SetBrush(*m_faceBrush
);
533 dc
.DrawRectangle( m_borderSize
-2, m_sashPosition
+ 2, w
-m_borderSize
+2, m_sashSize
- 4);
535 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
537 dc
.SetPen(*m_lightShadowPen
);
538 dc
.DrawLine(m_borderSize
-1, m_sashPosition
, w
-m_borderSize
, m_sashPosition
);
540 dc
.SetPen(*m_hilightPen
);
541 dc
.DrawLine(m_borderSize
-2, m_sashPosition
+1, w
-m_borderSize
+1, m_sashPosition
+1);
543 dc
.SetPen(*m_mediumShadowPen
);
544 dc
.DrawLine(m_borderSize
-1, m_sashPosition
+m_sashSize
-2, w
-m_borderSize
+1, m_sashPosition
+m_sashSize
-2);
546 dc
.SetPen(*m_darkShadowPen
);
547 dc
.DrawLine(m_borderSize
, m_sashPosition
+m_sashSize
-1, w
-m_borderSize
, m_sashPosition
+m_sashSize
-1);
552 if ( m_splitMode
== wxSPLIT_VERTICAL
)
554 dc
.SetPen(*wxBLACK_PEN
);
555 dc
.SetBrush(*wxBLACK_BRUSH
);
557 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
558 h1
+= 1; // Not sure why this is necessary...
559 dc
.DrawRectangle(m_sashPosition
, 0, m_sashSize
, h1
);
563 dc
.SetPen(*wxBLACK_PEN
);
564 dc
.SetBrush(*wxBLACK_BRUSH
);
566 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
569 dc
.DrawRectangle(0, m_sashPosition
, w1
, m_sashSize
);
574 dc
.SetPen(wxNullPen
);
575 dc
.SetBrush(wxNullBrush
);
578 // Draw the sash tracker (for whilst moving the sash)
579 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
582 GetClientSize(&w
, &h
);
588 if ( m_splitMode
== wxSPLIT_VERTICAL
)
619 ClientToScreen(&x1
, &y1
);
620 ClientToScreen(&x2
, &y2
);
622 screenDC
.SetLogicalFunction(wxINVERT
);
623 screenDC
.SetPen(*m_sashTrackerPen
);
624 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
626 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
628 screenDC
.SetLogicalFunction(wxCOPY
);
630 screenDC
.SetPen(wxNullPen
);
631 screenDC
.SetBrush(wxNullBrush
);
634 // Position and size subwindows.
635 // Note that the border size applies to each subwindow, not
636 // including the edges next to the sash.
637 void wxSplitterWindow::SizeWindows()
640 GetClientSize(&w
, &h
);
642 if ( m_windowOne
&& !m_windowTwo
)
644 m_windowOne
->SetSize(m_borderSize
, m_borderSize
, w
- 2*m_borderSize
, h
- 2*m_borderSize
);
647 else if ( m_windowOne
&& m_windowTwo
)
649 if (m_splitMode
== wxSPLIT_VERTICAL
)
651 int x1
= m_borderSize
;
652 int y1
= m_borderSize
;
653 int w1
= m_sashPosition
- m_borderSize
;
654 int h1
= h
- 2*m_borderSize
;
656 int x2
= m_sashPosition
+ m_sashSize
;
657 int y2
= m_borderSize
;
658 int w2
= w
- 2*m_borderSize
- m_sashSize
- w1
;
659 int h2
= h
- 2*m_borderSize
;
661 m_windowOne
->SetSize(x1
, y1
, w1
, h1
);
662 m_windowTwo
->SetSize(x2
, y2
, w2
, h2
);
667 m_windowOne
->SetSize(m_borderSize
, m_borderSize
,
668 w
- 2*m_borderSize
, m_sashPosition
- m_borderSize
);
669 m_windowTwo
->SetSize(m_borderSize
, m_sashPosition
+ m_sashSize
,
670 w
- 2*m_borderSize
, h
- 2*m_borderSize
- m_sashSize
- (m_sashPosition
- m_borderSize
));
675 if ( m_borderSize
> 0 )
680 // Set pane for unsplit window
681 void wxSplitterWindow::Initialize(wxWindow
*window
)
683 m_windowOne
= window
;
684 m_windowTwo
= (wxWindow
*) NULL
;
688 // Associates the given window with window 2, drawing the appropriate sash
689 // and changing the split mode.
690 // Does nothing and returns FALSE if the window is already split.
691 bool wxSplitterWindow::SplitVertically(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
697 GetClientSize(&w
, &h
);
699 m_splitMode
= wxSPLIT_VERTICAL
;
700 m_windowOne
= window1
;
701 m_windowTwo
= window2
;
702 if ( sashPosition
> 0 )
703 m_sashPosition
= sashPosition
;
704 else if ( sashPosition
< 0 )
705 m_sashPosition
= w
- sashPosition
;
707 m_sashPosition
= w
/2;
714 bool wxSplitterWindow::SplitHorizontally(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
720 GetClientSize(&w
, &h
);
722 m_splitMode
= wxSPLIT_HORIZONTAL
;
723 m_windowOne
= window1
;
724 m_windowTwo
= window2
;
725 if ( sashPosition
> 0 )
726 m_sashPosition
= sashPosition
;
727 else if ( sashPosition
< 0 )
728 m_sashPosition
= h
- sashPosition
;
730 m_sashPosition
= h
/2;
738 // Remove the specified (or second) window from the view
739 // Doesn't actually delete the window.
740 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
745 wxWindow
*win
= NULL
;
746 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
749 m_windowTwo
= (wxWindow
*) NULL
;
751 else if ( toRemove
== m_windowOne
)
754 m_windowOne
= m_windowTwo
;
755 m_windowTwo
= (wxWindow
*) NULL
;
759 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
764 SendUnsplitEvent(win
);
771 // Replace a window with another one
772 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
774 wxCHECK_MSG( winOld
, FALSE
, wxT("use one of Split() functions instead") );
775 wxCHECK_MSG( winNew
, FALSE
, wxT("use Unsplit() functions instead") );
777 if ( winOld
== m_windowTwo
)
779 m_windowTwo
= winNew
;
781 else if ( winOld
== m_windowOne
)
783 m_windowOne
= winNew
;
787 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
797 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
799 m_sashPosition
= position
;
807 // Initialize colours
808 void wxSplitterWindow::InitColours()
810 wxDELETE( m_facePen
);
811 wxDELETE( m_faceBrush
);
812 wxDELETE( m_mediumShadowPen
);
813 wxDELETE( m_darkShadowPen
);
814 wxDELETE( m_lightShadowPen
);
815 wxDELETE( m_hilightPen
);
818 #if defined(__WIN95__)
819 wxColour
faceColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
820 m_facePen
= new wxPen(faceColour
, 1, wxSOLID
);
821 m_faceBrush
= new wxBrush(faceColour
, wxSOLID
);
823 wxColour
mediumShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW
));
824 m_mediumShadowPen
= new wxPen(mediumShadowColour
, 1, wxSOLID
);
826 wxColour
darkShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW
));
827 m_darkShadowPen
= new wxPen(darkShadowColour
, 1, wxSOLID
);
829 wxColour
lightShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT
));
830 m_lightShadowPen
= new wxPen(lightShadowColour
, 1, wxSOLID
);
832 wxColour
hilightColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT
));
833 m_hilightPen
= new wxPen(hilightColour
, 1, wxSOLID
);
835 m_facePen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
836 m_faceBrush
= new wxBrush("LIGHT GREY", wxSOLID
);
837 m_mediumShadowPen
= new wxPen("GREY", 1, wxSOLID
);
838 m_darkShadowPen
= new wxPen("BLACK", 1, wxSOLID
);
839 m_lightShadowPen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
840 m_hilightPen
= new wxPen("WHITE", 1, wxSOLID
);
841 #endif // Win32/!Win32
844 void wxSplitterWindow::SendUnsplitEvent(wxWindow
*winRemoved
)
846 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
847 event
.m_data
.win
= winRemoved
;
849 (void)GetEventHandler()->ProcessEvent(event
);
852 // ---------------------------------------------------------------------------
853 // splitter event handlers
854 // ---------------------------------------------------------------------------
856 void wxSplitterWindow::OnSashPosChanged(wxSplitterEvent
& event
)
858 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
859 const int UNSPLIT_THRESHOLD
= 4;
861 int newSashPosition
= event
.GetSashPosition();
863 // Obtain relevant window dimension for bottom / right threshold check
865 GetClientSize(&w
, &h
);
866 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
) ? w
: h
;
868 bool unsplit_scenario
= FALSE
;
869 if ( m_permitUnsplitAlways
870 || m_minimumPaneSize
== 0 )
872 // Do edge detection if unsplit premitted
873 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
875 // threshold top / left check
877 unsplit_scenario
= TRUE
;
879 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
881 // threshold bottom/right check
882 newSashPosition
= window_size
;
883 unsplit_scenario
= TRUE
;
887 if ( !unsplit_scenario
)
889 // If resultant pane would be too small, enlarge it
890 if ( newSashPosition
< m_minimumPaneSize
)
891 newSashPosition
= m_minimumPaneSize
;
892 if ( newSashPosition
> window_size
- m_minimumPaneSize
)
893 newSashPosition
= window_size
- m_minimumPaneSize
;
896 // If the result is out of bounds it means minimum size is too big,
897 // so split window in half as best compromise.
898 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
899 newSashPosition
= window_size
/ 2;
901 // for compatibility, call the virtual function
902 if ( !OnSashPositionChange(newSashPosition
) )
904 newSashPosition
= -1;
907 event
.SetSashPosition(newSashPosition
);
910 // Called when the sash is double-clicked. The default behaviour is to remove
911 // the sash if the minimum pane size is zero.
912 void wxSplitterWindow::OnDoubleClick(wxSplitterEvent
& event
)
914 // for compatibility, call the virtual function
915 OnDoubleClickSash(event
.GetX(), event
.GetY());
917 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
923 void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent
& event
)
925 wxWindow
*win
= event
.GetWindowBeingRemoved();
927 // do it before calling OnUnsplit() which may delete the window
930 // for compatibility, call the virtual function