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 bool wxSplitterWindow::Create(wxWindow
*parent
, wxWindowID id
,
62 if (!wxWindow::Create(parent
, id
, pos
, size
, style
, name
))
65 m_permitUnsplitAlways
= (style
& wxSP_PERMIT_UNSPLIT
) != 0;
67 if ( style
& wxSP_3DSASH
)
72 if ( style
& wxSP_3DBORDER
)
74 else if ( style
& wxSP_BORDER
)
82 void wxSplitterWindow::Init()
84 m_splitMode
= wxSPLIT_VERTICAL
;
85 m_permitUnsplitAlways
= TRUE
;
86 m_windowOne
= (wxWindow
*) NULL
;
87 m_windowTwo
= (wxWindow
*) NULL
;
88 m_dragMode
= wxSPLIT_DRAG_NONE
;
96 m_minimumPaneSize
= 0;
97 m_sashCursorWE
= new wxCursor(wxCURSOR_SIZEWE
);
98 m_sashCursorNS
= new wxCursor(wxCURSOR_SIZENS
);
99 m_sashTrackerPen
= new wxPen(*wxBLACK
, 2, wxSOLID
);
100 m_lightShadowPen
= (wxPen
*) NULL
;
101 m_mediumShadowPen
= (wxPen
*) NULL
;
102 m_darkShadowPen
= (wxPen
*) NULL
;
103 m_faceBrush
= (wxBrush
*) NULL
;
104 m_facePen
= (wxPen
*) NULL
;
105 m_hilightPen
= (wxPen
*) NULL
;
112 m_needUpdating
= FALSE
;
115 wxSplitterWindow::~wxSplitterWindow()
117 delete m_sashCursorWE
;
118 delete m_sashCursorNS
;
119 delete m_sashTrackerPen
;
120 delete m_lightShadowPen
;
121 delete m_darkShadowPen
;
122 delete m_mediumShadowPen
;
128 void wxSplitterWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
132 if ( m_borderSize
> 0 )
137 void wxSplitterWindow::OnIdle(wxIdleEvent
& event
)
145 void wxSplitterWindow::OnMouseEvent(wxMouseEvent
& event
)
147 wxCoord x
= (wxCoord
)event
.GetX(),
148 y
= (wxCoord
)event
.GetY();
152 SetCursor(* wxSTANDARD_CURSOR
);
155 SetCursor(wxCursor());
158 if (GetWindowStyle() & wxSP_NOSASH
)
161 if (event
.LeftDown())
163 if ( SashHitTest(x
, y
) )
167 m_dragMode
= wxSPLIT_DRAG_DRAGGING
;
169 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
171 DrawSashTracker(x
, y
);
177 if ( m_splitMode
== wxSPLIT_VERTICAL
)
179 SetCursor(*m_sashCursorWE
);
183 SetCursor(*m_sashCursorNS
);
188 else if (event
.LeftUp() && m_dragMode
== wxSPLIT_DRAG_DRAGGING
)
190 // We can stop dragging now and see what we've got.
191 m_dragMode
= wxSPLIT_DRAG_NONE
;
195 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
197 DrawSashTracker(m_oldX
, m_oldY
);
200 // Obtain window size. We are only interested in the dimension the sash
203 GetClientSize(&w
, &h
);
204 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
? w
: h
);
205 int new_sash_position
=
206 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
208 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
,
210 eventSplitter
.m_data
.pos
= new_sash_position
;
211 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
213 new_sash_position
= eventSplitter
.GetSashPosition();
214 if ( new_sash_position
== -1 )
216 // change not allowed
221 if ( m_permitUnsplitAlways
|| m_minimumPaneSize
== 0 )
223 // Deal with possible unsplit scenarios
224 if ( new_sash_position
== 0 )
226 // We remove the first window from the view
227 wxWindow
*removedWindow
= m_windowOne
;
228 m_windowOne
= m_windowTwo
;
229 m_windowTwo
= (wxWindow
*) NULL
;
230 SendUnsplitEvent(removedWindow
);
233 else if ( new_sash_position
== window_size
)
235 // We remove the second window from the view
236 wxWindow
*removedWindow
= m_windowTwo
;
237 m_windowTwo
= (wxWindow
*) NULL
;
238 SendUnsplitEvent(removedWindow
);
243 m_sashPosition
= new_sash_position
;
248 m_sashPosition
= new_sash_position
;
252 } // left up && dragging
253 else if (event
.Moving() && !event
.Dragging())
255 // Just change the cursor if required
256 if ( SashHitTest(x
, y
) )
258 if ( m_splitMode
== wxSPLIT_VERTICAL
)
260 SetCursor(*m_sashCursorWE
);
264 SetCursor(*m_sashCursorNS
);
267 #if defined(__WXGTK__) || defined(__WXMSW__)
270 // We must set the normal cursor in MSW, because
271 // if the child window doesn't have a cursor, the
272 // parent's (splitter window) will be used, and this
273 // must be the standard cursor.
275 // where else do we unset the cursor?
276 SetCursor(* wxSTANDARD_CURSOR
);
280 else if (event
.Dragging() && (m_dragMode
== wxSPLIT_DRAG_DRAGGING
))
283 // Otherwise, the cursor sometimes reverts to the normal cursor
285 if ( m_splitMode
== wxSPLIT_VERTICAL
)
287 SetCursor(*m_sashCursorWE
);
291 SetCursor(*m_sashCursorNS
);
295 // Obtain window size. We are only interested in the dimension the sash
297 int new_sash_position
=
298 (int) ( m_splitMode
== wxSPLIT_VERTICAL
? x
: y
);
300 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
,
302 eventSplitter
.m_data
.pos
= new_sash_position
;
303 if ( GetEventHandler()->ProcessEvent(eventSplitter
) )
305 new_sash_position
= eventSplitter
.GetSashPosition();
306 if ( new_sash_position
== -1 )
308 // change not allowed
313 if (new_sash_position
== m_sashPosition
)
317 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
319 DrawSashTracker(m_oldX
, m_oldY
);
322 if (m_splitMode
== wxSPLIT_VERTICAL
)
323 x
= new_sash_position
;
325 y
= new_sash_position
;
327 // Remember old positions
332 // As we captured the mouse, we may get the mouse events from outside
333 // our window - for example, negative values in x, y. This has a weird
334 // consequence under MSW where we use unsigned values sometimes and
335 // signed ones other times: the coordinates turn as big positive
336 // numbers and so the sash is drawn on the *right* side of the window
337 // instead of the left (or bottom instead of top). Correct this.
338 if ( (short)m_oldX
< 0 )
340 if ( (short)m_oldY
< 0 )
345 if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE
) == 0)
347 DrawSashTracker(m_oldX
, m_oldY
);
351 m_sashPosition
= new_sash_position
;
352 m_needUpdating
= TRUE
;
355 else if ( event
.LeftDClick() )
357 wxSplitterEvent
eventSplitter(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
,
359 eventSplitter
.m_data
.pt
.x
= x
;
360 eventSplitter
.m_data
.pt
.y
= y
;
362 (void)GetEventHandler()->ProcessEvent(eventSplitter
);
366 void wxSplitterWindow::OnSize(wxSizeEvent
& event
)
368 // only process this message if we're not iconized - otherwise iconizing
369 // and restoring a window containing the splitter has a funny side effect
370 // of changing the splitter position!
371 wxWindow
*parent
= GetParent();
372 while ( parent
&& !parent
->IsTopLevel() )
374 parent
= parent
->GetParent();
377 bool iconized
= FALSE
;
378 wxFrame
*frame
= wxDynamicCast(parent
, wxFrame
);
380 iconized
= frame
->IsIconized();
383 wxDialog
*dialog
= wxDynamicCast(parent
, wxDialog
);
385 iconized
= dialog
->IsIconized();
387 wxFAIL_MSG(wxT("should have a top level frame or dialog parent!"));
397 GetClientSize( &cw
, &ch
);
400 if ( m_splitMode
== wxSPLIT_VERTICAL
)
402 if ( m_sashPosition
>= (cw
- 5) )
403 m_sashPosition
= wxMax(10, cw
- 40);
405 if ( m_splitMode
== wxSPLIT_HORIZONTAL
)
407 if ( m_sashPosition
>= (ch
- 5) )
408 m_sashPosition
= wxMax(10, ch
- 40);
416 bool wxSplitterWindow::SashHitTest(int x
, int y
, int tolerance
)
418 if ( m_windowTwo
== NULL
|| m_sashPosition
== 0)
419 return FALSE
; // No sash
421 if ( m_splitMode
== wxSPLIT_VERTICAL
)
423 if ( (x
>= m_sashPosition
- tolerance
) && (x
<= m_sashPosition
+ m_sashSize
+ tolerance
) )
430 if ( (y
>= (m_sashPosition
- tolerance
)) && (y
<= (m_sashPosition
+ m_sashSize
+ tolerance
)) )
437 // Draw 3D effect borders
438 void wxSplitterWindow::DrawBorders(wxDC
& dc
)
441 GetClientSize(&w
, &h
);
443 if ( GetWindowStyleFlag() & wxSP_3DBORDER
)
446 dc
.SetPen(*m_facePen
);
447 dc
.SetBrush(*m_faceBrush
);
448 dc
.DrawRectangle(1, 1 , w
-1, m_borderSize
-2 ); //high
449 dc
.DrawRectangle(1, m_borderSize
-2 , m_borderSize
-2, h
-1 ); // left
450 dc
.DrawRectangle(w
-m_borderSize
+2, m_borderSize
-2 , w
-1, h
-1 ); // right
451 dc
.DrawRectangle(m_borderSize
-2, h
-m_borderSize
+2 , w
-m_borderSize
+2, h
-1 ); //bottom
453 dc
.SetPen(*m_mediumShadowPen
);
454 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, w
-m_borderSize
+1, m_borderSize
-2);
455 dc
.DrawLine(m_borderSize
-2, m_borderSize
-2, m_borderSize
-2, h
-m_borderSize
+1);
457 dc
.SetPen(*m_darkShadowPen
);
458 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, w
-m_borderSize
, m_borderSize
-1);
459 dc
.DrawLine(m_borderSize
-1, m_borderSize
-1, m_borderSize
-1, h
-m_borderSize
);
461 dc
.SetPen(*m_hilightPen
);
462 dc
.DrawLine(m_borderSize
- 2, h
-m_borderSize
+1, w
-m_borderSize
+1, h
-m_borderSize
+1);
463 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.
464 /// Anyway, h is required for MSW.
466 dc
.SetPen(*m_lightShadowPen
);
467 dc
.DrawLine(w
-m_borderSize
, m_borderSize
-1, w
-m_borderSize
, h
-m_borderSize
); // Right hand side
468 dc
.DrawLine(m_borderSize
-1, h
-m_borderSize
, w
-m_borderSize
+1, h
-m_borderSize
); // Bottom
470 else if ( GetWindowStyleFlag() & wxSP_BORDER
)
472 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
473 dc
.SetPen(*wxBLACK_PEN
);
474 dc
.DrawRectangle(0, 0, w
-1, h
-1);
477 dc
.SetPen(wxNullPen
);
478 dc
.SetBrush(wxNullBrush
);
482 void wxSplitterWindow::DrawSash(wxDC
& dc
)
484 if ( m_sashPosition
== 0 || !m_windowTwo
)
486 if (GetWindowStyle() & wxSP_NOSASH
)
490 GetClientSize(&w
, &h
);
492 if ( GetWindowStyleFlag() & wxSP_3DSASH
)
494 if ( m_splitMode
== wxSPLIT_VERTICAL
)
496 dc
.SetPen(*m_facePen
);
497 dc
.SetBrush(*m_faceBrush
);
498 dc
.DrawRectangle(m_sashPosition
+ 2, 0 , m_sashSize
- 4, h
);
500 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
502 dc
.SetPen(*m_lightShadowPen
);
503 int xShadow
= m_borderSize
? m_borderSize
- 1 : 0 ;
504 dc
.DrawLine(m_sashPosition
, xShadow
, m_sashPosition
, h
-m_borderSize
);
506 dc
.SetPen(*m_hilightPen
);
507 dc
.DrawLine(m_sashPosition
+1, m_borderSize
- 2, m_sashPosition
+1, h
- m_borderSize
+2);
509 dc
.SetPen(*m_mediumShadowPen
);
510 int yMedium
= m_borderSize
? h
-m_borderSize
+1 : h
;
511 dc
.DrawLine(m_sashPosition
+m_sashSize
-2, xShadow
, m_sashPosition
+m_sashSize
-2, yMedium
);
513 dc
.SetPen(*m_darkShadowPen
);
514 dc
.DrawLine(m_sashPosition
+m_sashSize
-1, m_borderSize
, m_sashPosition
+m_sashSize
-1, h
-m_borderSize
);
516 // Draw the top and bottom edges of the sash, if requested
517 if (GetWindowStyle() & wxSP_FULLSASH
)
520 dc
.SetPen(*m_hilightPen
);
521 dc
.DrawLine(m_sashPosition
+1, m_borderSize
, m_sashPosition
+m_sashSize
-1, m_borderSize
);
524 dc
.SetPen(*m_darkShadowPen
);
525 dc
.DrawLine(m_sashPosition
+1, h
-m_borderSize
-1, m_sashPosition
+m_sashSize
-1, h
-m_borderSize
-1);
530 dc
.SetPen(*m_facePen
);
531 dc
.SetBrush(*m_faceBrush
);
532 dc
.DrawRectangle( m_borderSize
-2, m_sashPosition
+ 2, w
-m_borderSize
+2, m_sashSize
- 4);
534 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
536 dc
.SetPen(*m_lightShadowPen
);
537 dc
.DrawLine(m_borderSize
-1, m_sashPosition
, w
-m_borderSize
, m_sashPosition
);
539 dc
.SetPen(*m_hilightPen
);
540 dc
.DrawLine(m_borderSize
-2, m_sashPosition
+1, w
-m_borderSize
+1, m_sashPosition
+1);
542 dc
.SetPen(*m_mediumShadowPen
);
543 dc
.DrawLine(m_borderSize
-1, m_sashPosition
+m_sashSize
-2, w
-m_borderSize
+1, m_sashPosition
+m_sashSize
-2);
545 dc
.SetPen(*m_darkShadowPen
);
546 dc
.DrawLine(m_borderSize
, m_sashPosition
+m_sashSize
-1, w
-m_borderSize
, m_sashPosition
+m_sashSize
-1);
548 // Draw the left and right edges of the sash, if requested
549 if (GetWindowStyle() & wxSP_FULLSASH
)
552 dc
.SetPen(*m_hilightPen
);
553 dc
.DrawLine(m_borderSize
, m_sashPosition
, m_borderSize
, m_sashPosition
+m_sashSize
);
556 dc
.SetPen(*m_darkShadowPen
);
557 dc
.DrawLine(w
-m_borderSize
-1, m_sashPosition
+1, w
-m_borderSize
-1, m_sashPosition
+m_sashSize
-1);
563 if ( m_splitMode
== wxSPLIT_VERTICAL
)
565 dc
.SetPen(*wxBLACK_PEN
);
566 dc
.SetBrush(*wxBLACK_BRUSH
);
569 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
&& (GetWindowStyleFlag() & wxSP_3DBORDER
) != wxSP_3DBORDER
)
570 h1
+= 1; // Not sure why this is necessary...
571 if ( (GetWindowStyleFlag() & wxSP_3DBORDER
) == wxSP_3DBORDER
)
575 dc
.DrawRectangle(m_sashPosition
, y1
, m_sashSize
, h1
);
579 dc
.SetPen(*wxBLACK_PEN
);
580 dc
.SetBrush(*wxBLACK_BRUSH
);
583 if ( (GetWindowStyleFlag() & wxSP_BORDER
) != wxSP_BORDER
&& (GetWindowStyleFlag() & wxSP_3DBORDER
) != wxSP_3DBORDER
)
585 if ( (GetWindowStyleFlag() & wxSP_3DBORDER
) == wxSP_3DBORDER
)
589 dc
.DrawRectangle(x1
, m_sashPosition
, w1
, m_sashSize
);
594 dc
.SetPen(wxNullPen
);
595 dc
.SetBrush(wxNullBrush
);
598 // Draw the sash tracker (for whilst moving the sash)
599 void wxSplitterWindow::DrawSashTracker(int x
, int y
)
602 GetClientSize(&w
, &h
);
608 if ( m_splitMode
== wxSPLIT_VERTICAL
)
639 ClientToScreen(&x1
, &y1
);
640 ClientToScreen(&x2
, &y2
);
642 screenDC
.SetLogicalFunction(wxINVERT
);
643 screenDC
.SetPen(*m_sashTrackerPen
);
644 screenDC
.SetBrush(*wxTRANSPARENT_BRUSH
);
646 screenDC
.DrawLine(x1
, y1
, x2
, y2
);
648 screenDC
.SetLogicalFunction(wxCOPY
);
650 screenDC
.SetPen(wxNullPen
);
651 screenDC
.SetBrush(wxNullBrush
);
654 // Position and size subwindows.
655 // Note that the border size applies to each subwindow, not
656 // including the edges next to the sash.
657 void wxSplitterWindow::SizeWindows()
660 GetClientSize(&w
, &h
);
662 if ( GetWindow1() && !GetWindow2() )
664 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(), w
- 2*GetBorderSize(), h
- 2*GetBorderSize());
667 else if ( GetWindow1() && GetWindow2() )
669 if (GetSplitMode() == wxSPLIT_VERTICAL
)
671 int x1
= GetBorderSize();
672 int y1
= GetBorderSize();
673 int w1
= GetSashPosition() - GetBorderSize();
674 int h1
= h
- 2*GetBorderSize();
676 int x2
= GetSashPosition() + GetSashSize();
677 int y2
= GetBorderSize();
678 int w2
= w
- 2*GetBorderSize() - GetSashSize() - w1
;
679 int h2
= h
- 2*GetBorderSize();
681 GetWindow1()->SetSize(x1
, y1
, w1
, h1
);
682 GetWindow2()->SetSize(x2
, y2
, w2
, h2
);
686 GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
687 w
- 2*GetBorderSize(), GetSashPosition() - GetBorderSize());
688 GetWindow2()->SetSize(GetBorderSize(), GetSashPosition() + GetSashSize(),
689 w
- 2*GetBorderSize(), h
- 2*GetBorderSize() - GetSashSize() - (GetSashPosition() - GetBorderSize()));
693 if ( GetBorderSize() > 0 )
697 SetNeedUpdating(FALSE
);
700 // Set pane for unsplit window
701 void wxSplitterWindow::Initialize(wxWindow
*window
)
703 m_windowOne
= window
;
704 m_windowTwo
= (wxWindow
*) NULL
;
708 // Associates the given window with window 2, drawing the appropriate sash
709 // and changing the split mode.
710 // Does nothing and returns FALSE if the window is already split.
711 bool wxSplitterWindow::SplitVertically(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
717 GetClientSize(&w
, &h
);
719 m_splitMode
= wxSPLIT_VERTICAL
;
720 m_windowOne
= window1
;
721 m_windowTwo
= window2
;
722 if ( sashPosition
> 0 )
723 m_sashPosition
= sashPosition
;
724 else if ( sashPosition
< 0 )
725 m_sashPosition
= w
- sashPosition
;
727 m_sashPosition
= w
/2;
734 bool wxSplitterWindow::SplitHorizontally(wxWindow
*window1
, wxWindow
*window2
, int sashPosition
)
740 GetClientSize(&w
, &h
);
742 m_splitMode
= wxSPLIT_HORIZONTAL
;
743 m_windowOne
= window1
;
744 m_windowTwo
= window2
;
745 if ( sashPosition
> 0 )
746 m_sashPosition
= sashPosition
;
747 else if ( sashPosition
< 0 )
748 m_sashPosition
= h
- sashPosition
;
750 m_sashPosition
= h
/2;
758 // Remove the specified (or second) window from the view
759 // Doesn't actually delete the window.
760 bool wxSplitterWindow::Unsplit(wxWindow
*toRemove
)
765 wxWindow
*win
= NULL
;
766 if ( toRemove
== NULL
|| toRemove
== m_windowTwo
)
769 m_windowTwo
= (wxWindow
*) NULL
;
771 else if ( toRemove
== m_windowOne
)
774 m_windowOne
= m_windowTwo
;
775 m_windowTwo
= (wxWindow
*) NULL
;
779 wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
784 SendUnsplitEvent(win
);
791 // Replace a window with another one
792 bool wxSplitterWindow::ReplaceWindow(wxWindow
*winOld
, wxWindow
*winNew
)
794 wxCHECK_MSG( winOld
, FALSE
, wxT("use one of Split() functions instead") );
795 wxCHECK_MSG( winNew
, FALSE
, wxT("use Unsplit() functions instead") );
797 if ( winOld
== m_windowTwo
)
799 m_windowTwo
= winNew
;
801 else if ( winOld
== m_windowOne
)
803 m_windowOne
= winNew
;
807 wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
817 void wxSplitterWindow::SetSashPosition(int position
, bool redraw
)
819 m_sashPosition
= position
;
827 // Initialize colours
828 void wxSplitterWindow::InitColours()
830 wxDELETE( m_facePen
);
831 wxDELETE( m_faceBrush
);
832 wxDELETE( m_mediumShadowPen
);
833 wxDELETE( m_darkShadowPen
);
834 wxDELETE( m_lightShadowPen
);
835 wxDELETE( m_hilightPen
);
839 wxColour
faceColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
840 m_facePen
= new wxPen(faceColour
, 1, wxSOLID
);
841 m_faceBrush
= new wxBrush(faceColour
, wxSOLID
);
843 wxColour
mediumShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW
));
844 m_mediumShadowPen
= new wxPen(mediumShadowColour
, 1, wxSOLID
);
846 wxColour
darkShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW
));
847 m_darkShadowPen
= new wxPen(darkShadowColour
, 1, wxSOLID
);
849 wxColour
lightShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT
));
850 m_lightShadowPen
= new wxPen(lightShadowColour
, 1, wxSOLID
);
852 wxColour
hilightColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT
));
853 m_hilightPen
= new wxPen(hilightColour
, 1, wxSOLID
);
855 m_facePen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
856 m_faceBrush
= new wxBrush("LIGHT GREY", wxSOLID
);
857 m_mediumShadowPen
= new wxPen("GREY", 1, wxSOLID
);
858 m_darkShadowPen
= new wxPen("BLACK", 1, wxSOLID
);
859 m_lightShadowPen
= new wxPen("LIGHT GREY", 1, wxSOLID
);
860 m_hilightPen
= new wxPen("WHITE", 1, wxSOLID
);
864 void wxSplitterWindow::SendUnsplitEvent(wxWindow
*winRemoved
)
866 wxSplitterEvent
event(wxEVT_COMMAND_SPLITTER_UNSPLIT
, this);
867 event
.m_data
.win
= winRemoved
;
869 (void)GetEventHandler()->ProcessEvent(event
);
872 // ---------------------------------------------------------------------------
873 // splitter event handlers
874 // ---------------------------------------------------------------------------
876 void wxSplitterWindow::OnSashPosChanged(wxSplitterEvent
& event
)
878 // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
879 const int UNSPLIT_THRESHOLD
= 4;
881 int newSashPosition
= event
.GetSashPosition();
883 // Obtain relevant window dimension for bottom / right threshold check
885 GetClientSize(&w
, &h
);
886 int window_size
= (m_splitMode
== wxSPLIT_VERTICAL
) ? w
: h
;
888 bool unsplit_scenario
= FALSE
;
889 if ( m_permitUnsplitAlways
890 || m_minimumPaneSize
== 0 )
892 // Do edge detection if unsplit premitted
893 if ( newSashPosition
<= UNSPLIT_THRESHOLD
)
895 // threshold top / left check
897 unsplit_scenario
= TRUE
;
899 if ( newSashPosition
>= window_size
- UNSPLIT_THRESHOLD
)
901 // threshold bottom/right check
902 newSashPosition
= window_size
;
903 unsplit_scenario
= TRUE
;
907 if ( !unsplit_scenario
)
909 // If resultant pane would be too small, enlarge it
910 if ( newSashPosition
< m_minimumPaneSize
)
911 newSashPosition
= m_minimumPaneSize
;
912 if ( newSashPosition
> window_size
- m_minimumPaneSize
)
913 newSashPosition
= window_size
- m_minimumPaneSize
;
916 // If the result is out of bounds it means minimum size is too big,
917 // so split window in half as best compromise.
918 if ( newSashPosition
< 0 || newSashPosition
> window_size
)
919 newSashPosition
= window_size
/ 2;
921 // for compatibility, call the virtual function
922 if ( !OnSashPositionChange(newSashPosition
) )
924 newSashPosition
= -1;
927 event
.SetSashPosition(newSashPosition
);
930 // Called when the sash is double-clicked. The default behaviour is to remove
931 // the sash if the minimum pane size is zero.
932 void wxSplitterWindow::OnDoubleClick(wxSplitterEvent
& event
)
934 // for compatibility, call the virtual function
935 OnDoubleClickSash(event
.GetX(), event
.GetY());
937 if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways
)
943 void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent
& event
)
945 wxWindow
*win
= event
.GetWindowBeingRemoved();
947 // do it before calling OnUnsplit() which may delete the window
950 // for compatibility, call the virtual function
954 #if defined(__WXMSW__)
955 #define WXUNUSED_UNLESS_MSW(identifier) identifier
957 #define WXUNUSED_UNLESS_MSW(identifier) WXUNUSED(identifier)
960 void wxSplitterWindow::OnSetCursor(wxSetCursorEvent
& WXUNUSED_UNLESS_MSW(event
))
962 // this is currently called (and needed) under MSW only...
965 // if we don't do it, the resizing cursor might be set for child window:
966 // and like this we explicitly say that our cursor should not be used for
967 // children windows which overlap us
969 if ( SashHitTest(event
.GetX(), event
.GetY()) )
971 // default processing is ok
974 //else: do nothing, in particular, don't call Skip()