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