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