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