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