Skip to content

Commit cc45503

Browse files
author
jossonsmith
committed
Implement FontDialog and improve related widgets
1 parent 8682d6b commit cc45503

File tree

7 files changed

+644
-32
lines changed

7 files changed

+644
-32
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/graphics/FontData.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public final class FontData {
5252
*/
5353
//public LOGFONT data;
5454

55+
public boolean isUnderline;
56+
57+
public boolean isStrikeout;
58+
5559
/**
5660
* The height of the font data in points
5761
* (Warning: This field is platform dependent)
@@ -235,11 +239,8 @@ public FontData(String string) {
235239
*/
236240
//if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
237241
name = string;
238-
if (name == null) {
239-
name = "Arial";
240-
}
241242
style = SWT.NORMAL;
242-
height = 12;
243+
height = 10;
243244
}
244245

245246
/**

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/ResizeHandler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313

1414
package org.eclipse.swt.internal;
1515

16+
import org.eclipse.swt.SWT;
1617
import org.eclipse.swt.graphics.Point;
1718
import org.eclipse.swt.graphics.Rectangle;
18-
import org.eclipse.swt.internal.xhtml.document;
19-
import org.eclipse.swt.internal.xhtml.window;
2019
import org.eclipse.swt.widgets.Decorations;
2120
import org.eclipse.swt.widgets.Monitor;
2221

@@ -52,8 +51,11 @@ public void updateMaximized() {
5251
if (width > bounds.width) {
5352
width = bounds.width;
5453
}
54+
int titleHeight = ((shell.getStyle() & SWT.TITLE) != 0) ? 20 : 0;
55+
// FIXME: maximized size is not accurate
56+
shell.setBounds(shell.computeTrim(0, 0, width + 4, height - titleHeight + 6));
5557
// shell.setBounds(0 - 4, 0 - 4, width - 2, height + 4);
56-
shell.setBounds(shell.computeTrim(0, 0, width + 2, height - 18));
58+
//shell.setBounds(shell.computeTrim(0, 0, width + 2, height - 18));
5759
}
5860
public void updateCentered() {
5961
// Not used now

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/package.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ $wt = org.eclipse.swt;
1313
"internal.dnd",
1414
"internal.browser",
1515
"internal.struct",
16-
"layout",
16+
"layout",
17+
"printing",
18+
"program",
1719
"widgets"]);
1820

1921
var path = ClazzLoader.getClasspathFor ("org.eclipse.swt.*");

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Control.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ public Font getFont () {
890890
*/
891891
String ff = handle.style.fontFamily;
892892
if (ff == null || ff.toString().length() == 0) {
893-
ff = "Tahoma, Arial, sans-serif";
893+
ff = null;//"Tahoma, Arial, sans-serif";
894894
}
895895
String fs = handle.style.fontSize;
896896
if (fs == null || fs.toString().length() == 0) {
@@ -2320,7 +2320,6 @@ public boolean setFocus () {
23202320
*/
23212321
public void setFont (Font font) {
23222322
checkWidget ();
2323-
if (font == null || font.data == null) return ;
23242323
/*
23252324
int hFont = 0;
23262325
if (font != null) {
@@ -2330,7 +2329,17 @@ public void setFont (Font font) {
23302329
if (hFont == 0) hFont = defaultFont ();
23312330
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 1);
23322331
*/
2333-
handle.style.fontFamily = font.data.name;
2332+
if (font == null || font.data == null) {
2333+
handle.style.fontFamily = "";
2334+
handle.style.fontSize = "";
2335+
handle.style.fontWeight = "";
2336+
handle.style.fontStyle = "";
2337+
handle.style.textDecoration = "";
2338+
return;
2339+
}
2340+
if (font.data.name != null) {
2341+
handle.style.fontFamily = font.data.name;
2342+
}
23342343
handle.style.fontSize = font.data.height + "pt";
23352344
if ((font.data.style & SWT.BOLD) != 0) {
23362345
handle.style.fontWeight = "bold";
@@ -2342,6 +2351,18 @@ public void setFont (Font font) {
23422351
} else {
23432352
handle.style.fontStyle = "normal";
23442353
}
2354+
String td = "";
2355+
if (font.data.isStrikeout) {
2356+
td = "line-through";
2357+
}
2358+
if (font.data.isUnderline) {
2359+
if (td.length() > 0) {
2360+
td += " underline";
2361+
} else {
2362+
td = "underline";
2363+
}
2364+
}
2365+
handle.style.textDecoration = td;
23452366
//handle.style.fontVariant = font.data.style;
23462367
//TODO:
23472368
}

0 commit comments

Comments
 (0)