]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/statusbar.cpp
fix for PCH-less builds
[wxWidgets.git] / src / msw / statusbar.cpp
index 0dcc35899c083630817b7566c10d04a8bb2f1309..e2fd86ab70b53b4a48f4b206b777b51be9a5d372 100644 (file)
@@ -27,6 +27,7 @@
     #include "wx/dcclient.h"
     #include "wx/intl.h"
     #include "wx/log.h"
+    #include "wx/control.h"
 #endif
 
 #include "wx/msw/private.h"
@@ -123,6 +124,12 @@ bool wxStatusBar::Create(wxWindow *parent,
 
     SetFieldsCount(1);
     SubclassWin(m_hWnd);
+
+    // cache the DC instance used by UpdateFieldText:
+    // 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));
@@ -135,9 +142,6 @@ bool wxStatusBar::Create(wxWindow *parent,
     // work correctly, we need to wait until we return to the main loop
     PostSizeEventToParent();
 
-    // cache the DC instance used by UpdateFieldText
-    m_pDC = new wxClientDC(this);
-
     return true;
 }
 
@@ -147,6 +151,8 @@ wxStatusBar::~wxStatusBar()
     // frame is not - otherwise statusbar leaves a hole in the place it used to
     // occupy
     PostSizeEventToParent();
+
+    wxDELETE(m_pDC);
 }
 
 bool wxStatusBar::SetFont(const wxFont& font)
@@ -154,7 +160,7 @@ bool wxStatusBar::SetFont(const wxFont& font)
     if (!wxWindow::SetFont(font))
         return false;
 
-    m_pDC->SetFont(font);
+    if (m_pDC) m_pDC->SetFont(font);
     return true;
 }
 
@@ -226,7 +232,7 @@ void wxStatusBar::UpdateFieldText(int nField)
 
     // Get field style, if any
     int style;
-    switch(m_panes[nField].nStyle)
+    switch(m_panes[nField].GetStyle())
     {
     case wxSB_RAISED:
         style = SBT_POPOUT;
@@ -332,7 +338,7 @@ wxSize wxStatusBar::DoGetBestSize() const
     for ( size_t i = 0; i < m_panes.GetCount(); ++i )
     {
         int widthField =
-            m_bSameWidthForAllPanes ? DEFAULT_FIELD_WIDTH : m_panes[i].nWidth;
+            m_bSameWidthForAllPanes ? DEFAULT_FIELD_WIDTH : m_panes[i].GetWidth();
         if ( widthField >= 0 )
         {
             width += widthField;