X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/208f99c3e398e7ddf95016fff5e67883714fff54..8a31648287be0ef976f133de2786b137f1e98340:/src/msw/statusbar.cpp?ds=sidebyside diff --git a/src/msw/statusbar.cpp b/src/msw/statusbar.cpp index e694abf247..48960afe22 100644 --- a/src/msw/statusbar.cpp +++ b/src/msw/statusbar.cpp @@ -176,10 +176,6 @@ void wxStatusBar::SetFieldsCount(int nFields, const int *widths) // this is a Windows limitation wxASSERT_MSG( (nFields > 0) && (nFields < 255), "too many fields" ); - wxStatusBarBase::SetFieldsCount(nFields, widths); - - MSWUpdateFieldsWidths(); - // keep in synch also our m_tooltips array // reset all current tooltips @@ -189,7 +185,11 @@ void wxStatusBar::SetFieldsCount(int nFields, const int *widths) } // shrink/expand the array: - m_tooltips.resize(m_panes.GetCount(), NULL); + m_tooltips.resize(nFields, NULL); + + wxStatusBarBase::SetFieldsCount(nFields, widths); + + MSWUpdateFieldsWidths(); } void wxStatusBar::SetStatusWidths(int n, const int widths[]) @@ -229,7 +229,8 @@ void wxStatusBar::MSWUpdateFieldsWidths() int *pWidths = new int[count]; int nCurPos = 0; - for ( int i = 0; i < count; i++ ) + int i; + for ( i = 0; i < count; i++ ) { nCurPos += widthsAbs[i] + extraWidth; pWidths[i] = nCurPos; @@ -245,10 +246,13 @@ void wxStatusBar::MSWUpdateFieldsWidths() wxLogLastError("StatusBar_SetParts"); } - delete [] pWidths; - + // Now that all parts have been created, set their text. + for ( i = 0; i < count; i++ ) + { + DoUpdateStatusText(i); + } - // FIXME: we may want to call DoUpdateStatusText() here since we may need to (de)ellipsize status texts + delete [] pWidths; } void wxStatusBar::DoUpdateStatusText(int nField) @@ -374,7 +378,7 @@ int wxStatusBar::MSWGetBorderWidth() const /* static */ const wxStatusBar::MSWMetrics& wxStatusBar::MSWGetMetrics() { - static MSWMetrics s_metrics = { 0 }; + static MSWMetrics s_metrics = { 0, 0 }; if ( !s_metrics.textMargin ) { // Grip size should be self explanatory (the only problem with it is @@ -401,7 +405,18 @@ const wxStatusBar::MSWMetrics& wxStatusBar::MSWGetMetrics() void wxStatusBar::SetMinHeight(int height) { - SendMessage(GetHwnd(), SB_SETMINHEIGHT, height + 2*GetBorderY(), 0); + // It looks like we need to count the border twice to really make the + // controls taking exactly height pixels fully fit in the status bar: + // at least under Windows 7 the checkbox in the custom status bar of the + // statbar sample gets truncated otherwise. + height += 4*GetBorderY(); + + // We need to set the size and not the size to reflect the height because + // wxFrame uses our size and not the minimal size as it assumes that the + // size of a status bar never changes anyhow. + SetSize(-1, height); + + SendMessage(GetHwnd(), SB_SETMINHEIGHT, height, 0); // we have to send a (dummy) WM_SIZE to redraw it now SendMessage(GetHwnd(), WM_SIZE, 0, 0); @@ -471,11 +486,10 @@ wxSize wxStatusBar::DoGetBestSize() const width = 2*DEFAULT_FIELD_WIDTH; } - // calculate height - int height; - wxGetCharSize(GetHWND(), NULL, &height, GetFont()); - height = EDIT_HEIGHT_FROM_CHAR_HEIGHT(height); - height += borders.vert; + // calculate height: by default it should be just big enough to show text + // (see SetMinHeight() for the explanation of 4 factor) + int height = GetCharHeight(); + height += 4*borders.vert; wxSize best(width, height); CacheBestSize(best);