void TestWidget::HandleDNDDrop ( const JPoint& pt, const JArray<Atom>& typeList, const Atom action, const Time time, const JXWidget* source ) { JXDisplay* display = GetDisplay(); JXSelectionManager* selMgr = GetSelectionManager(); std::cout << std::endl; std::cout << "Data types available from DND source:" << std::endl; std::cout << std::endl; // (JGetUserNotification())->DisplayMessage("testing"); Atom textType = None; JBoolean url = kJFalse; const JSize typeCount = typeList.GetElementCount(); for (JIndex i=1; i<=typeCount; i++) { const Atom type = typeList.GetElement(i); std::cout << XGetAtomName(*display, type) << std::endl; if (type == selMgr->GetMimePlainTextXAtom()) { textType = type; } else if (type == selMgr->GetURLXAtom()) { url = kJTrue; } } std::cout << std::endl; if (textType != None) { PrintSelectionText(GetDNDManager()->GetDNDSelectionName(), time, textType); } if (url) { PrintFileNames(GetDNDManager()->GetDNDSelectionName(), time); } }
void TestWidget::PrintSelectionText ( const Atom selectionName, const Time time, const Atom type ) const { JXDisplay* display = GetDisplay(); JXSelectionManager* selMgr = GetSelectionManager(); Atom returnType; unsigned char* data; JSize dataLength; JXSelectionManager::DeleteMethod delMethod; if (selMgr->GetData(selectionName, time, type, &returnType, &data, &dataLength, &delMethod)) { if (returnType == XA_STRING || returnType == selMgr->GetUtf8StringXAtom() || returnType == selMgr->GetMimePlainTextXAtom()) { std::cout << "Data is available as " << XGetAtomName(*display, type) << ":" << std::endl << std::endl; std::cout.write((char*) data, dataLength); std::cout << std::endl << std::endl; } else { std::cout << "Data has unrecognized return type: "; std::cout << XGetAtomName(*(GetDisplay()), returnType) << std::endl; std::cout << "Trying to print it anyway:" << std::endl << std::endl; std::cout.write((char*) data, dataLength); std::cout << std::endl << std::endl; } selMgr->DeleteData(&data, delMethod); } else { std::cout << "Data could not be retrieved as " << XGetAtomName(*display, type) << "." << std::endl << std::endl; } }
void TestWidget::PrintSelectionTargets ( const Time time ) { JXDisplay* display = GetDisplay(); JXSelectionManager* selMgr = GetSelectionManager(); JXDNDManager* dndMgr = GetDNDManager(); JArray<Atom> typeList; if (selMgr->GetAvailableTypes(kJXClipboardName, time, &typeList)) { std::cout << std::endl; std::cout << "Data types available from the clipboard:" << std::endl; std::cout << std::endl; const JSize typeCount = typeList.GetElementCount(); for (JIndex i=1; i<=typeCount; i++) { const Atom type = typeList.GetElement(i); std::cout << XGetAtomName(*display, type) << std::endl; } for (JIndex i=1; i<=typeCount; i++) { const Atom type = typeList.GetElement(i); if (type == XA_STRING || type == selMgr->GetUtf8StringXAtom() || type == selMgr->GetMimePlainTextXAtom()) { std::cout << std::endl; PrintSelectionText(kJXClipboardName, time, type); } } } else { std::cout << std::endl; std::cout << "Unable to access the clipboard." << std::endl; std::cout << std::endl; } }