]>
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 | |
184 | int width; | |
185 | GetClientSize(&width, &m_lastClientHeight); | |
186 | m_widthsAbs = CalculateAbsWidths(width); | |
c801d85f KB |
187 | } |
188 | ||
7422d7c4 VZ |
189 | bool wxStatusBarGeneric::ShowsSizeGrip() const |
190 | { | |
c4c178c1 | 191 | if ( !HasFlag(wxSTB_SIZEGRIP) ) |
7422d7c4 VZ |
192 | return false; |
193 | ||
194 | wxTopLevelWindow * const | |
195 | tlw = wxDynamicCast(wxGetTopLevelParent(GetParent()), wxTopLevelWindow); | |
196 | return tlw && !tlw->IsMaximized() && tlw->HasFlag(wxRESIZE_BORDER); | |
197 | } | |
198 | ||
ba4589db | 199 | void wxStatusBarGeneric::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight) |
c801d85f | 200 | { |
ba4589db FM |
201 | wxString text(GetStatusText(i)); |
202 | if (text.empty()) | |
203 | return; // optimization | |
c801d85f | 204 | |
ba4589db FM |
205 | int xpos = rect.x + wxFIELD_TEXT_MARGIN, |
206 | maxWidth = rect.width - 2*wxFIELD_TEXT_MARGIN, | |
207 | ypos = (int) (((rect.height - textHeight) / 2) + rect.y + 0.5); | |
78612fa6 FM |
208 | |
209 | if (ShowsSizeGrip()) | |
210 | { | |
211 | // don't write text over the size grip: | |
212 | // NOTE: overloading DoGetClientSize() and GetClientAreaOrigin() wouldn't | |
213 | // work because the adjustment needs to be done only when drawing | |
214 | // the field text and not also when drawing the background, the | |
215 | // size grip itself, etc | |
ba4589db FM |
216 | if ((GetLayoutDirection() == wxLayout_RightToLeft && i == 0) || |
217 | (GetLayoutDirection() != wxLayout_RightToLeft && | |
218 | i == (int)m_panes.GetCount()-1)) | |
78612fa6 | 219 | { |
ba4589db | 220 | const wxRect& gripRc = GetSizeGripRect(); |
78612fa6 | 221 | |
ba4589db FM |
222 | // NOTE: we don't need any special treatment wrt to the layout direction |
223 | // since DrawText() will automatically adjust the origin of the | |
224 | // text accordingly to the layout in use | |
78612fa6 | 225 | |
ba4589db | 226 | maxWidth -= gripRc.width; |
78612fa6 FM |
227 | } |
228 | } | |
229 | ||
230 | // eventually ellipsize the text so that it fits the field width | |
03647350 | 231 | |
c4c178c1 FM |
232 | wxEllipsizeMode ellmode = (wxEllipsizeMode)-1; |
233 | if (HasFlag(wxSTB_ELLIPSIZE_START)) ellmode = wxELLIPSIZE_START; | |
234 | else if (HasFlag(wxSTB_ELLIPSIZE_MIDDLE)) ellmode = wxELLIPSIZE_MIDDLE; | |
235 | else if (HasFlag(wxSTB_ELLIPSIZE_END)) ellmode = wxELLIPSIZE_END; | |
236 | ||
237 | if (ellmode == (wxEllipsizeMode)-1) | |
238 | { | |
239 | // if we have the wxSTB_SHOW_TIPS we must set the ellipsized flag even if | |
240 | // we don't ellipsize the text but just truncate it | |
241 | if (HasFlag(wxSTB_SHOW_TIPS)) | |
242 | SetEllipsizedFlag(i, dc.GetTextExtent(text).GetWidth() > maxWidth); | |
c801d85f | 243 | |
c4c178c1 FM |
244 | dc.SetClippingRegion(rect); |
245 | } | |
246 | else | |
247 | { | |
248 | text = wxControl::Ellipsize(text, dc, | |
249 | ellmode, | |
250 | maxWidth, | |
251 | wxELLIPSIZE_EXPAND_TAB); | |
252 | // Ellipsize() will do something only if necessary | |
253 | ||
03647350 VZ |
254 | // update the ellipsization status for this pane; this is used later to |
255 | // decide whether a tooltip should be shown or not for this pane | |
c4c178c1 FM |
256 | // (if we have wxSTB_SHOW_TIPS) |
257 | SetEllipsizedFlag(i, text != GetStatusText(i)); | |
258 | } | |
c94bdf2a | 259 | |
7c74e7fe | 260 | #if defined( __WXGTK__ ) || defined(__WXMAC__) |
48f7ffbe WS |
261 | xpos++; |
262 | ypos++; | |
92976ab6 | 263 | #endif |
c801d85f | 264 | |
78612fa6 | 265 | // draw the text |
48f7ffbe | 266 | dc.DrawText(text, xpos, ypos); |
03647350 | 267 | |
c4c178c1 FM |
268 | if (ellmode == (wxEllipsizeMode)-1) |
269 | dc.DestroyClippingRegion(); | |
c801d85f KB |
270 | } |
271 | ||
ba4589db | 272 | void wxStatusBarGeneric::DrawField(wxDC& dc, int i, int textHeight) |
c801d85f | 273 | { |
2b5f62a0 VZ |
274 | wxRect rect; |
275 | GetFieldRect(i, rect); | |
c801d85f | 276 | |
ba4589db FM |
277 | if (rect.GetWidth() <= 0) |
278 | return; // happens when the status bar is shrinked in a very small area! | |
279 | ||
b31eaa5c | 280 | int style = m_panes[i].GetStyle(); |
c2919ab3 VZ |
281 | if (style != wxSB_FLAT) |
282 | { | |
283 | // Draw border | |
c94bdf2a FM |
284 | // For wxSB_NORMAL: paint a grey background, plus 3-d border (one black rectangle) |
285 | // Inside this, left and top sides (dark grey). Bottom and right (white). | |
c2919ab3 VZ |
286 | // Reverse it for wxSB_RAISED |
287 | ||
288 | dc.SetPen((style == wxSB_RAISED) ? m_mediumShadowPen : m_hilightPen); | |
289 | ||
9a6aafe0 | 290 | #ifndef __WXPM__ |
c2919ab3 VZ |
291 | |
292 | // Right and bottom lines | |
293 | dc.DrawLine(rect.x + rect.width, rect.y, | |
294 | rect.x + rect.width, rect.y + rect.height); | |
295 | dc.DrawLine(rect.x + rect.width, rect.y + rect.height, | |
296 | rect.x, rect.y + rect.height); | |
297 | ||
298 | dc.SetPen((style == wxSB_RAISED) ? m_hilightPen : m_mediumShadowPen); | |
299 | ||
300 | // Left and top lines | |
301 | dc.DrawLine(rect.x, rect.y + rect.height, | |
302 | rect.x, rect.y); | |
303 | dc.DrawLine(rect.x, rect.y, | |
304 | rect.x + rect.width, rect.y); | |
9a6aafe0 | 305 | #else |
c2919ab3 VZ |
306 | |
307 | dc.DrawLine(rect.x + rect.width, rect.height + 2, | |
308 | rect.x, rect.height + 2); | |
309 | dc.DrawLine(rect.x + rect.width, rect.y, | |
310 | rect.x + rect.width, rect.y + rect.height); | |
311 | ||
312 | dc.SetPen((style == wxSB_RAISED) ? m_hilightPen : m_mediumShadowPen); | |
313 | dc.DrawLine(rect.x, rect.y, | |
314 | rect.x + rect.width, rect.y); | |
315 | dc.DrawLine(rect.x, rect.y + rect.height, | |
c94bdf2a | 316 | rect.x, rect.y); |
b34590eb | 317 | #endif |
c2919ab3 | 318 | } |
c801d85f | 319 | |
ba4589db | 320 | DrawFieldText(dc, rect, i, textHeight); |
c801d85f KB |
321 | } |
322 | ||
ed791986 | 323 | bool wxStatusBarGeneric::GetFieldRect(int n, wxRect& rect) const |
c801d85f | 324 | { |
7b6fefbe | 325 | wxCHECK_MSG( (n >= 0) && ((size_t)n < m_panes.GetCount()), false, |
9a83f860 | 326 | wxT("invalid status bar field index") ); |
c801d85f | 327 | |
ba4589db FM |
328 | if (m_widthsAbs.IsEmpty()) |
329 | return false; | |
c801d85f | 330 | |
390015c0 VZ |
331 | rect.x = 0; |
332 | for ( int i = 0; i < n; i++ ) | |
390015c0 | 333 | rect.x += m_widthsAbs[i]; |
390015c0 | 334 | rect.x += m_borderX; |
c801d85f | 335 | |
ba4589db | 336 | rect.y = m_borderY; |
390015c0 | 337 | rect.width = m_widthsAbs[n] - 2*m_borderX; |
ba4589db | 338 | rect.height = m_lastClientHeight - 2*m_borderY; |
c801d85f | 339 | |
ca65c044 | 340 | return true; |
c801d85f KB |
341 | } |
342 | ||
c94bdf2a FM |
343 | int wxStatusBarGeneric::GetFieldFromPoint(const wxPoint& pt) const |
344 | { | |
345 | if (m_widthsAbs.IsEmpty()) | |
346 | return wxNOT_FOUND; | |
347 | ||
348 | // NOTE: we explicitely don't take in count the borders since they are only | |
349 | // useful when rendering the status text, not for hit-test computations | |
03647350 | 350 | |
c94bdf2a FM |
351 | if (pt.y <= 0 || pt.y >= m_lastClientHeight) |
352 | return wxNOT_FOUND; | |
353 | ||
354 | int x = 0; | |
355 | for ( size_t i = 0; i < m_panes.GetCount(); i++ ) | |
356 | { | |
357 | if (pt.x > x && pt.x < x+m_widthsAbs[i]) | |
358 | return i; | |
03647350 | 359 | |
c94bdf2a FM |
360 | x += m_widthsAbs[i]; |
361 | } | |
362 | ||
363 | return wxNOT_FOUND; | |
364 | } | |
365 | ||
ed791986 | 366 | void wxStatusBarGeneric::InitColours() |
c801d85f | 367 | { |
ba959d4c | 368 | #if defined(__WXPM__) |
c34d2f35 | 369 | m_mediumShadowPen = wxPen(wxColour(127, 127, 127)); |
b0fa2187 | 370 | m_hilightPen = *wxWHITE_PEN; |
dd7d1435 | 371 | |
b0fa2187 PC |
372 | SetBackgroundColour(*wxLIGHT_GREY); |
373 | SetForegroundColour(*wxBLACK); | |
ba959d4c VZ |
374 | #else // !__WXPM__ |
375 | m_mediumShadowPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)); | |
376 | m_hilightPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT)); | |
377 | #endif // __WXPM__/!__WXPM__ | |
c801d85f KB |
378 | } |
379 | ||
ed791986 VZ |
380 | void wxStatusBarGeneric::SetMinHeight(int height) |
381 | { | |
382 | // check that this min height is not less than minimal height for the | |
ba4589db FM |
383 | // current font (min height is as calculated above in Create() except for border) |
384 | int minHeight = (int)((11*GetCharHeight())/10); | |
ed791986 | 385 | |
ba4589db | 386 | if ( height > minHeight ) |
422d0ff0 | 387 | SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height + 2*m_borderY); |
ed791986 VZ |
388 | } |
389 | ||
78612fa6 FM |
390 | wxRect wxStatusBarGeneric::GetSizeGripRect() const |
391 | { | |
392 | int width, height; | |
393 | wxWindow::DoGetClientSize(&width, &height); | |
394 | ||
395 | if (GetLayoutDirection() == wxLayout_RightToLeft) | |
396 | return wxRect(2, 2, height-2, height-4); | |
397 | else | |
398 | return wxRect(width-height-2, 2, height-2, height-4); | |
399 | } | |
9a6aafe0 FM |
400 | |
401 | // ---------------------------------------------------------------------------- | |
402 | // wxStatusBarGeneric - event handlers | |
403 | // ---------------------------------------------------------------------------- | |
404 | ||
405 | void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) ) | |
406 | { | |
407 | wxPaintDC dc(this); | |
408 | ||
409 | #ifdef __WXGTK20__ | |
410 | // Draw grip first | |
411 | if ( ShowsSizeGrip() ) | |
412 | { | |
78612fa6 FM |
413 | const wxRect& rc = GetSizeGripRect(); |
414 | GdkWindowEdge edge = | |
415 | GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST : | |
416 | GDK_WINDOW_EDGE_SOUTH_EAST; | |
417 | gtk_paint_resize_grip( m_widget->style, | |
418 | GTKGetDrawingWindow(), | |
419 | (GtkStateType) GTK_WIDGET_STATE (m_widget), | |
420 | NULL, | |
421 | m_widget, | |
422 | "statusbar", | |
423 | edge, | |
424 | rc.x, rc.y, rc.width, rc.height ); | |
9a6aafe0 FM |
425 | } |
426 | #endif // __WXGTK20__ | |
427 | ||
428 | if (GetFont().IsOk()) | |
429 | dc.SetFont(GetFont()); | |
430 | ||
ba4589db FM |
431 | // compute char height only once for all panes: |
432 | int textHeight = dc.GetCharHeight(); | |
9a6aafe0 | 433 | |
ba4589db | 434 | dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); |
9a6aafe0 | 435 | for (size_t i = 0; i < m_panes.GetCount(); i ++) |
ba4589db | 436 | DrawField(dc, i, textHeight); |
9a6aafe0 FM |
437 | } |
438 | ||
9a6aafe0 FM |
439 | void wxStatusBarGeneric::OnSysColourChanged(wxSysColourChangedEvent& event) |
440 | { | |
441 | InitColours(); | |
442 | ||
443 | // Propagate the event to the non-top-level children | |
444 | wxWindow::OnSysColourChanged(event); | |
445 | } | |
446 | ||
2b5f62a0 | 447 | void wxStatusBarGeneric::OnLeftDown(wxMouseEvent& event) |
390015c0 | 448 | { |
2b5f62a0 VZ |
449 | #ifdef __WXGTK20__ |
450 | int width, height; | |
451 | GetClientSize(&width, &height); | |
8aa2cea1 | 452 | |
7422d7c4 | 453 | if ( ShowsSizeGrip() && (event.GetX() > width-height) ) |
2b5f62a0 VZ |
454 | { |
455 | GtkWidget *ancestor = gtk_widget_get_toplevel( m_widget ); | |
456 | ||
457 | if (!GTK_IS_WINDOW (ancestor)) | |
458 | return; | |
390015c0 | 459 | |
08f53168 | 460 | GdkWindow *source = GTKGetDrawingWindow(); |
2b5f62a0 VZ |
461 | |
462 | int org_x = 0; | |
463 | int org_y = 0; | |
464 | gdk_window_get_origin( source, &org_x, &org_y ); | |
465 | ||
fc2d4209 RR |
466 | if (GetLayoutDirection() == wxLayout_RightToLeft) |
467 | { | |
468 | gtk_window_begin_resize_drag (GTK_WINDOW (ancestor), | |
469 | GDK_WINDOW_EDGE_SOUTH_WEST, | |
470 | 1, | |
471 | org_x - event.GetX() + GetSize().x , | |
472 | org_y + event.GetY(), | |
473 | 0); | |
474 | } | |
475 | else | |
476 | { | |
477 | gtk_window_begin_resize_drag (GTK_WINDOW (ancestor), | |
2b5f62a0 VZ |
478 | GDK_WINDOW_EDGE_SOUTH_EAST, |
479 | 1, | |
8aa2cea1 RD |
480 | org_x + event.GetX(), |
481 | org_y + event.GetY(), | |
2b5f62a0 | 482 | 0); |
fc2d4209 | 483 | } |
2b5f62a0 VZ |
484 | } |
485 | else | |
486 | { | |
ca65c044 | 487 | event.Skip( true ); |
2b5f62a0 VZ |
488 | } |
489 | #else | |
ca65c044 | 490 | event.Skip( true ); |
2b5f62a0 VZ |
491 | #endif |
492 | } | |
493 | ||
494 | void wxStatusBarGeneric::OnRightDown(wxMouseEvent& event) | |
495 | { | |
496 | #ifdef __WXGTK20__ | |
497 | int width, height; | |
498 | GetClientSize(&width, &height); | |
8aa2cea1 | 499 | |
7422d7c4 | 500 | if ( ShowsSizeGrip() && (event.GetX() > width-height) ) |
2b5f62a0 VZ |
501 | { |
502 | GtkWidget *ancestor = gtk_widget_get_toplevel( m_widget ); | |
503 | ||
504 | if (!GTK_IS_WINDOW (ancestor)) | |
505 | return; | |
506 | ||
08f53168 | 507 | GdkWindow *source = GTKGetDrawingWindow(); |
2b5f62a0 VZ |
508 | |
509 | int org_x = 0; | |
510 | int org_y = 0; | |
511 | gdk_window_get_origin( source, &org_x, &org_y ); | |
8aa2cea1 | 512 | |
2b5f62a0 VZ |
513 | gtk_window_begin_move_drag (GTK_WINDOW (ancestor), |
514 | 2, | |
8aa2cea1 RD |
515 | org_x + event.GetX(), |
516 | org_y + event.GetY(), | |
2b5f62a0 VZ |
517 | 0); |
518 | } | |
519 | else | |
520 | { | |
ca65c044 | 521 | event.Skip( true ); |
2b5f62a0 VZ |
522 | } |
523 | #else | |
ca65c044 | 524 | event.Skip( true ); |
2b5f62a0 | 525 | #endif |
390015c0 VZ |
526 | } |
527 | ||
ba4589db FM |
528 | void wxStatusBarGeneric::OnSize(wxSizeEvent& WXUNUSED(event)) |
529 | { | |
530 | // FIXME: workarounds for OS/2 bugs have nothing to do here (VZ) | |
531 | int width; | |
532 | #ifdef __WXPM__ | |
533 | GetSize(&width, &m_lastClientHeight); | |
534 | #else | |
535 | GetClientSize(&width, &m_lastClientHeight); | |
536 | #endif | |
537 | ||
538 | // recompute the cache of the field widths if the status bar width has changed | |
539 | m_widthsAbs = CalculateAbsWidths(width); | |
540 | } | |
541 | ||
1e6feb95 | 542 | #endif // wxUSE_STATUSBAR |