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
|
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.*;
import org.eclipse.swt.widgets.*;
public /*final*/ class FontDialog extends Dialog {
FontData fontData;
public FontDialog (Shell parent) {
this (parent, SWT.PRIMARY_MODAL);
}
public FontDialog (Shell parent, int style) {
super (parent, style);
}
public FontData getFontData() {
return fontData;
}
public FontData open () {
int parentHandle = 0;
if (parent != null) parentHandle = parent.shellHandle;
byte [] title = null;
if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
byte[] font = null;
if (fontData != null) {
if (fontData.stem != null) {
font = fontData.stem;
} else {
byte[] description = Converter.wcsToMbcs(null, fontData.getName(), true);
int osStyle = 0, style = fontData.getStyle();
if ((style & SWT.BOLD) != 0) osStyle |= OS.PF_STYLE_BOLD;
if ((style & SWT.ITALIC) != 0) osStyle |= OS.PF_STYLE_ITALIC;
int size = fontData.getHeight();
font = OS.PfGenerateFontName(description, osStyle, size, new byte[OS.MAX_FONT_TAG]);
}
fontData = null;
}
int fontPtr = OS.PtFontSelection (parentHandle, null, title, font, -1, OS.PHFONT_ALL_FONTS | OS.PFFONT_DONT_SHOW_LEGACY, null);
if (fontPtr != 0) {
int length = OS.strlen(fontPtr);
font = new byte[length];
OS.memmove(font, fontPtr, length);
fontData = FontData.photon_new(font);
}
return fontData;
}
public void setFontData (FontData fontData) {
this.fontData = fontData;
}
}
|