Skip to content

Commit 58781b5

Browse files
hansonrhansonr
authored andcommitted
cursor this.name corrected; cursor names consolidated; showing for panel
1 parent de97e2e commit 58781b5

File tree

10 files changed

+48
-73
lines changed

10 files changed

+48
-73
lines changed
-7 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181124101315
1+
20181124120031
-7 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181124101315
1+
20181124120031
-7 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/Cursor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
*/
2828
package java.awt;
2929

30+
import swingjs.JSToolkit;
31+
3032
/**
3133
* A class to encapsulate the bitmap representation of the mouse cursor.
3234
*
@@ -297,9 +299,9 @@ public Cursor(int type) {
297299
throw new IllegalArgumentException("illegal cursor type");
298300
}
299301
this.type = type;
300-
301-
// Lookup localized name.
302-
name = "TODO_CURSOR";//Toolkit.getProperty(cursorProperties[type][0],
302+
name = "TODO_CURSOR";
303+
name = JSToolkit.getCursorName(this);
304+
//Toolkit.getProperty(cursorProperties[type][0],
303305
// cursorProperties[type][1]);
304306
}
305307

sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -770,54 +770,45 @@ public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
770770
return null;
771771
}
772772

773-
public static void setCursor(Component comp, Cursor c) {
774-
String curs = null;
775-
switch(c == null ? Cursor.DEFAULT_CURSOR : c.getType()) {
776-
case Cursor.CROSSHAIR_CURSOR:
777-
curs = "crosshair";
778-
break;
779-
case Cursor.WAIT_CURSOR:
780-
curs = "wait";
781-
break;
782-
case Cursor.TEXT_CURSOR:
783-
curs = "text";
784-
break;
785-
case Cursor.N_RESIZE_CURSOR:
786-
case Cursor.S_RESIZE_CURSOR:
787-
curs = "ns-resize";
788-
break;
789-
case Cursor.HAND_CURSOR:
790-
curs = "grab";
791-
break;
792-
case Cursor.MOVE_CURSOR:
793-
curs = "move";
794-
break;
795-
case Cursor.NE_RESIZE_CURSOR:
796-
case Cursor.SW_RESIZE_CURSOR:
797-
curs = "nesw-resize";
798-
break;
799-
case Cursor.SE_RESIZE_CURSOR:
800-
case Cursor.NW_RESIZE_CURSOR:
801-
curs = "nwse-resize";
802-
break;
803-
case Cursor.E_RESIZE_CURSOR:
804-
case Cursor.W_RESIZE_CURSOR:
805-
curs = "ew-resize";
806-
break;
807-
case Cursor.DEFAULT_CURSOR:
808-
default:
809-
curs = "default";
810-
break;
811-
}
812-
DOMNode.setCursor(curs, comp);
813-
814-
}
815-
816-
817773

818-
//////// FONTS ///////
774+
//////// FONTS and CURSORS ///////
819775

776+
// public static void setCursor(Component comp, Cursor c) {
777+
// DOMNode.setCursor(getCursorName(c), comp);
778+
// }
820779

780+
public static String getCursorName(Cursor c) {
781+
switch (c == null ? Cursor.DEFAULT_CURSOR : c.getType()) {
782+
case Cursor.CROSSHAIR_CURSOR:
783+
return "crosshair";
784+
case Cursor.WAIT_CURSOR:
785+
return "wait";
786+
case Cursor.TEXT_CURSOR:
787+
return "text";
788+
case Cursor.HAND_CURSOR:
789+
return "grab";
790+
case Cursor.MOVE_CURSOR:
791+
return "move";
792+
case Cursor.N_RESIZE_CURSOR:
793+
case Cursor.S_RESIZE_CURSOR:
794+
return "ns-resize";
795+
case Cursor.NE_RESIZE_CURSOR:
796+
case Cursor.SW_RESIZE_CURSOR:
797+
return "nesw-resize";
798+
case Cursor.SE_RESIZE_CURSOR:
799+
case Cursor.NW_RESIZE_CURSOR:
800+
return "nwse-resize";
801+
case Cursor.E_RESIZE_CURSOR:
802+
case Cursor.W_RESIZE_CURSOR:
803+
return "ew-resize";
804+
case Cursor.CUSTOM_CURSOR:
805+
return c.getName();
806+
case Cursor.DEFAULT_CURSOR:
807+
default:
808+
return "default";
809+
}
810+
}
811+
821812
private static String[] hardwiredFontList;
822813

823814
// -- Obsolete font names from 1.0.2. It was decided that

sources/net.sf.j2s.java.core/src/swingjs/jquery/jquery-ui-j2sslider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236

237237
_destroy : function() {
238238

239-
for (i = 0; i < handles.length; i++) {
239+
for (i = 0; i < this.handles.length; i++) {
240240
J2S.setDraggable(this.handles[i], false);
241241
}
242242

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,31 +2138,12 @@ public void setFont(Font f) {
21382138

21392139
@Override
21402140
public void updateCursorImmediately() {
2141-
String curs = getCursorName(c.getCursor());
21422141
setHTMLElement();
2143-
DOMNode.setStyles(domNode, "cursor", curs);
2142+
String curs = JSToolkit.getCursorName(c.getCursor());
2143+
DOMNode.setStyles(outerNode, "cursor", curs);
21442144
setWaitImage(curs == "wait");
21452145
}
21462146

2147-
static String getCursorName(Cursor cursor) {
2148-
switch (cursor.getType()) {
2149-
case Cursor.CROSSHAIR_CURSOR:
2150-
return "crosshair";
2151-
case Cursor.WAIT_CURSOR:
2152-
return "wait";
2153-
case Cursor.N_RESIZE_CURSOR: // zoom
2154-
return "ns-resize";
2155-
case Cursor.HAND_CURSOR: // hand
2156-
return "grab";
2157-
case Cursor.MOVE_CURSOR:
2158-
return "move";
2159-
case Cursor.CUSTOM_CURSOR:
2160-
return cursor.getName();
2161-
default:
2162-
return "default";
2163-
}
2164-
}
2165-
21662147
protected void setWaitImage(boolean doShow) {
21672148
if (waitImage != null) {
21682149
if (!doShow)

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSSplitPaneUI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import javax.swing.UIManager;
5454

5555
import javajs.api.JSFunction;
56+
import swingjs.JSToolkit;
5657
import swingjs.api.js.DOMNode;
5758

5859
/**
@@ -238,7 +239,7 @@ protected void fHandleDrag(Object xyev, int type) {
238239
this.xyev = xyev;
239240
this.pressedLocation = splitPane.getDividerLocation();
240241
divider.setCursor(cursor);
241-
DOMNode.setCursor(getCursorName(cursor), null);
242+
DOMNode.setCursor(JSToolkit.getCursorName(cursor), null);
242243
return;
243244
case MouseEvent.MOUSE_DRAGGED:
244245
int d = this.pressedLocation + /** @j2sNative (this.isHorizontal ? xyev.dx : xyev.dy) || */

0 commit comments

Comments
 (0)