]> git.saurik.com Git - wxWidgets.git/blame - src/aui/dockart.cpp
Add virtual ~wxAnyScrollHelperBase() to fix compiler warning.
[wxWidgets.git] / src / aui / dockart.cpp
CommitLineData
50acee04 1///////////////////////////////////////////////////////////////////////////////
be66f18e 2// Name: src/aui/dockart.cpp
50acee04
JS
3// Purpose: wxaui: wx advanced user interface - docking window manager
4// Author: Benjamin I. Williams
5// Modified by:
6// Created: 2005-05-17
50acee04
JS
7// Copyright: (C) Copyright 2005-2006, Kirix Corporation, All Rights Reserved
8// Licence: wxWindows Library Licence, Version 3.1
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19#include "wx/wxprec.h"
20
21#ifdef __BORLANDC__
22 #pragma hdrstop
23#endif
24
25#if wxUSE_AUI
26
50acee04
JS
27#include "wx/aui/framemanager.h"
28#include "wx/aui/dockart.h"
9fa99f04
VZ
29#include "wx/aui/auibook.h"
30#include "wx/aui/tabart.h"
50acee04
JS
31
32#ifndef WX_PRECOMP
be66f18e
WS
33 #include "wx/settings.h"
34 #include "wx/dcclient.h"
155ecd4c 35 #include "wx/image.h"
50acee04
JS
36#endif
37
d618ed9b 38#ifdef __WXMAC__
d20db501 39#include "wx/osx/private.h"
8acd14d1 40#include "wx/graphics.h"
530a427a 41#include "wx/dcgraph.h"
d618ed9b
RD
42#endif
43
32205ebb
RR
44#ifdef __WXGTK__
45#include <gtk/gtk.h>
32205ebb 46#include "wx/renderer.h"
9dc44eff 47#ifdef __WXGTK20__
655e246b
JJ
48 #include "wx/gtk/private/gtk2-compat.h"
49#else
50 #define gtk_widget_is_drawable GTK_WIDGET_DRAWABLE
51#endif
9dc44eff
PC
52#ifdef __WXGTK3__
53 #include "wx/graphics.h"
54#endif
32205ebb
RR
55#endif
56
57
a3a5df9d 58// -- wxAuiDefaultDockArt class implementation --
50acee04 59
a3a5df9d
BW
60// wxAuiDefaultDockArt is an art provider class which does all of the drawing for
61// wxAuiManager. This allows the library caller to customize the dock art
50acee04
JS
62// (probably by deriving from this class), or to completely replace all drawing
63// with custom dock art (probably by writing a new stand-alone class derived
a3a5df9d
BW
64// from the wxAuiDockArt base class). The active dock art class can be set via
65// wxAuiManager::SetDockArt()
a500c7ed 66wxColor wxAuiLightContrastColour(const wxColour& c)
50acee04
JS
67{
68 int amount = 120;
69
70 // if the color is especially dark, then
71 // make the contrast even lighter
72 if (c.Red() < 128 && c.Green() < 128 && c.Blue() < 128)
73 amount = 160;
74
a310c91c 75 return c.ChangeLightness(amount);
50acee04
JS
76}
77
a500c7ed 78// wxAuiBitmapFromBits() is a utility function that creates a
50acee04 79// masked bitmap from raw bits (XBM format)
a500c7ed
BW
80wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
81 const wxColour& color)
50acee04
JS
82{
83 wxImage img = wxBitmap((const char*)bits, w, h).ConvertToImage();
c4d39711
RR
84 img.Replace(0,0,0,123,123,123);
85 img.Replace(255,255,255,color.Red(),color.Green(),color.Blue());
50acee04
JS
86 img.SetMaskColour(123,123,123);
87 return wxBitmap(img);
88}
cedd7b22 89
50acee04
JS
90
91static void DrawGradientRectangle(wxDC& dc,
92 const wxRect& rect,
93 const wxColour& start_color,
94 const wxColour& end_color,
95 int direction)
96{
97 int rd, gd, bd, high = 0;
98 rd = end_color.Red() - start_color.Red();
99 gd = end_color.Green() - start_color.Green();
100 bd = end_color.Blue() - start_color.Blue();
101
102 if (direction == wxAUI_GRADIENT_VERTICAL)
103 high = rect.GetHeight()-1;
cedd7b22 104 else
50acee04
JS
105 high = rect.GetWidth()-1;
106
107 for (int i = 0; i <= high; ++i)
108 {
dadacb5e 109 int r,g,b;
cedd7b22
PC
110
111
a6b7a521
VZ
112 r = start_color.Red() + (high <= 0 ? 0 : (((i*rd*100)/high)/100));
113 g = start_color.Green() + (high <= 0 ? 0 : (((i*gd*100)/high)/100));
114 b = start_color.Blue() + (high <= 0 ? 0 : (((i*bd*100)/high)/100));
50acee04 115
be66f18e
WS
116 wxPen p(wxColor((unsigned char)r,
117 (unsigned char)g,
118 (unsigned char)b));
50acee04
JS
119 dc.SetPen(p);
120
121 if (direction == wxAUI_GRADIENT_VERTICAL)
122 dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i);
cedd7b22 123 else
50acee04
JS
124 dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);
125 }
50acee04
JS
126}
127
a500c7ed 128wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size)
50d5ad7d
BW
129{
130 wxCoord x,y;
cedd7b22 131
50d5ad7d
BW
132 // first check if the text fits with no problems
133 dc.GetTextExtent(text, &x, &y);
134 if (x <= max_size)
135 return text;
cedd7b22 136
50d5ad7d
BW
137 size_t i, len = text.Length();
138 size_t last_good_length = 0;
139 for (i = 0; i < len; ++i)
140 {
141 wxString s = text.Left(i);
142 s += wxT("...");
cedd7b22 143
50d5ad7d
BW
144 dc.GetTextExtent(s, &x, &y);
145 if (x > max_size)
146 break;
cedd7b22 147
50d5ad7d
BW
148 last_good_length = i;
149 }
150
151 wxString ret = text.Left(last_good_length);
152 ret += wxT("...");
153 return ret;
154}
155
a3a5df9d 156wxAuiDefaultDockArt::wxAuiDefaultDockArt()
50acee04 157{
efdea9c3 158#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
9a29fe70 159 wxColor baseColour = wxColour( wxMacCreateCGColorFromHITheme(kThemeBrushToolbarBackground));
50acee04 160#else
9a29fe70 161 wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
50acee04 162#endif
be66f18e 163
9a29fe70 164 // the baseColour is too pale to use as our base colour,
3f7fce73 165 // so darken it a bit --
9a29fe70
VZ
166 if ((255-baseColour.Red()) +
167 (255-baseColour.Green()) +
168 (255-baseColour.Blue()) < 60)
3f7fce73 169 {
9a29fe70 170 baseColour = baseColour.ChangeLightness(92);
3f7fce73 171 }
cedd7b22 172
9a29fe70
VZ
173 m_baseColour = baseColour;
174 wxColor darker1Colour = baseColour.ChangeLightness(85);
175 wxColor darker2Colour = baseColour.ChangeLightness(75);
176 wxColor darker3Colour = baseColour.ChangeLightness(60);
177 //wxColor darker4Colour = baseColour.ChangeLightness(50);
178 wxColor darker5Colour = baseColour.ChangeLightness(40);
179
180 m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
181 m_activeCaptionGradientColour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
182 m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
183 m_inactiveCaptionColour = darker1Colour;
184 m_inactiveCaptionGradientColour = baseColour.ChangeLightness(97);
185 m_inactiveCaptionTextColour = *wxBLACK;
186
187 m_sashBrush = wxBrush(baseColour);
188 m_backgroundBrush = wxBrush(baseColour);
189 m_gripperBrush = wxBrush(baseColour);
190
191 m_borderPen = wxPen(darker2Colour);
192 m_gripperPen1 = wxPen(darker5Colour);
193 m_gripperPen2 = wxPen(darker3Colour);
194 m_gripperPen3 = *wxWHITE_PEN;
50acee04
JS
195
196#ifdef __WXMAC__
9a29fe70 197 m_captionFont = *wxSMALL_FONT;
50acee04 198#else
9a29fe70 199 m_captionFont = wxFont(8, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE);
50acee04
JS
200#endif
201
cae374ef
VZ
202 // default metric values
203#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
204 SInt32 height;
205 GetThemeMetric( kThemeMetricSmallPaneSplitterHeight , &height );
9a29fe70 206 m_sashSize = height;
cae374ef 207#elif defined(__WXGTK__)
9a29fe70 208 m_sashSize = wxRendererNative::Get().GetSplitterParams(NULL).widthSash;
cae374ef 209#else
9a29fe70 210 m_sashSize = 4;
cae374ef 211#endif
9a29fe70
VZ
212 m_captionSize = 17;
213 m_borderSize = 1;
214 m_buttonSize = 14;
215 m_gripperSize = 9;
216 m_gradientType = wxAUI_GRADIENT_VERTICAL;
cae374ef
VZ
217
218 InitBitmaps();
219}
220
221void
222wxAuiDefaultDockArt::InitBitmaps ()
223{
50acee04 224 // some built in bitmaps
ff03f567 225#if defined( __WXMAC__ )
a243da29 226 static const unsigned char close_bits[]={
50acee04
JS
227 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x03, 0xF8, 0x01, 0xF0, 0x19, 0xF3,
228 0xB8, 0xE3, 0xF0, 0xE1, 0xE0, 0xE0, 0xF0, 0xE1, 0xB8, 0xE3, 0x19, 0xF3,
229 0x01, 0xF0, 0x03, 0xF8, 0x0F, 0xFE, 0xFF, 0xFF };
cedd7b22 230#elif defined(__WXGTK__)
a243da29 231 static const unsigned char close_bits[]={
cedd7b22
PC
232 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xfb, 0xef, 0xdb, 0xed, 0x8b, 0xe8,
233 0x1b, 0xec, 0x3b, 0xee, 0x1b, 0xec, 0x8b, 0xe8, 0xdb, 0xed, 0xfb, 0xef,
234 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
50acee04 235#else
a243da29 236 static const unsigned char close_bits[]={
7ba40044 237 // reduced height, symmetric
03647350
VZ
238 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xf3, 0x9f, 0xf9,
239 0x3f, 0xfc, 0x7f, 0xfe, 0x3f, 0xfc, 0x9f, 0xf9, 0xcf, 0xf3, 0xff, 0xff,
7ba40044
VZ
240 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
241 /*
242 // same height as maximize/restore
03647350
VZ
243 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xe7, 0xcf, 0xf3, 0x9f, 0xf9,
244 0x3f, 0xfc, 0x7f, 0xfe, 0x3f, 0xfc, 0x9f, 0xf9, 0xcf, 0xf3, 0xe7, 0xe7,
7ba40044 245 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
03647350 246 */
50acee04
JS
247#endif
248
a243da29 249 static const unsigned char maximize_bits[] = {
37106ab2
BW
250 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xf7, 0xf7, 0x07, 0xf0,
251 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0x07, 0xf0,
252 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
253
a243da29 254 static const unsigned char restore_bits[]={
37106ab2
BW
255 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0x1f, 0xf0, 0xdf, 0xf7,
256 0x07, 0xf4, 0x07, 0xf4, 0xf7, 0xf5, 0xf7, 0xf1, 0xf7, 0xfd, 0xf7, 0xfd,
257 0x07, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
cedd7b22 258
a243da29 259 static const unsigned char pin_bits[]={
50acee04
JS
260 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0xdf,0xfc,0xdf,0xfc,
261 0xdf,0xfc,0xdf,0xfc,0xdf,0xfc,0x0f,0xf8,0x7f,0xff,0x7f,0xff,
262 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
be66f18e 263
50acee04 264#ifdef __WXMAC__
9a29fe70
VZ
265 m_inactiveCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE);
266 m_activeCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE );
50acee04 267#else
9a29fe70
VZ
268 m_inactiveCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_inactiveCaptionTextColour);
269 m_activeCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_activeCaptionTextColour);
50acee04 270#endif
37106ab2 271
50acee04 272#ifdef __WXMAC__
9a29fe70
VZ
273 m_inactiveMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE);
274 m_activeMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE );
50acee04 275#else
9a29fe70
VZ
276 m_inactiveMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_inactiveCaptionTextColour);
277 m_activeMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_activeCaptionTextColour);
50acee04 278#endif
37106ab2
BW
279
280#ifdef __WXMAC__
9a29fe70
VZ
281 m_inactiveRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE);
282 m_activeRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE );
37106ab2 283#else
9a29fe70
VZ
284 m_inactiveRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_inactiveCaptionTextColour);
285 m_activeRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_activeCaptionTextColour);
37106ab2
BW
286#endif
287
9a29fe70
VZ
288 m_inactivePinBitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_inactiveCaptionTextColour);
289 m_activePinBitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_activeCaptionTextColour);
50acee04
JS
290}
291
a3a5df9d 292int wxAuiDefaultDockArt::GetMetric(int id)
50acee04
JS
293{
294 switch (id)
295 {
9a29fe70
VZ
296 case wxAUI_DOCKART_SASH_SIZE: return m_sashSize;
297 case wxAUI_DOCKART_CAPTION_SIZE: return m_captionSize;
298 case wxAUI_DOCKART_GRIPPER_SIZE: return m_gripperSize;
299 case wxAUI_DOCKART_PANE_BORDER_SIZE: return m_borderSize;
300 case wxAUI_DOCKART_PANE_BUTTON_SIZE: return m_buttonSize;
301 case wxAUI_DOCKART_GRADIENT_TYPE: return m_gradientType;
50acee04
JS
302 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
303 }
304
305 return 0;
306}
307
a3a5df9d 308void wxAuiDefaultDockArt::SetMetric(int id, int new_val)
50acee04
JS
309{
310 switch (id)
311 {
9a29fe70
VZ
312 case wxAUI_DOCKART_SASH_SIZE: m_sashSize = new_val; break;
313 case wxAUI_DOCKART_CAPTION_SIZE: m_captionSize = new_val; break;
314 case wxAUI_DOCKART_GRIPPER_SIZE: m_gripperSize = new_val; break;
315 case wxAUI_DOCKART_PANE_BORDER_SIZE: m_borderSize = new_val; break;
316 case wxAUI_DOCKART_PANE_BUTTON_SIZE: m_buttonSize = new_val; break;
317 case wxAUI_DOCKART_GRADIENT_TYPE: m_gradientType = new_val; break;
50acee04
JS
318 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
319 }
320}
321
a3a5df9d 322wxColour wxAuiDefaultDockArt::GetColour(int id)
50acee04
JS
323{
324 switch (id)
325 {
9a29fe70
VZ
326 case wxAUI_DOCKART_BACKGROUND_COLOUR: return m_backgroundBrush.GetColour();
327 case wxAUI_DOCKART_SASH_COLOUR: return m_sashBrush.GetColour();
328 case wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR: return m_inactiveCaptionColour;
329 case wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR: return m_inactiveCaptionGradientColour;
330 case wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR: return m_inactiveCaptionTextColour;
331 case wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR: return m_activeCaptionColour;
332 case wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR: return m_activeCaptionGradientColour;
333 case wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR: return m_activeCaptionTextColour;
334 case wxAUI_DOCKART_BORDER_COLOUR: return m_borderPen.GetColour();
335 case wxAUI_DOCKART_GRIPPER_COLOUR: return m_gripperBrush.GetColour();
50acee04
JS
336 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
337 }
338
339 return wxColour();
340}
341
a3a5df9d 342void wxAuiDefaultDockArt::SetColour(int id, const wxColor& colour)
50acee04
JS
343{
344 switch (id)
345 {
9a29fe70
VZ
346 case wxAUI_DOCKART_BACKGROUND_COLOUR: m_backgroundBrush.SetColour(colour); break;
347 case wxAUI_DOCKART_SASH_COLOUR: m_sashBrush.SetColour(colour); break;
348 case wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR: m_inactiveCaptionColour = colour; break;
349 case wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR: m_inactiveCaptionGradientColour = colour; break;
350 case wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR: m_inactiveCaptionTextColour = colour; break;
351 case wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR: m_activeCaptionColour = colour; break;
352 case wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR: m_activeCaptionGradientColour = colour; break;
353 case wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR: m_activeCaptionTextColour = colour; break;
354 case wxAUI_DOCKART_BORDER_COLOUR: m_borderPen.SetColour(colour); break;
254a3429 355 case wxAUI_DOCKART_GRIPPER_COLOUR:
9a29fe70
VZ
356 m_gripperBrush.SetColour(colour);
357 m_gripperPen1.SetColour(colour.ChangeLightness(40));
358 m_gripperPen2.SetColour(colour.ChangeLightness(60));
50acee04
JS
359 break;
360 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
361 }
cae374ef
VZ
362
363 InitBitmaps();
50acee04
JS
364}
365
a3a5df9d 366void wxAuiDefaultDockArt::SetFont(int id, const wxFont& font)
50acee04 367{
254a3429 368 if (id == wxAUI_DOCKART_CAPTION_FONT)
9a29fe70 369 m_captionFont = font;
50acee04
JS
370}
371
a3a5df9d 372wxFont wxAuiDefaultDockArt::GetFont(int id)
50acee04 373{
254a3429 374 if (id == wxAUI_DOCKART_CAPTION_FONT)
9a29fe70 375 return m_captionFont;
50acee04
JS
376 return wxNullFont;
377}
378
a3a5df9d 379void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, const wxRect& rect)
50acee04 380{
efdea9c3 381#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
8a088306
VZ
382 wxUnusedVar(window);
383 wxUnusedVar(orientation);
384
50acee04
JS
385 HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height );
386 CGContextRef cgContext ;
888dde65
RR
387 wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
388 cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext() ;
be66f18e 389
50acee04
JS
390 HIThemeSplitterDrawInfo drawInfo ;
391 drawInfo.version = 0 ;
392 drawInfo.state = kThemeStateActive ;
393 drawInfo.adornment = kHIThemeSplitterAdornmentNone ;
be66f18e
WS
394 HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;
395
32205ebb 396#elif defined(__WXGTK__)
8e367bbf
BW
397 // clear out the rectangle first
398 dc.SetPen(*wxTRANSPARENT_PEN);
9a29fe70 399 dc.SetBrush(m_sashBrush);
8e367bbf 400 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
32205ebb 401
cedd7b22 402#if 0
32205ebb
RR
403 GdkRectangle gdk_rect;
404 if (orientation == wxVERTICAL )
405 {
406 gdk_rect.x = rect.x;
407 gdk_rect.y = rect.y;
9a29fe70 408 gdk_rect.width = m_sashSize;
32205ebb
RR
409 gdk_rect.height = rect.height;
410 }
411 else
412 {
413 gdk_rect.x = rect.x;
414 gdk_rect.y = rect.y;
415 gdk_rect.width = rect.width;
9a29fe70 416 gdk_rect.height = m_sashSize;
32205ebb 417 }
cedd7b22 418#endif
32205ebb
RR
419
420 if (!window) return;
421 if (!window->m_wxwindow) return;
fc9ab22a 422 if (!gtk_widget_is_drawable(window->m_wxwindow)) return;
32205ebb
RR
423
424 gtk_paint_handle
425 (
385e8575 426 gtk_widget_get_style(window->m_wxwindow),
9dc44eff
PC
427#ifdef __WXGTK3__
428 static_cast<cairo_t*>(dc.GetGraphicsContext()->GetNativeContext()),
429#else
08f53168 430 window->GTKGetDrawingWindow(),
9dc44eff 431#endif
32205ebb
RR
432 // flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
433 GTK_STATE_NORMAL,
434 GTK_SHADOW_NONE,
9dc44eff 435#ifndef __WXGTK3__
32205ebb 436 NULL /* no clipping */,
9dc44eff 437#endif
32205ebb
RR
438 window->m_wxwindow,
439 "paned",
440 rect.x,
441 rect.y,
442 rect.width,
443 rect.height,
444 (orientation == wxVERTICAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
445 );
446
50acee04 447#else
eec7f412
WS
448 wxUnusedVar(window);
449 wxUnusedVar(orientation);
50acee04 450 dc.SetPen(*wxTRANSPARENT_PEN);
9a29fe70 451 dc.SetBrush(m_sashBrush);
50acee04
JS
452 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
453#endif
454}
455
456
a3a5df9d 457void wxAuiDefaultDockArt::DrawBackground(wxDC& dc, wxWindow *WXUNUSED(window), int, const wxRect& rect)
50acee04
JS
458{
459 dc.SetPen(*wxTRANSPARENT_PEN);
460#ifdef __WXMAC__
461 // we have to clear first, otherwise we are drawing a light striped pattern
462 // over an already darker striped background
463 dc.SetBrush(*wxWHITE_BRUSH) ;
464 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
465#endif
9a29fe70 466 dc.SetBrush(m_backgroundBrush);
50acee04
JS
467 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
468}
469
9fa99f04 470void wxAuiDefaultDockArt::DrawBorder(wxDC& dc, wxWindow* window, const wxRect& _rect,
a3a5df9d 471 wxAuiPaneInfo& pane)
50acee04 472{
9a29fe70 473 dc.SetPen(m_borderPen);
50acee04
JS
474 dc.SetBrush(*wxTRANSPARENT_BRUSH);
475
476 wxRect rect = _rect;
254a3429 477 int i, border_width = GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE);
50acee04
JS
478
479 if (pane.IsToolbar())
480 {
481 for (i = 0; i < border_width; ++i)
482 {
483 dc.SetPen(*wxWHITE_PEN);
484 dc.DrawLine(rect.x, rect.y, rect.x+rect.width, rect.y);
485 dc.DrawLine(rect.x, rect.y, rect.x, rect.y+rect.height);
9a29fe70 486 dc.SetPen(m_borderPen);
50acee04
JS
487 dc.DrawLine(rect.x, rect.y+rect.height-1,
488 rect.x+rect.width, rect.y+rect.height-1);
489 dc.DrawLine(rect.x+rect.width-1, rect.y,
490 rect.x+rect.width-1, rect.y+rect.height);
491 rect.Deflate(1);
492 }
493 }
696978ee 494 else
50acee04 495 {
9fa99f04
VZ
496 // notebooks draw the border themselves, so they can use native rendering (e.g. tabartgtk)
497 wxAuiTabArt* art = 0;
498 wxAuiNotebook* nb = wxDynamicCast(window, wxAuiNotebook);
499 if (nb)
500 art = nb->GetArtProvider();
501
502 if (art)
503 art->DrawBorder(dc, window, rect);
504 else
50acee04 505 {
9fa99f04
VZ
506 for (i = 0; i < border_width; ++i)
507 {
508 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
509 rect.Deflate(1);
510 }
50acee04
JS
511 }
512 }
513}
514
515
a3a5df9d 516void wxAuiDefaultDockArt::DrawCaptionBackground(wxDC& dc, const wxRect& rect, bool active)
50acee04 517{
9a29fe70 518 if (m_gradientType == wxAUI_GRADIENT_NONE)
50acee04
JS
519 {
520 if (active)
9a29fe70 521 dc.SetBrush(wxBrush(m_activeCaptionColour));
cedd7b22 522 else
9a29fe70 523 dc.SetBrush(wxBrush(m_inactiveCaptionColour));
50acee04
JS
524
525 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
526 }
696978ee 527 else
50acee04
JS
528 {
529 if (active)
530 {
531 // on mac the gradients are expected to become darker from the top
532#ifdef __WXMAC__
533 DrawGradientRectangle(dc, rect,
9a29fe70
VZ
534 m_activeCaptionColour,
535 m_activeCaptionGradientColour,
536 m_gradientType);
50acee04 537#else
dadacb5e 538 // on other platforms, active gradients become lighter at the top
50acee04 539 DrawGradientRectangle(dc, rect,
9a29fe70
VZ
540 m_activeCaptionGradientColour,
541 m_activeCaptionColour,
542 m_gradientType);
50acee04
JS
543#endif
544 }
cedd7b22 545 else
50acee04 546 {
50acee04 547#ifdef __WXMAC__
dadacb5e 548 // on mac the gradients are expected to become darker from the top
50acee04 549 DrawGradientRectangle(dc, rect,
9a29fe70
VZ
550 m_inactiveCaptionGradientColour,
551 m_inactiveCaptionColour,
552 m_gradientType);
50acee04 553#else
dadacb5e 554 // on other platforms, inactive gradients become lighter at the bottom
50acee04 555 DrawGradientRectangle(dc, rect,
9a29fe70
VZ
556 m_inactiveCaptionColour,
557 m_inactiveCaptionGradientColour,
558 m_gradientType);
50acee04
JS
559#endif
560 }
561 }
562}
563
564
a3a5df9d 565void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxWindow *WXUNUSED(window),
50acee04
JS
566 const wxString& text,
567 const wxRect& rect,
a3a5df9d 568 wxAuiPaneInfo& pane)
50acee04
JS
569{
570 dc.SetPen(*wxTRANSPARENT_PEN);
9a29fe70 571 dc.SetFont(m_captionFont);
50acee04
JS
572
573 DrawCaptionBackground(dc, rect,
a3a5df9d 574 (pane.state & wxAuiPaneInfo::optionActive)?true:false);
50acee04 575
4254f672
VZ
576 int caption_offset = 0;
577 if ( pane.icon.IsOk() )
578 {
579 DrawIcon(dc, rect, pane);
580
581 caption_offset += pane.icon.GetWidth() + 3;
582 }
583
a3a5df9d 584 if (pane.state & wxAuiPaneInfo::optionActive)
9a29fe70 585 dc.SetTextForeground(m_activeCaptionTextColour);
696978ee 586 else
9a29fe70 587 dc.SetTextForeground(m_inactiveCaptionTextColour);
50acee04
JS
588
589
590 wxCoord w,h;
591 dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h);
592
50d5ad7d
BW
593 wxRect clip_rect = rect;
594 clip_rect.width -= 3; // text offset
595 clip_rect.width -= 2; // button padding
596 if (pane.HasCloseButton())
9a29fe70 597 clip_rect.width -= m_buttonSize;
50d5ad7d 598 if (pane.HasPinButton())
9a29fe70 599 clip_rect.width -= m_buttonSize;
50d5ad7d 600 if (pane.HasMaximizeButton())
9a29fe70 601 clip_rect.width -= m_buttonSize;
50d5ad7d 602
a500c7ed 603 wxString draw_text = wxAuiChopText(dc, text, clip_rect.width);
50d5ad7d
BW
604
605 dc.SetClippingRegion(clip_rect);
4254f672 606 dc.DrawText(draw_text, rect.x+3 + caption_offset, rect.y+(rect.height/2)-(h/2)-1);
50acee04
JS
607 dc.DestroyClippingRegion();
608}
609
4254f672
VZ
610void
611wxAuiDefaultDockArt::DrawIcon(wxDC& dc, const wxRect& rect, wxAuiPaneInfo& pane)
612{
613 // Draw the icon centered vertically
614 dc.DrawBitmap(pane.icon,
615 rect.x+2, rect.y+(rect.height-pane.icon.GetHeight())/2,
616 true);
617}
618
a3a5df9d 619void wxAuiDefaultDockArt::DrawGripper(wxDC& dc, wxWindow *WXUNUSED(window),
50acee04 620 const wxRect& rect,
a3a5df9d 621 wxAuiPaneInfo& pane)
50acee04
JS
622{
623 dc.SetPen(*wxTRANSPARENT_PEN);
9a29fe70 624 dc.SetBrush(m_gripperBrush);
50acee04
JS
625
626 dc.DrawRectangle(rect.x, rect.y, rect.width,rect.height);
627
628 if (!pane.HasGripperTop())
629 {
630 int y = 5;
631 while (1)
632 {
9a29fe70 633 dc.SetPen(m_gripperPen1);
50acee04 634 dc.DrawPoint(rect.x+3, rect.y+y);
9a29fe70 635 dc.SetPen(m_gripperPen2);
50acee04
JS
636 dc.DrawPoint(rect.x+3, rect.y+y+1);
637 dc.DrawPoint(rect.x+4, rect.y+y);
9a29fe70 638 dc.SetPen(m_gripperPen3);
50acee04
JS
639 dc.DrawPoint(rect.x+5, rect.y+y+1);
640 dc.DrawPoint(rect.x+5, rect.y+y+2);
641 dc.DrawPoint(rect.x+4, rect.y+y+2);
642
643 y += 4;
644 if (y > rect.GetHeight()-5)
645 break;
646 }
647 }
648 else
649 {
650 int x = 5;
651 while (1)
652 {
9a29fe70 653 dc.SetPen(m_gripperPen1);
50acee04 654 dc.DrawPoint(rect.x+x, rect.y+3);
9a29fe70 655 dc.SetPen(m_gripperPen2);
50acee04
JS
656 dc.DrawPoint(rect.x+x+1, rect.y+3);
657 dc.DrawPoint(rect.x+x, rect.y+4);
9a29fe70 658 dc.SetPen(m_gripperPen3);
50acee04
JS
659 dc.DrawPoint(rect.x+x+1, rect.y+5);
660 dc.DrawPoint(rect.x+x+2, rect.y+5);
661 dc.DrawPoint(rect.x+x+2, rect.y+4);
662
663 x += 4;
664 if (x > rect.GetWidth()-5)
665 break;
666 }
667 }
668}
669
a3a5df9d 670void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc, wxWindow *WXUNUSED(window),
50acee04
JS
671 int button,
672 int button_state,
673 const wxRect& _rect,
a3a5df9d 674 wxAuiPaneInfo& pane)
50acee04 675{
2b4b6ded 676 wxBitmap bmp;
cedd7b22
PC
677 if (!(&pane))
678 return;
2b4b6ded
BW
679 switch (button)
680 {
681 default:
682 case wxAUI_BUTTON_CLOSE:
683 if (pane.state & wxAuiPaneInfo::optionActive)
9a29fe70 684 bmp = m_activeCloseBitmap;
cedd7b22 685 else
9a29fe70 686 bmp = m_inactiveCloseBitmap;
2b4b6ded
BW
687 break;
688 case wxAUI_BUTTON_PIN:
689 if (pane.state & wxAuiPaneInfo::optionActive)
9a29fe70 690 bmp = m_activePinBitmap;
cedd7b22 691 else
9a29fe70 692 bmp = m_inactivePinBitmap;
2b4b6ded
BW
693 break;
694 case wxAUI_BUTTON_MAXIMIZE_RESTORE:
695 if (pane.IsMaximized())
696 {
697 if (pane.state & wxAuiPaneInfo::optionActive)
9a29fe70 698 bmp = m_activeRestoreBitmap;
cedd7b22 699 else
9a29fe70 700 bmp = m_inactiveRestoreBitmap;
2b4b6ded 701 }
cedd7b22 702 else
2b4b6ded
BW
703 {
704 if (pane.state & wxAuiPaneInfo::optionActive)
9a29fe70 705 bmp = m_activeMaximizeBitmap;
cedd7b22 706 else
9a29fe70 707 bmp = m_inactiveMaximizeBitmap;
2b4b6ded
BW
708 }
709 break;
710 }
711
712
50acee04
JS
713 wxRect rect = _rect;
714
2b4b6ded
BW
715 int old_y = rect.y;
716 rect.y = rect.y + (rect.height/2) - (bmp.GetHeight()/2);
717 rect.height = old_y + rect.height - rect.y - 1;
718
719
50acee04
JS
720 if (button_state == wxAUI_BUTTON_STATE_PRESSED)
721 {
722 rect.x++;
723 rect.y++;
724 }
725
726 if (button_state == wxAUI_BUTTON_STATE_HOVER ||
727 button_state == wxAUI_BUTTON_STATE_PRESSED)
728 {
a3a5df9d 729 if (pane.state & wxAuiPaneInfo::optionActive)
50acee04 730 {
9a29fe70
VZ
731 dc.SetBrush(wxBrush(m_activeCaptionColour.ChangeLightness(120)));
732 dc.SetPen(wxPen(m_activeCaptionColour.ChangeLightness(70)));
50acee04 733 }
cedd7b22 734 else
50acee04 735 {
9a29fe70
VZ
736 dc.SetBrush(wxBrush(m_inactiveCaptionColour.ChangeLightness(120)));
737 dc.SetPen(wxPen(m_inactiveCaptionColour.ChangeLightness(70)));
50acee04
JS
738 }
739
740 // draw the background behind the button
741 dc.DrawRectangle(rect.x, rect.y, 15, 15);
742 }
743
50acee04
JS
744
745 // draw the button itself
746 dc.DrawBitmap(bmp, rect.x, rect.y, true);
747}
748
749
750#endif // wxUSE_AUI