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