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