]> git.saurik.com Git - wxWidgets.git/blame - src/generic/sashwin.cpp
Use default GUI font for wxMessageDialog and wxFileDialog.
[wxWidgets.git] / src / generic / sashwin.cpp
CommitLineData
a6d70308
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: sashwin.cpp
3// Purpose: wxSashWindow implementation. A sash window has an optional
4// sash on each edge, allowing it to be dragged. An event
5// is generated when the sash is released.
6// Author: Julian Smart
7// Modified by:
8// Created: 01/02/97
9// RCS-ID: $Id$
10// Copyright: (c) Julian Smart
65571936 11// Licence: wxWindows licence
a6d70308
JS
12/////////////////////////////////////////////////////////////////////////////
13
14f355c2 14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
a6d70308
JS
15#pragma implementation "sashwin.h"
16#endif
17
18// For compilers that support precompilation, includes "wx.h".
19#include "wx/wxprec.h"
20
21#ifdef __BORLANDC__
22#pragma hdrstop
23#endif
24
1e6feb95
VZ
25#if wxUSE_SASH
26
a6d70308 27#ifndef WX_PRECOMP
04dbb646
VZ
28 #include "wx/dialog.h"
29 #include "wx/frame.h"
30 #include "wx/settings.h"
a6d70308
JS
31#endif
32
b713f891
WS
33#include "wx/math.h"
34
a6d70308
JS
35#include <stdlib.h>
36
a6d70308
JS
37#include "wx/dcscreen.h"
38#include "wx/sashwin.h"
f9b1708c 39#include "wx/laywin.h"
a6d70308 40
32956769
JS
41DEFINE_EVENT_TYPE(wxEVT_SASH_DRAGGED)
42
a6d70308
JS
43IMPLEMENT_DYNAMIC_CLASS(wxSashWindow, wxWindow)
44IMPLEMENT_DYNAMIC_CLASS(wxSashEvent, wxCommandEvent)
45
46BEGIN_EVENT_TABLE(wxSashWindow, wxWindow)
47 EVT_PAINT(wxSashWindow::OnPaint)
48 EVT_SIZE(wxSashWindow::OnSize)
49 EVT_MOUSE_EVENTS(wxSashWindow::OnMouseEvent)
64407854 50#if defined( __WXMSW__ ) || defined( __WXMAC__)
2b5f62a0
VZ
51 EVT_SET_CURSOR(wxSashWindow::OnSetCursor)
52#endif // wxMSW
53
a6d70308 54END_EVENT_TABLE()
a6d70308 55
f6bcfd97
BP
56bool wxSashWindow::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos,
57 const wxSize& size, long style, const wxString& name)
a6d70308 58{
f6bcfd97
BP
59 return wxWindow::Create(parent, id, pos, size, style, name);
60}
a6d70308 61
f6bcfd97
BP
62wxSashWindow::~wxSashWindow()
63{
64 delete m_sashCursorWE;
65 delete m_sashCursorNS;
a6d70308
JS
66}
67
f6bcfd97 68void wxSashWindow::Init()
a6d70308
JS
69{
70 m_draggingEdge = wxSASH_NONE;
71 m_dragMode = wxSASH_DRAG_NONE;
72 m_oldX = 0;
73 m_oldY = 0;
74 m_firstX = 0;
75 m_firstY = 0;
76 m_borderSize = 3;
77 m_extraBorderSize = 0;
78 m_minimumPaneSizeX = 0;
79 m_minimumPaneSizeY = 0;
f66b7050
MR
80 m_maximumPaneSizeX = 10000;
81 m_maximumPaneSizeY = 10000;
a6d70308
JS
82 m_sashCursorWE = new wxCursor(wxCURSOR_SIZEWE);
83 m_sashCursorNS = new wxCursor(wxCURSOR_SIZENS);
ca65c044 84 m_mouseCaptured = false;
2b5f62a0 85 m_currentCursor = NULL;
a6d70308
JS
86
87 // Eventually, we'll respond to colour change messages
88 InitColours();
89}
90
a6d70308
JS
91void wxSashWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
92{
93 wxPaintDC dc(this);
94
ee4c6942 95 DrawBorders(dc);
a6d70308
JS
96 DrawSashes(dc);
97}
98
99void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
100{
cfeb83fd
VZ
101 wxCoord x, y;
102 event.GetPosition(&x, &y);
a6d70308
JS
103
104 wxSashEdgePosition sashHit = SashHitTest(x, y);
105
a1b82138
VZ
106 if (event.LeftDown())
107 {
9f334bea 108 CaptureMouse();
ca65c044 109 m_mouseCaptured = true;
9f334bea 110
a6d70308
JS
111 if ( sashHit != wxSASH_NONE )
112 {
a1b82138 113 // Required for X to specify that
b412f9be
JS
114 // that we wish to draw on top of all windows
115 // - and we optimise by specifying the area
116 // for creating the overlap window.
117 // Find the first frame or dialog and use this to specify
118 // the area to draw on.
119 wxWindow* parent = this;
120
121 while (parent && !parent->IsKindOf(CLASSINFO(wxDialog)) &&
122 !parent->IsKindOf(CLASSINFO(wxFrame)))
123 parent = parent->GetParent();
124
125 wxScreenDC::StartDrawingOnTop(parent);
a6d70308
JS
126
127 // We don't say we're dragging yet; we leave that
128 // decision for the Dragging() branch, to ensure
129 // the user has dragged a little bit.
130 m_dragMode = wxSASH_DRAG_LEFT_DOWN;
131 m_draggingEdge = sashHit;
132 m_firstX = x;
133 m_firstY = y;
9f334bea
JS
134
135 if ( (sashHit == wxSASH_LEFT) || (sashHit == wxSASH_RIGHT) )
136 {
2b5f62a0
VZ
137 if (m_currentCursor != m_sashCursorWE)
138 {
139 SetCursor(*m_sashCursorWE);
140 }
141 m_currentCursor = m_sashCursorWE;
9f334bea
JS
142 }
143 else
144 {
2b5f62a0
VZ
145 if (m_currentCursor != m_sashCursorNS)
146 {
147 SetCursor(*m_sashCursorNS);
148 }
149 m_currentCursor = m_sashCursorNS;
9f334bea 150 }
a6d70308 151 }
a1b82138 152 }
a6d70308
JS
153 else if ( event.LeftUp() && m_dragMode == wxSASH_DRAG_LEFT_DOWN )
154 {
155 // Wasn't a proper drag
40fab78b
JS
156 if (m_mouseCaptured)
157 ReleaseMouse();
ca65c044 158 m_mouseCaptured = false;
40fab78b 159
a6d70308
JS
160 wxScreenDC::EndDrawingOnTop();
161 m_dragMode = wxSASH_DRAG_NONE;
162 m_draggingEdge = wxSASH_NONE;
a6d70308 163 }
a1b82138
VZ
164 else if (event.LeftUp() && m_dragMode == wxSASH_DRAG_DRAGGING)
165 {
a6d70308
JS
166 // We can stop dragging now and see what we've got.
167 m_dragMode = wxSASH_DRAG_NONE;
40fab78b
JS
168 if (m_mouseCaptured)
169 ReleaseMouse();
ca65c044 170 m_mouseCaptured = false;
40fab78b 171
a6d70308
JS
172 // Erase old tracker
173 DrawSashTracker(m_draggingEdge, m_oldX, m_oldY);
174
175 // End drawing on top (frees the window used for drawing
176 // over the screen)
177 wxScreenDC::EndDrawingOnTop();
178
179 int w, h;
a1b82138 180 GetSize(&w, &h);
a6d70308 181 int xp, yp;
a1b82138 182 GetPosition(&xp, &yp);
a6d70308
JS
183
184 wxSashEdgePosition edge = m_draggingEdge;
185 m_draggingEdge = wxSASH_NONE;
186
187 wxRect dragRect;
188 wxSashDragStatus status = wxSASH_STATUS_OK;
a1b82138
VZ
189
190 // the new height and width of the window - if -1, it didn't change
422d0ff0
WS
191 int newHeight = wxDefaultCoord,
192 newWidth = wxDefaultCoord;
a1b82138
VZ
193
194 // NB: x and y may be negative and they're relative to the sash window
195 // upper left corner, while xp and yp are expressed in the parent
196 // window system of coordinates, so adjust them! After this
197 // adjustment, all coordinates are relative to the parent window.
198 y += yp;
199 x += xp;
200
a6d70308
JS
201 switch (edge)
202 {
203 case wxSASH_TOP:
a1b82138
VZ
204 if ( y > yp + h )
205 {
206 // top sash shouldn't get below the bottom one
a6d70308 207 status = wxSASH_STATUS_OUT_OF_RANGE;
a1b82138
VZ
208 }
209 else
210 {
211 newHeight = h - (y - yp);
212 }
a6d70308 213 break;
a1b82138 214
a6d70308 215 case wxSASH_BOTTOM:
a1b82138
VZ
216 if ( y < yp )
217 {
218 // bottom sash shouldn't get above the top one
a6d70308 219 status = wxSASH_STATUS_OUT_OF_RANGE;
a1b82138
VZ
220 }
221 else
222 {
223 newHeight = y - yp;
224 }
a6d70308 225 break;
a1b82138 226
a6d70308 227 case wxSASH_LEFT:
a1b82138
VZ
228 if ( x > xp + w )
229 {
230 // left sash shouldn't get beyond the right one
a6d70308 231 status = wxSASH_STATUS_OUT_OF_RANGE;
a1b82138
VZ
232 }
233 else
234 {
235 newWidth = w - (x - xp);
236 }
a6d70308 237 break;
a1b82138 238
a6d70308 239 case wxSASH_RIGHT:
a1b82138
VZ
240 if ( x < xp )
241 {
242 // and the right sash, finally, shouldn't be beyond the
243 // left one
a6d70308 244 status = wxSASH_STATUS_OUT_OF_RANGE;
a1b82138
VZ
245 }
246 else
247 {
248 newWidth = x - xp;
249 }
a6d70308 250 break;
a1b82138
VZ
251
252 case wxSASH_NONE:
253 // can this happen at all?
254 break;
255 }
256
422d0ff0 257 if ( newHeight == wxDefaultCoord )
a1b82138
VZ
258 {
259 // didn't change
260 newHeight = h;
261 }
262 else
263 {
264 // make sure it's in m_minimumPaneSizeY..m_maximumPaneSizeY range
265 newHeight = wxMax(newHeight, m_minimumPaneSizeY);
266 newHeight = wxMin(newHeight, m_maximumPaneSizeY);
a6d70308
JS
267 }
268
422d0ff0 269 if ( newWidth == wxDefaultCoord )
a1b82138
VZ
270 {
271 // didn't change
272 newWidth = w;
273 }
274 else
275 {
276 // make sure it's in m_minimumPaneSizeY..m_maximumPaneSizeY range
277 newWidth = wxMax(newWidth, m_minimumPaneSizeX);
278 newWidth = wxMin(newWidth, m_maximumPaneSizeX);
279 }
280
281 dragRect = wxRect(x, y, newWidth, newHeight);
282
a6d70308
JS
283 wxSashEvent event(GetId(), edge);
284 event.SetEventObject(this);
285 event.SetDragStatus(status);
286 event.SetDragRect(dragRect);
287 GetEventHandler()->ProcessEvent(event);
a1b82138 288 }
9f334bea
JS
289 else if ( event.LeftUp() )
290 {
40fab78b
JS
291 if (m_mouseCaptured)
292 ReleaseMouse();
ca65c044 293 m_mouseCaptured = false;
9f334bea 294 }
a1b82138
VZ
295 else if (event.Moving() && !event.Dragging())
296 {
a6d70308
JS
297 // Just change the cursor if required
298 if ( sashHit != wxSASH_NONE )
299 {
a1b82138
VZ
300 if ( (sashHit == wxSASH_LEFT) || (sashHit == wxSASH_RIGHT) )
301 {
2b5f62a0
VZ
302 if (m_currentCursor != m_sashCursorWE)
303 {
304 SetCursor(*m_sashCursorWE);
305 }
306 m_currentCursor = m_sashCursorWE;
a1b82138
VZ
307 }
308 else
309 {
2b5f62a0
VZ
310 if (m_currentCursor != m_sashCursorNS)
311 {
312 SetCursor(*m_sashCursorNS);
313 }
314 m_currentCursor = m_sashCursorNS;
a1b82138
VZ
315 }
316 }
c0bcc480
JS
317 else
318 {
8a9c2246 319 SetCursor(wxNullCursor);
2b5f62a0 320 m_currentCursor = NULL;
c0bcc480 321 }
a1b82138
VZ
322 }
323 else if ( event.Dragging() &&
324 ((m_dragMode == wxSASH_DRAG_DRAGGING) ||
325 (m_dragMode == wxSASH_DRAG_LEFT_DOWN)) )
326 {
327 if ( (m_draggingEdge == wxSASH_LEFT) || (m_draggingEdge == wxSASH_RIGHT) )
328 {
2b5f62a0
VZ
329 if (m_currentCursor != m_sashCursorWE)
330 {
331 SetCursor(*m_sashCursorWE);
332 }
333 m_currentCursor = m_sashCursorWE;
a1b82138
VZ
334 }
335 else
336 {
2b5f62a0
VZ
337 if (m_currentCursor != m_sashCursorNS)
338 {
339 SetCursor(*m_sashCursorNS);
340 }
341 m_currentCursor = m_sashCursorNS;
a6d70308 342 }
a6d70308
JS
343
344 if (m_dragMode == wxSASH_DRAG_LEFT_DOWN)
345 {
346 m_dragMode = wxSASH_DRAG_DRAGGING;
347 DrawSashTracker(m_draggingEdge, x, y);
348 }
349 else
350 {
a1b82138
VZ
351 if ( m_dragMode == wxSASH_DRAG_DRAGGING )
352 {
353 // Erase old tracker
354 DrawSashTracker(m_draggingEdge, m_oldX, m_oldY);
a6d70308 355
a1b82138
VZ
356 // Draw new one
357 DrawSashTracker(m_draggingEdge, x, y);
358 }
a6d70308
JS
359 }
360 m_oldX = x;
361 m_oldY = y;
a1b82138 362 }
a6d70308
JS
363 else if ( event.LeftDClick() )
364 {
365 // Nothing
366 }
367 else
368 {
369 }
370}
371
372void wxSashWindow::OnSize(wxSizeEvent& WXUNUSED(event))
373{
374 SizeWindows();
375}
376
341287bf 377wxSashEdgePosition wxSashWindow::SashHitTest(int x, int y, int WXUNUSED(tolerance))
a6d70308
JS
378{
379 int cx, cy;
380 GetClientSize(& cx, & cy);
381
382 int i;
383 for (i = 0; i < 4; i++)
384 {
385 wxSashEdge& edge = m_sashes[i];
386 wxSashEdgePosition position = (wxSashEdgePosition) i ;
387
388 if (edge.m_show)
389 {
390 switch (position)
391 {
392 case wxSASH_TOP:
393 {
394 if (y >= 0 && y <= GetEdgeMargin(position))
395 return wxSASH_TOP;
396 break;
397 }
398 case wxSASH_RIGHT:
399 {
400 if ((x >= cx - GetEdgeMargin(position)) && (x <= cx))
401 return wxSASH_RIGHT;
402 break;
403 }
404 case wxSASH_BOTTOM:
405 {
406 if ((y >= cy - GetEdgeMargin(position)) && (y <= cy))
407 return wxSASH_BOTTOM;
408 break;
409 }
410 case wxSASH_LEFT:
411 {
82540ef2 412 if ((x <= GetEdgeMargin(position)) && (x >= 0))
a6d70308
JS
413 return wxSASH_LEFT;
414 break;
415 }
341287bf
JS
416 case wxSASH_NONE:
417 {
418 break;
419 }
a6d70308
JS
420 }
421 }
422 }
423 return wxSASH_NONE;
424}
425
426// Draw 3D effect borders
427void wxSashWindow::DrawBorders(wxDC& dc)
428{
429 int w, h;
430 GetClientSize(&w, &h);
431
432 wxPen mediumShadowPen(m_mediumShadowColour, 1, wxSOLID);
433 wxPen darkShadowPen(m_darkShadowColour, 1, wxSOLID);
434 wxPen lightShadowPen(m_lightShadowColour, 1, wxSOLID);
435 wxPen hilightPen(m_hilightColour, 1, wxSOLID);
436
f6bcfd97 437 if ( GetWindowStyleFlag() & wxSW_3DBORDER )
a6d70308
JS
438 {
439 dc.SetPen(mediumShadowPen);
440 dc.DrawLine(0, 0, w-1, 0);
441 dc.DrawLine(0, 0, 0, h - 1);
442
443 dc.SetPen(darkShadowPen);
444 dc.DrawLine(1, 1, w-2, 1);
445 dc.DrawLine(1, 1, 1, h-2);
446
447 dc.SetPen(hilightPen);
448 dc.DrawLine(0, h-1, w-1, h-1);
449 dc.DrawLine(w-1, 0, w-1, h); // Surely the maximum y pos. should be h - 1.
450 /// Anyway, h is required for MSW.
451
452 dc.SetPen(lightShadowPen);
453 dc.DrawLine(w-2, 1, w-2, h-2); // Right hand side
454 dc.DrawLine(1, h-2, w-1, h-2); // Bottom
455 }
448af9a4 456 else if ( GetWindowStyleFlag() & wxSW_BORDER )
a6d70308
JS
457 {
458 dc.SetBrush(*wxTRANSPARENT_BRUSH);
459 dc.SetPen(*wxBLACK_PEN);
460 dc.DrawRectangle(0, 0, w-1, h-1);
461 }
462
463 dc.SetPen(wxNullPen);
464 dc.SetBrush(wxNullBrush);
465}
466
467void wxSashWindow::DrawSashes(wxDC& dc)
468{
469 int i;
470 for (i = 0; i < 4; i++)
471 if (m_sashes[i].m_show)
472 DrawSash((wxSashEdgePosition) i, dc);
473}
474
475// Draw the sash
476void wxSashWindow::DrawSash(wxSashEdgePosition edge, wxDC& dc)
477{
478 int w, h;
479 GetClientSize(&w, &h);
480
481 wxPen facePen(m_faceColour, 1, wxSOLID);
482 wxBrush faceBrush(m_faceColour, wxSOLID);
483 wxPen mediumShadowPen(m_mediumShadowColour, 1, wxSOLID);
484 wxPen darkShadowPen(m_darkShadowColour, 1, wxSOLID);
485 wxPen lightShadowPen(m_lightShadowColour, 1, wxSOLID);
486 wxPen hilightPen(m_hilightColour, 1, wxSOLID);
42841dfc
WS
487 wxColour blackClr(0, 0, 0);
488 wxColour whiteClr(255, 255, 255);
489 wxPen blackPen(blackClr, 1, wxSOLID);
490 wxPen whitePen(whiteClr, 1, wxSOLID);
a6d70308
JS
491
492 if ( edge == wxSASH_LEFT || edge == wxSASH_RIGHT )
493 {
999836aa 494 int sashPosition = (edge == wxSASH_LEFT) ? 0 : ( w - GetEdgeMargin(edge) );
a6d70308
JS
495
496 dc.SetPen(facePen);
497 dc.SetBrush(faceBrush);
498 dc.DrawRectangle(sashPosition, 0, GetEdgeMargin(edge), h);
499
f6bcfd97 500 if (GetWindowStyleFlag() & wxSW_3DSASH)
a6d70308
JS
501 {
502 if (edge == wxSASH_LEFT)
503 {
d0b223a1 504 // Draw a dark grey line on the left to indicate that the
a6d70308 505 // sash is raised
d0b223a1 506 dc.SetPen(mediumShadowPen);
a6d70308
JS
507 dc.DrawLine(GetEdgeMargin(edge), 0, GetEdgeMargin(edge), h);
508 }
509 else
510 {
f6bcfd97 511 // Draw a highlight line on the right to indicate that the
a6d70308 512 // sash is raised
f6bcfd97 513 dc.SetPen(hilightPen);
a6d70308
JS
514 dc.DrawLine(w - GetEdgeMargin(edge), 0, w - GetEdgeMargin(edge), h);
515 }
516 }
517 }
518 else // top or bottom
519 {
999836aa 520 int sashPosition = (edge == wxSASH_TOP) ? 0 : ( h - GetEdgeMargin(edge) );
a6d70308
JS
521
522 dc.SetPen(facePen);
523 dc.SetBrush(faceBrush);
524 dc.DrawRectangle(0, sashPosition, w, GetEdgeMargin(edge));
525
f6bcfd97 526 if (GetWindowStyleFlag() & wxSW_3DSASH)
a6d70308
JS
527 {
528 if (edge == wxSASH_BOTTOM)
529 {
f6bcfd97 530 // Draw a highlight line on the bottom to indicate that the
a6d70308 531 // sash is raised
f6bcfd97 532 dc.SetPen(hilightPen);
058939fc 533 dc.DrawLine(0, h - GetEdgeMargin(edge), w, h - GetEdgeMargin(edge));
a6d70308
JS
534 }
535 else
536 {
d0b223a1 537 // Draw a drak grey line on the top to indicate that the
a6d70308 538 // sash is raised
d0b223a1 539 dc.SetPen(mediumShadowPen);
c0bcc480 540 dc.DrawLine(1, GetEdgeMargin(edge), w-1, GetEdgeMargin(edge));
a6d70308
JS
541 }
542 }
543 }
544
545 dc.SetPen(wxNullPen);
546 dc.SetBrush(wxNullBrush);
547}
548
549// Draw the sash tracker (for whilst moving the sash)
550void wxSashWindow::DrawSashTracker(wxSashEdgePosition edge, int x, int y)
551{
552 int w, h;
553 GetClientSize(&w, &h);
554
555 wxScreenDC screenDC;
556 int x1, y1;
557 int x2, y2;
558
559 if ( edge == wxSASH_LEFT || edge == wxSASH_RIGHT )
560 {
561 x1 = x; y1 = 2;
562 x2 = x; y2 = h-2;
563
564 if ( (edge == wxSASH_LEFT) && (x1 > w) )
565 {
566 x1 = w; x2 = w;
567 }
568 else if ( (edge == wxSASH_RIGHT) && (x1 < 0) )
569 {
570 x1 = 0; x2 = 0;
571 }
572 }
573 else
574 {
575 x1 = 2; y1 = y;
576 x2 = w-2; y2 = y;
577
578 if ( (edge == wxSASH_TOP) && (y1 > h) )
579 {
580 y1 = h;
581 y2 = h;
582 }
583 else if ( (edge == wxSASH_BOTTOM) && (y1 < 0) )
584 {
585 y1 = 0;
586 y2 = 0;
587 }
588 }
589
590 ClientToScreen(&x1, &y1);
591 ClientToScreen(&x2, &y2);
592
593 wxPen sashTrackerPen(*wxBLACK, 2, wxSOLID);
594
3c679789 595 screenDC.SetLogicalFunction(wxINVERT);
a6d70308
JS
596 screenDC.SetPen(sashTrackerPen);
597 screenDC.SetBrush(*wxTRANSPARENT_BRUSH);
598
599 screenDC.DrawLine(x1, y1, x2, y2);
600
601 screenDC.SetLogicalFunction(wxCOPY);
602
603 screenDC.SetPen(wxNullPen);
604 screenDC.SetBrush(wxNullBrush);
605}
606
607// Position and size subwindows.
608// Note that the border size applies to each subwindow, not
609// including the edges next to the sash.
610void wxSashWindow::SizeWindows()
611{
612 int cw, ch;
613 GetClientSize(&cw, &ch);
614
b1d4dd7a 615 if (GetChildren().GetCount() == 1)
a6d70308 616 {
b1d4dd7a 617 wxWindow* child = GetChildren().GetFirst()->GetData();
a6d70308
JS
618
619 int x = 0;
620 int y = 0;
621 int width = cw;
622 int height = ch;
623
624 // Top
625 if (m_sashes[0].m_show)
626 {
627 y = m_borderSize;
628 height -= m_borderSize;
629 }
630 y += m_extraBorderSize;
631
632 // Left
633 if (m_sashes[3].m_show)
634 {
635 x = m_borderSize;
636 width -= m_borderSize;
637 }
638 x += m_extraBorderSize;
639
640 // Right
641 if (m_sashes[1].m_show)
642 {
643 width -= m_borderSize;
644 }
645 width -= 2*m_extraBorderSize;
646
647 // Bottom
648 if (m_sashes[2].m_show)
649 {
650 height -= m_borderSize;
651 }
652 height -= 2*m_extraBorderSize;
653
654 child->SetSize(x, y, width, height);
655 }
b1d4dd7a 656 else if (GetChildren().GetCount() > 1)
f9b1708c
JS
657 {
658 // Perhaps multiple children are themselves sash windows.
659 // TODO: this doesn't really work because the subwindows sizes/positions
660 // must be set to leave a gap for the parent's sash (hit-test and decorations).
661 // Perhaps we can allow for this within LayoutWindow, testing whether the parent
662 // is a sash window, and if so, allowing some space for the edges.
663 wxLayoutAlgorithm layout;
664 layout.LayoutWindow(this);
665 }
a6d70308
JS
666
667 wxClientDC dc(this);
668 DrawBorders(dc);
669 DrawSashes(dc);
670}
671
672// Initialize colours
673void wxSashWindow::InitColours()
674{
675 // Shadow colours
a756f210
VS
676 m_faceColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
677 m_mediumShadowColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW);
678 m_darkShadowColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW);
679 m_lightShadowColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
680 m_hilightColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT);
a6d70308
JS
681}
682
683void wxSashWindow::SetSashVisible(wxSashEdgePosition edge, bool sash)
684{
685 m_sashes[edge].m_show = sash;
686 if (sash)
687 m_sashes[edge].m_margin = m_borderSize;
688 else
689 m_sashes[edge].m_margin = 0;
690}
691
64407854 692#if defined( __WXMSW__ ) || defined( __WXMAC__)
2b5f62a0
VZ
693
694// this is currently called (and needed) under MSW only...
695void wxSashWindow::OnSetCursor(wxSetCursorEvent& event)
696{
697 // if we don't do it, the resizing cursor might be set for child window:
698 // and like this we explicitly say that our cursor should not be used for
699 // children windows which overlap us
700
701 if ( SashHitTest(event.GetX(), event.GetY()) != wxSASH_NONE)
702 {
703 // default processing is ok
704 event.Skip();
705 }
706 //else: do nothing, in particular, don't call Skip()
707}
708
709#endif // wxMSW
710
75be3f5e 711#endif // wxUSE_SASH