]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
a71d815b | 2 | // Name: src/generic/statusbr.cpp |
ed791986 | 3 | // Purpose: wxStatusBarGeneric class implementation |
c801d85f | 4 | // Author: Julian Smart |
c94bdf2a | 5 | // Modified by: Francesco Montorsi |
c801d85f KB |
6 | // Created: 01/02/97 |
7 | // RCS-ID: $Id$ | |
6aa89a22 | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
c801d85f KB |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
76b49cf4 | 16 | #pragma hdrstop |
c801d85f KB |
17 | #endif |
18 | ||
1e6feb95 | 19 | #if wxUSE_STATUSBAR |
ed791986 | 20 | |
3304646d WS |
21 | #include "wx/statusbr.h" |
22 | ||
c801d85f | 23 | #ifndef WX_PRECOMP |
76b49cf4 WS |
24 | #include "wx/settings.h" |
25 | #include "wx/dcclient.h" | |
a0125cfc | 26 | #include "wx/toplevel.h" |
c34d2f35 | 27 | #include "wx/control.h" |
c801d85f KB |
28 | #endif |
29 | ||
2b5f62a0 | 30 | #ifdef __WXGTK20__ |
53b6d7a2 | 31 | #include <gtk/gtk.h> |
c94bdf2a | 32 | #include "wx/gtk/private.h" |
9dc44eff | 33 | #include "wx/gtk/private/gtk2-compat.h" |
2b5f62a0 VZ |
34 | #endif |
35 | ||
84f68c21 VZ |
36 | // we only have to do it here when we use wxStatusBarGeneric in addition to the |
37 | // standard wxStatusBar class, if wxStatusBarGeneric is the same as | |
38 | // wxStatusBar, then the corresponding IMPLEMENT_DYNAMIC_CLASS is already in | |
39 | // common/statbar.cpp | |
40 | #if defined(__WXMAC__) || \ | |
41 | (defined(wxUSE_NATIVE_STATUSBAR) && wxUSE_NATIVE_STATUSBAR) | |
b64a8473 | 42 | #include "wx/generic/statusbr.h" |
c801d85f | 43 | |
b64a8473 VZ |
44 | IMPLEMENT_DYNAMIC_CLASS(wxStatusBarGeneric, wxWindow) |
45 | #endif // wxUSE_NATIVE_STATUSBAR | |
ed791986 | 46 | |
7b6fefbe FM |
47 | // Default status border dimensions |
48 | #define wxTHICK_LINE_BORDER 2 | |
49 | ||
78612fa6 FM |
50 | // Margin between the field text and the field rect |
51 | #define wxFIELD_TEXT_MARGIN 2 | |
52 | ||
c94bdf2a FM |
53 | // ---------------------------------------------------------------------------- |
54 | // GTK+ signal handler | |
55 | // ---------------------------------------------------------------------------- | |
56 | ||
2d0a9aa4 FM |
57 | #if defined( __WXGTK20__ ) |
58 | #if GTK_CHECK_VERSION(2,12,0) | |
c94bdf2a FM |
59 | extern "C" { |
60 | static | |
c4c178c1 | 61 | gboolean statusbar_query_tooltip(GtkWidget* WXUNUSED(widget), |
c94bdf2a FM |
62 | gint x, |
63 | gint y, | |
c4c178c1 | 64 | gboolean WXUNUSED(keyboard_mode), |
c94bdf2a FM |
65 | GtkTooltip *tooltip, |
66 | wxStatusBar* statbar) | |
67 | { | |
68 | int n = statbar->GetFieldFromPoint(wxPoint(x,y)); | |
69 | if (n == wxNOT_FOUND) | |
70 | return FALSE; | |
71 | ||
72 | // should we show the tooltip for the n-th pane of the statusbar? | |
73 | if (!statbar->GetField(n).IsEllipsized()) | |
74 | return FALSE; // no, it's not useful | |
75 | ||
c4c178c1 FM |
76 | const wxString& str = statbar->GetStatusText(n); |
77 | if (str.empty()) | |
78 | return FALSE; | |
03647350 | 79 | |
c4c178c1 | 80 | gtk_tooltip_set_text(tooltip, wxGTK_CONV_SYS(str)); |
c94bdf2a FM |
81 | return TRUE; |
82 | } | |
83 | } | |
84 | #endif | |
2d0a9aa4 | 85 | #endif |
7b6fefbe FM |
86 | |
87 | // ---------------------------------------------------------------------------- | |
88 | // wxStatusBarGeneric | |
89 | // ---------------------------------------------------------------------------- | |
90 | ||
ed791986 VZ |
91 | BEGIN_EVENT_TABLE(wxStatusBarGeneric, wxWindow) |
92 | EVT_PAINT(wxStatusBarGeneric::OnPaint) | |
ba4589db | 93 | EVT_SIZE(wxStatusBarGeneric::OnSize) |
9dc44eff | 94 | #ifdef __WXGTK20__ |
2b5f62a0 VZ |
95 | EVT_LEFT_DOWN(wxStatusBarGeneric::OnLeftDown) |
96 | EVT_RIGHT_DOWN(wxStatusBarGeneric::OnRightDown) | |
9dc44eff | 97 | #endif |
ed791986 | 98 | EVT_SYS_COLOUR_CHANGED(wxStatusBarGeneric::OnSysColourChanged) |
c801d85f | 99 | END_EVENT_TABLE() |
c801d85f | 100 | |
390015c0 | 101 | void wxStatusBarGeneric::Init() |
c801d85f | 102 | { |
48f7ffbe WS |
103 | m_borderX = wxTHICK_LINE_BORDER; |
104 | m_borderY = wxTHICK_LINE_BORDER; | |
c801d85f KB |
105 | } |
106 | ||
ed791986 | 107 | wxStatusBarGeneric::~wxStatusBarGeneric() |
c801d85f | 108 | { |
c801d85f KB |
109 | } |
110 | ||
ed791986 | 111 | bool wxStatusBarGeneric::Create(wxWindow *parent, |
76880b87 RL |
112 | wxWindowID id, |
113 | long style, | |
114 | const wxString& name) | |
c801d85f | 115 | { |
53b6d7a2 | 116 | style |= wxTAB_TRAVERSAL | wxFULL_REPAINT_ON_RESIZE; |
48f7ffbe WS |
117 | if ( !wxWindow::Create(parent, id, |
118 | wxDefaultPosition, wxDefaultSize, | |
53b6d7a2 | 119 | style, name) ) |
48f7ffbe | 120 | return false; |
c801d85f | 121 | |
48f7ffbe WS |
122 | // The status bar should have a themed background |
123 | SetThemeEnabled( true ); | |
124 | ||
125 | InitColours(); | |
f90566f5 | 126 | |
1ca21594 | 127 | #ifdef __WXPM__ |
48f7ffbe | 128 | SetFont(*wxSMALL_FONT); |
1ca21594 | 129 | #endif |
c801d85f | 130 | |
ba4589db | 131 | int height = (int)((11*GetCharHeight())/10 + 2*GetBorderY()); |
48f7ffbe | 132 | SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height); |
71e03035 | 133 | |
48f7ffbe | 134 | SetFieldsCount(1); |
03647350 | 135 | |
2d0a9aa4 FM |
136 | #if defined( __WXGTK20__ ) |
137 | #if GTK_CHECK_VERSION(2,12,0) | |
9dc44eff PC |
138 | if (HasFlag(wxSTB_SHOW_TIPS) |
139 | #ifndef __WXGTK3__ | |
140 | && gtk_check_version(2,12,0) == NULL | |
141 | #endif | |
142 | ) | |
c94bdf2a | 143 | { |
03647350 VZ |
144 | g_object_set(m_widget, "has-tooltip", TRUE, NULL); |
145 | g_signal_connect(m_widget, "query-tooltip", | |
146 | G_CALLBACK(statusbar_query_tooltip), this); | |
c94bdf2a | 147 | } |
2d0a9aa4 | 148 | #endif |
c94bdf2a | 149 | #endif |
8aa2cea1 | 150 | |
48f7ffbe | 151 | return true; |
c801d85f KB |
152 | } |
153 | ||
595a9493 RD |
154 | wxSize wxStatusBarGeneric::DoGetBestSize() const |
155 | { | |
156 | int width, height; | |
157 | ||
158 | // best width is the width of the parent | |
ba4589db FM |
159 | if (GetParent()) |
160 | GetParent()->GetClientSize(&width, NULL); | |
161 | else | |
162 | width = 80; // a dummy value | |
595a9493 | 163 | |
9a6aafe0 | 164 | // best height is as calculated above in Create() |
ba4589db | 165 | height = (int)((11*GetCharHeight())/10 + 2*GetBorderY()); |
595a9493 RD |
166 | |
167 | return wxSize(width, height); | |
ca65c044 | 168 | } |
595a9493 | 169 | |
6cf68971 | 170 | void wxStatusBarGeneric::DoUpdateStatusText(int number) |
c801d85f | 171 | { |
6cf68971 VZ |
172 | wxRect rect; |
173 | GetFieldRect(number, rect); | |
76880b87 | 174 | |
6cf68971 | 175 | Refresh(true, &rect); |
e715f4e7 | 176 | |
6cf68971 VZ |
177 | // it's common to show some text in the status bar before starting a |
178 | // relatively lengthy operation, ensure that the text is shown to the | |
179 | // user immediately and not after the lengthy operation end | |
180 | Update(); | |
c801d85f KB |
181 | } |
182 | ||
ed791986 | 183 | void wxStatusBarGeneric::SetStatusWidths(int n, const int widths_field[]) |
c801d85f | 184 | { |
7b6fefbe | 185 | // only set status widths when n == number of statuswindows |
9a83f860 | 186 | wxCHECK_RET( (size_t)n == m_panes.GetCount(), wxT("status bar field count mismatch") ); |
633d67bb | 187 | |
1f361cdd | 188 | wxStatusBarBase::SetStatusWidths(n, widths_field); |
0cd15959 FM |
189 | |
190 | // update cache | |
8e8d9109 VZ |
191 | DoUpdateFieldWidths(); |
192 | } | |
193 | ||
194 | void wxStatusBarGeneric::DoUpdateFieldWidths() | |
195 | { | |
196 | m_lastClientSize = GetClientSize(); | |
197 | ||
198 | // recompute the cache of the field widths if the status bar width has changed | |
199 | m_widthsAbs = CalculateAbsWidths(m_lastClientSize.x); | |
c801d85f KB |
200 | } |
201 | ||
7422d7c4 VZ |
202 | bool wxStatusBarGeneric::ShowsSizeGrip() const |
203 | { | |
c4c178c1 | 204 | if ( !HasFlag(wxSTB_SIZEGRIP) ) |
7422d7c4 VZ |
205 | return false; |
206 | ||
207 | wxTopLevelWindow * const | |
208 | tlw = wxDynamicCast(wxGetTopLevelParent(GetParent()), wxTopLevelWindow); | |
209 | return tlw && !tlw->IsMaximized() && tlw->HasFlag(wxRESIZE_BORDER); | |
210 | } | |
211 | ||
ba4589db | 212 | void wxStatusBarGeneric::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight) |
c801d85f | 213 | { |
ba4589db FM |
214 | wxString text(GetStatusText(i)); |
215 | if (text.empty()) | |
216 | return; // optimization | |
c801d85f | 217 | |
ba4589db FM |
218 | int xpos = rect.x + wxFIELD_TEXT_MARGIN, |
219 | maxWidth = rect.width - 2*wxFIELD_TEXT_MARGIN, | |
220 | ypos = (int) (((rect.height - textHeight) / 2) + rect.y + 0.5); | |
78612fa6 FM |
221 | |
222 | if (ShowsSizeGrip()) | |
223 | { | |
224 | // don't write text over the size grip: | |
225 | // NOTE: overloading DoGetClientSize() and GetClientAreaOrigin() wouldn't | |
226 | // work because the adjustment needs to be done only when drawing | |
227 | // the field text and not also when drawing the background, the | |
228 | // size grip itself, etc | |
ba4589db FM |
229 | if ((GetLayoutDirection() == wxLayout_RightToLeft && i == 0) || |
230 | (GetLayoutDirection() != wxLayout_RightToLeft && | |
231 | i == (int)m_panes.GetCount()-1)) | |
78612fa6 | 232 | { |
ba4589db | 233 | const wxRect& gripRc = GetSizeGripRect(); |
78612fa6 | 234 | |
ba4589db FM |
235 | // NOTE: we don't need any special treatment wrt to the layout direction |
236 | // since DrawText() will automatically adjust the origin of the | |
237 | // text accordingly to the layout in use | |
78612fa6 | 238 | |
ba4589db | 239 | maxWidth -= gripRc.width; |
78612fa6 FM |
240 | } |
241 | } | |
242 | ||
243 | // eventually ellipsize the text so that it fits the field width | |
03647350 | 244 | |
c4c178c1 FM |
245 | wxEllipsizeMode ellmode = (wxEllipsizeMode)-1; |
246 | if (HasFlag(wxSTB_ELLIPSIZE_START)) ellmode = wxELLIPSIZE_START; | |
247 | else if (HasFlag(wxSTB_ELLIPSIZE_MIDDLE)) ellmode = wxELLIPSIZE_MIDDLE; | |
248 | else if (HasFlag(wxSTB_ELLIPSIZE_END)) ellmode = wxELLIPSIZE_END; | |
249 | ||
250 | if (ellmode == (wxEllipsizeMode)-1) | |
251 | { | |
252 | // if we have the wxSTB_SHOW_TIPS we must set the ellipsized flag even if | |
253 | // we don't ellipsize the text but just truncate it | |
254 | if (HasFlag(wxSTB_SHOW_TIPS)) | |
255 | SetEllipsizedFlag(i, dc.GetTextExtent(text).GetWidth() > maxWidth); | |
c801d85f | 256 | |
c4c178c1 FM |
257 | dc.SetClippingRegion(rect); |
258 | } | |
259 | else | |
260 | { | |
261 | text = wxControl::Ellipsize(text, dc, | |
262 | ellmode, | |
263 | maxWidth, | |
355ce7ad | 264 | wxELLIPSIZE_FLAGS_EXPAND_TABS); |
c4c178c1 FM |
265 | // Ellipsize() will do something only if necessary |
266 | ||
03647350 VZ |
267 | // update the ellipsization status for this pane; this is used later to |
268 | // decide whether a tooltip should be shown or not for this pane | |
c4c178c1 FM |
269 | // (if we have wxSTB_SHOW_TIPS) |
270 | SetEllipsizedFlag(i, text != GetStatusText(i)); | |
271 | } | |
c94bdf2a | 272 | |
7c74e7fe | 273 | #if defined( __WXGTK__ ) || defined(__WXMAC__) |
48f7ffbe WS |
274 | xpos++; |
275 | ypos++; | |
92976ab6 | 276 | #endif |
c801d85f | 277 | |
78612fa6 | 278 | // draw the text |
48f7ffbe | 279 | dc.DrawText(text, xpos, ypos); |
03647350 | 280 | |
c4c178c1 FM |
281 | if (ellmode == (wxEllipsizeMode)-1) |
282 | dc.DestroyClippingRegion(); | |
c801d85f KB |
283 | } |
284 | ||
ba4589db | 285 | void wxStatusBarGeneric::DrawField(wxDC& dc, int i, int textHeight) |
c801d85f | 286 | { |
2b5f62a0 VZ |
287 | wxRect rect; |
288 | GetFieldRect(i, rect); | |
c801d85f | 289 | |
ba4589db | 290 | if (rect.GetWidth() <= 0) |
e75e8815 | 291 | return; // happens when the status bar is shrunk in a very small area! |
ba4589db | 292 | |
b31eaa5c | 293 | int style = m_panes[i].GetStyle(); |
c2919ab3 VZ |
294 | if (style != wxSB_FLAT) |
295 | { | |
296 | // Draw border | |
c94bdf2a FM |
297 | // For wxSB_NORMAL: paint a grey background, plus 3-d border (one black rectangle) |
298 | // Inside this, left and top sides (dark grey). Bottom and right (white). | |
c2919ab3 VZ |
299 | // Reverse it for wxSB_RAISED |
300 | ||
301 | dc.SetPen((style == wxSB_RAISED) ? m_mediumShadowPen : m_hilightPen); | |
302 | ||
9a6aafe0 | 303 | #ifndef __WXPM__ |
c2919ab3 VZ |
304 | |
305 | // Right and bottom lines | |
306 | dc.DrawLine(rect.x + rect.width, rect.y, | |
307 | rect.x + rect.width, rect.y + rect.height); | |
308 | dc.DrawLine(rect.x + rect.width, rect.y + rect.height, | |
309 | rect.x, rect.y + rect.height); | |
310 | ||
311 | dc.SetPen((style == wxSB_RAISED) ? m_hilightPen : m_mediumShadowPen); | |
312 | ||
313 | // Left and top lines | |
314 | dc.DrawLine(rect.x, rect.y + rect.height, | |
315 | rect.x, rect.y); | |
316 | dc.DrawLine(rect.x, rect.y, | |
317 | rect.x + rect.width, rect.y); | |
9a6aafe0 | 318 | #else |
c2919ab3 VZ |
319 | |
320 | dc.DrawLine(rect.x + rect.width, rect.height + 2, | |
321 | rect.x, rect.height + 2); | |
322 | dc.DrawLine(rect.x + rect.width, rect.y, | |
323 | rect.x + rect.width, rect.y + rect.height); | |
324 | ||
325 | dc.SetPen((style == wxSB_RAISED) ? m_hilightPen : m_mediumShadowPen); | |
326 | dc.DrawLine(rect.x, rect.y, | |
327 | rect.x + rect.width, rect.y); | |
328 | dc.DrawLine(rect.x, rect.y + rect.height, | |
c94bdf2a | 329 | rect.x, rect.y); |
b34590eb | 330 | #endif |
c2919ab3 | 331 | } |
c801d85f | 332 | |
ba4589db | 333 | DrawFieldText(dc, rect, i, textHeight); |
c801d85f KB |
334 | } |
335 | ||
ed791986 | 336 | bool wxStatusBarGeneric::GetFieldRect(int n, wxRect& rect) const |
c801d85f | 337 | { |
7b6fefbe | 338 | wxCHECK_MSG( (n >= 0) && ((size_t)n < m_panes.GetCount()), false, |
9a83f860 | 339 | wxT("invalid status bar field index") ); |
c801d85f | 340 | |
8e8d9109 VZ |
341 | // We can be called from the user-defined EVT_SIZE handler in which case |
342 | // the widths haven't been updated yet and we need to do it now. This is | |
343 | // not very efficient as we keep testing the size but there is no other way | |
344 | // to make the code needing the up-to-date fields sizes in its EVT_SIZE to | |
345 | // work. | |
346 | if ( GetClientSize().x != m_lastClientSize.x ) | |
347 | { | |
348 | const_cast<wxStatusBarGeneric*>(this)->DoUpdateFieldWidths(); | |
349 | } | |
350 | ||
ba4589db FM |
351 | if (m_widthsAbs.IsEmpty()) |
352 | return false; | |
c801d85f | 353 | |
390015c0 VZ |
354 | rect.x = 0; |
355 | for ( int i = 0; i < n; i++ ) | |
390015c0 | 356 | rect.x += m_widthsAbs[i]; |
390015c0 | 357 | rect.x += m_borderX; |
c801d85f | 358 | |
ba4589db | 359 | rect.y = m_borderY; |
390015c0 | 360 | rect.width = m_widthsAbs[n] - 2*m_borderX; |
8e8d9109 | 361 | rect.height = m_lastClientSize.y - 2*m_borderY; |
c801d85f | 362 | |
ca65c044 | 363 | return true; |
c801d85f KB |
364 | } |
365 | ||
c94bdf2a FM |
366 | int wxStatusBarGeneric::GetFieldFromPoint(const wxPoint& pt) const |
367 | { | |
368 | if (m_widthsAbs.IsEmpty()) | |
369 | return wxNOT_FOUND; | |
370 | ||
4c51a665 | 371 | // NOTE: we explicitly don't take in count the borders since they are only |
c94bdf2a | 372 | // useful when rendering the status text, not for hit-test computations |
03647350 | 373 | |
8e8d9109 | 374 | if (pt.y <= 0 || pt.y >= m_lastClientSize.y) |
c94bdf2a FM |
375 | return wxNOT_FOUND; |
376 | ||
377 | int x = 0; | |
378 | for ( size_t i = 0; i < m_panes.GetCount(); i++ ) | |
379 | { | |
380 | if (pt.x > x && pt.x < x+m_widthsAbs[i]) | |
381 | return i; | |
03647350 | 382 | |
c94bdf2a FM |
383 | x += m_widthsAbs[i]; |
384 | } | |
385 | ||
386 | return wxNOT_FOUND; | |
387 | } | |
388 | ||
ed791986 | 389 | void wxStatusBarGeneric::InitColours() |
c801d85f | 390 | { |
ba959d4c | 391 | #if defined(__WXPM__) |
c34d2f35 | 392 | m_mediumShadowPen = wxPen(wxColour(127, 127, 127)); |
b0fa2187 | 393 | m_hilightPen = *wxWHITE_PEN; |
dd7d1435 | 394 | |
b0fa2187 PC |
395 | SetBackgroundColour(*wxLIGHT_GREY); |
396 | SetForegroundColour(*wxBLACK); | |
ba959d4c VZ |
397 | #else // !__WXPM__ |
398 | m_mediumShadowPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)); | |
399 | m_hilightPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT)); | |
400 | #endif // __WXPM__/!__WXPM__ | |
c801d85f KB |
401 | } |
402 | ||
ed791986 VZ |
403 | void wxStatusBarGeneric::SetMinHeight(int height) |
404 | { | |
405 | // check that this min height is not less than minimal height for the | |
ba4589db FM |
406 | // current font (min height is as calculated above in Create() except for border) |
407 | int minHeight = (int)((11*GetCharHeight())/10); | |
ed791986 | 408 | |
ba4589db | 409 | if ( height > minHeight ) |
422d0ff0 | 410 | SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height + 2*m_borderY); |
ed791986 VZ |
411 | } |
412 | ||
78612fa6 FM |
413 | wxRect wxStatusBarGeneric::GetSizeGripRect() const |
414 | { | |
415 | int width, height; | |
416 | wxWindow::DoGetClientSize(&width, &height); | |
417 | ||
418 | if (GetLayoutDirection() == wxLayout_RightToLeft) | |
419 | return wxRect(2, 2, height-2, height-4); | |
420 | else | |
421 | return wxRect(width-height-2, 2, height-2, height-4); | |
422 | } | |
9a6aafe0 FM |
423 | |
424 | // ---------------------------------------------------------------------------- | |
425 | // wxStatusBarGeneric - event handlers | |
426 | // ---------------------------------------------------------------------------- | |
427 | ||
428 | void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) ) | |
429 | { | |
430 | wxPaintDC dc(this); | |
431 | ||
432 | #ifdef __WXGTK20__ | |
433 | // Draw grip first | |
434 | if ( ShowsSizeGrip() ) | |
435 | { | |
78612fa6 | 436 | const wxRect& rc = GetSizeGripRect(); |
9dc44eff PC |
437 | #ifdef __WXGTK3__ |
438 | GtkWidget* toplevel = gtk_widget_get_toplevel(m_widget); | |
439 | if (toplevel && !gtk_window_get_has_resize_grip(GTK_WINDOW(toplevel))) | |
440 | { | |
441 | GtkStyleContext* sc = gtk_widget_get_style_context(toplevel); | |
442 | gtk_style_context_save(sc); | |
443 | gtk_style_context_add_class(sc, GTK_STYLE_CLASS_GRIP); | |
444 | GtkJunctionSides sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT; | |
445 | if (GetLayoutDirection() == wxLayout_RightToLeft) | |
446 | sides = GTK_JUNCTION_CORNER_BOTTOMLEFT; | |
447 | gtk_style_context_set_junction_sides(sc, sides); | |
448 | gtk_render_handle(sc, | |
449 | static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext()), | |
450 | rc.x, rc.y, rc.width, rc.height); | |
451 | gtk_style_context_restore(sc); | |
452 | } | |
453 | #else | |
78612fa6 FM |
454 | GdkWindowEdge edge = |
455 | GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST : | |
456 | GDK_WINDOW_EDGE_SOUTH_EAST; | |
385e8575 | 457 | gtk_paint_resize_grip(gtk_widget_get_style(m_widget), |
78612fa6 | 458 | GTKGetDrawingWindow(), |
fc9ab22a | 459 | gtk_widget_get_state(m_widget), |
78612fa6 FM |
460 | NULL, |
461 | m_widget, | |
462 | "statusbar", | |
463 | edge, | |
464 | rc.x, rc.y, rc.width, rc.height ); | |
9dc44eff | 465 | #endif |
9a6aafe0 FM |
466 | } |
467 | #endif // __WXGTK20__ | |
468 | ||
469 | if (GetFont().IsOk()) | |
470 | dc.SetFont(GetFont()); | |
471 | ||
ba4589db FM |
472 | // compute char height only once for all panes: |
473 | int textHeight = dc.GetCharHeight(); | |
9a6aafe0 | 474 | |
ba4589db | 475 | dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); |
9a6aafe0 | 476 | for (size_t i = 0; i < m_panes.GetCount(); i ++) |
ba4589db | 477 | DrawField(dc, i, textHeight); |
9a6aafe0 FM |
478 | } |
479 | ||
9a6aafe0 FM |
480 | void wxStatusBarGeneric::OnSysColourChanged(wxSysColourChangedEvent& event) |
481 | { | |
482 | InitColours(); | |
483 | ||
484 | // Propagate the event to the non-top-level children | |
485 | wxWindow::OnSysColourChanged(event); | |
486 | } | |
487 | ||
9dc44eff | 488 | #ifdef __WXGTK20__ |
2b5f62a0 | 489 | void wxStatusBarGeneric::OnLeftDown(wxMouseEvent& event) |
390015c0 | 490 | { |
2b5f62a0 VZ |
491 | int width, height; |
492 | GetClientSize(&width, &height); | |
8aa2cea1 | 493 | |
9dc44eff PC |
494 | GtkWidget* ancestor = gtk_widget_get_toplevel(m_widget); |
495 | #ifdef __WXGTK3__ | |
496 | if (ancestor && gtk_window_get_has_resize_grip(GTK_WINDOW(ancestor))) | |
497 | ancestor = NULL; | |
498 | #endif | |
390015c0 | 499 | |
9dc44eff PC |
500 | if (ancestor && ShowsSizeGrip() && event.GetX() > width - height) |
501 | { | |
08f53168 | 502 | GdkWindow *source = GTKGetDrawingWindow(); |
2b5f62a0 VZ |
503 | |
504 | int org_x = 0; | |
505 | int org_y = 0; | |
506 | gdk_window_get_origin( source, &org_x, &org_y ); | |
507 | ||
fc2d4209 RR |
508 | if (GetLayoutDirection() == wxLayout_RightToLeft) |
509 | { | |
510 | gtk_window_begin_resize_drag (GTK_WINDOW (ancestor), | |
511 | GDK_WINDOW_EDGE_SOUTH_WEST, | |
512 | 1, | |
513 | org_x - event.GetX() + GetSize().x , | |
514 | org_y + event.GetY(), | |
515 | 0); | |
516 | } | |
517 | else | |
518 | { | |
519 | gtk_window_begin_resize_drag (GTK_WINDOW (ancestor), | |
2b5f62a0 VZ |
520 | GDK_WINDOW_EDGE_SOUTH_EAST, |
521 | 1, | |
8aa2cea1 RD |
522 | org_x + event.GetX(), |
523 | org_y + event.GetY(), | |
2b5f62a0 | 524 | 0); |
fc2d4209 | 525 | } |
2b5f62a0 VZ |
526 | } |
527 | else | |
528 | { | |
ca65c044 | 529 | event.Skip( true ); |
2b5f62a0 | 530 | } |
2b5f62a0 VZ |
531 | } |
532 | ||
533 | void wxStatusBarGeneric::OnRightDown(wxMouseEvent& event) | |
534 | { | |
2b5f62a0 VZ |
535 | int width, height; |
536 | GetClientSize(&width, &height); | |
8aa2cea1 | 537 | |
9dc44eff PC |
538 | GtkWidget* ancestor = gtk_widget_get_toplevel(m_widget); |
539 | #ifdef __WXGTK3__ | |
540 | if (ancestor && gtk_window_get_has_resize_grip(GTK_WINDOW(ancestor))) | |
541 | ancestor = NULL; | |
542 | #endif | |
2b5f62a0 | 543 | |
9dc44eff PC |
544 | if (ancestor && ShowsSizeGrip() && event.GetX() > width - height) |
545 | { | |
08f53168 | 546 | GdkWindow *source = GTKGetDrawingWindow(); |
2b5f62a0 VZ |
547 | |
548 | int org_x = 0; | |
549 | int org_y = 0; | |
550 | gdk_window_get_origin( source, &org_x, &org_y ); | |
8aa2cea1 | 551 | |
2b5f62a0 VZ |
552 | gtk_window_begin_move_drag (GTK_WINDOW (ancestor), |
553 | 2, | |
8aa2cea1 RD |
554 | org_x + event.GetX(), |
555 | org_y + event.GetY(), | |
2b5f62a0 VZ |
556 | 0); |
557 | } | |
558 | else | |
559 | { | |
ca65c044 | 560 | event.Skip( true ); |
2b5f62a0 | 561 | } |
390015c0 | 562 | } |
9dc44eff | 563 | #endif // __WXGTK20__ |
390015c0 | 564 | |
8e8d9109 | 565 | void wxStatusBarGeneric::OnSize(wxSizeEvent& event) |
ba4589db | 566 | { |
8e8d9109 | 567 | DoUpdateFieldWidths(); |
ba4589db | 568 | |
8e8d9109 | 569 | event.Skip(); |
ba4589db FM |
570 | } |
571 | ||
1e6feb95 | 572 | #endif // wxUSE_STATUSBAR |