]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dataobj.cpp
   1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/motif/dataobj.cpp 
   3 // Purpose:     wxDataObject class 
   4 // Author:      Julian Smart 
   6 // Copyright:   (c) 1998 Julian Smart 
   7 // Licence:     wxWindows licence 
   8 /////////////////////////////////////////////////////////////////////////////// 
  10 // For compilers that support precompilation, includes "wx.h". 
  11 #include "wx/wxprec.h" 
  15 #include "wx/dataobj.h" 
  23 #pragma message disable nosimpint 
  27 #pragma message enable nosimpint 
  30 #include "wx/motif/private.h" 
  32 //------------------------------------------------------------------------- 
  34 //------------------------------------------------------------------------- 
  37 Atom  g_bitmapAtom      
= 0; 
  40 //------------------------------------------------------------------------- 
  42 //------------------------------------------------------------------------- 
  44 wxDataFormat::wxDataFormat() 
  46     // do *not* call PrepareFormats() from here for 2 reasons: 
  48     // 1. we will have time to do it later because some other Set function 
  49     //    must be called before we really need them 
  51     // 2. doing so prevents us from declaring global wxDataFormats because 
  52     //    calling PrepareFormats (and thus gdk_atom_intern) before GDK is 
  53     //    initialised will result in a crash 
  54     m_type 
= wxDF_INVALID
; 
  58 wxDataFormat::wxDataFormat( wxDataFormatId type 
) 
  64 wxDataFormat::wxDataFormat( const wxString 
&id 
) 
  70 wxDataFormat::wxDataFormat( NativeFormat format 
) 
  76 void wxDataFormat::SetType( wxDataFormatId type 
) 
  81     if (m_type 
== wxDF_TEXT
) 
  82         m_format 
= g_textAtom
; 
  84     if (m_type 
== wxDF_BITMAP
) 
  85         m_format 
= g_bitmapAtom
; 
  87     if (m_type 
== wxDF_FILENAME
) 
  88         m_format 
= g_fileAtom
; 
  91        wxFAIL_MSG( wxT("invalid dataformat") ); 
  95 wxDataFormatId 
wxDataFormat::GetType() const 
 100 wxString 
wxDataFormat::GetId() const 
 102     char *t 
= XGetAtomName ((Display
*) wxGetDisplay(), m_format
); 
 103     wxString 
ret( t 
);  // this will convert from ascii to Unicode 
 109 void wxDataFormat::SetId( NativeFormat format 
) 
 114     if (m_format 
== g_textAtom
) 
 117     if (m_format 
== g_bitmapAtom
) 
 118         m_type 
= wxDF_BITMAP
; 
 120     if (m_format 
== g_fileAtom
) 
 121         m_type 
= wxDF_FILENAME
; 
 123         m_type 
= wxDF_PRIVATE
; 
 126 void wxDataFormat::SetId( const wxString
& id 
) 
 129     m_type 
= wxDF_PRIVATE
; 
 130     m_format 
= XInternAtom( wxGlobalDisplay(), 
 131                             id
.mbc_str(), False 
); 
 134 void wxDataFormat::PrepareFormats() 
 137         g_textAtom 
= XInternAtom( wxGlobalDisplay(), "STRING", False 
); 
 139         g_bitmapAtom 
= XInternAtom( wxGlobalDisplay(), "PIXMAP", False 
); 
 141         g_fileAtom 
= XInternAtom( wxGlobalDisplay(), "file:ALL", False 
); 
 144 // ---------------------------------------------------------------------------- 
 146 // ---------------------------------------------------------------------------- 
 148 wxDataObject::~wxDataObject() 
 152 // ---------------------------------------------------------------------------- 
 153 // wxBitmapDataObject 
 154 // ---------------------------------------------------------------------------- 
 156 size_t wxBitmapDataObject::GetDataSize() const 
 158     return sizeof(Pixmap
); 
 161 bool wxBitmapDataObject::GetDataHere(void* buf
) const 
 163     if( !GetBitmap().IsOk() ) 
 166     (*(Pixmap
*)buf
) = (Pixmap
)GetBitmap().GetDrawable(); 
 171 bool wxBitmapDataObject::SetData(size_t len
, const void* buf
) 
 173     if( len 
!= sizeof(Pixmap
) ) 
 176     WXPixmap pixmap 
= (WXPixmap
)*(Pixmap
*)buf
; 
 178     m_bitmap
.Create( pixmap 
); 
 183 #endif // wxUSE_CLIPBOARD