X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c721b14c6527ede25adb6345b5266622150b46f..ac0d36b5237d14ec05b4b7f5d88a08bdad82a511:/src/gtk1/dataobj.cpp diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp index e6b756326a..331a728254 100644 --- a/src/gtk1/dataobj.cpp +++ b/src/gtk1/dataobj.cpp @@ -23,37 +23,21 @@ IMPLEMENT_CLASS(wxDataFormat, wxObject) -wxDataFormat::wxDataFormat( wxDataType type ) +wxDataFormat::wxDataFormat() { - m_type = type; - - if (m_type == wxDF_TEXT) - { - m_id = "STRING"; - } - else - if (m_type == wxDF_BITMAP) - { - m_id = "BITMAP"; - } - else - if (m_type == wxDF_FILENAME) - { - m_id = "file:ALL"; - } - else - { - wxFAIL_MSG( "invalid dataformat" ); - } - + m_type = wxDF_INVALID; m_hasAtom = FALSE; + m_atom = (GdkAtom) 0; +} + +wxDataFormat::wxDataFormat( wxDataType type ) +{ + SetType( type ); } wxDataFormat::wxDataFormat( const wxString &id ) { - m_type = wxDF_PRIVATE; - m_id = id; - m_hasAtom = FALSE; + SetId( id ); } wxDataFormat::wxDataFormat( wxDataFormat &format ) @@ -89,7 +73,33 @@ wxDataFormat::wxDataFormat( const GdkAtom atom ) } } -int wxDataFormat::GetType() const +void wxDataFormat::SetType( wxDataType type ) +{ + m_type = type; + + if (m_type == wxDF_TEXT) + { + m_id = "STRING"; + } + else + if (m_type == wxDF_BITMAP) + { + m_id = "BITMAP"; + } + else + if (m_type == wxDF_FILENAME) + { + m_id = "file:ALL"; + } + else + { + wxFAIL_MSG( "invalid dataformat" ); + } + + m_hasAtom = FALSE; +} + +wxDataType wxDataFormat::GetType() const { return m_type; } @@ -231,7 +241,7 @@ void wxDataBroker::WriteData( wxDataFormat& format, void *dest ) const if (dobj->GetFormat().GetAtom() == format.GetAtom()) { - return dobj->WriteData( dest ); + dobj->WriteData( dest ); } node = node->Next(); @@ -246,21 +256,33 @@ IMPLEMENT_ABSTRACT_CLASS( wxDataObject, wxObject ) wxDataObject::wxDataObject() { - m_format = (wxDataFormat*) NULL; } wxDataObject::~wxDataObject() { - if (m_format) delete m_format; } -wxDataFormat &wxDataObject::GetFormat() const +wxDataFormat &wxDataObject::GetFormat() { - wxASSERT( m_format ); + return m_format; +} - return (*m_format); +wxDataType wxDataObject::GetFormatType() const +{ + return m_format.GetType(); +} + +wxString wxDataObject::GetFormatId() const +{ + return m_format.GetId(); } +GdkAtom wxDataObject::GetFormatAtom() const +{ + GdkAtom ret = ((wxDataObject*) this)->m_format.GetAtom(); + return ret; +} + // ---------------------------------------------------------------------------- // wxTextDataObject // ---------------------------------------------------------------------------- @@ -269,12 +291,12 @@ IMPLEMENT_DYNAMIC_CLASS( wxTextDataObject, wxDataObject ) wxTextDataObject::wxTextDataObject() { - m_format = new wxDataFormat( wxDF_TEXT ); + m_format.SetType( wxDF_TEXT ); } wxTextDataObject::wxTextDataObject( const wxString& data ) { - m_format = new wxDataFormat( wxDF_TEXT ); + m_format.SetType( wxDF_TEXT ); m_data = data; } @@ -310,9 +332,9 @@ void wxTextDataObject::WriteString( const wxString &str, void *dest ) const IMPLEMENT_DYNAMIC_CLASS( wxFileDataObject, wxDataObject ) -wxFileDataObject::wxFileDataObject(void) +wxFileDataObject::wxFileDataObject() { - m_format = new wxDataFormat( wxDF_FILENAME ); + m_format.SetType( wxDF_FILENAME ); } void wxFileDataObject::AddFile( const wxString &file ) @@ -344,12 +366,12 @@ IMPLEMENT_DYNAMIC_CLASS( wxBitmapDataObject, wxDataObject ) wxBitmapDataObject::wxBitmapDataObject() { - m_format = new wxDataFormat( wxDF_BITMAP ); + m_format.SetType( wxDF_BITMAP ); } wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& bitmap ) { - m_format = new wxDataFormat( wxDF_BITMAP ); + m_format.SetType( wxDF_BITMAP ); m_bitmap = bitmap; } @@ -390,7 +412,7 @@ wxPrivateDataObject::wxPrivateDataObject() m_id = "application/"; m_id += wxTheApp->GetAppName(); - m_format = new wxDataFormat( m_id ); + m_format.SetId( m_id ); m_size = 0; m_data = (char*) NULL; @@ -404,7 +426,7 @@ wxPrivateDataObject::~wxPrivateDataObject() void wxPrivateDataObject::SetId( const wxString& id ) { m_id = id; - m_format->SetId( m_id ); + m_format.SetId( m_id ); } wxString wxPrivateDataObject::GetId() const