X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6cf68971005ab7a0ccee82ffffa2924eeb62f689..72c5855f5c9e6b5747dc9571d64e217eff26561d:/src/msw/statusbar.cpp diff --git a/src/msw/statusbar.cpp b/src/msw/statusbar.cpp index 8b58819757..c2767b34df 100644 --- a/src/msw/statusbar.cpp +++ b/src/msw/statusbar.cpp @@ -9,6 +9,14 @@ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -38,8 +46,17 @@ #include "wx/msw/uxtheme.h" #endif +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +namespace +{ + // no idea for a default width, just choose something -#define DEFAULT_FIELD_WIDTH 25 +static const int DEFAULT_FIELD_WIDTH = 25; + +} // anonymous namespace // ---------------------------------------------------------------------------- // macros @@ -67,25 +84,17 @@ wxStatusBar::wxStatusBar() m_pDC = NULL; } -bool wxStatusBar::Create(wxWindow *parent, - wxWindowID id, - long style, - const wxString& name) +WXDWORD wxStatusBar::MSWGetStyle(long style, WXDWORD *exstyle) const { - wxCHECK_MSG( parent, false, "status bar must have a parent" ); - - SetName(name); - SetWindowStyleFlag(style); - SetParent(parent); - - parent->AddChild(this); + WXDWORD msStyle = wxStatusBarBase::MSWGetStyle(style, exstyle); - m_windowId = id == wxID_ANY ? NewControlId() : id; - - DWORD wstyle = WS_CHILD | WS_VISIBLE; - - if ( style & wxCLIP_SIBLINGS ) - wstyle |= WS_CLIPSIBLINGS; + // wxSTB_SIZEGRIP is part of our default style but it doesn't make sense to + // show size grip if this is the status bar of a non-resizable TLW so turn + // it off in such case + wxWindow * const parent = GetParent(); + wxCHECK_MSG( parent, msStyle, wxS("Status bar must have a parent") ); + if ( parent->IsTopLevel() && !parent->HasFlag(wxRESIZE_BORDER) ) + style &= ~wxSTB_SIZEGRIP; // setting SBARS_SIZEGRIP is perfectly useless: it's always on by default // (at least in the version of comctl32.dll I'm using), and the only way to @@ -94,47 +103,38 @@ bool wxStatusBar::Create(wxWindow *parent, // is not given if ( !(style & wxSTB_SIZEGRIP) ) { - wstyle |= CCS_TOP; + msStyle |= CCS_TOP; } else { #ifndef __WXWINCE__ // may be some versions of comctl32.dll do need it - anyhow, it won't // do any harm - wstyle |= SBARS_SIZEGRIP; + msStyle |= SBARS_SIZEGRIP; #endif } - m_hWnd = CreateWindow - ( - STATUSCLASSNAME, - wxT(""), - wstyle, - 0, 0, 0, 0, - GetHwndOf(parent), - (HMENU)wxUIntToPtr(m_windowId.GetValue()), - wxGetInstance(), - NULL - ); - if ( m_hWnd == 0 ) - { - wxLogSysError(_("Failed to create a status bar.")); + return msStyle; +} +bool wxStatusBar::Create(wxWindow *parent, + wxWindowID id, + long style, + const wxString& name) +{ + if ( !CreateControl(parent, id, wxDefaultPosition, wxDefaultSize, + style, wxDefaultValidator, name) ) + return false; + + if ( !MSWCreateControl(STATUSCLASSNAME, wxString(), + wxDefaultPosition, wxDefaultSize) ) return false; - } SetFieldsCount(1); - SubclassWin(m_hWnd); // cache the DC instance used by DoUpdateStatusText: - // NOTE: create the DC before calling InheritAttributes() since - // it may result in a call to our SetFont() m_pDC = new wxClientDC(this); - InheritAttributes(); - - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR)); - // we must refresh the frame size when the statusbar is created, because // its client area might change // @@ -153,15 +153,13 @@ wxStatusBar::~wxStatusBar() // occupy PostSizeEventToParent(); +#if wxUSE_TOOLTIPS // delete existing tooltips for (size_t i=0; i 0) && (nFields < 255), "too many fields" ); - wxStatusBarBase::SetFieldsCount(nFields, widths); - - MSWUpdateFieldsWidths(); - // keep in synch also our m_tooltips array +#if wxUSE_TOOLTIPS // reset all current tooltips for (size_t i=0; i