void JXSelectionData::SetSelectionInfo ( const Atom selectionName, const Time startTime ) { assert( selectionName != None ); itsSelectionName = selectionName; itsStartTime = startTime; if (selectionName != GetDNDSelectionName()) { JXSelectionManager* selMgr = GetSelectionManager(); AddType(selMgr->GetTargetsXAtom()); AddType(selMgr->GetTimeStampXAtom()); } AddTypes(selectionName); }
JBoolean JXSelectionData::Convert ( const Atom requestType, Atom* returnType, unsigned char** data, JSize* dataLength, JSize* bitsPerBlock ) const { JXSelectionManager* selMgr = GetSelectionManager(); // TARGETS if (requestType == selMgr->GetTargetsXAtom()) { const JSize atomCount = itsTypeList->GetElementCount(); assert( atomCount > 0 ); *returnType = XA_ATOM; *bitsPerBlock = sizeof(Atom)*8; *dataLength = sizeof(Atom)*atomCount; *data = new unsigned char [ *dataLength ]; if (*data == NULL) { return kJFalse; } Atom* atomData = reinterpret_cast<Atom*>(*data); for (JIndex i=1; i<=atomCount; i++) { atomData[i-1] = itsTypeList->GetElement(i); } return kJTrue; } // TIMESTAMP else if (requestType == selMgr->GetTimeStampXAtom()) { *returnType = XA_INTEGER; *bitsPerBlock = sizeof(Time)*8; *dataLength = sizeof(Time); *data = new unsigned char [ *dataLength ]; if (*data == NULL) { return kJFalse; } *(reinterpret_cast<Time*>(*data)) = itsStartTime; return kJTrue; } // everything else else { Resolve(); return ConvertData(requestType, returnType, data, dataLength, bitsPerBlock); } }