Refactor wxStatusBar creation in wxMSW to do it in standard way.

Use wxControl-provided CreateControl() and MSWCreateControl() methods to
create the status bar instead of duplicating their code in its Create().

Also translate wx styles to MSW ones in overridden MSWGetStyle() now.

In addition to making the code smaller and more clear, this fixes the
non-respect of the styles specified at status bar creation (e.g. border),
see #12655.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-11-22 01:22:41 +00:00
parent f771bae35a
commit db6150d59a
2 changed files with 20 additions and 40 deletions

View File

@@ -62,6 +62,7 @@ protected:
virtual void DoUpdateStatusText(int number);
// override some base class virtuals
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
virtual wxSize DoGetBestSize() const;
virtual void DoMoveWindow(int x, int y, int width, int height);
#if wxUSE_TOOLTIPS

View File

@@ -84,29 +84,15 @@ 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);
m_windowId = id == wxID_ANY ? NewControlId() : id;
DWORD wstyle = WS_CHILD | WS_VISIBLE;
if ( style & wxCLIP_SIBLINGS )
wstyle |= WS_CLIPSIBLINGS;
WXDWORD msStyle = wxStatusBarBase::MSWGetStyle(style, exstyle);
// 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-resizeable 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;
@@ -117,45 +103,38 @@ bool wxStatusBar::Create(wxWindow *parent,
// is not given
if ( !(style & wxSTB_SIZEGRIP) )
{
wstyle |= CCS_TOP;
*exstyle |= 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;
*exstyle |= 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 false;
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