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