]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/pen.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/gtk/pen.cpp 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  10 // For compilers that support precompilation, includes "wx.h". 
  11 #include "wx/wxprec.h" 
  16     #include "wx/colour.h" 
  21 //----------------------------------------------------------------------------- 
  23 //----------------------------------------------------------------------------- 
  25 class wxPenRefData
: public wxGDIRefData
 
  31         m_style 
= wxPENSTYLE_SOLID
; 
  32         m_joinStyle 
= wxJOIN_ROUND
; 
  33         m_capStyle 
= wxCAP_ROUND
; 
  38     wxPenRefData( const wxPenRefData
& data 
) 
  41         m_style 
= data
.m_style
; 
  42         m_width 
= data
.m_width
; 
  43         m_joinStyle 
= data
.m_joinStyle
; 
  44         m_capStyle 
= data
.m_capStyle
; 
  45         m_colour 
= data
.m_colour
; 
  46         m_countDashes 
= data
.m_countDashes
; 
  50     bool operator == (const wxPenRefData
& data
) const 
  52         if ( m_countDashes 
!= data
.m_countDashes 
) 
  58                  memcmp(m_dash
, data
.m_dash
, m_countDashes
*sizeof(wxGTKDash
)) ) 
  63         else if ( data
.m_dash 
) 
  69         return m_style 
== data
.m_style 
&& 
  70                m_width 
== data
.m_width 
&& 
  71                m_joinStyle 
== data
.m_joinStyle 
&& 
  72                m_capStyle 
== data
.m_capStyle 
&& 
  73                m_colour 
== data
.m_colour
; 
  78     wxPenJoin  m_joinStyle
; 
  85 //----------------------------------------------------------------------------- 
  87 #define M_PENDATA ((wxPenRefData *)m_refData) 
  89 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
) 
  91 wxPen::wxPen( const wxColour 
&colour
, int width
, wxPenStyle style 
) 
  93     m_refData 
= new wxPenRefData(); 
  94     M_PENDATA
->m_width 
= width
; 
  95     M_PENDATA
->m_style 
= style
; 
  96     M_PENDATA
->m_colour 
= colour
; 
  99 #if FUTURE_WXWIN_COMPATIBILITY_3_0 
 100 wxPen::wxPen(const wxColour
& colour
, int width
, int style
) 
 102     m_refData 
= new wxPenRefData(); 
 103     M_PENDATA
->m_width 
= width
; 
 104     M_PENDATA
->m_style 
= (wxPenStyle
)style
; 
 105     M_PENDATA
->m_colour 
= colour
; 
 111     // m_refData unrefed in ~wxObject 
 114 wxGDIRefData 
*wxPen::CreateGDIRefData() const 
 116     return new wxPenRefData
; 
 119 wxGDIRefData 
*wxPen::CloneGDIRefData(const wxGDIRefData 
*data
) const 
 121     return new wxPenRefData(*(wxPenRefData 
*)data
); 
 124 bool wxPen::operator == ( const wxPen
& pen 
) const 
 126     if (m_refData 
== pen
.m_refData
) return true; 
 128     if (!m_refData 
|| !pen
.m_refData
) return false; 
 130     return ( *(wxPenRefData
*)m_refData 
== *(wxPenRefData
*)pen
.m_refData 
); 
 133 void wxPen::SetColour( const wxColour 
&colour 
) 
 137     M_PENDATA
->m_colour 
= colour
; 
 140 void wxPen::SetDashes( int number_of_dashes
, const wxDash 
*dash 
) 
 144     M_PENDATA
->m_countDashes 
= number_of_dashes
; 
 145     M_PENDATA
->m_dash 
= (wxGTKDash 
*)dash
; 
 148 void wxPen::SetColour( unsigned char red
, unsigned char green
, unsigned char blue 
) 
 152     M_PENDATA
->m_colour
.Set( red
, green
, blue 
); 
 155 void wxPen::SetCap( wxPenCap capStyle 
) 
 159     M_PENDATA
->m_capStyle 
= capStyle
; 
 162 void wxPen::SetJoin( wxPenJoin joinStyle 
) 
 166     M_PENDATA
->m_joinStyle 
= joinStyle
; 
 169 void wxPen::SetStyle( wxPenStyle style 
) 
 173     M_PENDATA
->m_style 
= style
; 
 176 void wxPen::SetWidth( int width 
) 
 180     M_PENDATA
->m_width 
= width
; 
 183 int wxPen::GetDashes( wxDash 
**ptr 
) const 
 185     wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); 
 187      *ptr 
= (wxDash
*)M_PENDATA
->m_dash
; 
 188      return M_PENDATA
->m_countDashes
; 
 191 int wxPen::GetDashCount() const 
 193     wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); 
 195     return (M_PENDATA
->m_countDashes
); 
 198 wxDash
* wxPen::GetDash() const 
 200     wxCHECK_MSG( Ok(), NULL
, wxT("invalid pen") ); 
 202     return (wxDash
*)M_PENDATA
->m_dash
; 
 205 wxPenCap 
wxPen::GetCap() const 
 207     wxCHECK_MSG( Ok(), wxCAP_INVALID
, wxT("invalid pen") ); 
 209     return M_PENDATA
->m_capStyle
; 
 212 wxPenJoin 
wxPen::GetJoin() const 
 214     wxCHECK_MSG( Ok(), wxJOIN_INVALID
, wxT("invalid pen") ); 
 216     return M_PENDATA
->m_joinStyle
; 
 219 wxPenStyle 
wxPen::GetStyle() const 
 221     wxCHECK_MSG( Ok(), wxPENSTYLE_INVALID
, wxT("invalid pen") ); 
 223     return M_PENDATA
->m_style
; 
 226 int wxPen::GetWidth() const 
 228     wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); 
 230     return M_PENDATA
->m_width
; 
 233 wxColour 
wxPen::GetColour() const 
 235     wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") ); 
 237     return M_PENDATA
->m_colour
; 
 240 // stippled pens are not supported by wxGTK 
 241 void wxPen::SetStipple(const wxBitmap
& WXUNUSED(stipple
)) 
 243     wxFAIL_MSG( "stippled pens not supported" ); 
 246 wxBitmap 
*wxPen::GetStipple() const