Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
Clipboard.cc File Reference
#include "wx.h"
#include <X11/Xatom.h>
#include "widgets.h"
#include "scheme.h"

Go to the source code of this file.

Defines

#define Uses_wxApp
#define Uses_wxFrame
#define Uses_wxClipboard
#define Uses_XtIntrinsic
#define Uses_XtIntrinsicP
#define Uses_XLib
#define Uses_ShellWidget
#define ATOM(atom)   XInternAtom(XtDisplay(wxAPP_TOPLEVEL), atom, FALSE)
#define VALUE_TYPE   void*

Functions

void MrEdQueueBeingReplaced (wxClipboardClient *clipOwner)
void wxInitClipboard (void)
Window wxAddClipboardWindowProperty (Atom prop)
static void AddClipboardFrame (wxClipboard *cb, int on)
static Boolean doConvertClipboard (wxClipboard *cb, Widget WXUNUSED(w), Atom *WXUNUSED(selection), Atom *target, Atom *type_return, XtPointer *value_return, unsigned long *length_return, int *format_return)
static Boolean wxConvertClipboard (Widget w, Atom *selection, Atom *target, Atom *type_return, XtPointer *value_return, unsigned long *length_return, int *format_return)
static Boolean wxConvertSelection (Widget w, Atom *selection, Atom *target, Atom *type_return, XtPointer *value_return, unsigned long *length_return, int *format_return)
static void doSelectionDone (wxClipboard *cb, Widget WXUNUSED(w), Atom *WXUNUSED(selection), Atom *WXUNUSED(target))
static void wxClipboardDone (Widget w, Atom *selection, Atom *target)
static void wxSelectionDone (Widget w, Atom *selection, Atom *target)
static void wxStringClipboardDone (Widget WXUNUSED(w), Atom *WXUNUSED(selection), Atom *WXUNUSED(target))
static void wxStringSelectionDone (Widget WXUNUSED(w), Atom *WXUNUSED(selection), Atom *WXUNUSED(target))
static void doLoseClipboard (wxClipboard *cb, Widget WXUNUSED(w), Atom *WXUNUSED(selection))
static void wxLoseClipboard (Widget w, Atom *selection)
static void wxLoseSelection (Widget w, Atom *selection)
static void wxGetTargets (Widget WXUNUSED(w), XtPointer _cb, Atom *WXUNUSED(sel), Atom *WXUNUSED(type), XtPointer value, unsigned long *len, int *WXUNUSED(format))
static void wxGetSelection (Widget WXUNUSED(w), XtPointer _cb, Atom *WXUNUSED(sel), Atom *WXUNUSED(type), XtPointer value, unsigned long *len, int *WXUNUSED(format))
void wxBlockUntil (int(*)(void *), void *)
void wxBlockUntilTimeout (int(*)(void *), void *, float)
double scheme_get_inexact_milliseconds (void)
static int CheckNotInProgress (void *_cb)
static int CheckReadyTarget (void *_cb)
static int CheckReadyString (void *_cb)
static void abandoned_clip (void *_cb)

Variables

wxClipboardwxTheSelection
wxClipboardwxTheClipboard
static Widget getClipWindow
Widget wx_clipWindow
Widget wx_selWindow
Atom xa_utf8
Atom xa_text
Atom xa_targets
Atom xa_clipboard
static wxFrameclipboard_frame
static wxFrameselection_frame
static wxFrameget_clipboard_frame
static int clip_timeout

Define Documentation

#define ATOM (   atom)    XInternAtom(XtDisplay(wxAPP_TOPLEVEL), atom, FALSE)

Definition at line 44 of file Clipboard.cc.

Definition at line 23 of file Clipboard.cc.

#define Uses_wxApp

Definition at line 15 of file Clipboard.cc.

Definition at line 17 of file Clipboard.cc.

#define Uses_wxFrame

Definition at line 16 of file Clipboard.cc.

#define Uses_XLib

Definition at line 20 of file Clipboard.cc.

Definition at line 18 of file Clipboard.cc.

Definition at line 19 of file Clipboard.cc.

#define VALUE_TYPE   void*

Definition at line 46 of file Clipboard.cc.


Function Documentation

static void abandoned_clip ( void _cb) [static]

Definition at line 458 of file Clipboard.cc.

{
  wxClipboard *cb = (wxClipboard *)GET_SAFEREF(_cb);

  if (cb->in_progress)
    cb->in_progress = -1;
}

Here is the caller graph for this function:

static void AddClipboardFrame ( wxClipboard cb,
int  on 
) [static]

Definition at line 119 of file Clipboard.cc.

{
  if (!on)
    cb->frame->context = NULL;
}

Here is the caller graph for this function:

static int CheckNotInProgress ( void _cb) [static]

Definition at line 432 of file Clipboard.cc.

{
  wxClipboard *cb = (wxClipboard *)GET_SAFEREF(_cb);
  return !cb->in_progress;
}

Here is the caller graph for this function:

static int CheckReadyString ( void _cb) [static]

Definition at line 448 of file Clipboard.cc.

{
  wxClipboard *cb = (wxClipboard *)GET_SAFEREF(_cb);
  double now;
  now = scheme_get_inexact_milliseconds();
  if (now > cb->start_time + clip_timeout)
    return 1;
  return !!cb->receivedString;
}

Here is the caller graph for this function:

static int CheckReadyTarget ( void _cb) [static]

Definition at line 438 of file Clipboard.cc.

{
  wxClipboard *cb = (wxClipboard *)GET_SAFEREF(_cb);
  double now;
  now = scheme_get_inexact_milliseconds();
  if (now > cb->start_time + clip_timeout)
    return 1;
  return !!cb->receivedTargets;
}

Here is the caller graph for this function:

static Boolean doConvertClipboard ( wxClipboard cb,
Widget   WXUNUSEDw,
Atom *  WXUNUSEDselection,
Atom *  target,
Atom *  type_return,
XtPointer *  value_return,
unsigned long *  length_return,
int format_return 
) [static]

Definition at line 147 of file Clipboard.cc.

{
  Atom xa;
  char **formats = NULL;
  int i = 0, count, extra;

  if (*target == xa_targets) {
    if (cb->clipOwner) {
      count = cb->clipOwner->formats->Number();
      extra = (cb->clipOwner->formats->Member("TEXT")) ? 2 : 0;
      cb->receivedTargets = new WXGC_ATOMIC Atom[count + extra];
      formats = cb->clipOwner->formats->ListToArray(FALSE);
      for (i = 0; i < count; i++) {
       Atom atm;
       atm = ATOM(formats[i]);
       ((Atom *)cb->receivedTargets)[i] = atm;
      }
      if (extra) {
       ((Atom *)cb->receivedTargets)[count] = xa_utf8;
       ((Atom *)cb->receivedTargets)[count+1] = XA_STRING;
      }
    } else {
      count = 3;
      cb->receivedTargets = new WXGC_ATOMIC Atom[3];
      ((Atom *)cb->receivedTargets)[0] = xa_utf8;
      ((Atom *)cb->receivedTargets)[1] = XA_STRING;
      ((Atom *)cb->receivedTargets)[2] = xa_text;
      extra = 0;
    }

    *value_return = (VALUE_TYPE)cb->receivedTargets;
    *type_return = XA_ATOM;
    if (sizeof(Atom) > 4) {
      *format_return = 32;
      *length_return = (count + extra) * (sizeof(Atom) / 4);
    } else {
      *format_return = 8 * sizeof(Atom);
      *length_return = count + extra;
    }

    cb->sentString = NULL;

    return TRUE;
  } 
  
  cb->receivedTargets = NULL;

  if (cb->clipOwner) {
    formats = cb->clipOwner->formats->ListToArray(FALSE);
    for (i = cb->clipOwner->formats->Number(); i--; ) {
      xa = ATOM(formats[i]);
      if (xa == *target)
       break;
      if (xa == xa_text && (*target == xa_utf8 || *target == XA_STRING))
       break;
    }
    if (i < 0)
      return FALSE;
  } else if (*target != xa_text && *target != xa_utf8 && *target != XA_STRING)
    return FALSE;

  *type_return = xa_utf8;
  *format_return = 8;
  if (cb->clipOwner) {
    long sz = 0;
    char *s;
    s = cb->clipOwner->GetData(formats[i], &sz);
    cb->sentString = s;
    *length_return = sz;
    *value_return = (VALUE_TYPE)cb->sentString;
  } else {
    *value_return = (VALUE_TYPE)cb->cbString;
    *length_return = strlen(cb->cbString);
  }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void doLoseClipboard ( wxClipboard cb,
Widget   WXUNUSEDw,
Atom *  WXUNUSEDselection 
) [static]

Definition at line 273 of file Clipboard.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

static void doSelectionDone ( wxClipboard cb,
Widget   WXUNUSEDw,
Atom *  WXUNUSEDselection,
Atom *  WXUNUSEDtarget 
) [static]

Definition at line 247 of file Clipboard.cc.

{
  cb->sentString = NULL;
  cb->receivedTargets = NULL;
}

Here is the caller graph for this function:

Definition at line 2175 of file mred.cxx.

{
  Scheme_Object *p;
  MrEdContext *c = (MrEdContext *)clipOwner->context;
  Q_Callback *cb;

  if (c) {
    clipOwner->context = NULL;

    p = scheme_make_closed_prim(CAST_SCP call_being_replaced, clipOwner);

    cb = (Q_Callback*)scheme_malloc(sizeof(Q_Callback));
    cb->context = c;
    cb->callback = p;

    insert_q_callback(q_callbacks + 1, cb);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Window wxAddClipboardWindowProperty ( Atom  prop)

Definition at line 111 of file Clipboard.cc.

{
  unsigned char data[1] = { 'm' };
  XChangeProperty(XtDisplay(wx_clipWindow), XtWindow(wx_clipWindow),
                prop, prop, 8, PropModeReplace, data, 1);
  return XtWindow(wx_clipWindow);
}

Here is the caller graph for this function:

void wxBlockUntil ( int(*)(void *)  ,
void  
)

Definition at line 1704 of file mred.cxx.

Here is the caller graph for this function:

void wxBlockUntilTimeout ( int(*)(void *)  ,
void ,
float   
)

Definition at line 1709 of file mred.cxx.

Here is the caller graph for this function:

static void wxClipboardDone ( Widget  w,
Atom *  selection,
Atom *  target 
) [static]

Definition at line 253 of file Clipboard.cc.

{
  doSelectionDone(wxTheClipboard, w, selection, target);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Boolean wxConvertClipboard ( Widget  w,
Atom *  selection,
Atom *  target,
Atom *  type_return,
XtPointer *  value_return,
unsigned long *  length_return,
int format_return 
) [static]

Definition at line 229 of file Clipboard.cc.

{
  return doConvertClipboard(wxTheClipboard, w, selection, target, type_return, value_return,
                         length_return, format_return);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Boolean wxConvertSelection ( Widget  w,
Atom *  selection,
Atom *  target,
Atom *  type_return,
XtPointer *  value_return,
unsigned long *  length_return,
int format_return 
) [static]

Definition at line 238 of file Clipboard.cc.

{
  return doConvertClipboard(wxTheSelection, w, selection, target, type_return, value_return,
                         length_return, format_return);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void wxGetSelection ( Widget   WXUNUSEDw,
XtPointer  _cb,
Atom *  WXUNUSEDsel,
Atom *  WXUNUSEDtype,
XtPointer  value,
unsigned long *  len,
int WXUNUSEDformat 
) [static]

Definition at line 399 of file Clipboard.cc.

{
  wxClipboard *cb = (wxClipboard *)GET_SAFEREF(_cb);

  if (cb->in_progress < 0) {
    cb->in_progress = 0;
  } else {
    cb->receivedString = new WXGC_ATOMIC char[(*len) + 1];
    memcpy(cb->receivedString, value, *len);
    cb->receivedString[*len] = 0;
    cb->receivedLength = *len;
  }
}

Here is the caller graph for this function:

static void wxGetTargets ( Widget   WXUNUSEDw,
XtPointer  _cb,
Atom *  WXUNUSEDsel,
Atom *  WXUNUSEDtype,
XtPointer  value,
unsigned long *  len,
int WXUNUSEDformat 
) [static]

Definition at line 380 of file Clipboard.cc.

{
  wxClipboard *cb = (wxClipboard *)GET_SAFEREF(_cb);

  if (cb->in_progress < 0) {
    cb->in_progress = 0;
  } else {
    if (*len <= 0) {
      cb->receivedTargets = (void *)1; /* To break the waiting loop */
      cb->receivedLength = 0;
    } else {
      cb->receivedTargets = new WXGC_ATOMIC Atom[*len];
      memcpy(cb->receivedTargets, value, *len * sizeof(Atom));
      cb->receivedLength = *len;
    }
  }
}

Here is the caller graph for this function:

Definition at line 53 of file Clipboard.cc.

{
  if (!wx_clipWindow) {
    /* Hack: We need a window for clipboard stuff */
    wxWindow_Xintern *fh;
    wxREGGLOB(clipboard_frame);
    wxREGGLOB(selection_frame);
    wxREGGLOB(get_clipboard_frame);
    clipboard_frame = new wxFrame(NULL, "clipboard", 0, 0, 10, 10);
    selection_frame = new wxFrame(NULL, "selection", 0, 0, 10, 10);
    get_clipboard_frame = new wxFrame(NULL, "get clipboard", 0, 0, 10, 10);

    fh = clipboard_frame->GetHandle();
    wx_clipWindow = fh->frame;
    XtRealizeWidget(wx_clipWindow);

    fh = selection_frame->GetHandle();
    wx_selWindow = fh->frame;
    XtRealizeWidget(wx_selWindow);

    fh = get_clipboard_frame->GetHandle();
    getClipWindow = fh->frame;
    XtRealizeWidget(getClipWindow);

    /* Initially not in any specific context. */
    clipboard_frame->context = NULL;
    selection_frame->context = NULL;
    /* Not in any specific context. */
    get_clipboard_frame->context = NULL;
  }

  if (!wxTheClipboard) {
    int cts;
    
    wxREGGLOB(wxTheClipboard);
    wxREGGLOB(wxTheSelection);

    wxTheSelection = new wxClipboard;
    wxTheSelection->is_sel = 1;
    wxTheSelection->frame = selection_frame;

    if (!wxGetBoolPreference("selectionAsClipboard", &cts))
      cts = 0;

    if (cts) {
      wxTheClipboard = wxTheSelection;
    } else {
      wxTheClipboard = new wxClipboard;
      wxTheClipboard->frame = clipboard_frame;      
    }
  }

  xa_utf8 = ATOM("UTF8_STRING");
  xa_text = ATOM("TEXT");
  xa_targets = ATOM("TARGETS");
  xa_clipboard = ATOM("CLIPBOARD");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void wxLoseClipboard ( Widget  w,
Atom *  selection 
) [static]

Definition at line 283 of file Clipboard.cc.

{
  doLoseClipboard(wxTheClipboard, w, selection);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void wxLoseSelection ( Widget  w,
Atom *  selection 
) [static]

Definition at line 288 of file Clipboard.cc.

{
  doLoseClipboard(wxTheSelection, w, selection);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void wxSelectionDone ( Widget  w,
Atom *  selection,
Atom *  target 
) [static]

Definition at line 258 of file Clipboard.cc.

{
  doSelectionDone(wxTheSelection, w, selection, target);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void wxStringClipboardDone ( Widget   WXUNUSEDw,
Atom *  WXUNUSEDselection,
Atom *  WXUNUSEDtarget 
) [static]

Definition at line 263 of file Clipboard.cc.

{
  /* do nothing */
}

Here is the caller graph for this function:

static void wxStringSelectionDone ( Widget   WXUNUSEDw,
Atom *  WXUNUSEDselection,
Atom *  WXUNUSEDtarget 
) [static]

Definition at line 268 of file Clipboard.cc.

{
  /* do nothing */
}

Here is the caller graph for this function:


Variable Documentation

int clip_timeout [static]

Definition at line 430 of file Clipboard.cc.

Definition at line 50 of file Clipboard.cc.

Definition at line 51 of file Clipboard.cc.

Widget getClipWindow [static]

Definition at line 30 of file Clipboard.cc.

Definition at line 50 of file Clipboard.cc.

Widget wx_clipWindow

Definition at line 32 of file Clipboard.cc.

Widget wx_selWindow

Definition at line 32 of file Clipboard.cc.

Definition at line 28 of file Clipboard.cc.

Definition at line 27 of file Clipboard.cc.

Definition at line 48 of file Clipboard.cc.

Atom xa_targets

Definition at line 48 of file Clipboard.cc.

Atom xa_text

Definition at line 48 of file Clipboard.cc.

Atom xa_utf8

Definition at line 48 of file Clipboard.cc.