]> git.saurik.com Git - wxWidgets.git/commitdiff
Refactor wxStatusBar creation in wxMSW to do it in standard way.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 22 Nov 2010 01:22:41 +0000 (01:22 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 22 Nov 2010 01:22:41 +0000 (01:22 +0000)
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

include/wx/msw/statusbar.h
src/msw/statusbar.cpp

index e942dd56b990582187531825fb1c940cd391cf28..60eaf7d7fcf69168299961aeeef72531b291e9e0 100644 (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
index a7031f4f5195e8b1171fd6537d4426b0cc1d02f7..1f3fbbb4d43b18e78f1d3e0e370bcac319dee67b 100644 (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 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