]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/pen.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  11 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  12 #pragma implementation "pen.h" 
  15 // For compilers that support precompilation, includes "wx.h". 
  16 #include "wx/wxprec.h" 
  19 #include "wx/colour.h" 
  23 //----------------------------------------------------------------------------- 
  25 //----------------------------------------------------------------------------- 
  27 class wxPenRefData
: public wxObjectRefData
 
  34         m_joinStyle 
= wxJOIN_ROUND
; 
  35         m_capStyle 
= wxCAP_ROUND
; 
  36         m_dash 
= (wxGTKDash
*) NULL
; 
  40     wxPenRefData( const wxPenRefData
& data 
) 
  43         m_style 
= data
.m_style
; 
  44         m_width 
= data
.m_width
; 
  45         m_joinStyle 
= data
.m_joinStyle
; 
  46         m_capStyle 
= data
.m_capStyle
; 
  47         m_colour 
= data
.m_colour
; 
  48         m_countDashes 
= data
.m_countDashes
; 
  52     bool operator == (const wxPenRefData
& data
) const 
  54         if ( m_countDashes 
!= data
.m_countDashes 
) 
  60                  memcmp(m_dash
, data
.m_dash
, m_countDashes
*sizeof(wxGTKDash
)) ) 
  65         else if ( data
.m_dash 
) 
  71         return m_style 
== data
.m_style 
&& 
  72                m_width 
== data
.m_width 
&& 
  73                m_joinStyle 
== data
.m_joinStyle 
&& 
  74                m_capStyle 
== data
.m_capStyle 
&& 
  75                m_colour 
== data
.m_colour
; 
  87 //----------------------------------------------------------------------------- 
  89 #define M_PENDATA ((wxPenRefData *)m_refData) 
  91 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
) 
  93 wxPen::wxPen( const wxColour 
&colour
, int width
, int style 
) 
  95     m_refData 
= new wxPenRefData(); 
  96     M_PENDATA
->m_width 
= width
; 
  97     M_PENDATA
->m_style 
= style
; 
  98     M_PENDATA
->m_colour 
= colour
; 
 103     // m_refData unrefed in ~wxObject 
 106 wxObjectRefData 
*wxPen::CreateRefData() const 
 108     return new wxPenRefData
; 
 111 wxObjectRefData 
*wxPen::CloneRefData(const wxObjectRefData 
*data
) const 
 113     return new wxPenRefData(*(wxPenRefData 
*)data
); 
 116 bool wxPen::operator == ( const wxPen
& pen 
) const 
 118     if (m_refData 
== pen
.m_refData
) return TRUE
; 
 120     if (!m_refData 
|| !pen
.m_refData
) return FALSE
; 
 122     return ( *(wxPenRefData
*)m_refData 
== *(wxPenRefData
*)pen
.m_refData 
); 
 125 void wxPen::SetColour( const wxColour 
&colour 
) 
 129     M_PENDATA
->m_colour 
= colour
; 
 132 void wxPen::SetDashes( int number_of_dashes
, const wxDash 
*dash 
) 
 136     M_PENDATA
->m_countDashes 
= number_of_dashes
; 
 137     M_PENDATA
->m_dash 
= (wxGTKDash 
*)dash
; 
 140 void wxPen::SetColour( int red
, int green
, int blue 
) 
 144     M_PENDATA
->m_colour
.Set( red
, green
, blue 
); 
 147 void wxPen::SetCap( int capStyle 
) 
 151     M_PENDATA
->m_capStyle 
= capStyle
; 
 154 void wxPen::SetJoin( int joinStyle 
) 
 158     M_PENDATA
->m_joinStyle 
= joinStyle
; 
 161 void wxPen::SetStyle( int style 
) 
 165     M_PENDATA
->m_style 
= style
; 
 168 void wxPen::SetWidth( int width 
) 
 172     M_PENDATA
->m_width 
= width
; 
 175 int wxPen::GetDashes( wxDash 
**ptr 
) const 
 177      *ptr 
= (M_PENDATA 
? (wxDash
*)M_PENDATA
->m_dash 
: (wxDash
*) NULL
); 
 178      return (M_PENDATA 
? M_PENDATA
->m_countDashes 
: 0); 
 181 int wxPen::GetDashCount() const 
 183     return (M_PENDATA
->m_countDashes
); 
 186 wxDash
* wxPen::GetDash() const 
 188     return (wxDash
*)M_PENDATA
->m_dash
; 
 191 int wxPen::GetCap() const 
 193     wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); 
 195     return M_PENDATA
->m_capStyle
; 
 198 int wxPen::GetJoin() const 
 200     wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); 
 202     return M_PENDATA
->m_joinStyle
; 
 205 int wxPen::GetStyle() const 
 207     wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); 
 209     return M_PENDATA
->m_style
; 
 212 int wxPen::GetWidth() const 
 214     wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); 
 216     return M_PENDATA
->m_width
; 
 219 wxColour 
&wxPen::GetColour() const 
 221     wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") ); 
 223     return M_PENDATA
->m_colour
;