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