]> git.saurik.com Git - wxWidgets.git/blame - src/msw/statusbar.cpp
fixes to pass tests
[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
864c08b2 156#if wxUSE_TOOLTIPS
421962be
FM
157 // delete existing tooltips
158 for (size_t i=0; i<m_tooltips.size(); i++)
159 {
5276b0a5 160 wxDELETE(m_tooltips[i]);
421962be 161 }
864c08b2 162#endif // wxUSE_TOOLTIPS
421962be 163
80255b7e 164 wxDELETE(m_pDC);
2bda0e17
KB
165}
166
0cd15959
FM
167bool wxStatusBar::SetFont(const wxFont& font)
168{
169 if (!wxWindow::SetFont(font))
170 return false;
171
80255b7e 172 if (m_pDC) m_pDC->SetFont(font);
0cd15959
FM
173 return true;
174}
175
936f6353 176void wxStatusBar::SetFieldsCount(int nFields, const int *widths)
2bda0e17 177{
f6bcfd97 178 // this is a Windows limitation
6418ad5e 179 wxASSERT_MSG( (nFields > 0) && (nFields < 255), "too many fields" );
2bda0e17 180
6418ad5e
FM
181 // keep in synch also our m_tooltips array
182
864c08b2 183#if wxUSE_TOOLTIPS
6418ad5e
FM
184 // reset all current tooltips
185 for (size_t i=0; i<m_tooltips.size(); i++)
186 {
5276b0a5 187 wxDELETE(m_tooltips[i]);
6418ad5e
FM
188 }
189
190 // shrink/expand the array:
796be923 191 m_tooltips.resize(nFields, NULL);
864c08b2 192#endif // wxUSE_TOOLTIPS
796be923
VZ
193
194 wxStatusBarBase::SetFieldsCount(nFields, widths);
195
196 MSWUpdateFieldsWidths();
2bda0e17
KB
197}
198
936f6353 199void wxStatusBar::SetStatusWidths(int n, const int widths[])
2bda0e17 200{
498fd97d 201 wxStatusBarBase::SetStatusWidths(n, widths);
2bda0e17 202
6cf68971 203 MSWUpdateFieldsWidths();
2bda0e17
KB
204}
205
6cf68971 206void wxStatusBar::MSWUpdateFieldsWidths()
2bda0e17 207{
7b6fefbe 208 if ( m_panes.IsEmpty() )
3175c712
VZ
209 return;
210
edd608b1
VZ
211 const int count = m_panes.GetCount();
212
213 const int extraWidth = MSWGetBorderWidth() + MSWGetMetrics().textMargin;
2bda0e17 214
edd608b1
VZ
215 // compute the effectively available amount of space:
216 int widthAvailable = GetClientSize().x; // start with the entire width
217 widthAvailable -= extraWidth*(count - 1); // extra space between fields
218 widthAvailable -= MSWGetMetrics().textMargin; // and for the last field
2bda0e17 219
8e76e931
VZ
220 // Deal with the grip: we shouldn't overflow onto the space occupied by it
221 // so the effectively available space is smaller.
222 const int gripWidth = HasFlag(wxSTB_SIZEGRIP) ? MSWGetMetrics().gripWidth
223 : 0;
224 widthAvailable -= gripWidth;
6418ad5e
FM
225
226 // distribute the available space (client width) among the various fields:
227
edd608b1 228 wxArrayInt widthsAbs = CalculateAbsWidths(widthAvailable);
2bda0e17 229
6418ad5e
FM
230
231 // update the field widths in the native control:
232
edd608b1 233 int *pWidths = new int[count];
2bda0e17 234
498fd97d 235 int nCurPos = 0;
a496a72d
VZ
236 int i;
237 for ( i = 0; i < count; i++ )
6418ad5e 238 {
498fd97d
VZ
239 nCurPos += widthsAbs[i] + extraWidth;
240 pWidths[i] = nCurPos;
2bda0e17 241 }
2bda0e17 242
8e76e931
VZ
243 // The total width of the panes passed to Windows must be equal to the
244 // total width available, including the grip. Otherwise we get an extra
245 // separator line just before it.
246 pWidths[count - 1] += gripWidth;
247
edd608b1 248 if ( !StatusBar_SetParts(GetHwnd(), count, pWidths) )
43b2d5e7 249 {
6418ad5e 250 wxLogLastError("StatusBar_SetParts");
43b2d5e7 251 }
2bda0e17 252
a496a72d
VZ
253 // Now that all parts have been created, set their text.
254 for ( i = 0; i < count; i++ )
255 {
256 DoUpdateStatusText(i);
257 }
258
ed791986 259 delete [] pWidths;
2bda0e17
KB
260}
261
6cf68971 262void wxStatusBar::DoUpdateStatusText(int nField)
0cd15959
FM
263{
264 if (!m_pDC)
265 return;
266
c2919ab3
VZ
267 // Get field style, if any
268 int style;
b31eaa5c 269 switch(m_panes[nField].GetStyle())
c2919ab3 270 {
7b6fefbe
FM
271 case wxSB_RAISED:
272 style = SBT_POPOUT;
273 break;
274 case wxSB_FLAT:
275 style = SBT_NOBORDERS;
276 break;
277
98eb2e84 278 case wxSB_SUNKEN:
7b6fefbe
FM
279 case wxSB_NORMAL:
280 default:
c2919ab3 281 style = 0;
7b6fefbe
FM
282 break;
283 }
c2919ab3 284
0cd15959
FM
285 wxRect rc;
286 GetFieldRect(nField, rc);
287
edd608b1 288 const int maxWidth = rc.GetWidth() - MSWGetMetrics().textMargin;
0cd15959 289
6418ad5e
FM
290 wxString text = GetStatusText(nField);
291
0cd15959 292 // do we need to ellipsize this string?
6418ad5e
FM
293 wxEllipsizeMode ellmode = (wxEllipsizeMode)-1;
294 if (HasFlag(wxSTB_ELLIPSIZE_START)) ellmode = wxELLIPSIZE_START;
295 else if (HasFlag(wxSTB_ELLIPSIZE_MIDDLE)) ellmode = wxELLIPSIZE_MIDDLE;
296 else if (HasFlag(wxSTB_ELLIPSIZE_END)) ellmode = wxELLIPSIZE_END;
297
298 if (ellmode == (wxEllipsizeMode)-1)
299 {
300 // if we have the wxSTB_SHOW_TIPS we must set the ellipsized flag even if
301 // we don't ellipsize the text but just truncate it
302 if (HasFlag(wxSTB_SHOW_TIPS))
303 SetEllipsizedFlag(nField, m_pDC->GetTextExtent(text).GetWidth() > maxWidth);
304 }
305 else
b3d008db 306 {
43b2d5e7 307 text = wxControl::Ellipsize(text,
6418ad5e
FM
308 *m_pDC,
309 ellmode,
310 maxWidth,
355ce7ad 311 wxELLIPSIZE_FLAGS_EXPAND_TABS);
43b2d5e7
VZ
312
313 // update the ellipsization status for this pane; this is used later to
314 // decide whether a tooltip should be shown or not for this pane
6418ad5e
FM
315 // (if we have wxSTB_SHOW_TIPS)
316 SetEllipsizedFlag(nField, text != GetStatusText(nField));
317 }
318
43b2d5e7 319 // Set the status text in the native control passing both field number and style.
6418ad5e 320 // NOTE: MSDN library doesn't mention that nField and style have to be 'ORed'
017dc06b 321 if ( !StatusBar_SetText(GetHwnd(), nField | style, text.t_str()) )
43b2d5e7 322 {
6418ad5e 323 wxLogLastError("StatusBar_SetText");
43b2d5e7 324 }
6418ad5e 325
864c08b2 326#if wxUSE_TOOLTIPS
6418ad5e
FM
327 if (HasFlag(wxSTB_SHOW_TIPS))
328 {
329 wxASSERT(m_tooltips.size() == m_panes.GetCount());
330
331 if (m_tooltips[nField])
332 {
333 if (GetField(nField).IsEllipsized())
334 {
335 // update the rect of this tooltip:
336 m_tooltips[nField]->SetRect(rc);
337
338 // update also the text:
339 m_tooltips[nField]->SetTip(GetStatusText(nField));
340 }
341 else
342 {
343 // delete the tooltip associated with this pane; it's not needed anymore
5276b0a5 344 wxDELETE(m_tooltips[nField]);
6418ad5e
FM
345 }
346 }
347 else
348 {
349 // create a new tooltip for this pane if needed
350 if (GetField(nField).IsEllipsized())
351 m_tooltips[nField] = new wxToolTip(this, nField, GetStatusText(nField), rc);
352 //else: leave m_tooltips[nField]==NULL
353 }
b3d008db 354 }
864c08b2 355#endif // wxUSE_TOOLTIPS
2bda0e17
KB
356}
357
edd608b1 358wxStatusBar::MSWBorders wxStatusBar::MSWGetBorders() const
ed791986
VZ
359{
360 int aBorders[3];
361 SendMessage(GetHwnd(), SB_GETBORDERS, 0, (LPARAM)aBorders);
362
edd608b1
VZ
363 MSWBorders borders;
364 borders.horz = aBorders[0];
365 borders.vert = aBorders[1];
366 borders.between = aBorders[2];
367 return borders;
368}
369
370int wxStatusBar::GetBorderX() const
371{
372 return MSWGetBorders().horz;
ed791986
VZ
373}
374
936f6353 375int wxStatusBar::GetBorderY() const
ed791986 376{
edd608b1
VZ
377 return MSWGetBorders().vert;
378}
ed791986 379
edd608b1
VZ
380int wxStatusBar::MSWGetBorderWidth() const
381{
382 return MSWGetBorders().between;
383}
384
385/* static */
386const wxStatusBar::MSWMetrics& wxStatusBar::MSWGetMetrics()
387{
917b0085 388 static MSWMetrics s_metrics = { 0, 0 };
edd608b1
VZ
389 if ( !s_metrics.textMargin )
390 {
391 // Grip size should be self explanatory (the only problem with it is
392 // that it's hard coded as we don't know how to find its size using
393 // API) but the margin might merit an explanation: Windows offsets the
394 // text drawn in status bar panes so we need to take this extra margin
395 // into account to make sure the text drawn by user fits inside the
396 // pane. Notice that it's not the value returned by SB_GETBORDERS
397 // which, at least on this Windows 2003 system, returns {0, 2, 2}
864c08b2 398#if wxUSE_UXTHEME
edd608b1
VZ
399 if ( wxUxThemeEngine::GetIfActive() )
400 {
401 s_metrics.gripWidth = 20;
402 s_metrics.textMargin = 8;
403 }
404 else // classic/unthemed look
864c08b2 405#endif // wxUSE_UXTHEME
edd608b1
VZ
406 {
407 s_metrics.gripWidth = 18;
408 s_metrics.textMargin = 4;
409 }
410 }
411
412 return s_metrics;
ed791986
VZ
413}
414
936f6353 415void wxStatusBar::SetMinHeight(int height)
ed791986 416{
d9fc8e99
VZ
417 // It looks like we need to count the border twice to really make the
418 // controls taking exactly height pixels fully fit in the status bar:
419 // at least under Windows 7 the checkbox in the custom status bar of the
420 // statbar sample gets truncated otherwise.
421 height += 4*GetBorderY();
422
423 // We need to set the size and not the size to reflect the height because
424 // wxFrame uses our size and not the minimal size as it assumes that the
425 // size of a status bar never changes anyhow.
426 SetSize(-1, height);
427
428 SendMessage(GetHwnd(), SB_SETMINHEIGHT, height, 0);
ed791986 429
6418ad5e 430 // we have to send a (dummy) WM_SIZE to redraw it now
ed791986
VZ
431 SendMessage(GetHwnd(), WM_SIZE, 0, 0);
432}
433
936f6353 434bool wxStatusBar::GetFieldRect(int i, wxRect& rect) const
ed791986 435{
a37d94d3 436 wxCHECK_MSG( (i >= 0) && ((size_t)i < m_panes.GetCount()), false,
6418ad5e 437 "invalid statusbar field index" );
ed791986
VZ
438
439 RECT r;
440 if ( !::SendMessage(GetHwnd(), SB_GETRECT, i, (LPARAM)&r) )
43b2d5e7 441 {
6418ad5e 442 wxLogLastError("SendMessage(SB_GETRECT)");
43b2d5e7 443 }
ed791986 444
1feb5443 445#if wxUSE_UXTHEME
6418ad5e 446 wxUxThemeHandle theme(const_cast<wxStatusBar*>(this), L"Status");
1feb5443
JG
447 if ( theme )
448 {
449 // by default Windows has a 2 pixel border to the right of the left
450 // divider (or it could be a bug) but it looks wrong so remove it
451 if ( i != 0 )
452 {
453 r.left -= 2;
454 }
455
456 wxUxThemeEngine::Get()->GetThemeBackgroundContentRect(theme, NULL,
457 1 /* SP_PANE */, 0,
458 &r, &r);
459 }
460#endif
461
ed791986
VZ
462 wxCopyRECTToRect(r, rect);
463
57f4f925 464 return true;
ed791986
VZ
465}
466
936f6353 467wxSize wxStatusBar::DoGetBestSize() const
c0ac3149 468{
edd608b1 469 const MSWBorders borders = MSWGetBorders();
c0ac3149
VZ
470
471 // calculate width
472 int width = 0;
a37d94d3 473 for ( size_t i = 0; i < m_panes.GetCount(); ++i )
c0ac3149 474 {
7b6fefbe 475 int widthField =
b31eaa5c 476 m_bSameWidthForAllPanes ? DEFAULT_FIELD_WIDTH : m_panes[i].GetWidth();
c0ac3149
VZ
477 if ( widthField >= 0 )
478 {
e408d9ca 479 width += widthField;
c0ac3149
VZ
480 }
481 else
482 {
483 // variable width field, its width is really a proportion
484 // related to the other fields
485 width += -widthField*DEFAULT_FIELD_WIDTH;
486 }
487
488 // add the space between fields
edd608b1 489 width += borders.between;
c0ac3149
VZ
490 }
491
492 if ( !width )
493 {
494 // still need something even for an empty status bar
495 width = 2*DEFAULT_FIELD_WIDTH;
496 }
497
d9fc8e99
VZ
498 // calculate height: by default it should be just big enough to show text
499 // (see SetMinHeight() for the explanation of 4 factor)
500 int height = GetCharHeight();
501 height += 4*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 527
57f4f925 528 // we have to trigger wxSizeEvent if there are children window in status
dafa4925
VS
529 // bar because GetFieldRect returned incorrect (not updated) values up to
530 // here, which almost certainly resulted in incorrectly redrawn statusbar
531 if ( m_children.GetCount() > 0 )
532 {
533 wxSizeEvent event(GetClientSize(), m_windowId);
534 event.SetEventObject(this);
937013e0 535 HandleWindowEvent(event);
dafa4925 536 }
2bda0e17
KB
537}
538
936f6353 539void wxStatusBar::SetStatusStyles(int n, const int styles[])
c2919ab3
VZ
540{
541 wxStatusBarBase::SetStatusStyles(n, styles);
542
a37d94d3 543 if (n != (int)m_panes.GetCount())
c2919ab3
VZ
544 return;
545
546 for (int i = 0; i < n; i++)
547 {
548 int style;
549 switch(styles[i])
550 {
551 case wxSB_RAISED:
552 style = SBT_POPOUT;
553 break;
554 case wxSB_FLAT:
555 style = SBT_NOBORDERS;
556 break;
98eb2e84 557 case wxSB_SUNKEN:
c2919ab3
VZ
558 case wxSB_NORMAL:
559 default:
560 style = 0;
561 break;
562 }
6418ad5e 563
c2919ab3 564 // The SB_SETTEXT message is both used to set the field's text as well as
43b2d5e7 565 // the fields' styles.
6418ad5e 566 // NOTE: MSDN library doesn't mention that nField and style have to be 'ORed'
c2919ab3 567 wxString text = GetStatusText(i);
017dc06b 568 if (!StatusBar_SetText(GetHwnd(), style | i, text.t_str()))
43b2d5e7 569 {
6418ad5e 570 wxLogLastError("StatusBar_SetText");
43b2d5e7 571 }
c2919ab3
VZ
572 }
573}
574
c07103f2 575WXLRESULT
936f6353 576wxStatusBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
c07103f2 577{
e78e8583 578#ifndef __WXWINCE__
c07103f2
VZ
579 if ( nMsg == WM_WINDOWPOSCHANGING )
580 {
581 WINDOWPOS *lpPos = (WINDOWPOS *)lParam;
582 int x, y, w, h;
583 GetPosition(&x, &y);
584 GetSize(&w, &h);
585
4ce18ecb
VZ
586 // we need real window coords and not wx client coords
587 AdjustForParentClientOrigin(x, y);
588
c07103f2
VZ
589 lpPos->x = x;
590 lpPos->y = y;
591 lpPos->cx = w;
592 lpPos->cy = h;
593
594 return 0;
595 }
e78e8583 596
c07103f2
VZ
597 if ( nMsg == WM_NCLBUTTONDOWN )
598 {
599 // if hit-test is on gripper then send message to TLW to begin
600 // resizing. It is possible to send this message to any window.
601 if ( wParam == HTBOTTOMRIGHT )
602 {
603 wxWindow *win;
604
605 for ( win = GetParent(); win; win = win->GetParent() )
606 {
607 if ( win->IsTopLevel() )
608 {
609 SendMessage(GetHwndOf(win), WM_NCLBUTTONDOWN,
610 wParam, lParam);
611
612 return 0;
613 }
614 }
615 }
616 }
e78e8583 617#endif
c07103f2 618
208f99c3 619 if ( nMsg == WM_SIZE )
0cd15959 620 {
208f99c3
VZ
621 MSWUpdateFieldsWidths();
622
623 if ( HasFlag(wxSTB_ELLIPSIZE_START) ||
624 HasFlag(wxSTB_ELLIPSIZE_MIDDLE) ||
625 HasFlag(wxSTB_ELLIPSIZE_END) )
626 {
627 for (int i=0; i<GetFieldsCount(); i++)
628 {
629 // re-set the field text, in case we need to ellipsize
630 // (or de-ellipsize) some parts of it
631 DoUpdateStatusText(i);
632 }
633 }
0cd15959
FM
634 }
635
c07103f2
VZ
636 return wxStatusBarBase::MSWWindowProc(nMsg, wParam, lParam);
637}
638
6418ad5e
FM
639#if wxUSE_TOOLTIPS
640bool wxStatusBar::MSWProcessMessage(WXMSG* pMsg)
641{
642 if ( HasFlag(wxSTB_SHOW_TIPS) )
643 {
644 // for a tooltip to be shown, we need to relay mouse events to it;
645 // this is typically done by wxWindowMSW::MSWProcessMessage but only
646 // if wxWindow::m_tooltip pointer is non-NULL.
647 // Since wxStatusBar has multiple tooltips for a single HWND, it keeps
648 // wxWindow::m_tooltip == NULL and then relays mouse events here:
649 MSG *msg = (MSG *)pMsg;
650 if ( msg->message == WM_MOUSEMOVE )
651 wxToolTip::RelayEvent(pMsg);
652 }
653
654 return wxWindow::MSWProcessMessage(pMsg);
655}
656
778adf4c 657bool wxStatusBar::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM* WXUNUSED(result))
6418ad5e
FM
658{
659 if ( HasFlag(wxSTB_SHOW_TIPS) )
660 {
661 // see comment in wxStatusBar::MSWProcessMessage for more info;
662 // basically we need to override wxWindow::MSWOnNotify because
663 // we have wxWindow::m_tooltip always NULL but we still use tooltips...
664
665 NMHDR* hdr = (NMHDR *)lParam;
666
667 wxString str;
668 if (hdr->idFrom < m_tooltips.size() && m_tooltips[hdr->idFrom])
669 str = m_tooltips[hdr->idFrom]->GetTip();
670
671 if ( HandleTooltipNotify(hdr->code, lParam, str))
672 {
673 // processed
674 return true;
675 }
676 }
677
678 return false;
679}
680#endif // wxUSE_TOOLTIPS
681
a71d815b 682#endif // wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR