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