]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/stattext.cpp
Do not allow events to fire after socket is closed (fixes crash on GTK with GDK_Input...
[wxWidgets.git] / src / msw / stattext.cpp
index 466fb5484d981a815ee5523f67e20a60a6081e22..e881b3f838f72fdf60a10b2759ee651329e4dba4 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "stattext.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -123,28 +119,10 @@ WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const
     else
         msStyle |= SS_LEFT;
 
-    return msStyle;
-}
+    // this style is necessary to receive mouse events
+    msStyle |= SS_NOTIFY;
 
-WXHBRUSH wxStaticText::DoMSWControlColor(WXHDC pDC, wxColour colBg)
-{
-    // If this control has a non-standard fg colour but still has the standard
-    // bg then we need to also give it a non-standard bg otherwise the fg
-    // setting has no effect.
-    WXHBRUSH hbr = wxControl::DoMSWControlColor(pDC, colBg);
-    if (!hbr && m_hasFgCol)
-    {
-        hbr = MSWGetBgBrushForChild(pDC, this);
-        if (!hbr)
-        {
-            HDC hdc = (HDC)pDC;
-            wxColour bg = GetBackgroundColour();
-            ::SetBkColor(hdc, wxColourToRGB(bg));
-            wxBrush *brush = wxTheBrushList->FindOrCreateBrush(bg, wxSOLID);
-            hbr = (WXHBRUSH)brush->GetResourceHandle();
-        }
-    }
-    return hbr;
+    return msStyle;
 }
 
 wxSize wxStaticText::DoGetBestSize() const
@@ -153,7 +131,7 @@ wxSize wxStaticText::DoGetBestSize() const
     wxFont font(GetFont());
     if (!font.Ok())
         font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
-    
+
     dc.SetFont(font);
 
     wxCoord widthTextMax, heightTextTotal;
@@ -164,7 +142,40 @@ wxSize wxStaticText::DoGetBestSize() const
         widthTextMax += 2;
 #endif // __WXWINCE__
 
-    return wxSize(widthTextMax, heightTextTotal);
+    // border takes extra space
+    //
+    // TODO: this is probably not wxStaticText-specific and should be moved
+    wxCoord border;
+    switch ( GetBorder() )
+    {
+        case wxBORDER_STATIC:
+        case wxBORDER_SIMPLE:
+            border = 1;
+            break;
+
+        case wxBORDER_SUNKEN:
+            border = 2;
+            break;
+
+        case wxBORDER_RAISED:
+        case wxBORDER_DOUBLE:
+            border = 3;
+            break;
+
+        default:
+            wxFAIL_MSG( _T("unknown border style") );
+            // fall through
+
+        case wxBORDER_NONE:
+            border = 0;
+    }
+
+    widthTextMax += 2*border;
+    heightTextTotal += 2*border;
+
+    wxSize best(widthTextMax, heightTextTotal);
+    CacheBestSize(best);
+    return best;
 }
 
 void wxStaticText::DoSetSize(int x, int y, int w, int h, int sizeFlags)