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