]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/brush.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  11 #pragma implementation "brush.h" 
  18 //----------------------------------------------------------------------------- 
  20 //----------------------------------------------------------------------------- 
  22 class wxBrushRefData
: public wxObjectRefData
 
  26     wxBrushRefData( const wxBrushRefData
& data 
); 
  33 wxBrushRefData::wxBrushRefData() 
  38 wxBrushRefData::wxBrushRefData( const wxBrushRefData
& data 
) 
  40     m_style 
= data
.m_style
; 
  41     m_stipple 
= data
.m_stipple
; 
  42     m_colour 
= data
.m_colour
; 
  45 //----------------------------------------------------------------------------- 
  47 #define M_BRUSHDATA ((wxBrushRefData *)m_refData) 
  49 IMPLEMENT_DYNAMIC_CLASS(wxBrush
,wxGDIObject
) 
  53     if (wxTheBrushList
) wxTheBrushList
->AddBrush( this ); 
  56 wxBrush::wxBrush( const wxColour 
&colour
, int style 
) 
  58     m_refData 
= new wxBrushRefData(); 
  59     M_BRUSHDATA
->m_style 
= style
; 
  60     M_BRUSHDATA
->m_colour 
= colour
; 
  62     if (wxTheBrushList
) wxTheBrushList
->AddBrush( this ); 
  65 wxBrush::wxBrush( const wxBitmap 
&stippleBitmap 
) 
  67     m_refData 
= new wxBrushRefData(); 
  68     M_BRUSHDATA
->m_colour 
= *wxBLACK
; 
  69     M_BRUSHDATA
->m_stipple 
= stippleBitmap
; 
  70     if (M_BRUSHDATA
->m_stipple
.GetMask()) 
  72                    M_BRUSHDATA
->m_style 
= wxSTIPPLE_MASK_OPAQUE
; 
  76                    M_BRUSHDATA
->m_style 
= wxSTIPPLE
; 
  79     if (wxTheBrushList
) wxTheBrushList
->AddBrush( this ); 
  82 wxBrush::wxBrush( const wxBrush 
&brush 
) 
  86     if (wxTheBrushList
) wxTheBrushList
->AddBrush( this ); 
  91     if (wxTheBrushList
) wxTheBrushList
->RemoveBrush( this ); 
  94 wxBrush
& wxBrush::operator = ( const wxBrush
& brush 
) 
  96     if (*this == brush
) return (*this); 
 101 bool wxBrush::operator == ( const wxBrush
& brush 
) 
 103     return m_refData 
== brush
.m_refData
; 
 106 bool wxBrush::operator != ( const wxBrush
& brush 
) 
 108     return m_refData 
!= brush
.m_refData
; 
 111 bool wxBrush::Ok() const 
 113     return ((m_refData
) && M_BRUSHDATA
->m_colour
.Ok()); 
 116 int wxBrush::GetStyle() const 
 118     if (m_refData 
== NULL
) 
 120         wxFAIL_MSG( wxT("invalid brush") ); 
 124     return M_BRUSHDATA
->m_style
; 
 127 wxColour 
&wxBrush::GetColour() const 
 129     if (m_refData 
== NULL
) 
 131         wxFAIL_MSG( wxT("invalid brush") ); 
 135     return M_BRUSHDATA
->m_colour
; 
 138 wxBitmap 
*wxBrush::GetStipple() const 
 140     if (m_refData 
== NULL
) 
 142         wxFAIL_MSG( wxT("invalid brush") ); 
 143         return &wxNullBitmap
; 
 146     return &M_BRUSHDATA
->m_stipple
; 
 149 void wxBrush::SetColour( const wxColour
& col 
) 
 152     M_BRUSHDATA
->m_colour 
= col
; 
 155 void wxBrush::SetColour( unsigned char r
, unsigned char g
, unsigned char b 
) 
 158     M_BRUSHDATA
->m_colour
.Set( r
, g
, b 
); 
 161 void wxBrush::SetStyle( int style 
) 
 164     M_BRUSHDATA
->m_style 
= style
; 
 167 void wxBrush::SetStipple( const wxBitmap
& stipple 
) 
 170     M_BRUSHDATA
->m_stipple 
= stipple
; 
 171     if (M_BRUSHDATA
->m_stipple
.GetMask()) 
 173                    M_BRUSHDATA
->m_style 
= wxSTIPPLE_MASK_OPAQUE
; 
 177                    M_BRUSHDATA
->m_style 
= wxSTIPPLE
; 
 181 void wxBrush::Unshare() 
 185         m_refData 
= new wxBrushRefData(); 
 189         wxBrushRefData
* ref 
= new wxBrushRefData( *(wxBrushRefData
*)m_refData 
);