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