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"
35 #if !USE_SHARED_LIBRARY
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
)
54 wxSplitterWindow::wxSplitterWindow()
56 m_splitMode
= wxSPLIT_VERTICAL
;
57 m_permitUnsplitAlways
= FALSE
;
58 m_windowOne
= (wxWindow
*) NULL
;
59 m_windowTwo
= (wxWindow
*) NULL
;
60 m_dragMode
= wxSPLIT_DRAG_NONE
;
68 m_sashCursorWE
= (wxCursor
*) NULL
;
69 m_sashCursorNS
= (wxCursor
*) NULL
;
70 m_sashTrackerPen
= (wxPen
*) NULL
;
71 m_lightShadowPen
= (wxPen
*) NULL
;
72 m_mediumShadowPen
= (wxPen
*) NULL
;
73 m_darkShadowPen
= (wxPen
*) NULL
;
74 m_faceBrush
= (wxBrush
*) NULL
;
75 m_facePen
= (wxPen
*) NULL
;
76 m_hilightPen
= (wxPen
*) NULL
;
77 m_minimumPaneSize
= 0;
78 m_needUpdating
= FALSE
;
81 wxSplitterWindow::wxSplitterWindow(wxWindow
*parent
, wxWindowID id
,
86 : wxWindow(parent
, id
, pos
, size
, style
, name
)
88 m_splitMode
= wxSPLIT_VERTICAL
;
89 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
90 m_windowOne
= (wxWindow
*) NULL
;
91 m_windowTwo
= (wxWindow
*) NULL
;
92 m_dragMode
= wxSPLIT_DRAG_NONE
;
100 m_minimumPaneSize
= 0;
101 m_sashCursorWE
= new wxCursor(wxCURSOR_SIZEWE
);
102 m_sashCursorNS
= new wxCursor(wxCURSOR_SIZENS
);
103 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
104 m_lightShadowPen
= (wxPen
*) NULL
;
105 m_mediumShadowPen
= (wxPen
*) NULL
;
106 m_darkShadowPen
= (wxPen
*) NULL
;
107 m_faceBrush
= (wxBrush
*) NULL
;
108 m_facePen
= (wxPen
*) NULL
;
109 m_hilightPen
= (wxPen
*) NULL
;
111 if ( style
& wxSP_3D
)
116 else if ( style
& wxSP_BORDER
)
127 // Eventually, we'll respond to colour change messages
130 // For debugging purposes, to see the background.
131 // SetBackground(wxBLUE_BRUSH);
133 m_needUpdating
= FALSE
;
136 wxSplitterWindow::~wxSplitterWindow()
138 delete m_sashCursorWE
;
139 delete m_sashCursorNS
;
140 delete m_sashTrackerPen
;
141 delete m_lightShadowPen
;
142 delete m_darkShadowPen
;
143 delete m_mediumShadowPen
;
149 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
153 if ( m_borderSize
> 0 )
158 void wxSplitterWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
))
164 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
166 long x
= event
.GetX();
167 long y
= event
.GetY();
171 SetCursor(* wxSTANDARD_CURSOR
);
174 SetCursor(wxCursor());
178 if (event
.LeftDown())
180 if ( SashHitTest(x
, y
) )
184 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
186 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
188 DrawSashTracker(x
, y
);
196 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
198 // We can stop dragging now and see what we've got.
199 m_dragMode
= wxSPLIT_DRAG_NONE
;
203 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
205 DrawSashTracker(m_oldX
, m_oldY
);
208 // Obtain window size. We are only interested in the dimension the sash
211 GetClientSize(&w
, &h
);
212 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
? w
: h
);
213 int new_sash_position
=
214 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
216 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
,
218 eventSplitter
.m_data
.pos
= new_sash_position
;
219 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
221 new_sash_position
= eventSplitter
.GetSashPosition();
222 if ( new_sash_position
== -1 )
224 // change not allowed
229 if ( m_permitUnsplitAlways
230 || m_minimumPaneSize
== 0 )
232 // Deal with possible unsplit scenarios
233 if ( new_sash_position
== 0 )
235 // We remove the first window from the view
236 wxWindow
*removedWindow
= m_windowOne
;
237 m_windowOne
= m_windowTwo
;
238 m_windowTwo
= (wxWindow
*) NULL
;
239 SendUnsplitEvent(removedWindow
);
242 else if ( new_sash_position
== window_size
)
244 // We remove the second window from the view
245 wxWindow
*removedWindow
= m_windowTwo
;
246 m_windowTwo
= (wxWindow
*) NULL
;
247 SendUnsplitEvent(removedWindow
);
252 m_sashPosition
= new_sash_position
;
257 m_sashPosition
= new_sash_position
;
261 } // left up && dragging
262 else if (event
.Moving() && !event
.Dragging())
264 // Just change the cursor if required
265 if ( SashHitTest(x
, y
) )
267 if ( m_splitMode
== wxSPLIT_VERTICAL
)
269 SetCursor(*m_sashCursorWE
);
273 SetCursor(*m_sashCursorNS
);
279 // where else do we unset the cursor?
280 SetCursor(* wxSTANDARD_CURSOR
);
284 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
286 // Obtain window size. We are only interested in the dimension the sash
288 int new_sash_position
=
289 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
291 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
,
293 eventSplitter
.m_data
.pos
= new_sash_position
;
294 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
296 new_sash_position
= eventSplitter
.GetSashPosition();
297 if ( new_sash_position
== -1 )
299 // change not allowed
305 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
307 DrawSashTracker(m_oldX
, m_oldY
);
310 if (m_splitMode
== wxSPLIT_VERTICAL
)
311 x
= new_sash_position
;
313 y
= new_sash_position
;
315 if (new_sash_position
!= -1)
317 // Only modify if permitted
323 // As we captured the mouse, we may get the mouse events from outside
324 // our window - for example, negative values in x, y. This has a weird
325 // consequence under MSW where we use unsigned values sometimes and
326 // signed ones other times: the coordinates turn as big positive
327 // numbers and so the sash is drawn on the *right* side of the window
328 // instead of the left (or bottom instead of top). Correct this.
329 if ( (short)m_oldX
< 0 )
331 if ( (short)m_oldY
< 0 )
336 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
338 DrawSashTracker(m_oldX
, m_oldY
);
342 m_sashPosition
= new_sash_position
;
343 m_needUpdating
= TRUE
;
346 else if ( event
.LeftDClick() )
348 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
,
350 eventSplitter
.m_data
.pt
.x
= x
;
351 eventSplitter
.m_data
.pt
.y
= y
;
353 (void)GetEventHandler()->ProcessEvent(eventSplitter
);
357 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
359 // only process this message if we're not iconized - otherwise iconizing
360 // and restoring a window containing the splitter has a funny side effect
361 // of changing the splitter position!
362 wxWindow
*parent
= GetParent();
363 while ( parent
&& !parent
->IsTopLevel() )
365 parent
= parent
->GetParent();
368 bool iconized
= FALSE
;
369 wxFrame
*frame
= wxDynamicCast(parent
, wxFrame
);
371 iconized
= frame
->IsIconized();
374 wxDialog
*dialog
= wxDynamicCast(parent
, wxDialog
);
376 iconized
= dialog
->IsIconized();
378 wxFAIL_MSG(wxT("should have a top level frame or dialog parent!"));
388 GetClientSize( &cw
, &ch
);
391 if ( m_splitMode
== wxSPLIT_VERTICAL
)
393 if ( m_sashPosition
>= (cw
- 5) )
394 m_sashPosition
= wxMax(10, cw
- 40);
396 if ( m_splitMode
== wxSPLIT_HORIZONTAL
)
398 if ( m_sashPosition
>= (ch
- 5) )
399 m_sashPosition
= wxMax(10, ch
- 40);
407 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
409 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
410 return FALSE
; // No sash
412 if ( m_splitMode
== wxSPLIT_VERTICAL
)
414 if ( (x
>= m_sashPosition
- tolerance
) && (x
<= m_sashPosition
+ m_sashSize
+ tolerance
) )
421 if ( (y
>= (m_sashPosition
- tolerance
)) && (y
<= (m_sashPosition
+ m_sashSize
+ tolerance
)) )
430 // Draw 3D effect borders
431 void wxSplitterWindow::DrawBorders(wxDC
& dc
)
434 GetClientSize(&w
, &h
);
436 if ( GetWindowStyleFlag() & wxSP_3D
)
439 dc
.SetPen(*m_facePen
);
440 dc
.SetBrush(*m_faceBrush
);
441 dc
.DrawRectangle(1, 1 , w
-1, m_borderSize
-2 ); //high
442 dc
.DrawRectangle(1, m_borderSize
-2 , m_borderSize
-2, h
-1 ); // left
443 dc
.DrawRectangle(w
-m_borderSize
+2, m_borderSize
-2 , w
-1, h
-1 ); // right
444 dc
.DrawRectangle(m_borderSize
-2, h
-m_borderSize
+2 , w
-m_borderSize
+2, h
-1 ); //bottom
446 dc
.SetPen(*m_mediumShadowPen
);
447 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, w
-m_borderSize
+1, m_borderSize
-2);
448 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, m_borderSize
-2, h
-m_borderSize
+1);
450 dc
.SetPen(*m_darkShadowPen
);
451 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, w
-m_borderSize
, m_borderSize
-1);
452 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, m_borderSize
-1, h
-m_borderSize
);
454 dc
.SetPen(*m_hilightPen
);
455 dc
.DrawLine(m_borderSize
- 2, h
-m_borderSize
+1, w
-m_borderSize
+1, h
-m_borderSize
+1);
456 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.
457 /// Anyway, h is required for MSW.
459 dc
.SetPen(*m_lightShadowPen
);
460 dc
.DrawLine(w
-m_borderSize
, m_borderSize
-1, w
-m_borderSize
, h
-m_borderSize
); // Right hand side
461 dc
.DrawLine(m_borderSize
-1, h
-m_borderSize
, w
-m_borderSize
+1, h
-m_borderSize
); // Bottom
463 else if ( GetWindowStyleFlag() & wxSP_BORDER
)
465 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
466 dc
.SetPen(*wxBLACK_PEN
);
467 dc
.DrawRectangle(0, 0, w
-1, h
-1);
470 dc
.SetPen(wxNullPen
);
471 dc
.SetBrush(wxNullBrush
);
475 void wxSplitterWindow::DrawSash(wxDC
& dc
)
477 if ( m_sashPosition
== 0 || !m_windowTwo
)
481 GetClientSize(&w
, &h
);
483 if ( GetWindowStyleFlag() & wxSP_3D
)
485 if ( m_splitMode
== wxSPLIT_VERTICAL
)
487 dc
.SetPen(*m_facePen
);
488 dc
.SetBrush(*m_faceBrush
);
489 dc
.DrawRectangle(m_sashPosition
+ 2, 0 , m_sashSize
- 4, h
);
491 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
493 dc
.SetPen(*m_lightShadowPen
);
494 int xShadow
= m_borderSize
? m_borderSize
- 1 : 0 ;
495 dc
.DrawLine(m_sashPosition
, xShadow
, m_sashPosition
, h
-m_borderSize
);
497 dc
.SetPen(*m_hilightPen
);
498 dc
.DrawLine(m_sashPosition
+1, m_borderSize
- 2, m_sashPosition
+1, h
- m_borderSize
+2);
500 dc
.SetPen(*m_mediumShadowPen
);
501 int yMedium
= m_borderSize
? h
-m_borderSize
+1 : h
;
502 dc
.DrawLine(m_sashPosition
+m_sashSize
-2, xShadow
, m_sashPosition
+m_sashSize
-2, yMedium
);
504 dc
.SetPen(*m_darkShadowPen
);
505 dc
.DrawLine(m_sashPosition
+m_sashSize
-1, m_borderSize
, m_sashPosition
+m_sashSize
-1, h
-m_borderSize
);
509 dc
.SetPen(*m_facePen
);
510 dc
.SetBrush(*m_faceBrush
);
511 dc
.DrawRectangle( m_borderSize
-2, m_sashPosition
+ 2, w
-m_borderSize
+2, m_sashSize
- 4);
513 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
515 dc
.SetPen(*m_lightShadowPen
);
516 dc
.DrawLine(m_borderSize
-1, m_sashPosition
, w
-m_borderSize
, m_sashPosition
);
518 dc
.SetPen(*m_hilightPen
);
519 dc
.DrawLine(m_borderSize
-2, m_sashPosition
+1, w
-m_borderSize
+1, m_sashPosition
+1);
521 dc
.SetPen(*m_mediumShadowPen
);
522 dc
.DrawLine(m_borderSize
-1, m_sashPosition
+m_sashSize
-2, w
-m_borderSize
+1, m_sashPosition
+m_sashSize
-2);
524 dc
.SetPen(*m_darkShadowPen
);
525 dc
.DrawLine(m_borderSize
, m_sashPosition
+m_sashSize
-1, w
-m_borderSize
, m_sashPosition
+m_sashSize
-1);
530 if ( m_splitMode
== wxSPLIT_VERTICAL
)
532 dc
.SetPen(*wxBLACK_PEN
);
533 dc
.SetBrush(*wxBLACK_BRUSH
);
535 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
536 h1
+= 1; // Not sure why this is necessary...
537 dc
.DrawRectangle(m_sashPosition
, 0, m_sashSize
, h1
);
541 dc
.SetPen(*wxBLACK_PEN
);
542 dc
.SetBrush(*wxBLACK_BRUSH
);
544 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
)
547 dc
.DrawRectangle(0, m_sashPosition
, w1
, m_sashSize
);
552 dc
.SetPen(wxNullPen
);
553 dc
.SetBrush(wxNullBrush
);
556 // Draw the sash tracker (for whilst moving the sash)
557 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
560 GetClientSize(&w
, &h
);
566 if ( m_splitMode
== wxSPLIT_VERTICAL
)
597 ClientToScreen(&x1
, &y1
);
598 ClientToScreen(&x2
, &y2
);
600 screenDC
.SetLogicalFunction(wxINVERT
);
601 screenDC
.SetPen(*m_sashTrackerPen
);
602 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
604 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
606 screenDC
.SetLogicalFunction(wxCOPY
);
608 screenDC
.SetPen(wxNullPen
);
609 screenDC
.SetBrush(wxNullBrush
);
612 // Position and size subwindows.
613 // Note that the border size applies to each subwindow, not
614 // including the edges next to the sash.
615 void wxSplitterWindow::SizeWindows()
618 GetClientSize(&w
, &h
);
620 if ( m_windowOne
&& !m_windowTwo
)
622 m_windowOne
->SetSize(m_borderSize
, m_borderSize
, w
- 2*m_borderSize
, h
- 2*m_borderSize
);
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
);
645 m_windowOne
->SetSize(m_borderSize
, m_borderSize
,
646 w
- 2*m_borderSize
, m_sashPosition
- m_borderSize
);
647 m_windowTwo
->SetSize(m_borderSize
, m_sashPosition
+ m_sashSize
,
648 w
- 2*m_borderSize
, h
- 2*m_borderSize
- m_sashSize
- (m_sashPosition
- m_borderSize
));
653 if ( m_borderSize
> 0 )
658 // Set pane for unsplit window
659 void wxSplitterWindow::Initialize(wxWindow
*window
)
661 m_windowOne
= window
;
662 m_windowTwo
= (wxWindow
*) NULL
;
666 // Associates the given window with window 2, drawing the appropriate sash
667 // and changing the split mode.
668 // Does nothing and returns FALSE if the window is already split.
669 bool wxSplitterWindow::SplitVertically(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
675 GetClientSize(&w
, &h
);
677 m_splitMode
= wxSPLIT_VERTICAL
;
678 m_windowOne
= window1
;
679 m_windowTwo
= window2
;
680 if ( sashPosition
> 0 )
681 m_sashPosition
= sashPosition
;
682 else if ( sashPosition
< 0 )
683 m_sashPosition
= w
- sashPosition
;
685 m_sashPosition
= w
/2;
692 bool wxSplitterWindow::SplitHorizontally(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
698 GetClientSize(&w
, &h
);
700 m_splitMode
= wxSPLIT_HORIZONTAL
;
701 m_windowOne
= window1
;
702 m_windowTwo
= window2
;
703 if ( sashPosition
> 0 )
704 m_sashPosition
= sashPosition
;
705 else if ( sashPosition
< 0 )
706 m_sashPosition
= h
- sashPosition
;
708 m_sashPosition
= h
/2;
716 // Remove the specified (or second) window from the view
717 // Doesn't actually delete the window.
718 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
723 wxWindow
*win
= NULL
;
724 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
727 m_windowTwo
= (wxWindow
*) NULL
;
729 else if ( toRemove
== m_windowOne
)
732 m_windowOne
= m_windowTwo
;
733 m_windowTwo
= (wxWindow
*) NULL
;
737 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
742 SendUnsplitEvent(win
);
749 // Replace a window with another one
750 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
752 wxCHECK_MSG( winOld
, FALSE
, wxT("use one of Split() functions instead") );
753 wxCHECK_MSG( winNew
, FALSE
, wxT("use Unsplit() functions instead") );
755 if ( winOld
== m_windowTwo
)
757 m_windowTwo
= winNew
;
759 else if ( winOld
== m_windowOne
)
761 m_windowOne
= winNew
;
765 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
775 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
777 m_sashPosition
= position
;
785 // Initialize colours
786 void wxSplitterWindow::InitColours()
788 wxDELETE( m_facePen
);
789 wxDELETE( m_faceBrush
);
790 wxDELETE( m_mediumShadowPen
);
791 wxDELETE( m_darkShadowPen
);
792 wxDELETE( m_lightShadowPen
);
793 wxDELETE( m_hilightPen
);
796 #if defined(__WIN95__)
797 wxColour
faceColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
798 m_facePen
= new wxPen(faceColour
, 1, wxSOLID
);
799 m_faceBrush
= new wxBrush(faceColour
, wxSOLID
);
801 wxColour
mediumShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW
));
802 m_mediumShadowPen
= new wxPen(mediumShadowColour
, 1, wxSOLID
);
804 wxColour
darkShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW
));
805 m_darkShadowPen
= new wxPen(darkShadowColour
, 1, wxSOLID
);
807 wxColour
lightShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT
));
808 m_lightShadowPen
= new wxPen(lightShadowColour
, 1, wxSOLID
);
810 wxColour
hilightColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT
));
811 m_hilightPen
= new wxPen(hilightColour
, 1, wxSOLID
);
813 m_facePen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
814 m_faceBrush
= new wxBrush("LIGHT GREY", wxSOLID
);
815 m_mediumShadowPen
= new wxPen("GREY", 1, wxSOLID
);
816 m_darkShadowPen
= new wxPen("BLACK", 1, wxSOLID
);
817 m_lightShadowPen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
818 m_hilightPen
= new wxPen("WHITE", 1, wxSOLID
);
819 #endif // Win32/!Win32
822 void wxSplitterWindow::SendUnsplitEvent(wxWindow
*winRemoved
)
824 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
825 event
.m_data
.win
= winRemoved
;
827 (void)GetEventHandler()->ProcessEvent(event
);
830 // ---------------------------------------------------------------------------
831 // splitter event handlers
832 // ---------------------------------------------------------------------------
834 void wxSplitterWindow::OnSashPosChanged(wxSplitterEvent
& event
)
836 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
837 const int UNSPLIT_THRESHOLD
= 4;
839 int newSashPosition
= event
.GetSashPosition();
841 // Obtain relevant window dimension for bottom / right threshold check
843 GetClientSize(&w
, &h
);
844 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
) ? w
: h
;
846 bool unsplit_scenario
= FALSE
;
847 if ( m_permitUnsplitAlways
848 || m_minimumPaneSize
== 0 )
850 // Do edge detection if unsplit premitted
851 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
853 // threshold top / left check
855 unsplit_scenario
= TRUE
;
857 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
859 // threshold bottom/right check
860 newSashPosition
= window_size
;
861 unsplit_scenario
= TRUE
;
865 if ( !unsplit_scenario
)
867 // If resultant pane would be too small, enlarge it
868 if ( newSashPosition
< m_minimumPaneSize
)
869 newSashPosition
= m_minimumPaneSize
;
870 if ( newSashPosition
> window_size
- m_minimumPaneSize
)
871 newSashPosition
= window_size
- m_minimumPaneSize
;
874 // If the result is out of bounds it means minimum size is too big,
875 // so split window in half as best compromise.
876 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
877 newSashPosition
= window_size
/ 2;
879 // for compatibility, call the virtual function
880 if ( !OnSashPositionChange(newSashPosition
) )
882 newSashPosition
= -1;
885 event
.SetSashPosition(newSashPosition
);
888 // Called when the sash is double-clicked. The default behaviour is to remove
889 // the sash if the minimum pane size is zero.
890 void wxSplitterWindow::OnDoubleClick(wxSplitterEvent
& event
)
892 // for compatibility, call the virtual function
893 OnDoubleClickSash(event
.GetX(), event
.GetY());
895 if ( GetMinimumPaneSize() == 0
896 || m_permitUnsplitAlways
)
902 void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent
& event
)
904 wxWindow
*win
= event
.GetWindowBeingRemoved();
906 // for compatibility, call the virtual function