]>
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__ | |
4ae3fe39 | 202 | wxColor base_colour = wxColour( wxMacCreateCGColorFromHITheme(kThemeBrushToolbarBackground)); |
50acee04 | 203 | #else |
b826c7dc | 204 | wxColor base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); |
50acee04 | 205 | #endif |
be66f18e | 206 | |
3f7fce73 BW |
207 | // the base_colour is too pale to use as our base colour, |
208 | // so darken it a bit -- | |
209 | if ((255-base_colour.Red()) + | |
210 | (255-base_colour.Green()) + | |
211 | (255-base_colour.Blue()) < 60) | |
212 | { | |
213 | base_colour = wxAuiStepColour(base_colour, 92); | |
214 | } | |
cedd7b22 | 215 | |
b826c7dc | 216 | m_base_colour = base_colour; |
a500c7ed | 217 | wxColor darker1_colour = wxAuiStepColour(base_colour, 85); |
8096c425 | 218 | wxColor darker2_colour = wxAuiStepColour(base_colour, 75); |
a500c7ed | 219 | wxColor darker3_colour = wxAuiStepColour(base_colour, 60); |
cedd7b22 | 220 | //wxColor darker4_colour = wxAuiStepColour(base_colour, 50); |
a500c7ed | 221 | wxColor darker5_colour = wxAuiStepColour(base_colour, 40); |
50acee04 | 222 | |
dadacb5e | 223 | m_active_caption_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); |
a500c7ed | 224 | m_active_caption_gradient_colour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); |
50acee04 | 225 | m_active_caption_text_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); |
dadacb5e | 226 | m_inactive_caption_colour = darker1_colour; |
a500c7ed | 227 | m_inactive_caption_gradient_colour = wxAuiStepColour(base_colour, 97); |
50acee04 JS |
228 | m_inactive_caption_text_colour = *wxBLACK; |
229 | ||
b826c7dc BW |
230 | m_sash_brush = wxBrush(base_colour); |
231 | m_background_brush = wxBrush(base_colour); | |
232 | m_gripper_brush = wxBrush(base_colour); | |
4ae3fe39 | 233 | |
b826c7dc BW |
234 | m_border_pen = wxPen(darker2_colour); |
235 | m_gripper_pen1 = wxPen(darker5_colour); | |
236 | m_gripper_pen2 = wxPen(darker3_colour); | |
50acee04 JS |
237 | m_gripper_pen3 = *wxWHITE_PEN; |
238 | ||
239 | #ifdef __WXMAC__ | |
240 | m_caption_font = *wxSMALL_FONT; | |
241 | #else | |
242 | m_caption_font = wxFont(8, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE); | |
243 | #endif | |
244 | ||
245 | // some built in bitmaps | |
ff03f567 | 246 | #if defined( __WXMAC__ ) |
50acee04 JS |
247 | static unsigned char close_bits[]={ |
248 | 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x03, 0xF8, 0x01, 0xF0, 0x19, 0xF3, | |
249 | 0xB8, 0xE3, 0xF0, 0xE1, 0xE0, 0xE0, 0xF0, 0xE1, 0xB8, 0xE3, 0x19, 0xF3, | |
250 | 0x01, 0xF0, 0x03, 0xF8, 0x0F, 0xFE, 0xFF, 0xFF }; | |
cedd7b22 PC |
251 | #elif defined(__WXGTK__) |
252 | static unsigned char close_bits[]={ | |
253 | 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xfb, 0xef, 0xdb, 0xed, 0x8b, 0xe8, | |
254 | 0x1b, 0xec, 0x3b, 0xee, 0x1b, 0xec, 0x8b, 0xe8, 0xdb, 0xed, 0xfb, 0xef, | |
255 | 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | |
50acee04 JS |
256 | #else |
257 | static unsigned char close_bits[]={ | |
8896cb72 BW |
258 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xf3, 0xcf, 0xf9, |
259 | 0x9f, 0xfc, 0x3f, 0xfe, 0x3f, 0xfe, 0x9f, 0xfc, 0xcf, 0xf9, 0xe7, 0xf3, | |
260 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
50acee04 JS |
261 | #endif |
262 | ||
37106ab2 BW |
263 | static unsigned char maximize_bits[] = { |
264 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xf7, 0xf7, 0x07, 0xf0, | |
265 | 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0x07, 0xf0, | |
266 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
267 | ||
268 | static unsigned char restore_bits[]={ | |
269 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0x1f, 0xf0, 0xdf, 0xf7, | |
270 | 0x07, 0xf4, 0x07, 0xf4, 0xf7, 0xf5, 0xf7, 0xf1, 0xf7, 0xfd, 0xf7, 0xfd, | |
271 | 0x07, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
cedd7b22 | 272 | |
50acee04 JS |
273 | static unsigned char pin_bits[]={ |
274 | 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0xdf,0xfc,0xdf,0xfc, | |
275 | 0xdf,0xfc,0xdf,0xfc,0xdf,0xfc,0x0f,0xf8,0x7f,0xff,0x7f,0xff, | |
276 | 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; | |
be66f18e | 277 | |
50acee04 | 278 | #ifdef __WXMAC__ |
a500c7ed BW |
279 | m_inactive_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE); |
280 | m_active_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE ); | |
50acee04 | 281 | #else |
a500c7ed BW |
282 | m_inactive_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_inactive_caption_text_colour); |
283 | m_active_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_active_caption_text_colour); | |
50acee04 | 284 | #endif |
37106ab2 | 285 | |
50acee04 | 286 | #ifdef __WXMAC__ |
a500c7ed BW |
287 | m_inactive_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE); |
288 | m_active_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE ); | |
50acee04 | 289 | #else |
a500c7ed BW |
290 | m_inactive_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_inactive_caption_text_colour); |
291 | m_active_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_active_caption_text_colour); | |
50acee04 | 292 | #endif |
37106ab2 BW |
293 | |
294 | #ifdef __WXMAC__ | |
a500c7ed BW |
295 | m_inactive_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE); |
296 | m_active_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE ); | |
37106ab2 | 297 | #else |
a500c7ed BW |
298 | m_inactive_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_inactive_caption_text_colour); |
299 | m_active_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_active_caption_text_colour); | |
37106ab2 BW |
300 | #endif |
301 | ||
a500c7ed BW |
302 | m_inactive_pin_bitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_inactive_caption_text_colour); |
303 | m_active_pin_bitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_active_caption_text_colour); | |
50acee04 JS |
304 | |
305 | // default metric values | |
32205ebb | 306 | #if defined(__WXMAC__) |
50acee04 JS |
307 | SInt32 height; |
308 | GetThemeMetric( kThemeMetricSmallPaneSplitterHeight , &height ); | |
309 | m_sash_size = height; | |
32205ebb RR |
310 | #elif defined(__WXGTK__) |
311 | m_sash_size = wxRendererNative::Get().GetSplitterParams(NULL).widthSash; | |
50acee04 JS |
312 | #else |
313 | m_sash_size = 4; | |
314 | #endif | |
315 | m_caption_size = 17; | |
316 | m_border_size = 1; | |
317 | m_button_size = 14; | |
318 | m_gripper_size = 9; | |
319 | m_gradient_type = wxAUI_GRADIENT_VERTICAL; | |
320 | } | |
321 | ||
a3a5df9d | 322 | int wxAuiDefaultDockArt::GetMetric(int id) |
50acee04 JS |
323 | { |
324 | switch (id) | |
325 | { | |
254a3429 BW |
326 | case wxAUI_DOCKART_SASH_SIZE: return m_sash_size; |
327 | case wxAUI_DOCKART_CAPTION_SIZE: return m_caption_size; | |
328 | case wxAUI_DOCKART_GRIPPER_SIZE: return m_gripper_size; | |
329 | case wxAUI_DOCKART_PANE_BORDER_SIZE: return m_border_size; | |
330 | case wxAUI_DOCKART_PANE_BUTTON_SIZE: return m_button_size; | |
331 | case wxAUI_DOCKART_GRADIENT_TYPE: return m_gradient_type; | |
50acee04 JS |
332 | default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break; |
333 | } | |
334 | ||
335 | return 0; | |
336 | } | |
337 | ||
a3a5df9d | 338 | void wxAuiDefaultDockArt::SetMetric(int id, int new_val) |
50acee04 JS |
339 | { |
340 | switch (id) | |
341 | { | |
254a3429 BW |
342 | case wxAUI_DOCKART_SASH_SIZE: m_sash_size = new_val; break; |
343 | case wxAUI_DOCKART_CAPTION_SIZE: m_caption_size = new_val; break; | |
344 | case wxAUI_DOCKART_GRIPPER_SIZE: m_gripper_size = new_val; break; | |
345 | case wxAUI_DOCKART_PANE_BORDER_SIZE: m_border_size = new_val; break; | |
346 | case wxAUI_DOCKART_PANE_BUTTON_SIZE: m_button_size = new_val; break; | |
347 | case wxAUI_DOCKART_GRADIENT_TYPE: m_gradient_type = new_val; break; | |
50acee04 JS |
348 | default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break; |
349 | } | |
350 | } | |
351 | ||
a3a5df9d | 352 | wxColour wxAuiDefaultDockArt::GetColour(int id) |
50acee04 JS |
353 | { |
354 | switch (id) | |
355 | { | |
254a3429 BW |
356 | case wxAUI_DOCKART_BACKGROUND_COLOUR: return m_background_brush.GetColour(); |
357 | case wxAUI_DOCKART_SASH_COLOUR: return m_sash_brush.GetColour(); | |
358 | case wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR: return m_inactive_caption_colour; | |
359 | case wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR: return m_inactive_caption_gradient_colour; | |
360 | case wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR: return m_inactive_caption_text_colour; | |
361 | case wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR: return m_active_caption_colour; | |
362 | case wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR: return m_active_caption_gradient_colour; | |
363 | case wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR: return m_active_caption_text_colour; | |
364 | case wxAUI_DOCKART_BORDER_COLOUR: return m_border_pen.GetColour(); | |
365 | case wxAUI_DOCKART_GRIPPER_COLOUR: return m_gripper_brush.GetColour(); | |
50acee04 JS |
366 | default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break; |
367 | } | |
368 | ||
369 | return wxColour(); | |
370 | } | |
371 | ||
a3a5df9d | 372 | void wxAuiDefaultDockArt::SetColour(int id, const wxColor& colour) |
50acee04 JS |
373 | { |
374 | switch (id) | |
375 | { | |
254a3429 BW |
376 | case wxAUI_DOCKART_BACKGROUND_COLOUR: m_background_brush.SetColour(colour); break; |
377 | case wxAUI_DOCKART_SASH_COLOUR: m_sash_brush.SetColour(colour); break; | |
378 | case wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR: m_inactive_caption_colour = colour; break; | |
379 | case wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR: m_inactive_caption_gradient_colour = colour; break; | |
380 | case wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR: m_inactive_caption_text_colour = colour; break; | |
381 | case wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR: m_active_caption_colour = colour; break; | |
382 | case wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR: m_active_caption_gradient_colour = colour; break; | |
383 | case wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR: m_active_caption_text_colour = colour; break; | |
384 | case wxAUI_DOCKART_BORDER_COLOUR: m_border_pen.SetColour(colour); break; | |
385 | case wxAUI_DOCKART_GRIPPER_COLOUR: | |
50acee04 | 386 | m_gripper_brush.SetColour(colour); |
a500c7ed BW |
387 | m_gripper_pen1.SetColour(wxAuiStepColour(colour, 40)); |
388 | m_gripper_pen2.SetColour(wxAuiStepColour(colour, 60)); | |
50acee04 JS |
389 | break; |
390 | default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break; | |
391 | } | |
392 | } | |
393 | ||
a3a5df9d | 394 | void wxAuiDefaultDockArt::SetFont(int id, const wxFont& font) |
50acee04 | 395 | { |
254a3429 | 396 | if (id == wxAUI_DOCKART_CAPTION_FONT) |
50acee04 JS |
397 | m_caption_font = font; |
398 | } | |
399 | ||
a3a5df9d | 400 | wxFont wxAuiDefaultDockArt::GetFont(int id) |
50acee04 | 401 | { |
254a3429 | 402 | if (id == wxAUI_DOCKART_CAPTION_FONT) |
50acee04 JS |
403 | return m_caption_font; |
404 | return wxNullFont; | |
405 | } | |
406 | ||
a3a5df9d | 407 | void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, const wxRect& rect) |
50acee04 | 408 | { |
32205ebb | 409 | #if defined(__WXMAC__) |
8a088306 VZ |
410 | wxUnusedVar(window); |
411 | wxUnusedVar(orientation); | |
412 | ||
50acee04 JS |
413 | HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height ); |
414 | CGContextRef cgContext ; | |
888dde65 RR |
415 | wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl(); |
416 | cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext() ; | |
be66f18e | 417 | |
50acee04 JS |
418 | HIThemeSplitterDrawInfo drawInfo ; |
419 | drawInfo.version = 0 ; | |
420 | drawInfo.state = kThemeStateActive ; | |
421 | drawInfo.adornment = kHIThemeSplitterAdornmentNone ; | |
be66f18e WS |
422 | HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ; |
423 | ||
32205ebb | 424 | #elif defined(__WXGTK__) |
8e367bbf BW |
425 | // clear out the rectangle first |
426 | dc.SetPen(*wxTRANSPARENT_PEN); | |
427 | dc.SetBrush(m_sash_brush); | |
428 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
32205ebb | 429 | |
cedd7b22 | 430 | #if 0 |
32205ebb RR |
431 | GdkRectangle gdk_rect; |
432 | if (orientation == wxVERTICAL ) | |
433 | { | |
434 | gdk_rect.x = rect.x; | |
435 | gdk_rect.y = rect.y; | |
436 | gdk_rect.width = m_sash_size; | |
437 | gdk_rect.height = rect.height; | |
438 | } | |
439 | else | |
440 | { | |
441 | gdk_rect.x = rect.x; | |
442 | gdk_rect.y = rect.y; | |
443 | gdk_rect.width = rect.width; | |
444 | gdk_rect.height = m_sash_size; | |
445 | } | |
cedd7b22 | 446 | #endif |
32205ebb RR |
447 | |
448 | if (!window) return; | |
449 | if (!window->m_wxwindow) return; | |
08f53168 | 450 | if (!GTK_WIDGET_DRAWABLE(window->m_wxwindow)) return; |
32205ebb RR |
451 | |
452 | gtk_paint_handle | |
453 | ( | |
454 | window->m_wxwindow->style, | |
08f53168 | 455 | window->GTKGetDrawingWindow(), |
32205ebb RR |
456 | // flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, |
457 | GTK_STATE_NORMAL, | |
458 | GTK_SHADOW_NONE, | |
459 | NULL /* no clipping */, | |
460 | window->m_wxwindow, | |
461 | "paned", | |
462 | rect.x, | |
463 | rect.y, | |
464 | rect.width, | |
465 | rect.height, | |
466 | (orientation == wxVERTICAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL | |
467 | ); | |
468 | ||
50acee04 | 469 | #else |
eec7f412 WS |
470 | wxUnusedVar(window); |
471 | wxUnusedVar(orientation); | |
50acee04 JS |
472 | dc.SetPen(*wxTRANSPARENT_PEN); |
473 | dc.SetBrush(m_sash_brush); | |
474 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
475 | #endif | |
476 | } | |
477 | ||
478 | ||
a3a5df9d | 479 | void wxAuiDefaultDockArt::DrawBackground(wxDC& dc, wxWindow *WXUNUSED(window), int, const wxRect& rect) |
50acee04 JS |
480 | { |
481 | dc.SetPen(*wxTRANSPARENT_PEN); | |
482 | #ifdef __WXMAC__ | |
483 | // we have to clear first, otherwise we are drawing a light striped pattern | |
484 | // over an already darker striped background | |
485 | dc.SetBrush(*wxWHITE_BRUSH) ; | |
486 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
487 | #endif | |
488 | dc.SetBrush(m_background_brush); | |
489 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
490 | } | |
491 | ||
a3a5df9d BW |
492 | void wxAuiDefaultDockArt::DrawBorder(wxDC& dc, wxWindow *WXUNUSED(window), const wxRect& _rect, |
493 | wxAuiPaneInfo& pane) | |
50acee04 JS |
494 | { |
495 | dc.SetPen(m_border_pen); | |
496 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | |
497 | ||
498 | wxRect rect = _rect; | |
254a3429 | 499 | int i, border_width = GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE); |
50acee04 JS |
500 | |
501 | if (pane.IsToolbar()) | |
502 | { | |
503 | for (i = 0; i < border_width; ++i) | |
504 | { | |
505 | dc.SetPen(*wxWHITE_PEN); | |
506 | dc.DrawLine(rect.x, rect.y, rect.x+rect.width, rect.y); | |
507 | dc.DrawLine(rect.x, rect.y, rect.x, rect.y+rect.height); | |
be66f18e | 508 | dc.SetPen(m_border_pen); |
50acee04 JS |
509 | dc.DrawLine(rect.x, rect.y+rect.height-1, |
510 | rect.x+rect.width, rect.y+rect.height-1); | |
511 | dc.DrawLine(rect.x+rect.width-1, rect.y, | |
512 | rect.x+rect.width-1, rect.y+rect.height); | |
513 | rect.Deflate(1); | |
514 | } | |
515 | } | |
696978ee | 516 | else |
50acee04 JS |
517 | { |
518 | for (i = 0; i < border_width; ++i) | |
519 | { | |
520 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
521 | rect.Deflate(1); | |
522 | } | |
523 | } | |
524 | } | |
525 | ||
526 | ||
a3a5df9d | 527 | void wxAuiDefaultDockArt::DrawCaptionBackground(wxDC& dc, const wxRect& rect, bool active) |
50acee04 JS |
528 | { |
529 | if (m_gradient_type == wxAUI_GRADIENT_NONE) | |
530 | { | |
531 | if (active) | |
532 | dc.SetBrush(wxBrush(m_active_caption_colour)); | |
cedd7b22 | 533 | else |
50acee04 JS |
534 | dc.SetBrush(wxBrush(m_inactive_caption_colour)); |
535 | ||
536 | dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); | |
537 | } | |
696978ee | 538 | else |
50acee04 JS |
539 | { |
540 | if (active) | |
541 | { | |
542 | // on mac the gradients are expected to become darker from the top | |
543 | #ifdef __WXMAC__ | |
544 | DrawGradientRectangle(dc, rect, | |
50acee04 | 545 | m_active_caption_colour, |
dadacb5e | 546 | m_active_caption_gradient_colour, |
50acee04 JS |
547 | m_gradient_type); |
548 | #else | |
dadacb5e | 549 | // on other platforms, active gradients become lighter at the top |
50acee04 | 550 | DrawGradientRectangle(dc, rect, |
50acee04 | 551 | m_active_caption_gradient_colour, |
dadacb5e | 552 | m_active_caption_colour, |
50acee04 JS |
553 | m_gradient_type); |
554 | #endif | |
555 | } | |
cedd7b22 | 556 | else |
50acee04 | 557 | { |
50acee04 | 558 | #ifdef __WXMAC__ |
dadacb5e | 559 | // on mac the gradients are expected to become darker from the top |
50acee04 JS |
560 | DrawGradientRectangle(dc, rect, |
561 | m_inactive_caption_gradient_colour, | |
562 | m_inactive_caption_colour, | |
563 | m_gradient_type); | |
564 | #else | |
dadacb5e | 565 | // on other platforms, inactive gradients become lighter at the bottom |
50acee04 JS |
566 | DrawGradientRectangle(dc, rect, |
567 | m_inactive_caption_colour, | |
568 | m_inactive_caption_gradient_colour, | |
569 | m_gradient_type); | |
570 | #endif | |
571 | } | |
572 | } | |
573 | } | |
574 | ||
575 | ||
a3a5df9d | 576 | void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxWindow *WXUNUSED(window), |
50acee04 JS |
577 | const wxString& text, |
578 | const wxRect& rect, | |
a3a5df9d | 579 | wxAuiPaneInfo& pane) |
50acee04 JS |
580 | { |
581 | dc.SetPen(*wxTRANSPARENT_PEN); | |
582 | dc.SetFont(m_caption_font); | |
583 | ||
584 | DrawCaptionBackground(dc, rect, | |
a3a5df9d | 585 | (pane.state & wxAuiPaneInfo::optionActive)?true:false); |
50acee04 | 586 | |
a3a5df9d | 587 | if (pane.state & wxAuiPaneInfo::optionActive) |
50acee04 | 588 | dc.SetTextForeground(m_active_caption_text_colour); |
696978ee | 589 | else |
50acee04 JS |
590 | dc.SetTextForeground(m_inactive_caption_text_colour); |
591 | ||
592 | ||
593 | wxCoord w,h; | |
594 | dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h); | |
595 | ||
50d5ad7d BW |
596 | wxRect clip_rect = rect; |
597 | clip_rect.width -= 3; // text offset | |
598 | clip_rect.width -= 2; // button padding | |
599 | if (pane.HasCloseButton()) | |
600 | clip_rect.width -= m_button_size; | |
601 | if (pane.HasPinButton()) | |
cedd7b22 | 602 | clip_rect.width -= m_button_size; |
50d5ad7d | 603 | if (pane.HasMaximizeButton()) |
cedd7b22 | 604 | clip_rect.width -= m_button_size; |
50d5ad7d | 605 | |
a500c7ed | 606 | wxString draw_text = wxAuiChopText(dc, text, clip_rect.width); |
50d5ad7d BW |
607 | |
608 | dc.SetClippingRegion(clip_rect); | |
609 | dc.DrawText(draw_text, rect.x+3, rect.y+(rect.height/2)-(h/2)-1); | |
50acee04 JS |
610 | dc.DestroyClippingRegion(); |
611 | } | |
612 | ||
a3a5df9d | 613 | void wxAuiDefaultDockArt::DrawGripper(wxDC& dc, wxWindow *WXUNUSED(window), |
50acee04 | 614 | const wxRect& rect, |
a3a5df9d | 615 | wxAuiPaneInfo& pane) |
50acee04 JS |
616 | { |
617 | dc.SetPen(*wxTRANSPARENT_PEN); | |
618 | dc.SetBrush(m_gripper_brush); | |
619 | ||
620 | dc.DrawRectangle(rect.x, rect.y, rect.width,rect.height); | |
621 | ||
622 | if (!pane.HasGripperTop()) | |
623 | { | |
624 | int y = 5; | |
625 | while (1) | |
626 | { | |
627 | dc.SetPen(m_gripper_pen1); | |
628 | dc.DrawPoint(rect.x+3, rect.y+y); | |
629 | dc.SetPen(m_gripper_pen2); | |
630 | dc.DrawPoint(rect.x+3, rect.y+y+1); | |
631 | dc.DrawPoint(rect.x+4, rect.y+y); | |
632 | dc.SetPen(m_gripper_pen3); | |
633 | dc.DrawPoint(rect.x+5, rect.y+y+1); | |
634 | dc.DrawPoint(rect.x+5, rect.y+y+2); | |
635 | dc.DrawPoint(rect.x+4, rect.y+y+2); | |
636 | ||
637 | y += 4; | |
638 | if (y > rect.GetHeight()-5) | |
639 | break; | |
640 | } | |
641 | } | |
642 | else | |
643 | { | |
644 | int x = 5; | |
645 | while (1) | |
646 | { | |
647 | dc.SetPen(m_gripper_pen1); | |
648 | dc.DrawPoint(rect.x+x, rect.y+3); | |
649 | dc.SetPen(m_gripper_pen2); | |
650 | dc.DrawPoint(rect.x+x+1, rect.y+3); | |
651 | dc.DrawPoint(rect.x+x, rect.y+4); | |
652 | dc.SetPen(m_gripper_pen3); | |
653 | dc.DrawPoint(rect.x+x+1, rect.y+5); | |
654 | dc.DrawPoint(rect.x+x+2, rect.y+5); | |
655 | dc.DrawPoint(rect.x+x+2, rect.y+4); | |
656 | ||
657 | x += 4; | |
658 | if (x > rect.GetWidth()-5) | |
659 | break; | |
660 | } | |
661 | } | |
662 | } | |
663 | ||
a3a5df9d | 664 | void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc, wxWindow *WXUNUSED(window), |
50acee04 JS |
665 | int button, |
666 | int button_state, | |
667 | const wxRect& _rect, | |
a3a5df9d | 668 | wxAuiPaneInfo& pane) |
50acee04 | 669 | { |
2b4b6ded | 670 | wxBitmap bmp; |
cedd7b22 PC |
671 | if (!(&pane)) |
672 | return; | |
2b4b6ded BW |
673 | switch (button) |
674 | { | |
675 | default: | |
676 | case wxAUI_BUTTON_CLOSE: | |
677 | if (pane.state & wxAuiPaneInfo::optionActive) | |
678 | bmp = m_active_close_bitmap; | |
cedd7b22 | 679 | else |
2b4b6ded BW |
680 | bmp = m_inactive_close_bitmap; |
681 | break; | |
682 | case wxAUI_BUTTON_PIN: | |
683 | if (pane.state & wxAuiPaneInfo::optionActive) | |
684 | bmp = m_active_pin_bitmap; | |
cedd7b22 | 685 | else |
2b4b6ded BW |
686 | bmp = m_inactive_pin_bitmap; |
687 | break; | |
688 | case wxAUI_BUTTON_MAXIMIZE_RESTORE: | |
689 | if (pane.IsMaximized()) | |
690 | { | |
691 | if (pane.state & wxAuiPaneInfo::optionActive) | |
692 | bmp = m_active_restore_bitmap; | |
cedd7b22 | 693 | else |
2b4b6ded BW |
694 | bmp = m_inactive_restore_bitmap; |
695 | } | |
cedd7b22 | 696 | else |
2b4b6ded BW |
697 | { |
698 | if (pane.state & wxAuiPaneInfo::optionActive) | |
699 | bmp = m_active_maximize_bitmap; | |
cedd7b22 | 700 | else |
2b4b6ded BW |
701 | bmp = m_inactive_maximize_bitmap; |
702 | } | |
703 | break; | |
704 | } | |
705 | ||
706 | ||
50acee04 JS |
707 | wxRect rect = _rect; |
708 | ||
2b4b6ded BW |
709 | int old_y = rect.y; |
710 | rect.y = rect.y + (rect.height/2) - (bmp.GetHeight()/2); | |
711 | rect.height = old_y + rect.height - rect.y - 1; | |
712 | ||
713 | ||
50acee04 JS |
714 | if (button_state == wxAUI_BUTTON_STATE_PRESSED) |
715 | { | |
716 | rect.x++; | |
717 | rect.y++; | |
718 | } | |
719 | ||
720 | if (button_state == wxAUI_BUTTON_STATE_HOVER || | |
721 | button_state == wxAUI_BUTTON_STATE_PRESSED) | |
722 | { | |
a3a5df9d | 723 | if (pane.state & wxAuiPaneInfo::optionActive) |
50acee04 | 724 | { |
a500c7ed BW |
725 | dc.SetBrush(wxBrush(wxAuiStepColour(m_active_caption_colour, 120))); |
726 | dc.SetPen(wxPen(wxAuiStepColour(m_active_caption_colour, 70))); | |
50acee04 | 727 | } |
cedd7b22 | 728 | else |
50acee04 | 729 | { |
a500c7ed BW |
730 | dc.SetBrush(wxBrush(wxAuiStepColour(m_inactive_caption_colour, 120))); |
731 | dc.SetPen(wxPen(wxAuiStepColour(m_inactive_caption_colour, 70))); | |
50acee04 JS |
732 | } |
733 | ||
734 | // draw the background behind the button | |
735 | dc.DrawRectangle(rect.x, rect.y, 15, 15); | |
736 | } | |
737 | ||
50acee04 JS |
738 | |
739 | // draw the button itself | |
740 | dc.DrawBitmap(bmp, rect.x, rect.y, true); | |
741 | } | |
742 | ||
743 | ||
744 | #endif // wxUSE_AUI |