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:
@@ -62,6 +62,7 @@ protected:
|
|||||||
virtual void DoUpdateStatusText(int number);
|
virtual void DoUpdateStatusText(int number);
|
||||||
|
|
||||||
// override some base class virtuals
|
// override some base class virtuals
|
||||||
|
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
|
@@ -84,29 +84,15 @@ wxStatusBar::wxStatusBar()
|
|||||||
m_pDC = NULL;
|
m_pDC = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxStatusBar::Create(wxWindow *parent,
|
WXDWORD wxStatusBar::MSWGetStyle(long style, WXDWORD *exstyle) const
|
||||||
wxWindowID id,
|
|
||||||
long style,
|
|
||||||
const wxString& name)
|
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( parent, false, "status bar must have a parent" );
|
WXDWORD msStyle = wxStatusBarBase::MSWGetStyle(style, exstyle);
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
// wxSTB_SIZEGRIP is part of our default style but it doesn't make sense to
|
// 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
|
// show size grip if this is the status bar of a non-resizeable TLW so turn
|
||||||
// it off in such case
|
// 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) )
|
if ( parent->IsTopLevel() && !parent->HasFlag(wxRESIZE_BORDER) )
|
||||||
style &= ~wxSTB_SIZEGRIP;
|
style &= ~wxSTB_SIZEGRIP;
|
||||||
|
|
||||||
@@ -117,45 +103,38 @@ bool wxStatusBar::Create(wxWindow *parent,
|
|||||||
// is not given
|
// is not given
|
||||||
if ( !(style & wxSTB_SIZEGRIP) )
|
if ( !(style & wxSTB_SIZEGRIP) )
|
||||||
{
|
{
|
||||||
wstyle |= CCS_TOP;
|
*exstyle |= CCS_TOP;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef __WXWINCE__
|
#ifndef __WXWINCE__
|
||||||
// may be some versions of comctl32.dll do need it - anyhow, it won't
|
// may be some versions of comctl32.dll do need it - anyhow, it won't
|
||||||
// do any harm
|
// do any harm
|
||||||
wstyle |= SBARS_SIZEGRIP;
|
*exstyle |= SBARS_SIZEGRIP;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hWnd = CreateWindow
|
return msStyle;
|
||||||
(
|
}
|
||||||
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."));
|
|
||||||
|
|
||||||
|
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;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
SetFieldsCount(1);
|
SetFieldsCount(1);
|
||||||
SubclassWin(m_hWnd);
|
|
||||||
|
|
||||||
// cache the DC instance used by DoUpdateStatusText:
|
// 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);
|
m_pDC = new wxClientDC(this);
|
||||||
|
|
||||||
InheritAttributes();
|
|
||||||
|
|
||||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR));
|
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR));
|
||||||
|
|
||||||
// we must refresh the frame size when the statusbar is created, because
|
// we must refresh the frame size when the statusbar is created, because
|
||||||
|
Reference in New Issue
Block a user