]>
git.saurik.com Git - wxWidgets.git/blob - src/dfb/brush.cpp
da4a6935d9ab45fc10f409599a862d79fb91e3f6
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/dfb/brush.cpp 
   3 // Purpose:     wxBrush class implementation 
   4 // Author:      Vaclav Slavik 
   7 // Copyright:   (c) 2006 REA Elektronik GmbH 
   8 // Licence:     wxWindows licence 
   9 ///////////////////////////////////////////////////////////////////////////// 
  11 // For compilers that support precompilation, includes "wx.h". 
  12 #include "wx/wxprec.h" 
  21     #include "wx/colour.h" 
  25 //----------------------------------------------------------------------------- 
  27 //----------------------------------------------------------------------------- 
  29 class wxBrushRefData
: public wxObjectRefData
 
  32     wxBrushRefData(const wxColour
& clr 
= wxNullColour
, int style 
= wxSOLID
) 
  38     wxBrushRefData(const wxBrushRefData
& data
) 
  40         m_colour 
= data
.m_colour
; 
  41         m_style 
= data
.m_style
; 
  44     void SetStyle(int style
) 
  46         if ( m_style 
!= wxSOLID 
&& m_style 
== wxTRANSPARENT 
) 
  48             wxFAIL_MSG( _T("only wxSOLID and wxTRANSPARENT styles are supported") ); 
  59 //----------------------------------------------------------------------------- 
  61 #define M_BRUSHDATA ((wxBrushRefData *)m_refData) 
  63 IMPLEMENT_DYNAMIC_CLASS(wxBrush
, wxGDIObject
) 
  65 wxBrush::wxBrush(const wxColour 
&colour
, int style
) 
  67     m_refData 
= new wxBrushRefData(colour
, style
); 
  70 wxBrush::wxBrush(const wxBitmap 
&stippleBitmap
) 
  72     wxFAIL_MSG( "brushes with stipple bitmaps not implemented" ); 
  74     m_refData 
= new wxBrushRefData(*wxBLACK
); 
  77 bool wxBrush::operator==(const wxBrush
& brush
) const 
  79 #warning "this is incorrect (MGL too)" 
  80     return m_refData 
== brush
.m_refData
; 
  83 bool wxBrush::Ok() const 
  85     return ((m_refData
) && M_BRUSHDATA
->m_colour
.Ok()); 
  88 int wxBrush::GetStyle() const 
  90     if (m_refData 
== NULL
) 
  92         wxFAIL_MSG( wxT("invalid brush") ); 
  96     return M_BRUSHDATA
->m_style
; 
  99 wxColour
& wxBrush::GetColour() const 
 101     if (m_refData 
== NULL
) 
 103         wxFAIL_MSG( wxT("invalid brush") ); 
 107     return M_BRUSHDATA
->m_colour
; 
 110 wxBitmap 
*wxBrush::GetStipple() const 
 112     wxFAIL_MSG( "brushes with stipple bitmaps not implemented" ); 
 113     return &wxNullBitmap
; 
 116 void wxBrush::SetColour(const wxColour
& col
) 
 119     M_BRUSHDATA
->m_colour 
= col
; 
 122 void wxBrush::SetColour(unsigned char r
, unsigned char g
, unsigned char b
) 
 125     M_BRUSHDATA
->m_colour
.Set(r
, g
, b
); 
 128 void wxBrush::SetStyle(int style
) 
 131     M_BRUSHDATA
->SetStyle(style
); 
 134 void wxBrush::SetStipple(const wxBitmap
& WXUNUSED(stipple
)) 
 136     wxFAIL_MSG( "brushes with stipple bitmaps not implemented" ); 
 139 wxObjectRefData 
*wxBrush::CreateRefData() const 
 141     return new wxBrushRefData
; 
 144 wxObjectRefData 
*wxBrush::CloneRefData(const wxObjectRefData 
*data
) const 
 146     return new wxBrushRefData(*(wxBrushRefData 
*)data
);