| 63 | #if defined(__WXMAC__) |
| 64 | #if !wxCHECK_VERSION(3, 0, 0) |
| 65 | bool GetData() override |
| 66 | { |
| 67 | bool foundSupported = false; |
| 68 | bool firstFileAdded = false; |
| 69 | OSErr result; |
| 70 | |
| 71 | UInt16 items = 0; |
| 72 | CountDragItems((DragReference)m_currentDrag, &items); |
| 73 | |
| 74 | for (UInt16 index = 1; index <= items; index++) { |
| 75 | |
| 76 | DragItemRef theItem = 0; |
| 77 | GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem); |
| 78 | |
| 79 | UInt16 flavors = 0; |
| 80 | CountDragItemFlavors((DragReference)m_currentDrag, theItem , &flavors ) ; |
| 81 | |
| 82 | for (UInt16 flavor = 1 ;flavor <= flavors; flavor++) { |
| 83 | |
| 84 | FlavorType theType = 0; |
| 85 | result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor, &theType); |
| 86 | if (theType != kDragPromisedFlavorFindFile && theType != kDragFlavorTypeHFS) { |
| 87 | continue; |
| 88 | } |
| 89 | foundSupported = true; |
| 90 | |
| 91 | Size dataSize = 0; |
| 92 | GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize); |
| 93 | |
| 94 | ArrayOf<char> theData{ dataSize }; |
| 95 | GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData.get(), &dataSize, 0L); |
| 96 | |
| 97 | wxString name; |
| 98 | if (theType == kDragPromisedFlavorFindFile) { |
| 99 | name = wxMacFSSpec2MacFilename((FSSpec *)theData.get()); |
| 100 | } |
| 101 | else if (theType == kDragFlavorTypeHFS) { |
| 102 | name = wxMacFSSpec2MacFilename(&((HFSFlavor *)theData.get())->fileSpec); |
| 103 | } |
| 104 | |
| 105 | if (!firstFileAdded) { |
| 106 | // reset file list |
| 107 | ((wxFileDataObject*)GetDataObject())->SetData(0, ""); |
| 108 | firstFileAdded = true; |
| 109 | } |
| 110 | |
| 111 | ((wxFileDataObject*)GetDataObject())->AddFile(name); |
| 112 | |
| 113 | // We only want to process one flavor |
| 114 | break; |
| 115 | } |
| 116 | } |
| 117 | return foundSupported; |
| 118 | } |
| 119 | #endif |
| 120 | |
| 121 | bool OnDrop(wxCoord x, wxCoord y) override |