12#include <wx/dataobj.h>
21#if wxUSE_DRAG_AND_DROP
22class FileObject final :
public wxFileDataObject
29 bool IsSupportedFormat(
const wxDataFormat &
format, Direction WXUNUSED(dir =
Get))
const
32 if (
format.GetType() == wxDF_FILENAME) {
37#if !wxCHECK_VERSION(3, 0, 0)
38 if (
format.GetFormatId() == kDragPromisedFlavorFindFile) {
48class DropTarget final :
public wxFileDropTarget
56 SetDataObject(
safenew FileObject());
64#if !wxCHECK_VERSION(3, 0, 0)
65 bool GetData()
override
67 bool foundSupported =
false;
68 bool firstFileAdded =
false;
72 CountDragItems((DragReference)m_currentDrag, &items);
74 for (UInt16 index = 1; index <= items; index++) {
76 DragItemRef theItem = 0;
77 GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem);
80 CountDragItemFlavors((DragReference)m_currentDrag, theItem , &flavors ) ;
82 for (UInt16 flavor = 1 ;flavor <= flavors; flavor++) {
84 FlavorType theType = 0;
85 result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor, &theType);
86 if (theType != kDragPromisedFlavorFindFile && theType != kDragFlavorTypeHFS) {
89 foundSupported =
true;
92 GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize);
95 GetFlavorData((DragReference)m_currentDrag, theItem, theType, (
void*) theData.get(), &dataSize, 0L);
98 if (theType == kDragPromisedFlavorFindFile) {
99 name = wxMacFSSpec2MacFilename((FSSpec *)theData.get());
101 else if (theType == kDragFlavorTypeHFS) {
102 name = wxMacFSSpec2MacFilename(&((HFSFlavor *)theData.get())->fileSpec);
105 if (!firstFileAdded) {
107 ((wxFileDataObject*)GetDataObject())->SetData(0,
"");
108 firstFileAdded =
true;
111 ((wxFileDataObject*)GetDataObject())->AddFile(
name);
117 return foundSupported;
121 bool OnDrop(wxCoord x, wxCoord y)
override
124#if !wxCHECK_VERSION(3, 0, 0)
125 bool firstFileAdded =
false;
129 CountDragItems((DragReference)m_currentDrag, &items);
131 for (UInt16 index = 1; index <= items; index++) {
133 DragItemRef theItem = 0;
134 GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem);
137 CountDragItemFlavors((DragReference)m_currentDrag, theItem , &flavors ) ;
139 for (UInt16 flavor = 1 ;flavor <= flavors; flavor++) {
141 FlavorType theType = 0;
142 result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor, &theType);
143 if (theType != kDragPromisedFlavorFindFile && theType != kDragFlavorTypeHFS) {
150 return CurrentDragHasSupportedFormat();
155 bool OnDropFiles(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
const wxArrayString& filenames)
override
159 return GuardedCall<bool>(
Declare abstract class AudacityException, some often-used subclasses, and GuardedCall.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
bool Import(const FilePath &fileName, bool addToHistory=true)
static ProjectFileManager & Get(AudacityProject &project)
static TrackPanel & Get(AudacityProject &project)
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
SizeType< float > Size
Alias for SizeType<float>