]> git.saurik.com Git - wxWidgets.git/blob - src/aui/dockart.cpp
Document wxTE_MULTILINE support in wxTextEntryDialog.
[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/osx/private.h"
39 #include "wx/graphics.h"
40 #include "wx/dcgraph.h"
41 #endif
42
43 #ifdef __WXGTK__
44 #include <gtk/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 wxColor wxAuiLightContrastColour(const wxColour& c)
58 {
59 int amount = 120;
60
61 // if the color is especially dark, then
62 // make the contrast even lighter
63 if (c.Red() < 128 && c.Green() < 128 && c.Blue() < 128)
64 amount = 160;
65
66 return c.ChangeLightness(amount);
67 }
68
69 // wxAuiBitmapFromBits() is a utility function that creates a
70 // masked bitmap from raw bits (XBM format)
71 wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
72 const wxColour& color)
73 {
74 wxImage img = wxBitmap((const char*)bits, w, h).ConvertToImage();
75 img.Replace(0,0,0,123,123,123);
76 img.Replace(255,255,255,color.Red(),color.Green(),color.Blue());
77 img.SetMaskColour(123,123,123);
78 return wxBitmap(img);
79 }
80
81
82 static void DrawGradientRectangle(wxDC& dc,
83 const wxRect& rect,
84 const wxColour& start_color,
85 const wxColour& end_color,
86 int direction)
87 {
88 int rd, gd, bd, high = 0;
89 rd = end_color.Red() - start_color.Red();
90 gd = end_color.Green() - start_color.Green();
91 bd = end_color.Blue() - start_color.Blue();
92
93 if (direction == wxAUI_GRADIENT_VERTICAL)
94 high = rect.GetHeight()-1;
95 else
96 high = rect.GetWidth()-1;
97
98 for (int i = 0; i <= high; ++i)
99 {
100 int r,g,b;
101
102
103 r = start_color.Red() + (high <= 0 ? 0 : (((i*rd*100)/high)/100));
104 g = start_color.Green() + (high <= 0 ? 0 : (((i*gd*100)/high)/100));
105 b = start_color.Blue() + (high <= 0 ? 0 : (((i*bd*100)/high)/100));
106
107 wxPen p(wxColor((unsigned char)r,
108 (unsigned char)g,
109 (unsigned char)b));
110 dc.SetPen(p);
111
112 if (direction == wxAUI_GRADIENT_VERTICAL)
113 dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i);
114 else
115 dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);
116 }
117 }
118
119 wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size)
120 {
121 wxCoord x,y;
122
123 // first check if the text fits with no problems
124 dc.GetTextExtent(text, &x, &y);
125 if (x <= max_size)
126 return text;
127
128 size_t i, len = text.Length();
129 size_t last_good_length = 0;
130 for (i = 0; i < len; ++i)
131 {
132 wxString s = text.Left(i);
133 s += wxT("...");
134
135 dc.GetTextExtent(s, &x, &y);
136 if (x > max_size)
137 break;
138
139 last_good_length = i;
140 }
141
142 wxString ret = text.Left(last_good_length);
143 ret += wxT("...");
144 return ret;
145 }
146
147 wxAuiDefaultDockArt::wxAuiDefaultDockArt()
148 {
149 #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
150 wxColor base_colour = wxColour( wxMacCreateCGColorFromHITheme(kThemeBrushToolbarBackground));
151 #else
152 wxColor base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
153 #endif
154
155 // the base_colour is too pale to use as our base colour,
156 // so darken it a bit --
157 if ((255-base_colour.Red()) +
158 (255-base_colour.Green()) +
159 (255-base_colour.Blue()) < 60)
160 {
161 base_colour = base_colour.ChangeLightness(92);
162 }
163
164 m_base_colour = base_colour;
165 wxColor darker1_colour = base_colour.ChangeLightness(85);
166 wxColor darker2_colour = base_colour.ChangeLightness(75);
167 wxColor darker3_colour = base_colour.ChangeLightness(60);
168 //wxColor darker4_colour = base_colour.ChangeLightness(50);
169 wxColor darker5_colour = base_colour.ChangeLightness(40);
170
171 m_active_caption_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
172 m_active_caption_gradient_colour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
173 m_active_caption_text_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
174 m_inactive_caption_colour = darker1_colour;
175 m_inactive_caption_gradient_colour = base_colour.ChangeLightness(97);
176 m_inactive_caption_text_colour = *wxBLACK;
177
178 m_sash_brush = wxBrush(base_colour);
179 m_background_brush = wxBrush(base_colour);
180 m_gripper_brush = wxBrush(base_colour);
181
182 m_border_pen = wxPen(darker2_colour);
183 m_gripper_pen1 = wxPen(darker5_colour);
184 m_gripper_pen2 = wxPen(darker3_colour);
185 m_gripper_pen3 = *wxWHITE_PEN;
186
187 #ifdef __WXMAC__
188 m_caption_font = *wxSMALL_FONT;
189 #else
190 m_caption_font = wxFont(8, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE);
191 #endif
192
193 // default metric values
194 #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
195 SInt32 height;
196 GetThemeMetric( kThemeMetricSmallPaneSplitterHeight , &height );
197 m_sash_size = height;
198 #elif defined(__WXGTK__)
199 m_sash_size = wxRendererNative::Get().GetSplitterParams(NULL).widthSash;
200 #else
201 m_sash_size = 4;
202 #endif
203 m_caption_size = 17;
204 m_border_size = 1;
205 m_button_size = 14;
206 m_gripper_size = 9;
207 m_gradient_type = wxAUI_GRADIENT_VERTICAL;
208
209 InitBitmaps();
210 }
211
212 void
213 wxAuiDefaultDockArt::InitBitmaps ()
214 {
215 // some built in bitmaps
216 #if defined( __WXMAC__ )
217 static const unsigned char close_bits[]={
218 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x03, 0xF8, 0x01, 0xF0, 0x19, 0xF3,
219 0xB8, 0xE3, 0xF0, 0xE1, 0xE0, 0xE0, 0xF0, 0xE1, 0xB8, 0xE3, 0x19, 0xF3,
220 0x01, 0xF0, 0x03, 0xF8, 0x0F, 0xFE, 0xFF, 0xFF };
221 #elif defined(__WXGTK__)
222 static const unsigned char close_bits[]={
223 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xfb, 0xef, 0xdb, 0xed, 0x8b, 0xe8,
224 0x1b, 0xec, 0x3b, 0xee, 0x1b, 0xec, 0x8b, 0xe8, 0xdb, 0xed, 0xfb, 0xef,
225 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
226 #else
227 static const unsigned char close_bits[]={
228 // reduced height, symmetric
229 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xf3, 0x9f, 0xf9,
230 0x3f, 0xfc, 0x7f, 0xfe, 0x3f, 0xfc, 0x9f, 0xf9, 0xcf, 0xf3, 0xff, 0xff,
231 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
232 /*
233 // same height as maximize/restore
234 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xe7, 0xcf, 0xf3, 0x9f, 0xf9,
235 0x3f, 0xfc, 0x7f, 0xfe, 0x3f, 0xfc, 0x9f, 0xf9, 0xcf, 0xf3, 0xe7, 0xe7,
236 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
237 */
238 #endif
239
240 static const unsigned char maximize_bits[] = {
241 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xf7, 0xf7, 0x07, 0xf0,
242 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0x07, 0xf0,
243 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
244
245 static const unsigned char restore_bits[]={
246 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0x1f, 0xf0, 0xdf, 0xf7,
247 0x07, 0xf4, 0x07, 0xf4, 0xf7, 0xf5, 0xf7, 0xf1, 0xf7, 0xfd, 0xf7, 0xfd,
248 0x07, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
249
250 static const unsigned char pin_bits[]={
251 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0xdf,0xfc,0xdf,0xfc,
252 0xdf,0xfc,0xdf,0xfc,0xdf,0xfc,0x0f,0xf8,0x7f,0xff,0x7f,0xff,
253 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
254
255 #ifdef __WXMAC__
256 m_inactive_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE);
257 m_active_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE );
258 #else
259 m_inactive_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_inactive_caption_text_colour);
260 m_active_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_active_caption_text_colour);
261 #endif
262
263 #ifdef __WXMAC__
264 m_inactive_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE);
265 m_active_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE );
266 #else
267 m_inactive_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_inactive_caption_text_colour);
268 m_active_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_active_caption_text_colour);
269 #endif
270
271 #ifdef __WXMAC__
272 m_inactive_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE);
273 m_active_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE );
274 #else
275 m_inactive_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_inactive_caption_text_colour);
276 m_active_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_active_caption_text_colour);
277 #endif
278
279 m_inactive_pin_bitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_inactive_caption_text_colour);
280 m_active_pin_bitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_active_caption_text_colour);
281 }
282
283 int wxAuiDefaultDockArt::GetMetric(int id)
284 {
285 switch (id)
286 {
287 case wxAUI_DOCKART_SASH_SIZE: return m_sash_size;
288 case wxAUI_DOCKART_CAPTION_SIZE: return m_caption_size;
289 case wxAUI_DOCKART_GRIPPER_SIZE: return m_gripper_size;
290 case wxAUI_DOCKART_PANE_BORDER_SIZE: return m_border_size;
291 case wxAUI_DOCKART_PANE_BUTTON_SIZE: return m_button_size;
292 case wxAUI_DOCKART_GRADIENT_TYPE: return m_gradient_type;
293 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
294 }
295
296 return 0;
297 }
298
299 void wxAuiDefaultDockArt::SetMetric(int id, int new_val)
300 {
301 switch (id)
302 {
303 case wxAUI_DOCKART_SASH_SIZE: m_sash_size = new_val; break;
304 case wxAUI_DOCKART_CAPTION_SIZE: m_caption_size = new_val; break;
305 case wxAUI_DOCKART_GRIPPER_SIZE: m_gripper_size = new_val; break;
306 case wxAUI_DOCKART_PANE_BORDER_SIZE: m_border_size = new_val; break;
307 case wxAUI_DOCKART_PANE_BUTTON_SIZE: m_button_size = new_val; break;
308 case wxAUI_DOCKART_GRADIENT_TYPE: m_gradient_type = new_val; break;
309 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
310 }
311 }
312
313 wxColour wxAuiDefaultDockArt::GetColour(int id)
314 {
315 switch (id)
316 {
317 case wxAUI_DOCKART_BACKGROUND_COLOUR: return m_background_brush.GetColour();
318 case wxAUI_DOCKART_SASH_COLOUR: return m_sash_brush.GetColour();
319 case wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR: return m_inactive_caption_colour;
320 case wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR: return m_inactive_caption_gradient_colour;
321 case wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR: return m_inactive_caption_text_colour;
322 case wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR: return m_active_caption_colour;
323 case wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR: return m_active_caption_gradient_colour;
324 case wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR: return m_active_caption_text_colour;
325 case wxAUI_DOCKART_BORDER_COLOUR: return m_border_pen.GetColour();
326 case wxAUI_DOCKART_GRIPPER_COLOUR: return m_gripper_brush.GetColour();
327 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
328 }
329
330 return wxColour();
331 }
332
333 void wxAuiDefaultDockArt::SetColour(int id, const wxColor& colour)
334 {
335 switch (id)
336 {
337 case wxAUI_DOCKART_BACKGROUND_COLOUR: m_background_brush.SetColour(colour); break;
338 case wxAUI_DOCKART_SASH_COLOUR: m_sash_brush.SetColour(colour); break;
339 case wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR: m_inactive_caption_colour = colour; break;
340 case wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR: m_inactive_caption_gradient_colour = colour; break;
341 case wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR: m_inactive_caption_text_colour = colour; break;
342 case wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR: m_active_caption_colour = colour; break;
343 case wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR: m_active_caption_gradient_colour = colour; break;
344 case wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR: m_active_caption_text_colour = colour; break;
345 case wxAUI_DOCKART_BORDER_COLOUR: m_border_pen.SetColour(colour); break;
346 case wxAUI_DOCKART_GRIPPER_COLOUR:
347 m_gripper_brush.SetColour(colour);
348 m_gripper_pen1.SetColour(colour.ChangeLightness(40));
349 m_gripper_pen2.SetColour(colour.ChangeLightness(60));
350 break;
351 default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
352 }
353
354 InitBitmaps();
355 }
356
357 void wxAuiDefaultDockArt::SetFont(int id, const wxFont& font)
358 {
359 if (id == wxAUI_DOCKART_CAPTION_FONT)
360 m_caption_font = font;
361 }
362
363 wxFont wxAuiDefaultDockArt::GetFont(int id)
364 {
365 if (id == wxAUI_DOCKART_CAPTION_FONT)
366 return m_caption_font;
367 return wxNullFont;
368 }
369
370 void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, const wxRect& rect)
371 {
372 #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
373 wxUnusedVar(window);
374 wxUnusedVar(orientation);
375
376 HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height );
377 CGContextRef cgContext ;
378 wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
379 cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext() ;
380
381 HIThemeSplitterDrawInfo drawInfo ;
382 drawInfo.version = 0 ;
383 drawInfo.state = kThemeStateActive ;
384 drawInfo.adornment = kHIThemeSplitterAdornmentNone ;
385 HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;
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 #if 0
394 GdkRectangle gdk_rect;
395 if (orientation == wxVERTICAL )
396 {
397 gdk_rect.x = rect.x;
398 gdk_rect.y = rect.y;
399 gdk_rect.width = m_sash_size;
400 gdk_rect.height = rect.height;
401 }
402 else
403 {
404 gdk_rect.x = rect.x;
405 gdk_rect.y = rect.y;
406 gdk_rect.width = rect.width;
407 gdk_rect.height = m_sash_size;
408 }
409 #endif
410
411 if (!window) return;
412 if (!window->m_wxwindow) return;
413 if (!GTK_WIDGET_DRAWABLE(window->m_wxwindow)) return;
414
415 gtk_paint_handle
416 (
417 window->m_wxwindow->style,
418 window->GTKGetDrawingWindow(),
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_DOCKART_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 int caption_offset = 0;
551 if ( pane.icon.IsOk() )
552 {
553 DrawIcon(dc, rect, pane);
554
555 caption_offset += pane.icon.GetWidth() + 3;
556 }
557
558 if (pane.state & wxAuiPaneInfo::optionActive)
559 dc.SetTextForeground(m_active_caption_text_colour);
560 else
561 dc.SetTextForeground(m_inactive_caption_text_colour);
562
563
564 wxCoord w,h;
565 dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h);
566
567 wxRect clip_rect = rect;
568 clip_rect.width -= 3; // text offset
569 clip_rect.width -= 2; // button padding
570 if (pane.HasCloseButton())
571 clip_rect.width -= m_button_size;
572 if (pane.HasPinButton())
573 clip_rect.width -= m_button_size;
574 if (pane.HasMaximizeButton())
575 clip_rect.width -= m_button_size;
576
577 wxString draw_text = wxAuiChopText(dc, text, clip_rect.width);
578
579 dc.SetClippingRegion(clip_rect);
580 dc.DrawText(draw_text, rect.x+3 + caption_offset, rect.y+(rect.height/2)-(h/2)-1);
581 dc.DestroyClippingRegion();
582 }
583
584 void
585 wxAuiDefaultDockArt::DrawIcon(wxDC& dc, const wxRect& rect, wxAuiPaneInfo& pane)
586 {
587 // Draw the icon centered vertically
588 dc.DrawBitmap(pane.icon,
589 rect.x+2, rect.y+(rect.height-pane.icon.GetHeight())/2,
590 true);
591 }
592
593 void wxAuiDefaultDockArt::DrawGripper(wxDC& dc, wxWindow *WXUNUSED(window),
594 const wxRect& rect,
595 wxAuiPaneInfo& pane)
596 {
597 dc.SetPen(*wxTRANSPARENT_PEN);
598 dc.SetBrush(m_gripper_brush);
599
600 dc.DrawRectangle(rect.x, rect.y, rect.width,rect.height);
601
602 if (!pane.HasGripperTop())
603 {
604 int y = 5;
605 while (1)
606 {
607 dc.SetPen(m_gripper_pen1);
608 dc.DrawPoint(rect.x+3, rect.y+y);
609 dc.SetPen(m_gripper_pen2);
610 dc.DrawPoint(rect.x+3, rect.y+y+1);
611 dc.DrawPoint(rect.x+4, rect.y+y);
612 dc.SetPen(m_gripper_pen3);
613 dc.DrawPoint(rect.x+5, rect.y+y+1);
614 dc.DrawPoint(rect.x+5, rect.y+y+2);
615 dc.DrawPoint(rect.x+4, rect.y+y+2);
616
617 y += 4;
618 if (y > rect.GetHeight()-5)
619 break;
620 }
621 }
622 else
623 {
624 int x = 5;
625 while (1)
626 {
627 dc.SetPen(m_gripper_pen1);
628 dc.DrawPoint(rect.x+x, rect.y+3);
629 dc.SetPen(m_gripper_pen2);
630 dc.DrawPoint(rect.x+x+1, rect.y+3);
631 dc.DrawPoint(rect.x+x, rect.y+4);
632 dc.SetPen(m_gripper_pen3);
633 dc.DrawPoint(rect.x+x+1, rect.y+5);
634 dc.DrawPoint(rect.x+x+2, rect.y+5);
635 dc.DrawPoint(rect.x+x+2, rect.y+4);
636
637 x += 4;
638 if (x > rect.GetWidth()-5)
639 break;
640 }
641 }
642 }
643
644 void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc, wxWindow *WXUNUSED(window),
645 int button,
646 int button_state,
647 const wxRect& _rect,
648 wxAuiPaneInfo& pane)
649 {
650 wxBitmap bmp;
651 if (!(&pane))
652 return;
653 switch (button)
654 {
655 default:
656 case wxAUI_BUTTON_CLOSE:
657 if (pane.state & wxAuiPaneInfo::optionActive)
658 bmp = m_active_close_bitmap;
659 else
660 bmp = m_inactive_close_bitmap;
661 break;
662 case wxAUI_BUTTON_PIN:
663 if (pane.state & wxAuiPaneInfo::optionActive)
664 bmp = m_active_pin_bitmap;
665 else
666 bmp = m_inactive_pin_bitmap;
667 break;
668 case wxAUI_BUTTON_MAXIMIZE_RESTORE:
669 if (pane.IsMaximized())
670 {
671 if (pane.state & wxAuiPaneInfo::optionActive)
672 bmp = m_active_restore_bitmap;
673 else
674 bmp = m_inactive_restore_bitmap;
675 }
676 else
677 {
678 if (pane.state & wxAuiPaneInfo::optionActive)
679 bmp = m_active_maximize_bitmap;
680 else
681 bmp = m_inactive_maximize_bitmap;
682 }
683 break;
684 }
685
686
687 wxRect rect = _rect;
688
689 int old_y = rect.y;
690 rect.y = rect.y + (rect.height/2) - (bmp.GetHeight()/2);
691 rect.height = old_y + rect.height - rect.y - 1;
692
693
694 if (button_state == wxAUI_BUTTON_STATE_PRESSED)
695 {
696 rect.x++;
697 rect.y++;
698 }
699
700 if (button_state == wxAUI_BUTTON_STATE_HOVER ||
701 button_state == wxAUI_BUTTON_STATE_PRESSED)
702 {
703 if (pane.state & wxAuiPaneInfo::optionActive)
704 {
705 dc.SetBrush(wxBrush(m_active_caption_colour.ChangeLightness(120)));
706 dc.SetPen(wxPen(m_active_caption_colour.ChangeLightness(70)));
707 }
708 else
709 {
710 dc.SetBrush(wxBrush(m_inactive_caption_colour.ChangeLightness(120)));
711 dc.SetPen(wxPen(m_inactive_caption_colour.ChangeLightness(70)));
712 }
713
714 // draw the background behind the button
715 dc.DrawRectangle(rect.x, rect.y, 15, 15);
716 }
717
718
719 // draw the button itself
720 dc.DrawBitmap(bmp, rect.x, rect.y, true);
721 }
722
723
724 #endif // wxUSE_AUI