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