Skip to main content
summaryrefslogtreecommitdiffstats
blob: bd8b75d48307e157ba07d3cd35e9a874e81f16e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package org.eclipse.swt.dnd;

import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.photon.*;
import org.eclipse.swt.widgets.*;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved
 */

/*
 *
 * IMPORTANT: This class is <em>not</em> intended to be subclassed.
 *
 */ 
public class Clipboard {
	
	private Display display;
	private final int MAX_RETRIES = 10;
	private int shellHandle;


public Clipboard(Display display) {	
	checkSubclass ();
	if (display == null) {
		display = Display.getCurrent();
		if (display == null) {
			display =  Display.getDefault();
		}
	}
	if (display.getThread() != Thread.currentThread()) {
		SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
	}
	this.display = display;
	
//	int widgetClass = OS.TopLevelShellWidgetClass ();
//	shellHandle = OS.XtAppCreateShell (null, null, widgetClass, display.xDisplay, null, 0);
//	OS.XtSetMappedWhenManaged (shellHandle, false);
//	OS.XtRealizeWidget (shellHandle);
}
protected void checkSubclass () {
	String name = getClass().getName ();
	String validName = Clipboard.class.getName();
	if (!validName.equals(name)) {
		DND.error (SWT.ERROR_INVALID_SUBCLASS);
	}
}
public void dispose () {
//	if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
//	shellHandle = 0;
	display = null;
}
public Object getContents(Transfer transfer) {
	if (display.isDisposed() ) return null;
	return null;
}
public void setContents(Object[] data, Transfer[] transferAgents){
}
/*
 * Note: getAvailableTypeNames is a tool for writing a Transfer sub-class only.  It should
 * NOT be used within an application because it provides platform specfic 
 * information.
 */
public String[] getAvailableTypeNames() {
	int[] count = new int[1];
	int[] max_length = new int[1];
//	int xDisplay = OS.XtDisplay (shellHandle);
//	if (xDisplay == 0)
//		DND.error(SWT.ERROR_UNSPECIFIED);
//	int xWindow = OS.XtWindow (shellHandle);
//	if (xWindow == 0)
//		DND.error(SWT.ERROR_UNSPECIFIED);
//	if (OS.XmClipboardInquireCount(xDisplay, xWindow, count, max_length) != OS.XmClipboardSuccess)
//		DND.error(SWT.ERROR_UNSPECIFIED);
	String[] types = new String[count[0]];
//	for (int i = 0; i < count[0]; i++) {
//		byte[] buffer = new byte[max_length[0]];
//		int[] copied_length = new int[1];
//		int rc = OS.XmClipboardInquireFormat(xDisplay, xWindow, i + 1, buffer, buffer.length, copied_length);
//		if (rc == OS.XmClipboardNoData){
//			types[i] = "";
//			continue;
//		}
//		if (rc != OS.XmClipboardSuccess)
//			DND.error(SWT.ERROR_UNSPECIFIED);
//		byte[] buffer2 = new byte[copied_length[0]];
//		System.arraycopy(buffer, 0, buffer2, 0, copied_length[0]);
//		types[i] = new String(buffer2);
//	}
	return types;
}
}

Back to the top