JBoolean JXPathInput::WillAcceptDrop ( const JArray<Atom>& typeList, Atom* action, const JPoint& pt, const Time time, const JXWidget* source ) { itsExpectURLDropFlag = kJFalse; const Atom urlXAtom = (GetSelectionManager())->GetURLXAtom(); JString dirName; const JSize typeCount = typeList.GetElementCount(); for (JIndex i=1; i<=typeCount; i++) { if (typeList.GetElement(i) == urlXAtom && GetDroppedDirectory(time, kJFalse, &dirName)) { *action = (GetDNDManager())->GetDNDActionPrivateXAtom(); itsExpectURLDropFlag = kJTrue; return kJTrue; } } return JXInputField::WillAcceptDrop(typeList, action, pt, time, source); }
JBoolean JXDocktab::DockFinder::FindTarget ( const JXContainer* coordOwner, const JPoint& pt, Window* xWindow, Window* msgWindow, JXContainer** target, Atom* vers ) { if ((GetDisplay())->FindMouseContainer(coordOwner, pt, target, xWindow)) { JXDockWidget* dock; if (((**target).GetWindow())->GetDockWidget(&dock)) { *target = dock; *xWindow = (dock->JXContainer::GetWindow())->GetXWindow(); } return (GetDNDManager())->IsDNDAware(*xWindow, msgWindow, vers); } else { *target = NULL; *msgWindow = *xWindow; *vers = 0; return kJFalse; } }
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); } }
Atom JXWidget::GetDNDAction ( const JXContainer* target, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { return (GetDNDManager())->GetDNDActionCopyXAtom(); }
Atom GMFilterNameTable::GetDNDAction ( const JXContainer* target, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { return GetDNDManager()->GetDNDActionMoveXAtom(); }
Atom TestWidget::GetDNDAction ( const JXContainer* target, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { return GetDNDManager()->GetDNDActionPrivateXAtom(); }
Atom JXDocktab::GetDNDAction ( const JXContainer* target, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { return (GetDNDManager())->GetDNDActionPrivateXAtom(); }
void JXWidget::HandleDNDResponse ( const JXContainer* target, const JBoolean dropAccepted, const Atom action ) { DisplayCursor((GetDNDManager())->GetDefaultDNDCursor(dropAccepted, action)); }
JBoolean TestWidget::WillAcceptDrop ( const JArray<Atom>& typeList, Atom* action, const Time time, const JXWidget* source ) { JXDNDManager* dndMgr = GetDNDManager(); if (typeList.GetFirstElement() == (GetSelectionManager())->GetURLXAtom()) { cout << endl; cout << "Accepting the drop of type text/uri-list" << endl; cout << endl; *action = dndMgr->GetDNDActionPrivateXAtom(); return kJTrue; } else if (*action == dndMgr->GetDNDActionCopyXAtom()) { cout << endl; cout << "Accepting the drop" << endl; cout << endl; PrintSelectionText(dndMgr->GetDNDSelectionName(), time, (GetSelectionManager())->GetMimePlainTextXAtom()); return kJTrue; } else { JXDisplay* display = GetDisplay(); cout << endl; cout << "Not accepting the drop because the action isn't copy" << endl; cout << "Action: " << XGetAtomName(*display, *action) << endl; cout << endl; cout << "Data types available from DND source:" << endl; cout << endl; const JSize typeCount = typeList.GetElementCount(); for (JIndex i=1; i<=typeCount; i++) { const Atom type = typeList.GetElement(i); cout << XGetAtomName(*display, type) << endl; } cout << endl; PrintSelectionText(dndMgr->GetDNDSelectionName(), time, (GetSelectionManager())->GetMimePlainTextXAtom()); return kJFalse; } }
Atom GMMessageDragSource::GetDNDAction ( const JXContainer* target, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (modifiers.control()) { return GetDNDManager()->GetDNDActionAskXAtom(); } else if (modifiers.meta()) { return GetDNDManager()->GetDNDActionCopyXAtom(); } else { return GetDNDManager()->GetDNDActionMoveXAtom(); } }
Atom CBCommandTable::GetDNDAction ( const JXContainer* target, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { const JBoolean meta = modifiers.GetState(JXMenu::AdjustNMShortcutModifier(kJXMetaKeyIndex)); if ((target == this && !meta) || (target != this && meta)) { return (GetDNDManager())->GetDNDActionMoveXAtom(); } else { return (GetDNDManager())->GetDNDActionCopyXAtom(); } }
JBoolean JXTabGroup::WillAcceptDrop ( const JArray<Atom>& typeList, Atom* action, const JPoint& pt, const Time time, const JXWidget* source ) { *action = (GetDNDManager())->GetDNDActionPrivateXAtom(); return kJTrue; }
JBoolean JXWidget::BeginDND ( const JPoint& pt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers, JXSelectionData* data, JXDNDManager::TargetFinder* targetFinder ) { return (GetDNDManager())->BeginDND(this, pt, buttonStates, modifiers, data, targetFinder); }
JBoolean JXPathInput::GetDroppedDirectory ( const Time time, const JBoolean reportErrors, JString* dirName ) { dirName->Clear(); JXSelectionManager* selMgr = GetSelectionManager(); Atom returnType; unsigned char* data; JSize dataLength; JXSelectionManager::DeleteMethod delMethod; if (selMgr->GetData(GetDNDManager()->GetDNDSelectionName(), time, selMgr->GetURLXAtom(), &returnType, &data, &dataLength, &delMethod)) { if (returnType == selMgr->GetURLXAtom()) { JPtrArray<JString> fileNameList(JPtrArrayT::kDeleteAll), urlList(JPtrArrayT::kDeleteAll); JXUnpackFileNames((char*) data, dataLength, &fileNameList, &urlList); if (fileNameList.GetElementCount() == 1 && (JDirectoryExists(*(fileNameList.FirstElement())) || JFileExists(*(fileNameList.FirstElement())))) { *dirName = *(fileNameList.FirstElement()); JString homeDir; if (JGetHomeDirectory(&homeDir) && dirName->BeginsWith(homeDir)) { dirName->ReplaceSubstring(1, homeDir.GetLength(), "~" ACE_DIRECTORY_SEPARATOR_STR); } } JXReportUnreachableHosts(urlList); } selMgr->DeleteData(&data, delMethod); } return !dirName->IsEmpty(); }
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; } }
void TestWidget::PrintSelectionTargets ( const Time time ) { JXDisplay* display = GetDisplay(); JXSelectionManager* selMgr = GetSelectionManager(); JXDNDManager* dndMgr = GetDNDManager(); JArray<Atom> typeList; if (selMgr->GetAvailableTypes(kJXClipboardName, time, &typeList)) { cout << endl; cout << "Data types available from the clipboard:" << endl; cout << endl; Atom textType = None; const JSize typeCount = typeList.GetElementCount(); for (JIndex i=1; i<=typeCount; i++) { const Atom type = typeList.GetElement(i); cout << XGetAtomName(*display, type) << endl; if (type == XA_STRING) { textType = type; } } cout << endl; if (textType != None) { PrintSelectionText(kJXClipboardName, time, textType); } } else { cout << endl; cout << "Unable to access the clipboard." << endl; cout << endl; } }
void GMMessageDragSource::GetDNDAskActions ( const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers, JArray<Atom>* askActionList, JPtrArray<JString>* askDescriptionList ) { JXDNDManager* dndMgr = GetDNDManager(); askActionList->AppendElement(dndMgr->GetDNDActionCopyXAtom()); askActionList->AppendElement(dndMgr->GetDNDActionMoveXAtom()); JString* s = new JString(kDNDActionCopyDescrip); assert( s != NULL ); askDescriptionList->Append(s); s = new JString(kDNDActionMoveDescrip); assert( s != NULL ); askDescriptionList->Append(s); }
JBoolean JXFileInput::GetDroppedFileName ( const Time time, const JBoolean reportErrors, JString* fileName ) { fileName->Clear(); JXSelectionManager* selMgr = GetSelectionManager(); Atom returnType; unsigned char* data; JSize dataLength; JXSelectionManager::DeleteMethod delMethod; if (selMgr->GetData((GetDNDManager())->GetDNDSelectionName(), time, selMgr->GetURLXAtom(), &returnType, &data, &dataLength, &delMethod)) { if (returnType == selMgr->GetURLXAtom()) { JPtrArray<JString> fileNameList(JPtrArrayT::kDeleteAll), urlList(JPtrArrayT::kDeleteAll); JXUnpackFileNames((char*) data, dataLength, &fileNameList, &urlList); if (fileNameList.GetElementCount() == 1 && (JFileExists(*(fileNameList.FirstElement())) || JDirectoryExists(*(fileNameList.FirstElement())))) { *fileName = *(fileNameList.FirstElement()); } JXReportUnreachableHosts(urlList); } selMgr->DeleteData(&data, delMethod); } return JNegate( fileName->IsEmpty() ); }
void GMFilterNameTable::GMFilterNameTableX() { AppendCols(1, kDefColWidth); AdjustColWidths(); const JFontManager* fm = GetFontManager(); itsRowHeight = fm->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()) + kRowHeightAdjust; const JSize count = itsFilters->GetElementCount(); AppendRows(count, itsRowHeight); AdjustButtons(); WantInput(kJFalse); ListenTo(itsNewButton); ListenTo(itsRemoveButton); const Atom dndName = GetDNDManager()->GetDNDSelectionName(); GetDisplay()->RegisterXAtom(kDragFilterXAtomName); }
void CBCommandTable::HandleDNDDrop ( const JPoint& pt, const JArray<Atom>& typeList, const Atom action, const Time time, const JXWidget* source ) { JXSelectionManager* selMgr = GetSelectionManager(); JXDNDManager* dndMgr = GetDNDManager(); const Atom selName = dndMgr->GetDNDSelectionName(); if (source == this && action == dndMgr->GetDNDActionMoveXAtom()) { JPoint cell; if ((GetTableSelection()).GetSingleSelectedCell(&cell) && itsDNDRowIndex != JIndex(cell.y) && itsDNDRowIndex != JIndex(cell.y)+1) { JIndex newIndex = itsDNDRowIndex; if (newIndex > JIndex(cell.y)) { newIndex--; } newIndex = JMin(newIndex, GetRowCount()); itsCmdList->MoveElementToIndex(cell.y, newIndex); MoveRow(cell.y, newIndex); SelectSingleCell(JPoint(1, newIndex)); } } else if (source == this) { JPoint cell; if ((GetTableSelection()).GetSingleSelectedCell(&cell)) { itsCmdList->InsertElementAtIndex( itsDNDRowIndex, (itsCmdList->GetElement(cell.y)).Copy()); InsertRows(itsDNDRowIndex, 1); SelectSingleCell(JPoint(1, itsDNDRowIndex)); } } else { Atom returnType; unsigned char* data; JSize dataLength; JXSelectionManager::DeleteMethod delMethod; if (selMgr->GetData(selName, time, itsCommandXAtom, &returnType, &data, &dataLength, &delMethod)) { if (returnType == itsCommandXAtom) { const std::string s((char*) data, dataLength); std::istringstream input(s); CBCommandManager::CmdInfo cmdInfo = CBCommandManager::ReadCmdInfo(input, CBCommandManager::GetCurrentCmdInfoFileVersion()); if (!input.fail()) { const JIndex newIndex = JMax(JIndex(1), itsDNDRowIndex); itsCmdList->InsertElementAtIndex(newIndex, cmdInfo); InsertRows(newIndex, 1); SelectSingleCell(JPoint(1, newIndex)); if (action == dndMgr->GetDNDActionMoveXAtom()) { selMgr->SendDeleteRequest(selName, time); } } } selMgr->DeleteData(&data, delMethod); } } HandleDNDLeave(); }