// Static Data ////////////////////////////////////////////////////////////////////////////////
- private abstract static class Message extends Scheduler.Task {
- public abstract void perform();
- public Object call(Object arg) { perform(); return null; }
- }
-
/**< the most recently enqueued Move message; used to throttle the message rate */
- private static Message lastMoveMessage = null;
+ private static Scheduler.Task lastMoveMessage = null;
/** all instances of Surface which need to be refreshed by the Scheduler */
public static Vec allSurfaces = new Vec();
private int platform_window_height = 0;
protected final void setSize(int width, int height) {
if (root.width != width || root.height != height) {
- /*
root.dirty(0, root.height - Main.scarImage.getHeight(), Main.scarImage.getWidth(), Main.scarImage.getHeight());
- */
root.width = Math.max(Main.scarImage.getWidth(), width);
root.height = Math.max(Main.scarImage.getHeight(), height);
}
else if (button == 2) new SimpleMessage("Press2", Boolean.TRUE, Box.whoIs(root, mousex, mousey));
else if (button == 3) {
final Box who = Box.whoIs(root, mousex, mousey);
- Scheduler.add(new Message() { public void perform() {
+ Scheduler.add(new Scheduler.Task() { public void perform() {
Platform.clipboardReadEnabled = true;
- root.putAndTriggerJSTraps("Press3", Boolean.TRUE);
+ root.putAndTriggerTraps("Press3", Boolean.TRUE);
Platform.clipboardReadEnabled = false;
}});
}
else if (button == 3) new SimpleMessage("DoubleClick3", Boolean.TRUE, Box.whoIs(root, mousex, mousey));
}
- /** sends a KeyPressed message; subclasses should not add the C- or A- prefixes, nor should they capitalize alphabet characters */
+ /** Sends a KeyPressed message; subclasses should not add the C- or A- prefixes,
+ * nor should they capitalize alphabet characters
+ */
protected final void KeyPressed(String key) {
if (key == null) return;
}
// This is implemented as a private static class instead of an anonymous class to work around a GCJ bug
- private class KMessage extends Message {
+ private class KMessage extends Scheduler.Task {
String key = null;
public KMessage(String k) { key = k; }
public void perform() {
Box b = (Box)keywatchers.elementAt(i);
for(Box cur = b; cur != null; cur = cur.parent)
if (!cur.test(cur.VISIBLE)) continue outer;
- b.putAndTriggerJSTraps("KeyPressed", key);
+ b.putAndTriggerTraps("KeyPressed", key);
}
Platform.clipboardReadEnabled = false;
}
Vec keywatchers = new Vec();
- /** sends a KeyReleased message; subclasses should not add the C- or A- prefixes, nor should they capitalize alphabet characters */
+ /** sends a KeyReleased message; subclasses should not add the C- or A- prefixes,
+ * nor should they capitalize alphabet characters */
protected final void KeyReleased(final String key) {
if (key == null) return;
if (key.toLowerCase().equals("alt")) alt = false;
else if (key.toLowerCase().equals("control")) control = false;
else if (key.toLowerCase().equals("shift")) shift = false;
- Scheduler.add(new Message() { public void perform() {
+ Scheduler.add(new Scheduler.Task() { public void perform() {
outer: for(int i=0; i<keywatchers.size(); i++) {
Box b = (Box)keywatchers.elementAt(i);
for(Box cur = b; cur != null; cur = cur.parent)
if (!cur.test(cur.VISIBLE)) continue outer;
- b.putAndTriggerJSTraps("KeyReleased", key);
+ b.putAndTriggerTraps("KeyReleased", key);
}
}});
}
* message), the subclass should use (-1,-1).
*/
protected final void Move(final int newmousex, final int newmousey) {
- Scheduler.add(lastMoveMessage = new Message() { public void perform() {
+ Scheduler.add(lastMoveMessage = new Scheduler.Task() { public void perform() {
synchronized(Surface.this) {
// if move messages are arriving faster than we can process them, we just start ignoring them
// Root gets motion events outside itself (if trapped, of course)
if (!root.inside(oldmousex, oldmousey) && !root.inside(mousex, mousey) && (button1 || button2 || button3))
- root.putAndTriggerJSTraps("Move", Boolean.TRUE);
+ root.putAndTriggerTraps("Move", Boolean.TRUE);
root.Move(oldmousex, oldmousey, mousex, mousey);
if (!cursor.equals(oldcursor)) syncCursor();
}
protected final void SizeChange(final int width, final int height) {
- Scheduler.add(new Message() { public void perform() {
+ Scheduler.add(new Scheduler.Task() { public void perform() {
if (width == root.width && height == root.height) return;
root.set(root.REFLOW);
platform_window_width = width;
}
protected final void PosChange(final int x, final int y) {
- Scheduler.add(new Message() { public void perform() {
+ Scheduler.add(new Scheduler.Task() { public void perform() {
root.x = x;
root.y = y;
- root.putAndTriggerJSTraps("PosChange", Boolean.TRUE);
+ root.putAndTriggerTraps("PosChange", Boolean.TRUE);
}});
}
this.root = root;
Surface old = fromBox(root);
if (old != null) old.dispose(false);
- else root.remove();
+ else root.put("thisbox", null);
// make sure the root is properly sized
do { abort = false; root.reflow(root.width, root.height); } while(abort);
}
// FEATURE: reinstate recycler
- public class SimpleMessage extends Message {
+ public class SimpleMessage extends Scheduler.Task {
private Box boxContainingMouse;
private Object value;
Scheduler.add(this);
}
- public void perform() { boxContainingMouse.putAndTriggerJSTraps(name, value); }
+ public void perform() { boxContainingMouse.putAndTriggerTraps(name, value); }
public String toString() { return "SimpleMessage [name=" + name + ", value=" + value + "]"; }
}