]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/brush.cpp
Add more checks for wxUSE_DYNLIB_CLASS to wxMSW.
[wxWidgets.git] / src / msw / brush.cpp
index 5eae40c16a16c93f2ac807542f54e3dcc1a283b3..09f346bcdd7682d3fa2f639a0254878575844723 100644 (file)
@@ -6,17 +6,13 @@
 // Created:     04/01/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
 // Created:     04/01/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
-// Licence:     wxWidgets licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
 // declarations
 // ============================================================================
 
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
 // declarations
 // ============================================================================
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "brush.h"
-#endif
-
 // ----------------------------------------------------------------------------
 // headers
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // headers
 // ----------------------------------------------------------------------------
     #pragma hdrstop
 #endif
 
     #pragma hdrstop
 #endif
 
+#include "wx/brush.h"
+
 #ifndef WX_PRECOMP
     #include "wx/list.h"
     #include "wx/utils.h"
     #include "wx/app.h"
 #ifndef WX_PRECOMP
     #include "wx/list.h"
     #include "wx/utils.h"
     #include "wx/app.h"
-    #include "wx/brush.h"
+    #include "wx/bitmap.h"
 #endif // WX_PRECOMP
 
 #include "wx/msw/private.h"
 #endif // WX_PRECOMP
 
 #include "wx/msw/private.h"
@@ -44,7 +42,7 @@
 class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
 {
 public:
 class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
 {
 public:
-    wxBrushRefData(const wxColour& colour = wxNullColour, int style = wxSOLID);
+    wxBrushRefData(const wxColour& colour = wxNullColour, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
     wxBrushRefData(const wxBitmap& stipple);
     wxBrushRefData(const wxBrushRefData& data);
     virtual ~wxBrushRefData();
     wxBrushRefData(const wxBitmap& stipple);
     wxBrushRefData(const wxBrushRefData& data);
     virtual ~wxBrushRefData();
@@ -55,17 +53,17 @@ public:
     void Free();
 
     const wxColour& GetColour() const { return m_colour; }
     void Free();
 
     const wxColour& GetColour() const { return m_colour; }
-    int GetStyle() const { return m_style; }
+    wxBrushStyle GetStyle() const { return m_style; }
     wxBitmap *GetStipple() { return &m_stipple; }
 
     void SetColour(const wxColour& colour) { Free(); m_colour = colour; }
     wxBitmap *GetStipple() { return &m_stipple; }
 
     void SetColour(const wxColour& colour) { Free(); m_colour = colour; }
-    void SetStyle(int style) { Free(); m_style = style; }
+    void SetStyle(wxBrushStyle style) { Free(); m_style = style; }
     void SetStipple(const wxBitmap& stipple) { Free(); DoSetStipple(stipple); }
 
 private:
     void DoSetStipple(const wxBitmap& stipple);
 
     void SetStipple(const wxBitmap& stipple) { Free(); DoSetStipple(stipple); }
 
 private:
     void DoSetStipple(const wxBitmap& stipple);
 
-    int           m_style;
+    wxBrushStyle  m_style;
     wxBitmap      m_stipple;
     wxColour      m_colour;
     HBRUSH        m_hBrush;
     wxBitmap      m_stipple;
     wxColour      m_colour;
     HBRUSH        m_hBrush;
@@ -87,7 +85,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
 // wxBrushRefData ctors/dtor
 // ----------------------------------------------------------------------------
 
 // wxBrushRefData ctors/dtor
 // ----------------------------------------------------------------------------
 
-wxBrushRefData::wxBrushRefData(const wxColour& colour, int style)
+wxBrushRefData::wxBrushRefData(const wxColour& colour, wxBrushStyle style)
               : m_colour(colour)
 {
     m_style = style;
               : m_colour(colour)
 {
     m_style = style;
@@ -103,7 +101,8 @@ wxBrushRefData::wxBrushRefData(const wxBitmap& stipple)
 }
 
 wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
 }
 
 wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
-              : m_stipple(data.m_stipple),
+              : wxGDIRefData(),
+                m_stipple(data.m_stipple),
                 m_colour(data.m_colour)
 {
     m_style = data.m_style;
                 m_colour(data.m_colour)
 {
     m_style = data.m_style;
@@ -126,13 +125,14 @@ bool wxBrushRefData::operator==(const wxBrushRefData& data) const
     // don't compare HBRUSHes
     return m_style == data.m_style &&
            m_colour == data.m_colour &&
     // don't compare HBRUSHes
     return m_style == data.m_style &&
            m_colour == data.m_colour &&
-           m_stipple == data.m_stipple;
+           m_stipple.IsSameAs(data.m_stipple);
 }
 
 void wxBrushRefData::DoSetStipple(const wxBitmap& stipple)
 {
     m_stipple = stipple;
 }
 
 void wxBrushRefData::DoSetStipple(const wxBitmap& stipple)
 {
     m_stipple = stipple;
-    m_style = stipple.GetMask() ? wxSTIPPLE_MASK_OPAQUE : wxSTIPPLE;
+    m_style = stipple.GetMask() ? wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE
+                                : wxBRUSHSTYLE_STIPPLE;
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -155,12 +155,12 @@ static int TranslateHatchStyle(int style)
 {
     switch ( style )
     {
 {
     switch ( style )
     {
-        case wxBDIAGONAL_HATCH: return HS_BDIAGONAL;
-        case wxCROSSDIAG_HATCH: return HS_DIAGCROSS;
-        case wxFDIAGONAL_HATCH: return HS_FDIAGONAL;
-        case wxCROSS_HATCH:     return HS_CROSS;
-        case wxHORIZONTAL_HATCH:return HS_HORIZONTAL;
-        case wxVERTICAL_HATCH:  return HS_VERTICAL;
+        case wxBRUSHSTYLE_BDIAGONAL_HATCH: return HS_BDIAGONAL;
+        case wxBRUSHSTYLE_CROSSDIAG_HATCH: return HS_DIAGCROSS;
+        case wxBRUSHSTYLE_FDIAGONAL_HATCH: return HS_FDIAGONAL;
+        case wxBRUSHSTYLE_CROSS_HATCH:     return HS_CROSS;
+        case wxBRUSHSTYLE_HORIZONTAL_HATCH:return HS_HORIZONTAL;
+        case wxBRUSHSTYLE_VERTICAL_HATCH:  return HS_VERTICAL;
         default:                return -1;
     }
 }
         default:                return -1;
     }
 }
@@ -178,24 +178,24 @@ HBRUSH wxBrushRefData::GetHBRUSH()
         {
             switch ( m_style )
             {
         {
             switch ( m_style )
             {
-                case wxTRANSPARENT:
+                case wxBRUSHSTYLE_TRANSPARENT:
                     m_hBrush = (HBRUSH)::GetStockObject(NULL_BRUSH);
                     break;
 
                     m_hBrush = (HBRUSH)::GetStockObject(NULL_BRUSH);
                     break;
 
-                case wxSTIPPLE:
+                case wxBRUSHSTYLE_STIPPLE:
                     m_hBrush = ::CreatePatternBrush(GetHbitmapOf(m_stipple));
                     break;
 
                     m_hBrush = ::CreatePatternBrush(GetHbitmapOf(m_stipple));
                     break;
 
-                case wxSTIPPLE_MASK_OPAQUE:
+                case wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE:
                     m_hBrush = ::CreatePatternBrush((HBITMAP)m_stipple.GetMask()
                                                         ->GetMaskBitmap());
                     break;
 
                 default:
                     m_hBrush = ::CreatePatternBrush((HBITMAP)m_stipple.GetMask()
                                                         ->GetMaskBitmap());
                     break;
 
                 default:
-                    wxFAIL_MSG( _T("unknown brush style") );
+                    wxFAIL_MSG( wxT("unknown brush style") );
                     // fall through
 
                     // fall through
 
-                case wxSOLID:
+                case wxBRUSHSTYLE_SOLID:
                     m_hBrush = ::CreateSolidBrush(m_colour.GetPixel());
                     break;
             }
                     m_hBrush = ::CreateSolidBrush(m_colour.GetPixel());
                     break;
             }
@@ -209,7 +209,7 @@ HBRUSH wxBrushRefData::GetHBRUSH()
 
         if ( !m_hBrush )
         {
 
         if ( !m_hBrush )
         {
-            wxLogLastError(_T("CreateXXXBrush()"));
+            wxLogLastError(wxT("CreateXXXBrush()"));
         }
     }
 
         }
     }
 
@@ -228,11 +228,18 @@ wxBrush::wxBrush()
 {
 }
 
 {
 }
 
-wxBrush::wxBrush(const wxColour& col, int style)
+wxBrush::wxBrush(const wxColour& col, wxBrushStyle style)
 {
     m_refData = new wxBrushRefData(col, style);
 }
 
 {
     m_refData = new wxBrushRefData(col, style);
 }
 
+#if FUTURE_WXWIN_COMPATIBILITY_3_0
+wxBrush::wxBrush(const wxColour& col, int style)
+{
+    m_refData = new wxBrushRefData(col, (wxBrushStyle)style);
+}
+#endif
+
 wxBrush::wxBrush(const wxBitmap& stipple)
 {
     m_refData = new wxBrushRefData(stipple);
 wxBrush::wxBrush(const wxBitmap& stipple)
 {
     m_refData = new wxBrushRefData(stipple);
@@ -246,16 +253,6 @@ wxBrush::~wxBrush()
 // wxBrush house keeping stuff
 // ----------------------------------------------------------------------------
 
 // wxBrush house keeping stuff
 // ----------------------------------------------------------------------------
 
-wxBrush& wxBrush::operator=(const wxBrush& brush)
-{
-    if ( this != &brush )
-    {
-        Ref(brush);
-    }
-
-    return *this;
-}
-
 bool wxBrush::operator==(const wxBrush& brush) const
 {
     const wxBrushRefData *brushData = (wxBrushRefData *)brush.m_refData;
 bool wxBrush::operator==(const wxBrush& brush) const
 {
     const wxBrushRefData *brushData = (wxBrushRefData *)brush.m_refData;
@@ -264,12 +261,12 @@ bool wxBrush::operator==(const wxBrush& brush) const
     return m_refData ? (brushData && *M_BRUSHDATA == *brushData) : !brushData;
 }
 
     return m_refData ? (brushData && *M_BRUSHDATA == *brushData) : !brushData;
 }
 
-wxObjectRefData *wxBrush::CreateRefData() const
+wxGDIRefData *wxBrush::CreateGDIRefData() const
 {
     return new wxBrushRefData;
 }
 
 {
     return new wxBrushRefData;
 }
 
-wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
+wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const
 {
     return new wxBrushRefData(*(const wxBrushRefData *)data);
 }
 {
     return new wxBrushRefData(*(const wxBrushRefData *)data);
 }
@@ -280,28 +277,28 @@ wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
 
 wxColour wxBrush::GetColour() const
 {
 
 wxColour wxBrush::GetColour() const
 {
-    wxCHECK_MSG( Ok(), wxNullColour, _T("invalid brush") );
+    wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid brush") );
 
     return M_BRUSHDATA->GetColour();
 }
 
 
     return M_BRUSHDATA->GetColour();
 }
 
-int wxBrush::GetStyle() const
+wxBrushStyle wxBrush::GetStyle() const
 {
 {
-    wxCHECK_MSG( Ok(), 0, _T("invalid brush") );
+    wxCHECK_MSG( Ok(), wxBRUSHSTYLE_INVALID, wxT("invalid brush") );
 
     return M_BRUSHDATA->GetStyle();
 }
 
 wxBitmap *wxBrush::GetStipple() const
 {
 
     return M_BRUSHDATA->GetStyle();
 }
 
 wxBitmap *wxBrush::GetStipple() const
 {
-    wxCHECK_MSG( Ok(), NULL, _T("invalid brush") );
+    wxCHECK_MSG( Ok(), NULL, wxT("invalid brush") );
 
     return M_BRUSHDATA->GetStipple();
 }
 
 WXHANDLE wxBrush::GetResourceHandle() const
 {
 
     return M_BRUSHDATA->GetStipple();
 }
 
 WXHANDLE wxBrush::GetResourceHandle() const
 {
-    wxCHECK_MSG( Ok(), FALSE, _T("invalid brush") );
+    wxCHECK_MSG( Ok(), FALSE, wxT("invalid brush") );
 
     return (WXHANDLE)M_BRUSHDATA->GetHBRUSH();
 }
 
     return (WXHANDLE)M_BRUSHDATA->GetHBRUSH();
 }
@@ -324,7 +321,7 @@ void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
     M_BRUSHDATA->SetColour(wxColour(r, g, b));
 }
 
     M_BRUSHDATA->SetColour(wxColour(r, g, b));
 }
 
-void wxBrush::SetStyle(int style)
+void wxBrush::SetStyle(wxBrushStyle style)
 {
     AllocExclusive();
 
 {
     AllocExclusive();
 
@@ -337,5 +334,3 @@ void wxBrush::SetStipple(const wxBitmap& stipple)
 
     M_BRUSHDATA->SetStipple(stipple);
 }
 
     M_BRUSHDATA->SetStipple(stipple);
 }
-
-