// Somebody wants our clipped text long TextLabel::onClipboardRequest(FXObject* sender,FXSelector sel,void* ptr) { FXEvent *event=(FXEvent*)ptr; FXString string; // Perhaps the target wants to supply its own data for the clipboard if (FXFrame::onClipboardRequest(sender,sel,ptr)) return 1; // Recognize the request? if (event->target==stringType || event->target==textType || event->target==utf8Type || event->target==utf16Type) { // Get clipped string string=clipped; // If password mode, replace by stars if (options&TEXTFIELD_PASSWD) string.assign('*',string.count()); // Return clipped text as as UTF-8 if (event->target==utf8Type) { setDNDData(FROM_CLIPBOARD,event->target,string); return 1; } // Return clipped text translated to 8859-1 if (event->target==stringType || event->target==textType) { FX88591Codec ascii; setDNDData(FROM_CLIPBOARD,event->target,ascii.utf2mb(string)); return 1; } // Return text of the selection translated to UTF-16 if (event->target==utf16Type) { FXUTF16LECodec unicode; // FIXME maybe other endianness for unix setDNDData(FROM_CLIPBOARD,event->target,unicode.utf2mb(string)); return 1; } } return 0; }
// Somebody wants our selection; the text field will furnish it if the target doesn't long TextLabel::onSelectionRequest(FXObject* sender,FXSelector sel,void* ptr) { FXEvent *event=(FXEvent*)ptr; FXString string; FXuint start; FXuint len; // Make sure FXASSERT(0<=anchor && anchor<=contents.length()); FXASSERT(0<=cursor && cursor<=contents.length()); // Perhaps the target wants to supply its own data for the selection if (FXFrame::onSelectionRequest(sender,sel,ptr)) return 1; // Recognize the request? if (event->target==stringType || event->target==textType || event->target==utf8Type || event->target==utf16Type) { // Figure selected bytes if (anchor<cursor) { start=anchor; len=cursor-anchor; } else { start=cursor; len=anchor-cursor; } // Get selected fragment string=contents.mid(start,len); // If password mode, replace by stars if (options&TEXTFIELD_PASSWD) string.assign('*',string.count()); // Return text of the selection as UTF-8 if (event->target==utf8Type) { setDNDData(FROM_SELECTION,event->target,string); return 1; } // Return text of the selection translated to 8859-1 if (event->target==stringType || event->target==textType) { FX88591Codec ascii; setDNDData(FROM_SELECTION,event->target,ascii.utf2mb(string)); return 1; } // Return text of the selection translated to UTF-16 if (event->target==utf16Type) { FXUTF16LECodec unicode; // FIXME maybe other endianness for unix setDNDData(FROM_SELECTION,event->target,unicode.utf2mb(string)); return 1; } } return 0; }