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