+ if (dataFormat != wxDF_TEXT)
+ return (wxObject*) NULL;
+
+ bool done = FALSE;
+ long id = 0;
+ unsigned long numBytes = 0;
+ int result = 0;
+ Window window = (Window) 0;
+ if (wxTheApp->GetTopWindow())
+ window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() );
+
+ int currentDataSize = 256;
+ char* data = new char[currentDataSize];
+
+ while (!done)
+ {
+ if (result == ClipboardTruncate)
+ {
+ delete[] data;
+ currentDataSize = 2*currentDataSize;
+ data = new char[currentDataSize];
+ }
+ result = XmClipboardRetrieve((Display*) wxGetDisplay(),
+ window,
+ "TEXT",
+ (XtPointer) data,
+ currentDataSize,
+ &numBytes,
+ &id);
+
+ switch (result)
+ {
+ case ClipboardSuccess:
+ {
+ if (len)
+ *len = strlen(data) + 1;
+ return (wxObject*) data;
+ break;
+ }
+ case ClipboardTruncate:
+ case ClipboardLocked:
+ {
+ break;
+ }
+ default:
+ case ClipboardNoData:
+ {
+ return (wxObject*) NULL;
+ break;
+ }
+ }
+
+ }
+