X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c78e7c70271608b076b1dbed201b1204e6898d4..72c71d39724af116d419295b684dd2946efb3da3:/src/qt/pen.cpp?ds=sidebyside diff --git a/src/qt/pen.cpp b/src/qt/pen.cpp index 7ed7be02a7..9ff7032fb2 100644 --- a/src/qt/pen.cpp +++ b/src/qt/pen.cpp @@ -1,204 +1,227 @@ ///////////////////////////////////////////////////////////////////////////// // Name: pen.cpp -// Purpose: -// Author: Robert Roebling -// Created: 01/02/97 -// Id: -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem +// Purpose: wxPen +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// - #ifdef __GNUG__ #pragma implementation "pen.h" #endif +#include "wx/setup.h" +#include "wx/utils.h" #include "wx/pen.h" -//----------------------------------------------------------------------------- -// wxPen -//----------------------------------------------------------------------------- +IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject) -class wxPenRefData: public wxObjectRefData +wxPenRefData::wxPenRefData() { - public: - - wxPenRefData(void); - - int m_width; - int m_style; - int m_joinStyle; - int m_capStyle; - wxColour m_colour; -}; + m_style = wxSOLID; + m_width = 1; + m_join = wxJOIN_ROUND ; + m_cap = wxCAP_ROUND ; + m_nbDash = 0 ; + m_dash = (wxQTDash*)NULL; +/* TODO: null data + m_hPen = 0; +*/ +} -wxPenRefData::wxPenRefData(void) +wxPenRefData::wxPenRefData(const wxPenRefData& data) { - m_width = 1; - m_style = wxSOLID; - m_joinStyle = wxJOIN_ROUND; - m_capStyle = wxCAP_ROUND; -}; - -//----------------------------------------------------------------------------- + m_style = data.m_style; + m_width = data.m_width; + m_join = data.m_join; + m_cap = data.m_cap; + m_nbDash = data.m_nbDash; + m_dash = data.m_dash; + m_colour = data.m_colour; +/* TODO: null data + m_hPen = 0; +*/ +} -#define M_PENDATA ((wxPenRefData *)m_refData) +wxPenRefData::~wxPenRefData() +{ + // TODO: delete data +} -IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject) +// Pens -wxPen::wxPen(void) +wxPen::wxPen() { - if (wxThePenList) wxThePenList->AddPen( this ); -}; + if ( wxThePenList ) + wxThePenList->AddPen(this); +} -wxPen::wxPen( const wxColour &colour, int width, int style ) +wxPen::~wxPen() { - m_refData = new wxPenRefData(); - M_PENDATA->m_width = width; - M_PENDATA->m_style = style; - M_PENDATA->m_colour = colour; - if (wxThePenList) wxThePenList->AddPen( this ); -}; + if (wxThePenList) + wxThePenList->RemovePen(this); +} -wxPen::wxPen( const wxString &colourName, int width, int style ) +// Should implement Create +wxPen::wxPen(const wxColour& col, int Width, int Style) { - m_refData = new wxPenRefData(); - M_PENDATA->m_width = width; - M_PENDATA->m_style = style; - M_PENDATA->m_colour = colourName; - if (wxThePenList) wxThePenList->AddPen( this ); -}; + m_refData = new wxPenRefData; -wxPen::wxPen( const wxPen& pen ) -{ - Ref( pen ); - if (wxThePenList) wxThePenList->AddPen( this ); -}; + M_PENDATA->m_colour = col; + M_PENDATA->m_width = Width; + M_PENDATA->m_style = Style; + M_PENDATA->m_join = wxJOIN_ROUND ; + M_PENDATA->m_cap = wxCAP_ROUND ; + M_PENDATA->m_nbDash = 0 ; + M_PENDATA->m_dash = (wxQTDash*)NULL; -wxPen::wxPen( const wxPen* pen ) -{ - UnRef(); - if (pen) Ref( *pen ); - if (wxThePenList) wxThePenList->AddPen( this ); -}; + RealizeResource(); -wxPen::~wxPen(void) -{ - if (wxThePenList) wxThePenList->RemovePen( this ); -}; + if ( wxThePenList ) + wxThePenList->AddPen(this); +} -wxPen& wxPen::operator = ( const wxPen& pen ) +wxPen::wxPen(const wxBitmap& stipple, int Width) { - if (*this == pen) return (*this); - Ref( pen ); - return *this; -}; + m_refData = new wxPenRefData; + + M_PENDATA->m_stipple = stipple; + M_PENDATA->m_width = Width; + M_PENDATA->m_style = wxSTIPPLE; + M_PENDATA->m_join = wxJOIN_ROUND ; + M_PENDATA->m_cap = wxCAP_ROUND ; + M_PENDATA->m_nbDash = 0 ; + M_PENDATA->m_dash = (wxQTDash*)NULL; + + RealizeResource(); -bool wxPen::operator == ( const wxPen& pen ) + if ( wxThePenList ) + wxThePenList->AddPen(this); +} + +wxPen::wxPen(const wxString& col, int Width, int Style) { - return m_refData == pen.m_refData; -}; + m_refData = new wxPenRefData; + + M_PENDATA->m_colour = col; + M_PENDATA->m_width = Width; + M_PENDATA->m_style = Style; + M_PENDATA->m_join = wxJOIN_ROUND ; + M_PENDATA->m_cap = wxCAP_ROUND ; + M_PENDATA->m_nbDash = 0 ; + M_PENDATA->m_dash = (wxQTDash*)NULL; + + RealizeResource(); -bool wxPen::operator != ( const wxPen& pen ) + if ( wxThePenList ) + wxThePenList->AddPen(this); +} + +void wxPen::Unshare() { - return m_refData != pen.m_refData; -}; + // Don't change shared data + if (!m_refData) + { + m_refData = new wxPenRefData(); + } + else + { + wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); + UnRef(); + m_refData = ref; + } +} -void wxPen::SetColour( const wxColour &colour ) +void wxPen::SetColour(const wxColour& col) { - if (!m_refData) - m_refData = new wxPenRefData(); + Unshare(); - M_PENDATA->m_colour = colour; -}; + M_PENDATA->m_colour = col; + + RealizeResource(); +} -void wxPen::SetColour( const wxString &colourName ) +void wxPen::SetColour(const wxString& col) { - if (!m_refData) - m_refData = new wxPenRefData(); + Unshare(); - M_PENDATA->m_colour = colourName; -}; + M_PENDATA->m_colour = col; + + RealizeResource(); +} -void wxPen::SetColour( int red, int green, int blue ) +void wxPen::SetColour(const unsigned char r, const unsigned char g, const unsigned char b) { - if (!m_refData) - m_refData = new wxPenRefData(); + Unshare(); - M_PENDATA->m_colour.Set( red, green, blue ); -}; + M_PENDATA->m_colour.Set(r, g, b); + + RealizeResource(); +} -void wxPen::SetCap( int capStyle ) +void wxPen::SetWidth(int Width) { - if (!m_refData) - m_refData = new wxPenRefData(); + Unshare(); - M_PENDATA->m_capStyle = capStyle; -}; + M_PENDATA->m_width = Width; -void wxPen::SetJoin( int joinStyle ) + RealizeResource(); +} + +void wxPen::SetStyle(int Style) { - if (!m_refData) - m_refData = new wxPenRefData(); + Unshare(); + + M_PENDATA->m_style = Style; - M_PENDATA->m_joinStyle = joinStyle; -}; + RealizeResource(); +} -void wxPen::SetStyle( int style ) +void wxPen::SetStipple(const wxBitmap& Stipple) { - if (!m_refData) - m_refData = new wxPenRefData(); + Unshare(); - M_PENDATA->m_style = style; -}; + M_PENDATA->m_stipple = Stipple; + M_PENDATA->m_style = wxSTIPPLE; + + RealizeResource(); +} -void wxPen::SetWidth( int width ) +void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) { - if (!m_refData) - m_refData = new wxPenRefData(); + Unshare(); - M_PENDATA->m_width = width; -}; + M_PENDATA->m_nbDash = nb_dashes; + M_PENDATA->m_dash = (wxQTDash *)Dash; + + RealizeResource(); +} -int wxPen::GetCap(void) const +void wxPen::SetJoin(int Join) { - return M_PENDATA->m_capStyle; -}; + Unshare(); -int wxPen::GetJoin(void) const -{ - if (!m_refData) - return 0; - else - return M_PENDATA->m_joinStyle; -}; + M_PENDATA->m_join = Join; -int wxPen::GetStyle(void) const -{ - if (!m_refData) - return 0; - else - return M_PENDATA->m_style; -}; + RealizeResource(); +} -int wxPen::GetWidth(void) const +void wxPen::SetCap(int Cap) { - if (!m_refData) - return 0; - else - return M_PENDATA->m_width; -}; + Unshare(); -wxColour &wxPen::GetColour(void) const -{ - if (!m_refData) - return wxNullColour; - else - return M_PENDATA->m_colour; -}; + M_PENDATA->m_cap = Cap; + + RealizeResource(); +} -bool wxPen::Ok(void) const +bool wxPen::RealizeResource() { - return (m_refData); -}; + // TODO: create actual pen + return FALSE; +} +