Skip to main content
summaryrefslogtreecommitdiffstats
blob: dd2d8b6b81b345668977d836987fd5f468f5719b (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
package org.eclipse.swt.widgets;

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

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

public /*final*/ class ColorDialog extends Dialog {
	RGB rgb;

public ColorDialog (Shell parent) {
	this (parent, SWT.PRIMARY_MODAL);
}

public ColorDialog (Shell parent, int style) {
	super (parent, style);
}

public RGB getRGB () {
	return rgb;
}

public RGB open () {
	int parentHandle = 0;
	if (parent != null) parentHandle = parent.shellHandle;
	byte[] title = null;
	if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
	PtColorSelectInfo_t info = new PtColorSelectInfo_t();
	info.flags = OS.Pt_COLORSELECT_MODAL;
	if (rgb != null) info.rgb = (rgb. blue & 0xFF) | ((rgb.green & 0xFF) << 8) | ((rgb.red & 0xFF) << 16);
	rgb = null;

	OS.PtColorSelect(parentHandle, title, info);
	
	if ((info.flags & OS.Pt_COLORSELECT_ACCEPT) != 0) {
		int color = info.rgb;
		rgb = new RGB ((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, color & 0xFF);
	}	
	return rgb;
}

public void setRGB (RGB rgb) {
	this.rgb = rgb;
}

}

Back to the top