]> git.saurik.com Git - wxWidgets.git/blame - src/msw/statusbar.cpp
Ensure that validators work even in presence of pushed event handlers.
[wxWidgets.git] / src / msw / statusbar.cpp
CommitLineData
2bda0e17 1///////////////////////////////////////////////////////////////////////////////
936f6353 2// Name: src/msw/statusbar.cpp
2bda0e17
KB
3// Purpose: native implementation of wxStatusBar
4// Author: Vadim Zeitlin
ed791986 5// Modified by:
2bda0e17
KB
6// Created: 04.04.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10///////////////////////////////////////////////////////////////////////////////
11
edd608b1
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
2bda0e17
KB
20// for compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
88a7a4e1
WS
27#if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR
28
29#include "wx/statusbr.h"
30
2bda0e17 31#ifndef WX_PRECOMP
57bd4c60 32 #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
88a7a4e1
WS
33 #include "wx/frame.h"
34 #include "wx/settings.h"
35 #include "wx/dcclient.h"
36 #include "wx/intl.h"
e4db172a 37 #include "wx/log.h"
cbbf47f3 38 #include "wx/control.h"
2bda0e17
KB
39#endif
40
42e69d6b 41#include "wx/msw/private.h"
6418ad5e 42#include "wx/tooltip.h"
42e69d6b 43#include <windowsx.h>
2bda0e17 44
1feb5443
JG
45#if wxUSE_UXTHEME
46 #include "wx/msw/uxtheme.h"
47#endif
48
edd608b1
VZ
49// ----------------------------------------------------------------------------
50// constants
51// ----------------------------------------------------------------------------
52
53namespace
54{
55
0cd15959 56// no idea for a default width, just choose something
edd608b1
VZ
57static const int DEFAULT_FIELD_WIDTH = 25;
58
59} // anonymous namespace
0cd15959 60
2bda0e17
KB
61// ----------------------------------------------------------------------------
62// macros
63// ----------------------------------------------------------------------------
64
65// windowsx.h and commctrl.h don't define those, so we do it here
66#define StatusBar_SetParts(h, n, w) SendMessage(h, SB_SETPARTS, (WPARAM)n, (LPARAM)w)
837e5743 67#define StatusBar_SetText(h, n, t) SendMessage(h, SB_SETTEXT, (WPARAM)n, (LPARAM)(LPCTSTR)t)
2bda0e17 68#define StatusBar_GetTextLen(h, n) LOWORD(SendMessage(h, SB_GETTEXTLENGTH, (WPARAM)n, 0))
837e5743 69#define StatusBar_GetText(h, n, s) LOWORD(SendMessage(h, SB_GETTEXT, (WPARAM)n, (LPARAM)(LPTSTR)s))
2bda0e17 70
2bda0e17
KB
71// ============================================================================
72// implementation
73// ============================================================================
74
75// ----------------------------------------------------------------------------
936f6353 76// wxStatusBar class
2bda0e17
KB
77// ----------------------------------------------------------------------------
78
936f6353 79wxStatusBar::wxStatusBar()
2bda0e17 80{
b3d008db
VZ
81 SetParent(NULL);
82 m_hWnd = 0;
83 m_windowId = 0;
0cd15959 84 m_pDC = NULL;
2bda0e17
KB
85}
86
936f6353
VZ
87bool wxStatusBar::Create(wxWindow *parent,
88 wxWindowID id,
89 long style,
90 const wxString& name)
2bda0e17 91{
6418ad5e 92 wxCHECK_MSG( parent, false, "status bar must have a parent" );
cbc66a27 93
ed791986 94 SetName(name);
cbc66a27 95 SetWindowStyleFlag(style);
ed791986
VZ
96 SetParent(parent);
97
cbc66a27
VZ
98 parent->AddChild(this);
99
57f4f925 100 m_windowId = id == wxID_ANY ? NewControlId() : id;
ed791986 101
b0766406
JS
102 DWORD wstyle = WS_CHILD | WS_VISIBLE;
103
104 if ( style & wxCLIP_SIBLINGS )
105 wstyle |= WS_CLIPSIBLINGS;
106
9584818a
VZ
107 // wxSTB_SIZEGRIP is part of our default style but it doesn't make sense to
108 // show size grip if this is the status bar of a non-resizeable TLW so turn
109 // it off in such case
110 if ( parent->IsTopLevel() && !parent->HasFlag(wxRESIZE_BORDER) )
111 style &= ~wxSTB_SIZEGRIP;
112
43b5058d
VZ
113 // setting SBARS_SIZEGRIP is perfectly useless: it's always on by default
114 // (at least in the version of comctl32.dll I'm using), and the only way to
115 // turn it off is to use CCS_TOP style - as we position the status bar
c4c178c1 116 // manually anyhow (see DoMoveWindow), use CCS_TOP style if wxSTB_SIZEGRIP
43b5058d 117 // is not given
c4c178c1 118 if ( !(style & wxSTB_SIZEGRIP) )
43b5058d
VZ
119 {
120 wstyle |= CCS_TOP;
121 }
122 else
123 {
4676948b 124#ifndef __WXWINCE__
43b5058d
VZ
125 // may be some versions of comctl32.dll do need it - anyhow, it won't
126 // do any harm
ed791986 127 wstyle |= SBARS_SIZEGRIP;
4676948b 128#endif
43b5058d 129 }
ed791986 130
2a11c826
VZ
131 m_hWnd = CreateWindow
132 (
133 STATUSCLASSNAME,
9a83f860 134 wxT(""),
2a11c826
VZ
135 wstyle,
136 0, 0, 0, 0,
137 GetHwndOf(parent),
dca0f651 138 (HMENU)wxUIntToPtr(m_windowId.GetValue()),
2a11c826
VZ
139 wxGetInstance(),
140 NULL
141 );
ed791986
VZ
142 if ( m_hWnd == 0 )
143 {
144 wxLogSysError(_("Failed to create a status bar."));
145
57f4f925 146 return false;
ed791986 147 }
2bda0e17 148
c6e7d14f 149 SetFieldsCount(1);
b3d008db 150 SubclassWin(m_hWnd);
80255b7e 151
6cf68971 152 // cache the DC instance used by DoUpdateStatusText:
80255b7e
FM
153 // NOTE: create the DC before calling InheritAttributes() since
154 // it may result in a call to our SetFont()
155 m_pDC = new wxClientDC(this);
156
e0176dd9 157 InheritAttributes();
2bda0e17 158
7d6d3bf3 159 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR));
c07103f2 160
c10d3a54
VS
161 // we must refresh the frame size when the statusbar is created, because
162 // its client area might change
ecdc1183
VZ
163 //
164 // notice that we must post the event, not send it, as the frame doesn't
165 // know that we're its status bar yet so laying it out right now wouldn't
166 // work correctly, we need to wait until we return to the main loop
167 PostSizeEventToParent();
7d6d3bf3 168
57f4f925 169 return true;
ed791986 170}
2bda0e17 171
936f6353 172wxStatusBar::~wxStatusBar()
ed791986 173{
6b5c56bd
VS
174 // we must refresh the frame size when the statusbar is deleted but the
175 // frame is not - otherwise statusbar leaves a hole in the place it used to
176 // occupy
ecdc1183 177 PostSizeEventToParent();
80255b7e 178
421962be
FM
179 // delete existing tooltips
180 for (size_t i=0; i<m_tooltips.size(); i++)
181 {
5276b0a5 182 wxDELETE(m_tooltips[i]);
421962be
FM
183 }
184
80255b7e 185 wxDELETE(m_pDC);
2bda0e17
KB
186}
187
0cd15959
FM
188bool wxStatusBar::SetFont(const wxFont& font)
189{
190 if (!wxWindow::SetFont(font))
191 return false;
192
80255b7e 193 if (m_pDC) m_pDC->SetFont(font);
0cd15959
FM
194 return true;
195}
196
936f6353 197void wxStatusBar::SetFieldsCount(int nFields, const int *widths)
2bda0e17 198{
f6bcfd97 199 // this is a Windows limitation
6418ad5e 200 wxASSERT_MSG( (nFields > 0) && (nFields < 255), "too many fields" );
2bda0e17 201
498fd97d 202 wxStatusBarBase::SetFieldsCount(nFields, widths);
27d2cd5c 203
6cf68971 204 MSWUpdateFieldsWidths();
43b2d5e7 205
6418ad5e
FM
206 // keep in synch also our m_tooltips array
207
208 // reset all current tooltips
209 for (size_t i=0; i<m_tooltips.size(); i++)
210 {
5276b0a5 211 wxDELETE(m_tooltips[i]);
6418ad5e
FM
212 }
213
214 // shrink/expand the array:
215 m_tooltips.resize(m_panes.GetCount(), NULL);
2bda0e17
KB
216}
217
936f6353 218void wxStatusBar::SetStatusWidths(int n, const int widths[])
2bda0e17 219{
498fd97d 220 wxStatusBarBase::SetStatusWidths(n, widths);
2bda0e17 221
6cf68971 222 MSWUpdateFieldsWidths();
2bda0e17
KB
223}
224
6cf68971 225void wxStatusBar::MSWUpdateFieldsWidths()
2bda0e17 226{
7b6fefbe 227 if ( m_panes.IsEmpty() )
3175c712
VZ
228 return;
229
edd608b1
VZ
230 const int count = m_panes.GetCount();
231
232 const int extraWidth = MSWGetBorderWidth() + MSWGetMetrics().textMargin;
2bda0e17 233
edd608b1
VZ
234 // compute the effectively available amount of space:
235 int widthAvailable = GetClientSize().x; // start with the entire width
236 widthAvailable -= extraWidth*(count - 1); // extra space between fields
237 widthAvailable -= MSWGetMetrics().textMargin; // and for the last field
2bda0e17 238
edd608b1
VZ
239 if ( HasFlag(wxSTB_SIZEGRIP) )
240 widthAvailable -= MSWGetMetrics().gripWidth;
6418ad5e
FM
241
242 // distribute the available space (client width) among the various fields:
243
edd608b1 244 wxArrayInt widthsAbs = CalculateAbsWidths(widthAvailable);
2bda0e17 245
6418ad5e
FM
246
247 // update the field widths in the native control:
248
edd608b1 249 int *pWidths = new int[count];
2bda0e17 250
498fd97d 251 int nCurPos = 0;
edd608b1 252 for ( int i = 0; i < count; i++ )
6418ad5e 253 {
498fd97d
VZ
254 nCurPos += widthsAbs[i] + extraWidth;
255 pWidths[i] = nCurPos;
2bda0e17 256 }
2bda0e17 257
edd608b1 258 if ( !StatusBar_SetParts(GetHwnd(), count, pWidths) )
43b2d5e7 259 {
6418ad5e 260 wxLogLastError("StatusBar_SetParts");
43b2d5e7 261 }
2bda0e17 262
ed791986 263 delete [] pWidths;
6418ad5e
FM
264
265
6cf68971 266 // FIXME: we may want to call DoUpdateStatusText() here since we may need to (de)ellipsize status texts
2bda0e17
KB
267}
268
6cf68971 269void wxStatusBar::DoUpdateStatusText(int nField)
0cd15959
FM
270{
271 if (!m_pDC)
272 return;
273
c2919ab3
VZ
274 // Get field style, if any
275 int style;
b31eaa5c 276 switch(m_panes[nField].GetStyle())
c2919ab3 277 {
7b6fefbe
FM
278 case wxSB_RAISED:
279 style = SBT_POPOUT;
280 break;
281 case wxSB_FLAT:
282 style = SBT_NOBORDERS;
283 break;
284
285 case wxSB_NORMAL:
286 default:
c2919ab3 287 style = 0;
7b6fefbe
FM
288 break;
289 }
c2919ab3 290
0cd15959
FM
291 wxRect rc;
292 GetFieldRect(nField, rc);
293
edd608b1 294 const int maxWidth = rc.GetWidth() - MSWGetMetrics().textMargin;
0cd15959 295
6418ad5e
FM
296 wxString text = GetStatusText(nField);
297
0cd15959 298 // do we need to ellipsize this string?
6418ad5e
FM
299 wxEllipsizeMode ellmode = (wxEllipsizeMode)-1;
300 if (HasFlag(wxSTB_ELLIPSIZE_START)) ellmode = wxELLIPSIZE_START;
301 else if (HasFlag(wxSTB_ELLIPSIZE_MIDDLE)) ellmode = wxELLIPSIZE_MIDDLE;
302 else if (HasFlag(wxSTB_ELLIPSIZE_END)) ellmode = wxELLIPSIZE_END;
303
304 if (ellmode == (wxEllipsizeMode)-1)
305 {
306 // if we have the wxSTB_SHOW_TIPS we must set the ellipsized flag even if
307 // we don't ellipsize the text but just truncate it
308 if (HasFlag(wxSTB_SHOW_TIPS))
309 SetEllipsizedFlag(nField, m_pDC->GetTextExtent(text).GetWidth() > maxWidth);
310 }
311 else
b3d008db 312 {
43b2d5e7 313 text = wxControl::Ellipsize(text,
6418ad5e
FM
314 *m_pDC,
315 ellmode,
316 maxWidth,
355ce7ad 317 wxELLIPSIZE_FLAGS_EXPAND_TABS);
43b2d5e7
VZ
318
319 // update the ellipsization status for this pane; this is used later to
320 // decide whether a tooltip should be shown or not for this pane
6418ad5e
FM
321 // (if we have wxSTB_SHOW_TIPS)
322 SetEllipsizedFlag(nField, text != GetStatusText(nField));
323 }
324
43b2d5e7 325 // Set the status text in the native control passing both field number and style.
6418ad5e
FM
326 // NOTE: MSDN library doesn't mention that nField and style have to be 'ORed'
327 if ( !StatusBar_SetText(GetHwnd(), nField | style, text.wx_str()) )
43b2d5e7 328 {
6418ad5e 329 wxLogLastError("StatusBar_SetText");
43b2d5e7 330 }
6418ad5e
FM
331
332 if (HasFlag(wxSTB_SHOW_TIPS))
333 {
334 wxASSERT(m_tooltips.size() == m_panes.GetCount());
335
336 if (m_tooltips[nField])
337 {
338 if (GetField(nField).IsEllipsized())
339 {
340 // update the rect of this tooltip:
341 m_tooltips[nField]->SetRect(rc);
342
343 // update also the text:
344 m_tooltips[nField]->SetTip(GetStatusText(nField));
345 }
346 else
347 {
348 // delete the tooltip associated with this pane; it's not needed anymore
5276b0a5 349 wxDELETE(m_tooltips[nField]);
6418ad5e
FM
350 }
351 }
352 else
353 {
354 // create a new tooltip for this pane if needed
355 if (GetField(nField).IsEllipsized())
356 m_tooltips[nField] = new wxToolTip(this, nField, GetStatusText(nField), rc);
357 //else: leave m_tooltips[nField]==NULL
358 }
b3d008db 359 }
2bda0e17
KB
360}
361
edd608b1 362wxStatusBar::MSWBorders wxStatusBar::MSWGetBorders() const
ed791986
VZ
363{
364 int aBorders[3];
365 SendMessage(GetHwnd(), SB_GETBORDERS, 0, (LPARAM)aBorders);
366
edd608b1
VZ
367 MSWBorders borders;
368 borders.horz = aBorders[0];
369 borders.vert = aBorders[1];
370 borders.between = aBorders[2];
371 return borders;
372}
373
374int wxStatusBar::GetBorderX() const
375{
376 return MSWGetBorders().horz;
ed791986
VZ
377}
378
936f6353 379int wxStatusBar::GetBorderY() const
ed791986 380{
edd608b1
VZ
381 return MSWGetBorders().vert;
382}
ed791986 383
edd608b1
VZ
384int wxStatusBar::MSWGetBorderWidth() const
385{
386 return MSWGetBorders().between;
387}
388
389/* static */
390const wxStatusBar::MSWMetrics& wxStatusBar::MSWGetMetrics()
391{
392 static MSWMetrics s_metrics = { 0 };
393 if ( !s_metrics.textMargin )
394 {
395 // Grip size should be self explanatory (the only problem with it is
396 // that it's hard coded as we don't know how to find its size using
397 // API) but the margin might merit an explanation: Windows offsets the
398 // text drawn in status bar panes so we need to take this extra margin
399 // into account to make sure the text drawn by user fits inside the
400 // pane. Notice that it's not the value returned by SB_GETBORDERS
401 // which, at least on this Windows 2003 system, returns {0, 2, 2}
402 if ( wxUxThemeEngine::GetIfActive() )
403 {
404 s_metrics.gripWidth = 20;
405 s_metrics.textMargin = 8;
406 }
407 else // classic/unthemed look
408 {
409 s_metrics.gripWidth = 18;
410 s_metrics.textMargin = 4;
411 }
412 }
413
414 return s_metrics;
ed791986
VZ
415}
416
936f6353 417void wxStatusBar::SetMinHeight(int height)
ed791986
VZ
418{
419 SendMessage(GetHwnd(), SB_SETMINHEIGHT, height + 2*GetBorderY(), 0);
420
6418ad5e 421 // we have to send a (dummy) WM_SIZE to redraw it now
ed791986
VZ
422 SendMessage(GetHwnd(), WM_SIZE, 0, 0);
423}
424
936f6353 425bool wxStatusBar::GetFieldRect(int i, wxRect& rect) const
ed791986 426{
a37d94d3 427 wxCHECK_MSG( (i >= 0) && ((size_t)i < m_panes.GetCount()), false,
6418ad5e 428 "invalid statusbar field index" );
ed791986
VZ
429
430 RECT r;
431 if ( !::SendMessage(GetHwnd(), SB_GETRECT, i, (LPARAM)&r) )
43b2d5e7 432 {
6418ad5e 433 wxLogLastError("SendMessage(SB_GETRECT)");
43b2d5e7 434 }
ed791986 435
1feb5443 436#if wxUSE_UXTHEME
6418ad5e 437 wxUxThemeHandle theme(const_cast<wxStatusBar*>(this), L"Status");
1feb5443
JG
438 if ( theme )
439 {
440 // by default Windows has a 2 pixel border to the right of the left
441 // divider (or it could be a bug) but it looks wrong so remove it
442 if ( i != 0 )
443 {
444 r.left -= 2;
445 }
446
447 wxUxThemeEngine::Get()->GetThemeBackgroundContentRect(theme, NULL,
448 1 /* SP_PANE */, 0,
449 &r, &r);
450 }
451#endif
452
ed791986
VZ
453 wxCopyRECTToRect(r, rect);
454
edd608b1
VZ
455 // Windows seems to under-report the size of the last field rectangle,
456 // presumably in order to prevent the buggy applications from overflowing
457 // onto the size grip but we want to return the real size to wx users
458 if ( HasFlag(wxSTB_SIZEGRIP) && i == (int)m_panes.GetCount() - 1 )
459 {
460 rect.width += MSWGetMetrics().gripWidth - MSWGetBorderWidth();
461 }
462
57f4f925 463 return true;
ed791986
VZ
464}
465
936f6353 466wxSize wxStatusBar::DoGetBestSize() const
c0ac3149 467{
edd608b1 468 const MSWBorders borders = MSWGetBorders();
c0ac3149
VZ
469
470 // calculate width
471 int width = 0;
a37d94d3 472 for ( size_t i = 0; i < m_panes.GetCount(); ++i )
c0ac3149 473 {
7b6fefbe 474 int widthField =
b31eaa5c 475 m_bSameWidthForAllPanes ? DEFAULT_FIELD_WIDTH : m_panes[i].GetWidth();
c0ac3149
VZ
476 if ( widthField >= 0 )
477 {
e408d9ca 478 width += widthField;
c0ac3149
VZ
479 }
480 else
481 {
482 // variable width field, its width is really a proportion
483 // related to the other fields
484 width += -widthField*DEFAULT_FIELD_WIDTH;
485 }
486
487 // add the space between fields
edd608b1 488 width += borders.between;
c0ac3149
VZ
489 }
490
491 if ( !width )
492 {
493 // still need something even for an empty status bar
494 width = 2*DEFAULT_FIELD_WIDTH;
495 }
496
c0ac3149
VZ
497 // calculate height
498 int height;
499 wxGetCharSize(GetHWND(), NULL, &height, GetFont());
500 height = EDIT_HEIGHT_FROM_CHAR_HEIGHT(height);
edd608b1 501 height += borders.vert;
c0ac3149
VZ
502
503 wxSize best(width, height);
504 CacheBestSize(best);
505 return best;
506}
507
936f6353 508void wxStatusBar::DoMoveWindow(int x, int y, int width, int height)
2bda0e17 509{
c07103f2
VZ
510 if ( GetParent()->IsSizeDeferred() )
511 {
512 wxWindowMSW::DoMoveWindow(x, y, width, height);
513 }
514 else
515 {
516 // parent pos/size isn't deferred so do it now but don't send
517 // WM_WINDOWPOSCHANGING since we don't want to change pos/size later
dd28827a
JG
518 // we must use SWP_NOCOPYBITS here otherwise it paints incorrectly
519 // if other windows are size deferred
c07103f2 520 ::SetWindowPos(GetHwnd(), NULL, x, y, width, height,
99cc862c 521 SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE
521bf4ff 522#ifndef __WXWINCE__
99cc862c
JS
523 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING
524#endif
525 );
c07103f2 526 }
43b5058d
VZ
527
528 // adjust fields widths to the new size
6cf68971 529 MSWUpdateFieldsWidths();
dafa4925 530
57f4f925 531 // we have to trigger wxSizeEvent if there are children window in status
dafa4925
VS
532 // bar because GetFieldRect returned incorrect (not updated) values up to
533 // here, which almost certainly resulted in incorrectly redrawn statusbar
534 if ( m_children.GetCount() > 0 )
535 {
536 wxSizeEvent event(GetClientSize(), m_windowId);
537 event.SetEventObject(this);
937013e0 538 HandleWindowEvent(event);
dafa4925 539 }
2bda0e17
KB
540}
541
936f6353 542void wxStatusBar::SetStatusStyles(int n, const int styles[])
c2919ab3
VZ
543{
544 wxStatusBarBase::SetStatusStyles(n, styles);
545
a37d94d3 546 if (n != (int)m_panes.GetCount())
c2919ab3
VZ
547 return;
548
549 for (int i = 0; i < n; i++)
550 {
551 int style;
552 switch(styles[i])
553 {
554 case wxSB_RAISED:
555 style = SBT_POPOUT;
556 break;
557 case wxSB_FLAT:
558 style = SBT_NOBORDERS;
559 break;
560 case wxSB_NORMAL:
561 default:
562 style = 0;
563 break;
564 }
6418ad5e 565
c2919ab3 566 // The SB_SETTEXT message is both used to set the field's text as well as
43b2d5e7 567 // the fields' styles.
6418ad5e 568 // NOTE: MSDN library doesn't mention that nField and style have to be 'ORed'
c2919ab3 569 wxString text = GetStatusText(i);
e0a050e3 570 if (!StatusBar_SetText(GetHwnd(), style | i, text.wx_str()))
43b2d5e7 571 {
6418ad5e 572 wxLogLastError("StatusBar_SetText");
43b2d5e7 573 }
c2919ab3
VZ
574 }
575}
576
c07103f2 577WXLRESULT
936f6353 578wxStatusBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
c07103f2 579{
e78e8583 580#ifndef __WXWINCE__
c07103f2
VZ
581 if ( nMsg == WM_WINDOWPOSCHANGING )
582 {
583 WINDOWPOS *lpPos = (WINDOWPOS *)lParam;
584 int x, y, w, h;
585 GetPosition(&x, &y);
586 GetSize(&w, &h);
587
4ce18ecb
VZ
588 // we need real window coords and not wx client coords
589 AdjustForParentClientOrigin(x, y);
590
c07103f2
VZ
591 lpPos->x = x;
592 lpPos->y = y;
593 lpPos->cx = w;
594 lpPos->cy = h;
595
596 return 0;
597 }
e78e8583 598
c07103f2
VZ
599 if ( nMsg == WM_NCLBUTTONDOWN )
600 {
601 // if hit-test is on gripper then send message to TLW to begin
602 // resizing. It is possible to send this message to any window.
603 if ( wParam == HTBOTTOMRIGHT )
604 {
605 wxWindow *win;
606
607 for ( win = GetParent(); win; win = win->GetParent() )
608 {
609 if ( win->IsTopLevel() )
610 {
611 SendMessage(GetHwndOf(win), WM_NCLBUTTONDOWN,
612 wParam, lParam);
613
614 return 0;
615 }
616 }
617 }
618 }
e78e8583 619#endif
c07103f2 620
6418ad5e
FM
621 bool needsEllipsization = HasFlag(wxSTB_ELLIPSIZE_START) ||
622 HasFlag(wxSTB_ELLIPSIZE_MIDDLE) ||
623 HasFlag(wxSTB_ELLIPSIZE_END);
624 if ( nMsg == WM_SIZE && needsEllipsization )
0cd15959
FM
625 {
626 for (int i=0; i<GetFieldsCount(); i++)
6cf68971 627 DoUpdateStatusText(i);
0cd15959
FM
628 // re-set the field text, in case we need to ellipsize
629 // (or de-ellipsize) some parts of it
630 }
631
c07103f2
VZ
632 return wxStatusBarBase::MSWWindowProc(nMsg, wParam, lParam);
633}
634
6418ad5e
FM
635#if wxUSE_TOOLTIPS
636bool wxStatusBar::MSWProcessMessage(WXMSG* pMsg)
637{
638 if ( HasFlag(wxSTB_SHOW_TIPS) )
639 {
640 // for a tooltip to be shown, we need to relay mouse events to it;
641 // this is typically done by wxWindowMSW::MSWProcessMessage but only
642 // if wxWindow::m_tooltip pointer is non-NULL.
643 // Since wxStatusBar has multiple tooltips for a single HWND, it keeps
644 // wxWindow::m_tooltip == NULL and then relays mouse events here:
645 MSG *msg = (MSG *)pMsg;
646 if ( msg->message == WM_MOUSEMOVE )
647 wxToolTip::RelayEvent(pMsg);
648 }
649
650 return wxWindow::MSWProcessMessage(pMsg);
651}
652
778adf4c 653bool wxStatusBar::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM* WXUNUSED(result))
6418ad5e
FM
654{
655 if ( HasFlag(wxSTB_SHOW_TIPS) )
656 {
657 // see comment in wxStatusBar::MSWProcessMessage for more info;
658 // basically we need to override wxWindow::MSWOnNotify because
659 // we have wxWindow::m_tooltip always NULL but we still use tooltips...
660
661 NMHDR* hdr = (NMHDR *)lParam;
662
663 wxString str;
664 if (hdr->idFrom < m_tooltips.size() && m_tooltips[hdr->idFrom])
665 str = m_tooltips[hdr->idFrom]->GetTip();
666
667 if ( HandleTooltipNotify(hdr->code, lParam, str))
668 {
669 // processed
670 return true;
671 }
672 }
673
674 return false;
675}
676#endif // wxUSE_TOOLTIPS
677
a71d815b 678#endif // wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR