Ejemplo n.º 1
0
// 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;
}
long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
    FXEvent* event = (FXEvent*)ptr;
    FXString string = GUIUserIO::clipped.c_str();
    setDNDData(FROM_CLIPBOARD, event->target, string);
    return 1;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
// Somebody wants our selection
long ShutterBug::onClipboardRequest(FXObject* sender,FXSelector sel,void* ptr){
  FXEvent *event=(FXEvent*)ptr;
  FXuchar *pointer;
  FXuval   length;

  FXTRACE((1,"%s::onClipboardRequest \n",getClassName()));

  // Try handling it in base class first
  if(FXShell::onClipboardRequest(sender,sel,ptr)) return 1;

  if(clipbuffer){

    // One of the supported image types?
    if(event->target==dndTypes[0] || event->target==dndTypes[1] || event->target==dndTypes[2] || event->target==dndTypes[3] || event->target==dndTypes[4] || event->target==dndTypes[5] || event->target==dndTypes[6]){
      FXMemoryStream ms;

      // Open memory stream
      ms.open(FXStreamSave,NULL,0);

      // Render image to memory stream
      if(event->target==dndTypes[0]){
        FXTRACE((1,"Request for bmpType\n"));
        fxsaveBMP(ms,clipbuffer,clipwidth,clipheight);
        }
      else if(event->target==dndTypes[1]){
        FXTRACE((1,"Request for gifType\n"));
        fxsaveGIF(ms,clipbuffer,clipwidth,clipheight);
        }
      else if(event->target==dndTypes[2]){
        FXTRACE((1,"Request for xpmType\n"));
        fxsaveXPM(ms,clipbuffer,clipwidth,clipheight);
        }
      else if(event->target==dndTypes[3]){
        FXTRACE((1,"Request for ppmType\n"));
        fxsavePPM(ms,clipbuffer,clipwidth,clipheight);
        }
      else if(event->target==dndTypes[4]){
        FXTRACE((1,"Request for jpgType\n"));
        fxsaveJPG(ms,clipbuffer,clipwidth,clipheight,75);
        }
      else if(event->target==dndTypes[5]){
        FXTRACE((1,"Request for pngType\n"));
        fxsavePNG(ms,clipbuffer,clipwidth,clipheight);
        }
      else if(event->target==dndTypes[6]){
        FXTRACE((1,"Request for tifType\n"));
        fxsaveTIF(ms,clipbuffer,clipwidth,clipheight,0);
        }
#ifdef WIN32
  //  else if(event->target==imageType){
  //    FXTRACE((1,"Request for imageType\n"));
  //    fxsaveBMP(ms,chart->getData(),chart->getWidth(),chart->getHeight());
  //    }
#endif

      // Grab buffered image
      ms.takeBuffer(pointer,length);

      // Close memory stream
      ms.close();

      // Set DND data
      setDNDData(FROM_CLIPBOARD,event->target,pointer,length);
      return 1;
      }
    }
  return 0;
  }