size_t SetInfoDataObject::GetDataSize(const wxDataFormat& format) const { if (format.GetType() != wxDF_TEXT && format.GetType() != wxDF_FILENAME // && format.GetType() != wxDF_OEMTEXT && format.GetType() != wxDF_UNICODETEXT) assert(false); wxString url = GetUrl(); size_t ret = url.length(); if (format.GetType() == wxDF_FILENAME) ret += 1; return ret; }
bool SetInfoDataObject::GetDataHere(const wxDataFormat& format, void *pbuf) const { if (format.GetType() != wxDF_TEXT && format.GetType() != wxDF_FILENAME // && format.GetType() != wxDF_OEMTEXT && format.GetType() != wxDF_UNICODETEXT) return false; wxString url = GetUrl(); char *curl = strdup((char*)SC::S2U(url).c_str()); size_t len = strlen(curl); if (format.GetType() == wxDF_FILENAME) len += 1; memcpy(pbuf, curl, len); free(curl); return true; }
bool SetInfoDataObject::SetData(const wxDataFormat& format, size_t len, const void *buf) { if (format.GetType() != wxDF_TEXT && format.GetType() != wxDF_FILENAME // && format.GetType() != wxDF_OEMTEXT && format.GetType() != wxDF_UNICODETEXT) return false; unsigned char *escaped = (unsigned char*)malloc(len + 1); memcpy(escaped, buf, len); escaped[len] = '\0'; wxString url = decode_string(escaped); free(escaped); url.Trim(true); url.Trim(false); if (!decode_url(url, m_prefix, m_set, m_period, m_time, m_selected_draw)) return false; return true; }
void CIDataObject::SetData ( const wxDataFormat& rFormat , char* pzBuffer ) { ULONG ulSize = 0; switch (rFormat.GetType()) { case wxDF_TEXT: case wxDF_OEMTEXT: case wxDF_FILENAME: case wxDF_HTML: ulSize = strlen((const char *)pzBuffer); break; #if wxUSE_UNICODE case wxDF_UNICODETEXT: ulSize = ::wcslen((const wchar_t *)pzBuffer); break; #endif case wxDF_BITMAP: case wxDF_METAFILE: case wxDF_ENHMETAFILE: case wxDF_TIFF: case wxDF_DIB: ulSize = 0; // pass via a handle break; case wxDF_SYLK: case wxDF_DIF: case wxDF_PALETTE: case wxDF_PENDATA: case wxDF_RIFF: case wxDF_WAVE: case wxDF_LOCALE: //PUNT break; case wxDF_PRIVATE: size_t* p = (size_t *)pzBuffer; ulSize = *p++; pzBuffer = (char*)p; break; } m_pDataObject->SetData( rFormat ,ulSize ,(void*)pzBuffer ); } // end of CIDataObject::SetData
bool CIDataObject::GetData ( const wxDataFormat& rFormat, char* pzBuffer, ULONG ulLen ) { QueryGetData(rFormat); if (rFormat.GetType() == wxDF_INVALID) return false; ULONG ulSize = m_pDataObject->GetDataSize(rFormat); if (ulSize == 0) { // // It probably means that the method is just not implemented // return false; } if (rFormat.GetType() == wxDF_PRIVATE) { // // For custom formats, put the size with the data - alloc the // space for it // ulSize += sizeof(ULONG); } if (ulSize > ulLen) // not enough room to copy return false; // // Copy the data // GetDataHere( rFormat ,pzBuffer ,ulSize ); return true; } // end of CIDataObject::GetData
bool wxDataObject::IsFormatInPasteboard( void * pb, const wxDataFormat &dataFormat ) { PasteboardRef pasteboard = (PasteboardRef) pb; bool hasData = false; OSStatus err = noErr; ItemCount itemCount; // we synchronize here once again, so we don't mind which flags get returned PasteboardSynchronize( pasteboard ); err = PasteboardGetItemCount( pasteboard, &itemCount ); if ( err == noErr ) { for( UInt32 itemIndex = 1; itemIndex <= itemCount && hasData == false ; itemIndex++ ) { PasteboardItemID itemID; CFArrayRef flavorTypeArray; CFIndex flavorCount; err = PasteboardGetItemIdentifier( pasteboard, itemIndex, &itemID ); if ( err != noErr ) continue; err = PasteboardCopyItemFlavors( pasteboard, itemID, &flavorTypeArray ); if ( err != noErr ) continue; flavorCount = CFArrayGetCount( flavorTypeArray ); for( CFIndex flavorIndex = 0; flavorIndex < flavorCount && hasData == false ; flavorIndex++ ) { CFStringRef flavorType; flavorType = (CFStringRef)CFArrayGetValueAtIndex( flavorTypeArray, flavorIndex ); wxDataFormat flavorFormat( (wxDataFormat::NativeFormat) flavorType ); if ( dataFormat == flavorFormat ) hasData = true; else if ( dataFormat.GetType() == wxDF_UNICODETEXT && flavorFormat.GetType() == wxDF_TEXT ) hasData = true; } CFRelease (flavorTypeArray); } } return hasData; }