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