prevent sash artifacts on gtk
[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 // StepColour() it a utility function that simply darkens
60 // or lightens a color, based on the specified percentage
61 static wxColor StepColour(const wxColor& c, int percent)
62 {
63 int r = c.Red(), g = c.Green(), b = c.Blue();
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));
67 }
68
69 static 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)
83 static 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();
87 img.Replace(0,0,0,123,123,123);
88 img.Replace(255,255,255,color.Red(),color.Green(),color.Blue());
89 img.SetMaskColour(123,123,123);
90 return wxBitmap(img);
91 }
92
93
94 static 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 {
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;
118
119 wxPen p(wxColor((unsigned char)r,
120 (unsigned char)g,
121 (unsigned char)b));
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
132 static 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
160 wxAuiDefaultDockArt::wxAuiDefaultDockArt()
161 {
162 #ifdef __WXMAC__
163 wxBrush toolbarbrush;
164 toolbarbrush.MacSetTheme( kThemeBrushToolbarBackground );
165 wxColor base_colour = toolbarbrush.GetColour();
166 #else
167 wxColor base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
168 #endif
169
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);
176
177 m_active_caption_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
178 m_active_caption_gradient_colour = LightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
179 m_active_caption_text_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
180 m_inactive_caption_colour = darker1_colour;
181 m_inactive_caption_gradient_colour = StepColour(base_colour, 97);
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
189 m_sash_brush = wxBrush(base_colour);
190 m_background_brush = wxBrush(base_colour);
191 m_gripper_brush = wxBrush(base_colour);
192 #endif
193 m_border_pen = wxPen(darker2_colour);
194 m_gripper_pen1 = wxPen(darker5_colour);
195 m_gripper_pen2 = wxPen(darker3_colour);
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
205 #if defined( __WXMAC__ )
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 };
210 #else
211 static unsigned char close_bits[]={
212 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xf3, 0xcf, 0xf9,
213 0x9f, 0xfc, 0x3f, 0xfe, 0x3f, 0xfe, 0x9f, 0xfc, 0xcf, 0xf9, 0xe7, 0xf3,
214 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
215 #endif
216
217 static unsigned char maximize_bits[] = {
218 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xf7, 0xf7, 0x07, 0xf0,
219 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0x07, 0xf0,
220 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
221
222 static unsigned char restore_bits[]={
223 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0x1f, 0xf0, 0xdf, 0xf7,
224 0x07, 0xf4, 0x07, 0xf4, 0xf7, 0xf5, 0xf7, 0xf1, 0xf7, 0xfd, 0xf7, 0xfd,
225 0x07, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
226
227 static unsigned char pin_bits[]={
228 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0xdf,0xfc,0xdf,0xfc,
229 0xdf,0xfc,0xdf,0xfc,0xdf,0xfc,0x0f,0xf8,0x7f,0xff,0x7f,0xff,
230 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
231
232 #ifdef __WXMAC__
233 m_inactive_close_bitmap = BitmapFromBits(close_bits, 16, 16, *wxWHITE);
234 m_active_close_bitmap = BitmapFromBits(close_bits, 16, 16, *wxWHITE );
235 #else
236 m_inactive_close_bitmap = BitmapFromBits(close_bits, 16, 16, m_inactive_caption_text_colour);
237 m_active_close_bitmap = BitmapFromBits(close_bits, 16, 16, m_active_caption_text_colour);
238 #endif
239
240 #ifdef __WXMAC__
241 m_inactive_maximize_bitmap = BitmapFromBits(maximize_bits, 16, 16, *wxWHITE);
242 m_active_maximize_bitmap = BitmapFromBits(maximize_bits, 16, 16, *wxWHITE );
243 #else
244 m_inactive_maximize_bitmap = BitmapFromBits(maximize_bits, 16, 16, m_inactive_caption_text_colour);
245 m_active_maximize_bitmap = BitmapFromBits(maximize_bits, 16, 16, m_active_caption_text_colour);
246 #endif
247
248 #ifdef __WXMAC__
249 m_inactive_restore_bitmap = BitmapFromBits(restore_bits, 16, 16, *wxWHITE);
250 m_active_restore_bitmap = BitmapFromBits(restore_bits, 16, 16, *wxWHITE );
251 #else
252 m_inactive_restore_bitmap = BitmapFromBits(restore_bits, 16, 16, m_inactive_caption_text_colour);
253 m_active_restore_bitmap = BitmapFromBits(restore_bits, 16, 16, m_active_caption_text_colour);
254 #endif
255
256 m_inactive_pin_bitmap = BitmapFromBits(pin_bits, 16, 16, m_inactive_caption_text_colour);
257 m_active_pin_bitmap = BitmapFromBits(pin_bits, 16, 16, m_active_caption_text_colour);
258
259 // default metric values
260 #if defined(__WXMAC__)
261 SInt32 height;
262 GetThemeMetric( kThemeMetricSmallPaneSplitterHeight , &height );
263 m_sash_size = height;
264 #elif defined(__WXGTK__)
265 m_sash_size = wxRendererNative::Get().GetSplitterParams(NULL).widthSash;
266 #else
267 m_sash_size = 4;
268 #endif
269 m_caption_size = 17;
270 m_border_size = 1;
271 m_button_size = 14;
272 m_gripper_size = 9;
273 m_gradient_type = wxAUI_GRADIENT_VERTICAL;
274 }
275
276 int wxAuiDefaultDockArt::GetMetric(int id)
277 {
278 switch (id)
279 {
280 case wxAUI_ART_SASH_SIZE: return m_sash_size;
281 case wxAUI_ART_CAPTION_SIZE: return m_caption_size;
282 case wxAUI_ART_GRIPPER_SIZE: return m_gripper_size;
283 case wxAUI_ART_PANE_BORDER_SIZE: return m_border_size;
284 case wxAUI_ART_PANE_BUTTON_SIZE: return m_button_size;
285 case wxAUI_ART_GRADIENT_TYPE: return m_gradient_type;
286 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
287 }
288
289 return 0;
290 }
291
292 void wxAuiDefaultDockArt::SetMetric(int id, int new_val)
293 {
294 switch (id)
295 {
296 case wxAUI_ART_SASH_SIZE: m_sash_size = new_val; break;
297 case wxAUI_ART_CAPTION_SIZE: m_caption_size = new_val; break;
298 case wxAUI_ART_GRIPPER_SIZE: m_gripper_size = new_val; break;
299 case wxAUI_ART_PANE_BORDER_SIZE: m_border_size = new_val; break;
300 case wxAUI_ART_PANE_BUTTON_SIZE: m_button_size = new_val; break;
301 case wxAUI_ART_GRADIENT_TYPE: m_gradient_type = new_val; break;
302 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
303 }
304 }
305
306 wxColour wxAuiDefaultDockArt::GetColour(int id)
307 {
308 switch (id)
309 {
310 case wxAUI_ART_BACKGROUND_COLOUR: return m_background_brush.GetColour();
311 case wxAUI_ART_SASH_COLOUR: return m_sash_brush.GetColour();
312 case wxAUI_ART_INACTIVE_CAPTION_COLOUR: return m_inactive_caption_colour;
313 case wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR: return m_inactive_caption_gradient_colour;
314 case wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR: return m_inactive_caption_text_colour;
315 case wxAUI_ART_ACTIVE_CAPTION_COLOUR: return m_active_caption_colour;
316 case wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR: return m_active_caption_gradient_colour;
317 case wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR: return m_active_caption_text_colour;
318 case wxAUI_ART_BORDER_COLOUR: return m_border_pen.GetColour();
319 case wxAUI_ART_GRIPPER_COLOUR: return m_gripper_brush.GetColour();
320 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
321 }
322
323 return wxColour();
324 }
325
326 void wxAuiDefaultDockArt::SetColour(int id, const wxColor& colour)
327 {
328 switch (id)
329 {
330 case wxAUI_ART_BACKGROUND_COLOUR: m_background_brush.SetColour(colour); break;
331 case wxAUI_ART_SASH_COLOUR: m_sash_brush.SetColour(colour); break;
332 case wxAUI_ART_INACTIVE_CAPTION_COLOUR: m_inactive_caption_colour = colour; break;
333 case wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR: m_inactive_caption_gradient_colour = colour; break;
334 case wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR: m_inactive_caption_text_colour = colour; break;
335 case wxAUI_ART_ACTIVE_CAPTION_COLOUR: m_active_caption_colour = colour; break;
336 case wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR: m_active_caption_gradient_colour = colour; break;
337 case wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR: m_active_caption_text_colour = colour; break;
338 case wxAUI_ART_BORDER_COLOUR: m_border_pen.SetColour(colour); break;
339 case wxAUI_ART_GRIPPER_COLOUR:
340 m_gripper_brush.SetColour(colour);
341 m_gripper_pen1.SetColour(StepColour(colour, 40));
342 m_gripper_pen2.SetColour(StepColour(colour, 60));
343 break;
344 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
345 }
346 }
347
348 void wxAuiDefaultDockArt::SetFont(int id, const wxFont& font)
349 {
350 if (id == wxAUI_ART_CAPTION_FONT)
351 m_caption_font = font;
352 }
353
354 wxFont wxAuiDefaultDockArt::GetFont(int id)
355 {
356 if (id == wxAUI_ART_CAPTION_FONT)
357 return m_caption_font;
358 return wxNullFont;
359 }
360
361 void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, const wxRect& rect)
362 {
363 #if defined(__WXMAC__)
364 HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height );
365 CGContextRef cgContext ;
366 #if wxMAC_USE_CORE_GRAPHICS
367 cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext() ;
368 #else
369 Rect bounds ;
370 GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
371 QDBeginCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
372 CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
373 CGContextScaleCTM( cgContext , 1 , -1 ) ;
374 #endif
375
376 HIThemeSplitterDrawInfo drawInfo ;
377 drawInfo.version = 0 ;
378 drawInfo.state = kThemeStateActive ;
379 drawInfo.adornment = kHIThemeSplitterAdornmentNone ;
380 HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;
381
382 #if wxMAC_USE_CORE_GRAPHICS
383 #else
384 QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
385 #endif
386
387 #elif defined(__WXGTK__)
388 // clear out the rectangle first
389 dc.SetPen(*wxTRANSPARENT_PEN);
390 dc.SetBrush(m_sash_brush);
391 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
392
393 GdkRectangle gdk_rect;
394 if (orientation == wxVERTICAL )
395 {
396 gdk_rect.x = rect.x;
397 gdk_rect.y = rect.y;
398 gdk_rect.width = m_sash_size;
399 gdk_rect.height = rect.height;
400 }
401 else
402 {
403 gdk_rect.x = rect.x;
404 gdk_rect.y = rect.y;
405 gdk_rect.width = rect.width;
406 gdk_rect.height = m_sash_size;
407 }
408
409 if (!window) return;
410 if (!window->m_wxwindow) return;
411 if (!GTK_PIZZA(window->m_wxwindow)->bin_window) return;
412
413 gtk_paint_handle
414 (
415 window->m_wxwindow->style,
416 GTK_PIZZA(window->m_wxwindow)->bin_window,
417 // flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
418 GTK_STATE_NORMAL,
419 GTK_SHADOW_NONE,
420 NULL /* no clipping */,
421 window->m_wxwindow,
422 "paned",
423 rect.x,
424 rect.y,
425 rect.width,
426 rect.height,
427 (orientation == wxVERTICAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
428 );
429
430 #else
431 wxUnusedVar(window);
432 wxUnusedVar(orientation);
433 dc.SetPen(*wxTRANSPARENT_PEN);
434 dc.SetBrush(m_sash_brush);
435 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
436 #endif
437 }
438
439
440 void wxAuiDefaultDockArt::DrawBackground(wxDC& dc, wxWindow *WXUNUSED(window), int, const wxRect& rect)
441 {
442 dc.SetPen(*wxTRANSPARENT_PEN);
443 #ifdef __WXMAC__
444 // we have to clear first, otherwise we are drawing a light striped pattern
445 // over an already darker striped background
446 dc.SetBrush(*wxWHITE_BRUSH) ;
447 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
448 #endif
449 dc.SetBrush(m_background_brush);
450 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
451 }
452
453 void wxAuiDefaultDockArt::DrawBorder(wxDC& dc, wxWindow *WXUNUSED(window), const wxRect& _rect,
454 wxAuiPaneInfo& pane)
455 {
456 dc.SetPen(m_border_pen);
457 dc.SetBrush(*wxTRANSPARENT_BRUSH);
458
459 wxRect rect = _rect;
460 int i, border_width = GetMetric(wxAUI_ART_PANE_BORDER_SIZE);
461
462 if (pane.IsToolbar())
463 {
464 for (i = 0; i < border_width; ++i)
465 {
466 dc.SetPen(*wxWHITE_PEN);
467 dc.DrawLine(rect.x, rect.y, rect.x+rect.width, rect.y);
468 dc.DrawLine(rect.x, rect.y, rect.x, rect.y+rect.height);
469 dc.SetPen(m_border_pen);
470 dc.DrawLine(rect.x, rect.y+rect.height-1,
471 rect.x+rect.width, rect.y+rect.height-1);
472 dc.DrawLine(rect.x+rect.width-1, rect.y,
473 rect.x+rect.width-1, rect.y+rect.height);
474 rect.Deflate(1);
475 }
476 }
477 else
478 {
479 for (i = 0; i < border_width; ++i)
480 {
481 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
482 rect.Deflate(1);
483 }
484 }
485 }
486
487
488 void wxAuiDefaultDockArt::DrawCaptionBackground(wxDC& dc, const wxRect& rect, bool active)
489 {
490 if (m_gradient_type == wxAUI_GRADIENT_NONE)
491 {
492 if (active)
493 dc.SetBrush(wxBrush(m_active_caption_colour));
494 else
495 dc.SetBrush(wxBrush(m_inactive_caption_colour));
496
497 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
498 }
499 else
500 {
501 if (active)
502 {
503 // on mac the gradients are expected to become darker from the top
504 #ifdef __WXMAC__
505 DrawGradientRectangle(dc, rect,
506 m_active_caption_colour,
507 m_active_caption_gradient_colour,
508 m_gradient_type);
509 #else
510 // on other platforms, active gradients become lighter at the top
511 DrawGradientRectangle(dc, rect,
512 m_active_caption_gradient_colour,
513 m_active_caption_colour,
514 m_gradient_type);
515 #endif
516 }
517 else
518 {
519 #ifdef __WXMAC__
520 // on mac the gradients are expected to become darker from the top
521 DrawGradientRectangle(dc, rect,
522 m_inactive_caption_gradient_colour,
523 m_inactive_caption_colour,
524 m_gradient_type);
525 #else
526 // on other platforms, inactive gradients become lighter at the bottom
527 DrawGradientRectangle(dc, rect,
528 m_inactive_caption_colour,
529 m_inactive_caption_gradient_colour,
530 m_gradient_type);
531 #endif
532 }
533 }
534 }
535
536
537 void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxWindow *WXUNUSED(window),
538 const wxString& text,
539 const wxRect& rect,
540 wxAuiPaneInfo& pane)
541 {
542 dc.SetPen(*wxTRANSPARENT_PEN);
543 dc.SetFont(m_caption_font);
544
545 DrawCaptionBackground(dc, rect,
546 (pane.state & wxAuiPaneInfo::optionActive)?true:false);
547
548 if (pane.state & wxAuiPaneInfo::optionActive)
549 dc.SetTextForeground(m_active_caption_text_colour);
550 else
551 dc.SetTextForeground(m_inactive_caption_text_colour);
552
553
554 wxCoord w,h;
555 dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h);
556
557 wxRect clip_rect = rect;
558 clip_rect.width -= 3; // text offset
559 clip_rect.width -= 2; // button padding
560 if (pane.HasCloseButton())
561 clip_rect.width -= m_button_size;
562 if (pane.HasPinButton())
563 clip_rect.width -= m_button_size;
564 if (pane.HasMaximizeButton())
565 clip_rect.width -= m_button_size;
566
567 wxString draw_text = ChopText(dc, text, clip_rect.width);
568
569 dc.SetClippingRegion(clip_rect);
570 dc.DrawText(draw_text, rect.x+3, rect.y+(rect.height/2)-(h/2)-1);
571 dc.DestroyClippingRegion();
572 }
573
574 void wxAuiDefaultDockArt::DrawGripper(wxDC& dc, wxWindow *WXUNUSED(window),
575 const wxRect& rect,
576 wxAuiPaneInfo& pane)
577 {
578 dc.SetPen(*wxTRANSPARENT_PEN);
579 dc.SetBrush(m_gripper_brush);
580
581 dc.DrawRectangle(rect.x, rect.y, rect.width,rect.height);
582
583 if (!pane.HasGripperTop())
584 {
585 int y = 5;
586 while (1)
587 {
588 dc.SetPen(m_gripper_pen1);
589 dc.DrawPoint(rect.x+3, rect.y+y);
590 dc.SetPen(m_gripper_pen2);
591 dc.DrawPoint(rect.x+3, rect.y+y+1);
592 dc.DrawPoint(rect.x+4, rect.y+y);
593 dc.SetPen(m_gripper_pen3);
594 dc.DrawPoint(rect.x+5, rect.y+y+1);
595 dc.DrawPoint(rect.x+5, rect.y+y+2);
596 dc.DrawPoint(rect.x+4, rect.y+y+2);
597
598 y += 4;
599 if (y > rect.GetHeight()-5)
600 break;
601 }
602 }
603 else
604 {
605 int x = 5;
606 while (1)
607 {
608 dc.SetPen(m_gripper_pen1);
609 dc.DrawPoint(rect.x+x, rect.y+3);
610 dc.SetPen(m_gripper_pen2);
611 dc.DrawPoint(rect.x+x+1, rect.y+3);
612 dc.DrawPoint(rect.x+x, rect.y+4);
613 dc.SetPen(m_gripper_pen3);
614 dc.DrawPoint(rect.x+x+1, rect.y+5);
615 dc.DrawPoint(rect.x+x+2, rect.y+5);
616 dc.DrawPoint(rect.x+x+2, rect.y+4);
617
618 x += 4;
619 if (x > rect.GetWidth()-5)
620 break;
621 }
622 }
623 }
624
625 void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc, wxWindow *WXUNUSED(window),
626 int button,
627 int button_state,
628 const wxRect& _rect,
629 wxAuiPaneInfo& pane)
630 {
631 wxRect rect = _rect;
632
633 if (button_state == wxAUI_BUTTON_STATE_PRESSED)
634 {
635 rect.x++;
636 rect.y++;
637 }
638
639 if (button_state == wxAUI_BUTTON_STATE_HOVER ||
640 button_state == wxAUI_BUTTON_STATE_PRESSED)
641 {
642 if (pane.state & wxAuiPaneInfo::optionActive)
643 {
644 dc.SetBrush(wxBrush(StepColour(m_active_caption_colour, 120)));
645 dc.SetPen(wxPen(StepColour(m_active_caption_colour, 70)));
646 }
647 else
648 {
649 dc.SetBrush(wxBrush(StepColour(m_inactive_caption_colour, 120)));
650 dc.SetPen(wxPen(StepColour(m_inactive_caption_colour, 70)));
651 }
652
653 // draw the background behind the button
654 dc.DrawRectangle(rect.x, rect.y, 15, 15);
655 }
656
657 wxBitmap bmp;
658 switch (button)
659 {
660 default:
661 case wxAUI_BUTTON_MAXIMIZE_RESTORE:
662 if (pane.IsMaximized()) {
663 if (pane.state & wxAuiPaneInfo::optionActive)
664 bmp = m_active_restore_bitmap;
665 else
666 bmp = m_inactive_restore_bitmap;
667 } else {
668 if (pane.state & wxAuiPaneInfo::optionActive)
669 bmp = m_active_maximize_bitmap;
670 else
671 bmp = m_inactive_maximize_bitmap;
672 }
673 break;
674 case wxAUI_BUTTON_CLOSE:
675 if (pane.state & wxAuiPaneInfo::optionActive)
676 bmp = m_active_close_bitmap;
677 else
678 bmp = m_inactive_close_bitmap;
679 break;
680 case wxAUI_BUTTON_PIN:
681 if (pane.state & wxAuiPaneInfo::optionActive)
682 bmp = m_active_pin_bitmap;
683 else
684 bmp = m_inactive_pin_bitmap;
685 break;
686 }
687
688 // draw the button itself
689 dc.DrawBitmap(bmp, rect.x, rect.y, true);
690 }
691
692
693 #endif // wxUSE_AUI