]> git.saurik.com Git - wxWidgets.git/blame - src/generic/splitter.cpp
Yet another one.
[wxWidgets.git] / src / generic / splitter.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: splitter.cpp
3// Purpose: wxSplitterWindow implementation
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
f4621a09 9// Licence: wxWindows license
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
f4621a09 13 #pragma implementation "splitter.h"
c801d85f
KB
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
f4621a09 20 #pragma hdrstop
c801d85f
KB
21#endif
22
23#ifndef WX_PRECOMP
f4621a09 24 #include "wx/wx.h"
c801d85f
KB
25#endif
26
27#include <math.h>
28#include <stdlib.h>
29
30#include "wx/string.h"
31#include "wx/splitter.h"
32#include "wx/dcscreen.h"
33
34#if !USE_SHARED_LIBRARY
35IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow, wxWindow)
36
37BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow)
38 EVT_PAINT(wxSplitterWindow::OnPaint)
39 EVT_SIZE(wxSplitterWindow::OnSize)
40 EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent)
41END_EVENT_TABLE()
42#endif
43
0d559d69 44wxSplitterWindow::wxSplitterWindow()
c801d85f
KB
45{
46 m_splitMode = wxSPLIT_VERTICAL;
c67daf87
UR
47 m_windowOne = (wxWindow *) NULL;
48 m_windowTwo = (wxWindow *) NULL;
c801d85f
KB
49 m_dragMode = wxSPLIT_DRAG_NONE;
50 m_oldX = 0;
51 m_oldY = 0;
52 m_firstX = 0;
53 m_firstY = 0;
54 m_sashSize = 7;
55 m_borderSize = 2;
56 m_sashPosition = 0;
c67daf87
UR
57 m_sashCursorWE = (wxCursor *) NULL;
58 m_sashCursorNS = (wxCursor *) NULL;
59 m_sashTrackerPen = (wxPen *) NULL;
60 m_lightShadowPen = (wxPen *) NULL;
61 m_mediumShadowPen = (wxPen *) NULL;
62 m_darkShadowPen = (wxPen *) NULL;
63 m_faceBrush = (wxBrush *) NULL;
64 m_facePen = (wxPen *) NULL;
65 m_hilightPen = (wxPen *) NULL;
c801d85f
KB
66 m_minimumPaneSize = 0;
67}
68
0d559d69
VZ
69wxSplitterWindow::wxSplitterWindow(wxWindow *parent, wxWindowID id,
70 const wxPoint& pos,
71 const wxSize& size,
72 long style,
73 const wxString& name)
74 : wxWindow(parent, id, pos, size, style, name)
c801d85f
KB
75{
76 m_splitMode = wxSPLIT_VERTICAL;
c67daf87
UR
77 m_windowOne = (wxWindow *) NULL;
78 m_windowTwo = (wxWindow *) NULL;
c801d85f
KB
79 m_dragMode = wxSPLIT_DRAG_NONE;
80 m_oldX = 0;
81 m_oldY = 0;
82 m_firstX = 0;
83 m_firstY = 0;
84 m_sashSize = 7;
85 m_borderSize = 2;
86 m_sashPosition = 0;
87 m_minimumPaneSize = 0;
88 m_sashCursorWE = new wxCursor(wxCURSOR_SIZEWE);
89 m_sashCursorNS = new wxCursor(wxCURSOR_SIZENS);
90 m_sashTrackerPen = new wxPen(*wxBLACK, 2, wxSOLID);
c67daf87
UR
91 m_lightShadowPen = (wxPen *) NULL;
92 m_mediumShadowPen = (wxPen *) NULL;
93 m_darkShadowPen = (wxPen *) NULL;
94 m_faceBrush = (wxBrush *) NULL;
95 m_facePen = (wxPen *) NULL;
96 m_hilightPen = (wxPen *) NULL;
c801d85f
KB
97
98 if ( style & wxSP_3D )
99 {
100 m_borderSize = 2;
101 m_sashSize = 7;
102 }
103 else if ( style & wxSP_BORDER )
104 {
105 m_borderSize = 1;
106 m_sashSize = 3;
107 }
108 else
109 {
110 m_borderSize = 0;
111 m_sashSize = 3;
112 }
113
114 // Eventually, we'll respond to colour change messages
115 InitColours();
116
c801d85f
KB
117 // For debugging purposes, to see the background.
118// SetBackground(wxBLUE_BRUSH);
119}
120
0d559d69 121wxSplitterWindow::~wxSplitterWindow()
c801d85f
KB
122{
123 delete m_sashCursorWE;
124 delete m_sashCursorNS;
125 delete m_sashTrackerPen;
126 delete m_lightShadowPen;
127 delete m_darkShadowPen;
128 delete m_mediumShadowPen;
129 delete m_hilightPen;
130 delete m_facePen;
131 delete m_faceBrush;
132}
133
134void wxSplitterWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
135{
136 wxPaintDC dc(this);
137
138 if ( m_borderSize > 0 )
139 DrawBorders(dc);
140 DrawSash(dc);
141}
142
143void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
144{
145 long x, y;
146 event.Position(&x, &y);
147
f4621a09 148 // reset the cursor
b69f1bd1
JS
149#ifdef __WXMOTIF__
150 SetCursor(* wxSTANDARD_CURSOR);
17867d61
RR
151#endif
152#ifdef __WXMSW__
f4621a09 153 SetCursor(wxCursor());
b69f1bd1 154#endif
f4621a09 155
0d559d69
VZ
156 if (event.LeftDown())
157 {
c801d85f
KB
158 if ( SashHitTest(x, y) )
159 {
0d559d69 160 CaptureMouse();
c801d85f 161
4a33eba6 162 m_dragMode = wxSPLIT_DRAG_DRAGGING;
f4621a09 163
4a33eba6
RR
164 DrawSashTracker(x, y);
165 m_oldX = x;
166 m_oldY = y;
f4621a09 167 return;
c801d85f 168 }
0d559d69 169 }
0d559d69
VZ
170 else if (event.LeftUp() && m_dragMode == wxSPLIT_DRAG_DRAGGING)
171 {
c801d85f
KB
172 // We can stop dragging now and see what we've got.
173 m_dragMode = wxSPLIT_DRAG_NONE;
0d559d69 174 ReleaseMouse();
dbc208e9 175
c801d85f
KB
176 // Erase old tracker
177 DrawSashTracker(m_oldX, m_oldY);
178
c801d85f 179 int w, h;
0d559d69 180 GetClientSize(&w, &h);
c801d85f
KB
181 if ( m_splitMode == wxSPLIT_VERTICAL )
182 {
0d559d69 183 if ( !OnSashPositionChange(x) )
c801d85f
KB
184 return;
185
186 if ( x <= 4 )
187 {
188 // We remove the first window from the view
189 wxWindow *removedWindow = m_windowOne;
190 m_windowOne = m_windowTwo;
c67daf87 191 m_windowTwo = (wxWindow *) NULL;
c801d85f
KB
192
193 OnUnsplit(removedWindow);
194 m_sashPosition = 0;
195 }
196 else if ( x >= (w - 4) )
197 {
198 // We remove the second window from the view
199 wxWindow *removedWindow = m_windowTwo;
c67daf87 200 m_windowTwo = (wxWindow *) NULL;
c801d85f
KB
201 OnUnsplit(removedWindow);
202 m_sashPosition = 0;
203 }
204 else
205 {
206 m_sashPosition = x;
207 }
208 }
4a33eba6 209 else // m_splitMode == wxSPLIT_VERTICAL
c801d85f 210 {
0d559d69 211 if ( !OnSashPositionChange(y) )
c801d85f
KB
212 return;
213
214 if ( y <= 4 )
215 {
216 // We remove the first window from the view
217 wxWindow *removedWindow = m_windowOne;
218 m_windowOne = m_windowTwo;
c67daf87 219 m_windowTwo = (wxWindow *) NULL;
c801d85f
KB
220
221 OnUnsplit(removedWindow);
222 m_sashPosition = 0;
223 }
224 else if ( y >= (h - 4) )
225 {
226 // We remove the second window from the view
227 wxWindow *removedWindow = m_windowTwo;
c67daf87 228 m_windowTwo = (wxWindow *) NULL;
c801d85f
KB
229 OnUnsplit(removedWindow);
230 m_sashPosition = 0;
231 }
232 else
233 {
234 m_sashPosition = y;
235 }
4a33eba6 236 } // m_splitMode == wxSPLIT_VERTICAL
c801d85f 237 SizeWindows();
4a33eba6 238 } // left up && dragging
0d559d69
VZ
239 else if (event.Moving() && !event.Dragging())
240 {
c801d85f
KB
241 // Just change the cursor if required
242 if ( SashHitTest(x, y) )
243 {
0d559d69 244 if ( m_splitMode == wxSPLIT_VERTICAL )
c801d85f 245 {
0d559d69 246 SetCursor(*m_sashCursorWE);
c801d85f
KB
247 }
248 else
249 {
0d559d69 250 SetCursor(*m_sashCursorNS);
c801d85f
KB
251 }
252 }
0d559d69 253 }
4a33eba6 254 else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING))
0d559d69 255 {
4a33eba6
RR
256 // Erase old tracker
257 DrawSashTracker(m_oldX, m_oldY);
c801d85f 258
4a33eba6
RR
259 // Draw new one
260 DrawSashTracker(x, y);
dbc208e9 261
c801d85f
KB
262 m_oldX = x;
263 m_oldY = y;
0d559d69 264 }
c801d85f
KB
265 else if ( event.LeftDClick() )
266 {
267 OnDoubleClickSash(x, y);
268 }
c801d85f
KB
269}
270
271void wxSplitterWindow::OnSize(wxSizeEvent& WXUNUSED(event))
272{
273 int cw, ch;
274 GetClientSize( &cw, &ch );
275 if ( m_windowTwo )
276 {
277 if ( m_splitMode == wxSPLIT_VERTICAL )
278 {
279 if ( m_sashPosition >= (cw - 5) )
280 m_sashPosition = wxMax(10, cw - 40);
281 }
282 if ( m_splitMode == wxSPLIT_HORIZONTAL )
283 {
284 if ( m_sashPosition >= (ch - 5) )
285 m_sashPosition = wxMax(10, ch - 40);
286 }
287 }
288 SizeWindows();
289}
290
debe6624 291bool wxSplitterWindow::SashHitTest(int x, int y, int tolerance)
c801d85f
KB
292{
293 if ( m_windowTwo == NULL || m_sashPosition == 0)
294 return FALSE; // No sash
295
296 if ( m_splitMode == wxSPLIT_VERTICAL )
297 {
298 if ( (x >= m_sashPosition - tolerance) && (x <= m_sashPosition + m_sashSize + tolerance) )
299 return TRUE;
300 else
301 return FALSE;
302 }
303 else
304 {
305 if ( (y >= (m_sashPosition- tolerance)) && (y <= (m_sashPosition + m_sashSize + tolerance)) )
306 return TRUE;
307 else
308 return FALSE;
309 }
310
311 return FALSE;
312}
313
314// Draw 3D effect borders
315void wxSplitterWindow::DrawBorders(wxDC& dc)
316{
317 int w, h;
318 GetClientSize(&w, &h);
319
320 if ( GetWindowStyleFlag() & wxSP_3D )
321 {
322 dc.SetPen(*m_mediumShadowPen);
323 dc.DrawLine(0, 0, w-1, 0);
324 dc.DrawLine(0, 0, 0, h - 1);
325
326 dc.SetPen(*m_darkShadowPen);
327 dc.DrawLine(1, 1, w-2, 1);
328 dc.DrawLine(1, 1, 1, h-2);
329
330 dc.SetPen(*m_hilightPen);
331 dc.DrawLine(0, h-1, w-1, h-1);
332 dc.DrawLine(w-1, 0, w-1, h); // Surely the maximum y pos. should be h - 1.
333 /// Anyway, h is required for MSW.
334
335 dc.SetPen(*m_lightShadowPen);
336 dc.DrawLine(w-2, 1, w-2, h-2); // Right hand side
337 dc.DrawLine(1, h-2, w-1, h-2); // Bottom
338 }
339 else if ( GetWindowStyleFlag() & wxSP_BORDER )
340 {
341 dc.SetBrush(*wxTRANSPARENT_BRUSH);
342 dc.SetPen(*wxBLACK_PEN);
343 dc.DrawRectangle(0, 0, w-1, h-1);
344 }
345
346 dc.SetPen(wxNullPen);
347 dc.SetBrush(wxNullBrush);
348}
349
350// Draw the sash
351void wxSplitterWindow::DrawSash(wxDC& dc)
352{
353 if ( m_sashPosition == 0 || !m_windowTwo)
354 return;
355
356 int w, h;
357 GetClientSize(&w, &h);
358
359 if ( GetWindowStyleFlag() & wxSP_3D )
360 {
361 if ( m_splitMode == wxSPLIT_VERTICAL )
362 {
363 dc.SetPen(*m_facePen);
364 dc.SetBrush(*m_faceBrush);
365 dc.DrawRectangle(m_sashPosition + 2, 0, m_sashSize - 4, h);
366
367 dc.SetBrush(*wxTRANSPARENT_BRUSH);
368
369 dc.SetPen(*m_lightShadowPen);
370 dc.DrawLine(m_sashPosition, 1, m_sashPosition, h-2);
371
372 dc.SetPen(*m_hilightPen);
373 dc.DrawLine(m_sashPosition+1, 0, m_sashPosition+1, h);
374
375 dc.SetPen(*m_mediumShadowPen);
376 dc.DrawLine(m_sashPosition+m_sashSize-2, 1, m_sashPosition+m_sashSize-2, h-1);
377
378 dc.SetPen(*m_darkShadowPen);
0d559d69
VZ
379 dc.DrawLine(m_sashPosition+m_sashSize-1, 2, m_sashPosition+m_sashSize-1, h-2);
380 }
c801d85f
KB
381 else
382 {
383 dc.SetPen(*m_facePen);
384 dc.SetBrush(*m_faceBrush);
385 dc.DrawRectangle(0, m_sashPosition + 2, w, m_sashSize - 4);
386
387 dc.SetBrush(*wxTRANSPARENT_BRUSH);
388
389 dc.SetPen(*m_lightShadowPen);
390 dc.DrawLine(1, m_sashPosition, w-2, m_sashPosition);
391
392 dc.SetPen(*m_hilightPen);
393 dc.DrawLine(0, m_sashPosition+1, w, m_sashPosition+1);
394
395 dc.SetPen(*m_mediumShadowPen);
396 dc.DrawLine(1, m_sashPosition+m_sashSize-2, w-1, m_sashPosition+m_sashSize-2);
397
398 dc.SetPen(*m_darkShadowPen);
399 dc.DrawLine(2, m_sashPosition+m_sashSize-1, w-2, m_sashPosition+m_sashSize-1);
400 }
401 }
402 else
403 {
404 if ( m_splitMode == wxSPLIT_VERTICAL )
405 {
406 dc.SetPen(*wxBLACK_PEN);
407 dc.SetBrush(*wxBLACK_BRUSH);
408 int h1 = h-1;
409 if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER )
410 h1 += 1; // Not sure why this is necessary...
411 dc.DrawRectangle(m_sashPosition, 0, m_sashSize, h1);
412 }
413 else
414 {
415 dc.SetPen(*wxBLACK_PEN);
416 dc.SetBrush(*wxBLACK_BRUSH);
417 int w1 = w-1;
418 if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER )
419 w1 ++;
420
421 dc.DrawRectangle(0, m_sashPosition, w1, m_sashSize);
422 }
423
424 }
425
426 dc.SetPen(wxNullPen);
427 dc.SetBrush(wxNullBrush);
428}
429
430// Draw the sash tracker (for whilst moving the sash)
debe6624 431void wxSplitterWindow::DrawSashTracker(int x, int y)
c801d85f
KB
432{
433 int w, h;
434 GetClientSize(&w, &h);
435
436 wxScreenDC screenDC;
437 int x1, y1;
438 int x2, y2;
439
440 if ( m_splitMode == wxSPLIT_VERTICAL )
441 {
442 x1 = x; y1 = 2;
443 x2 = x; y2 = h-2;
444
445 if ( x1 > w )
446 {
447 x1 = w; x2 = w;
448 }
449 else if ( x1 < 0 )
450 {
451 x1 = 0; x2 = 0;
452 }
453 }
454 else
455 {
456 x1 = 2; y1 = y;
457 x2 = w-2; y2 = y;
458
459 if ( y1 > h )
460 {
461 y1 = h;
462 y2 = h;
463 }
464 else if ( y1 < 0 )
465 {
466 y1 = 0;
467 y2 = 0;
468 }
469 }
470
471 ClientToScreen(&x1, &y1);
472 ClientToScreen(&x2, &y2);
473
474 screenDC.SetLogicalFunction(wxXOR);
475 screenDC.SetPen(*m_sashTrackerPen);
476 screenDC.SetBrush(*wxTRANSPARENT_BRUSH);
477
478 screenDC.DrawLine(x1, y1, x2, y2);
479
480 screenDC.SetLogicalFunction(wxCOPY);
481
482 screenDC.SetPen(wxNullPen);
483 screenDC.SetBrush(wxNullBrush);
484}
485
486// Position and size subwindows.
487// Note that the border size applies to each subwindow, not
488// including the edges next to the sash.
0d559d69 489void wxSplitterWindow::SizeWindows()
c801d85f
KB
490{
491 int w, h;
492 GetClientSize(&w, &h);
493
494 if ( m_windowOne && !m_windowTwo )
495 {
496 m_windowOne->SetSize(m_borderSize, m_borderSize, w - 2*m_borderSize, h - 2*m_borderSize);
497 }
498 else if ( m_windowOne && m_windowTwo )
499 {
500 if (m_splitMode == wxSPLIT_VERTICAL)
501 {
502 int x1 = m_borderSize;
503 int y1 = m_borderSize;
504 int w1 = m_sashPosition - m_borderSize;
505 int h1 = h - 2*m_borderSize;
506
507 int x2 = m_sashPosition + m_sashSize;
508 int y2 = m_borderSize;
509 int w2 = w - 2*m_borderSize - m_sashSize - w1;
510 int h2 = h - 2*m_borderSize;
511
0d559d69
VZ
512 m_windowOne->SetSize(x1, y1, w1, h1);
513 m_windowTwo->SetSize(x2, y2, w2, h2);
c801d85f
KB
514 }
515 else
516 {
517 m_windowOne->SetSize(m_borderSize, m_borderSize,
518 w - 2*m_borderSize, m_sashPosition - m_borderSize);
519 m_windowTwo->SetSize(m_borderSize, m_sashPosition + m_sashSize,
520 w - 2*m_borderSize, h - 2*m_borderSize - m_sashSize - (m_sashPosition - m_borderSize));
521 }
522 }
523 wxClientDC dc(this);
524 DrawBorders(dc);
525 DrawSash(dc);
526}
527
528// Set pane for unsplit window
529void wxSplitterWindow::Initialize(wxWindow *window)
530{
531 m_windowOne = window;
c67daf87 532 m_windowTwo = (wxWindow *) NULL;
c801d85f
KB
533 m_sashPosition = 0;
534}
535
536// Associates the given window with window 2, drawing the appropriate sash
537// and changing the split mode.
538// Does nothing and returns FALSE if the window is already split.
debe6624 539bool wxSplitterWindow::SplitVertically(wxWindow *window1, wxWindow *window2, int sashPosition)
c801d85f
KB
540{
541 if ( IsSplit() )
542 return FALSE;
543
0d559d69
VZ
544 int w, h;
545 GetClientSize(&w, &h);
546
c801d85f
KB
547 m_splitMode = wxSPLIT_VERTICAL;
548 m_windowOne = window1;
549 m_windowTwo = window2;
0d559d69 550 if ( sashPosition > 0 )
c801d85f 551 m_sashPosition = sashPosition;
0d559d69
VZ
552 else if ( sashPosition < 0 )
553 m_sashPosition = w - sashPosition;
554 else // default
555 m_sashPosition = w/2;
c801d85f
KB
556
557 SizeWindows();
558
559 return TRUE;
560}
561
debe6624 562bool wxSplitterWindow::SplitHorizontally(wxWindow *window1, wxWindow *window2, int sashPosition)
c801d85f
KB
563{
564 if ( IsSplit() )
565 return FALSE;
566
0d559d69
VZ
567 int w, h;
568 GetClientSize(&w, &h);
569
c801d85f
KB
570 m_splitMode = wxSPLIT_HORIZONTAL;
571 m_windowOne = window1;
572 m_windowTwo = window2;
0d559d69 573 if ( sashPosition > 0 )
c801d85f 574 m_sashPosition = sashPosition;
0d559d69
VZ
575 else if ( sashPosition < 0 )
576 m_sashPosition = h - sashPosition;
577 else // default
578 m_sashPosition = h/2;
c801d85f
KB
579
580 SizeWindows();
581
582 return TRUE;
583}
584
585
586// Remove the specified (or second) window from the view
587// Doesn't actually delete the window.
588bool wxSplitterWindow::Unsplit(wxWindow *toRemove)
589{
590 if ( ! IsSplit() )
591 return FALSE;
592
3ad5e06b 593 wxWindow *win = NULL;
c801d85f
KB
594 if ( toRemove == NULL || toRemove == m_windowTwo)
595 {
3ad5e06b 596 win = m_windowTwo ;
c67daf87 597 m_windowTwo = (wxWindow *) NULL;
c801d85f
KB
598 }
599 else if ( toRemove == m_windowOne )
600 {
3ad5e06b 601 win = m_windowOne ;
c801d85f 602 m_windowOne = m_windowTwo;
c67daf87 603 m_windowTwo = (wxWindow *) NULL;
c801d85f
KB
604 }
605 else
dbc208e9 606 {
87138c52 607 wxFAIL_MSG(_T("splitter: attempt to remove a non-existent window"));
dbc208e9 608
c801d85f 609 return FALSE;
dbc208e9 610 }
c801d85f 611
3ad5e06b
VZ
612 OnUnsplit(win);
613 m_sashPosition = 0;
614 SizeWindows();
615
616 return TRUE;
617}
618
619// Replace a window with another one
620bool wxSplitterWindow::ReplaceWindow(wxWindow *winOld, wxWindow *winNew)
621{
87138c52
OK
622 wxCHECK_MSG( winOld, FALSE, _T("use one of Split() functions instead") );
623 wxCHECK_MSG( winNew, FALSE, _T("use Unsplit() functions instead") );
3ad5e06b
VZ
624
625 if ( winOld == m_windowTwo )
626 {
627 m_windowTwo = winNew;
628 }
629 else if ( winOld == m_windowOne )
630 {
631 m_windowOne = winNew;
632 }
633 else
634 {
87138c52 635 wxFAIL_MSG(_T("splitter: attempt to replace a non-existent window"));
3ad5e06b
VZ
636
637 return FALSE;
638 }
639
640 SizeWindows();
641
c801d85f
KB
642 return TRUE;
643}
644
debe6624 645void wxSplitterWindow::SetSashPosition(int position, bool redraw)
c801d85f
KB
646{
647 m_sashPosition = position;
648
649 if ( redraw )
650 {
651 SizeWindows();
652 }
653}
654
0d559d69
VZ
655bool wxSplitterWindow::OnSashPositionChange(int newSashPosition)
656{
657 // is the left/upper pane too small?
658 if ( newSashPosition < m_minimumPaneSize )
659 return NULL;
660
661 // is the right/lower pane too small?
662 int w, h;
663 GetClientSize(&w, &h);
664
665 if ( m_splitMode == wxSPLIT_VERTICAL )
666 {
f4a4bd13 667 if ( w - newSashPosition < m_minimumPaneSize )
0d559d69
VZ
668 return FALSE;
669 }
670 else // m_splitMode = wxSPLIT_HORIZONTAL
671 {
f4a4bd13 672 if ( h - newSashPosition < m_minimumPaneSize )
0d559d69
VZ
673 return FALSE;
674 }
675
676 // it's ok to move sash
677 return TRUE;
678}
679
c801d85f
KB
680// Called when the sash is double-clicked.
681// The default behaviour is to remove the sash if the
682// minimum pane size is zero.
683void wxSplitterWindow::OnDoubleClickSash(int WXUNUSED(x), int WXUNUSED(y) )
684{
685 if ( GetMinimumPaneSize() == 0 )
686 {
687 Unsplit();
688 }
689}
690
691// Initialize colours
0d559d69 692void wxSplitterWindow::InitColours()
c801d85f 693{
0d559d69
VZ
694 wxDELETE( m_facePen );
695 wxDELETE( m_faceBrush );
696 wxDELETE( m_mediumShadowPen );
697 wxDELETE( m_darkShadowPen );
698 wxDELETE( m_lightShadowPen );
699 wxDELETE( m_hilightPen );
c801d85f
KB
700
701 // Shadow colours
702#if defined(__WIN95__)
c801d85f
KB
703 wxColour faceColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
704 m_facePen = new wxPen(faceColour, 1, wxSOLID);
705 m_faceBrush = new wxBrush(faceColour, wxSOLID);
706
c801d85f
KB
707 wxColour mediumShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW));
708 m_mediumShadowPen = new wxPen(mediumShadowColour, 1, wxSOLID);
709
c801d85f
KB
710 wxColour darkShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW));
711 m_darkShadowPen = new wxPen(darkShadowColour, 1, wxSOLID);
712
c801d85f
KB
713 wxColour lightShadowColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT));
714 m_lightShadowPen = new wxPen(lightShadowColour, 1, wxSOLID);
715
c801d85f
KB
716 wxColour hilightColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT));
717 m_hilightPen = new wxPen(hilightColour, 1, wxSOLID);
0d559d69 718#else // !Win32
c801d85f
KB
719 m_facePen = new wxPen("LIGHT GREY", 1, wxSOLID);
720 m_faceBrush = new wxBrush("LIGHT GREY", wxSOLID);
721 m_mediumShadowPen = new wxPen("GREY", 1, wxSOLID);
722 m_darkShadowPen = new wxPen("BLACK", 1, wxSOLID);
723 m_lightShadowPen = new wxPen("LIGHT GREY", 1, wxSOLID);
724 m_hilightPen = new wxPen("WHITE", 1, wxSOLID);
0d559d69 725#endif // Win32/!Win32
c801d85f
KB
726}
727