Skip to content

Commit 0425b55

Browse files
author
zhourenjian
committed
Update SWT implementation to 20080907:
1. Add about page 2. Add support of Tray 3. Support text and image in Button 4. Support setting image size by native JavaScript 5. Fix bug on Combo, Tree, Text, and others
1 parent 5ab995b commit 0425b55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1660
-325
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/.j2s

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2000, 2007 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
package org.eclipse.swt.events;
12+
13+
14+
import org.eclipse.swt.widgets.Event;
15+
16+
/**
17+
* Instances of this class are sent whenever the platform-
18+
* specific trigger for showing a context menu is detected.
19+
*
20+
* @see MenuDetectListener
21+
*
22+
* @since 3.3
23+
*/
24+
25+
public final class MenuDetectEvent extends TypedEvent {
26+
27+
/**
28+
* the display-relative x coordinate of the pointer
29+
* at the time the context menu trigger occurred
30+
*/
31+
public int x;
32+
33+
/**
34+
* the display-relative y coordinate of the pointer
35+
* at the time the context menu trigger occurred
36+
*/
37+
public int y;
38+
39+
/**
40+
* A flag indicating whether the operation should be allowed.
41+
* Setting this field to <code>false</code> will cancel the operation.
42+
*/
43+
public boolean doit;
44+
45+
private static final long serialVersionUID = -3061660596590828941L;
46+
47+
/**
48+
* Constructs a new instance of this class based on the
49+
* information in the given untyped event.
50+
*
51+
* @param e the untyped event containing the information
52+
*/
53+
public MenuDetectEvent(Event e) {
54+
super(e);
55+
this.x = e.x;
56+
this.y = e.y;
57+
this.doit = e.doit;
58+
}
59+
60+
/**
61+
* Returns a string containing a concise, human-readable
62+
* description of the receiver.
63+
*
64+
* @return a string representation of the event
65+
*/
66+
public String toString() {
67+
String string = super.toString ();
68+
return string.substring (0, string.length() - 1) // remove trailing '}'
69+
+ " x=" + x
70+
+ " y=" + y
71+
+ " doit=" + doit
72+
+ "}";
73+
}
74+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2000, 2007 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
package org.eclipse.swt.events;
12+
13+
14+
import org.eclipse.swt.internal.SWTEventListener;
15+
16+
/**
17+
* Classes which implement this interface provide methods
18+
* that deal with the events that are generated when the
19+
* platform-specific trigger for showing a context menu is
20+
* detected.
21+
* <p>
22+
* After creating an instance of a class that implements
23+
* this interface it can be added to a control or TrayItem
24+
* using the <code>addMenuDetectListener</code> method and
25+
* removed using the <code>removeMenuDetectListener</code> method.
26+
* When the context menu trigger occurs, the
27+
* <code>menuDetected</code> method will be invoked.
28+
* </p>
29+
*
30+
* @see MenuDetectEvent
31+
*
32+
* @since 3.3
33+
*/
34+
public interface MenuDetectListener extends SWTEventListener {
35+
36+
/**
37+
* Sent when the platform-dependent trigger for showing a menu item is detected.
38+
*
39+
* @param e an event containing information about the menu detect
40+
*/
41+
public void menuDetected (MenuDetectEvent e);
42+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ void init(Device device, int width, int height) {
207207
// imgHandle.alt = "Inner Image";
208208
}
209209

210+
void setSize(int width, int height) {
211+
this.width = width;
212+
this.height = height;
213+
}
210214
/**
211215
* Constructs a new instance of this class based on the
212216
* provided image, with an appearance that varies depending

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
* 2006-4-24
2727
*/
2828
public class ResizeHandler {
29+
Monitor monitor;
2930
Decorations shell;
3031
int status;
3132

32-
private ResizeHandler() {
33+
public ResizeHandler(Monitor monitor) {
34+
this.monitor = monitor;
3335
}
3436

3537
public ResizeHandler(Decorations shell, int status) {
@@ -88,8 +90,7 @@ public void updateCentered() {
8890
* @j2sNative
8991
* tb = this.shell.titleBar;
9092
*/ {}
91-
int h = ((shell.getStyle() & SWT.TITLE) != 0) ? OS.getContainerHeight(tb) : 0;
92-
93+
int h = ((shell.getStyle() & SWT.TITLE) != 0) ? OS.getContainerHeight(tb) : 20;
9394
// Not used now
9495
Monitor monitor = shell.getMonitor();
9596
Point size = shell.getSize();
@@ -99,6 +100,13 @@ public void updateCentered() {
99100
}
100101
shell.setLocation((monitor.getClientArea().width - size.x) / 2, y);
101102
}
103+
/**
104+
* @j2sNative
105+
* this.monitor.clientWidth = document.body.clientWidth;
106+
* this.monitor.clientHeight = O$.getFixedBodyClientHeight(); //document.body.clientHeight;
107+
*/
108+
public void updateMonitor() {
109+
}
102110
public int getStatus() {
103111
return status;
104112
}

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import org.eclipse.swt.SWT;
1515
import org.eclipse.swt.widgets.Decorations;
16+
import org.eclipse.swt.widgets.Monitor;
1617

1718
/**
1819
* @author zhou renjian
@@ -60,10 +61,34 @@ public static void unregister(Decorations shell, int status) {
6061
}
6162
}
6263
}
64+
public static void register(Monitor monitor) {
65+
for (int i = 0; i < handlers.length; i++) {
66+
if (handlers[i] != null && handlers[i].monitor == monitor) {
67+
return ;
68+
}
69+
}
70+
for (int i = 0; i < handlers.length; i++) {
71+
if (handlers[i] == null) {
72+
handlers[i] = new ResizeHandler(monitor);
73+
return ;
74+
}
75+
}
76+
handlers[handlers.length] = new ResizeHandler(monitor);
77+
return ;
78+
}
79+
public static void unregister(Monitor monitor) {
80+
for (int i = 0; i < handlers.length; i++) {
81+
if (handlers[i] != null && handlers[i].monitor == monitor) {
82+
handlers[i] = null;
83+
return ;
84+
}
85+
}
86+
}
6387
public static void reset() {
6488
for (int i = 0; i < handlers.length; i++) {
6589
if (handlers[i] != null) {
6690
handlers[i].shell = null;
91+
handlers[i].monitor = null;
6792
handlers[i] = null;
6893
return ;
6994
}
@@ -83,7 +108,14 @@ public static void updateResize() {
83108
} else if (status == SWT.CENTER) {
84109
hdl.updateCentered();
85110
}
111+
} else if (hdl != null && hdl.monitor != null){
112+
hdl.updateMonitor();
86113
}
87114
}
115+
116+
/**
117+
* @j2sNative
118+
* $wt.widgets.ShellManager.layoutShortcuts();
119+
*/ {}
88120
}
89121
}

0 commit comments

Comments
 (0)