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