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