// Instance Methods /////////////////////////////////////////////////////////////////////
+ public int fontSize() { return (font == null ? DEFAULT_FONT : font).pointsize; }
/** invoked when a resource needed to render ourselves finishes loading */
public void perform() throws JSExn {
case "Enter": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.putAndTriggerTraps(name, value);
case "Leave": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.putAndTriggerTraps(name, value);
+ case "HScroll": if (!test(STOP_UPWARD_PROPAGATION) && parent != null)
+ parent.putAndTriggerTraps(name, N(((Number)value).floatValue() * ((float)parent.fontSize()) / ((float)fontSize())));
+ case "VScroll": if (!test(STOP_UPWARD_PROPAGATION) && parent != null)
+ parent.putAndTriggerTraps(name, N(((Number)value).floatValue() * ((float)parent.fontSize()) / ((float)fontSize())));
+
case "_Move": propagateDownward(name, value, false);
case "_Press1": propagateDownward(name, value, false);
case "_Press2": propagateDownward(name, value, false);
case "_DoubleClick3": propagateDownward(name, value, false);
case "_KeyPressed": propagateDownward(name, value, false);
case "_KeyReleased": propagateDownward(name, value, false);
+ case "_HScroll": propagateDownward(name, value, false);
+ case "_VScroll": propagateDownward(name, value, false);
case "PosChange": return;
case "SizeChange": return;
if (wasinside || isinside)
for(Box child = getChild(treeSize() - 1); child != null; child = child.prevSibling()) {
boolean save_stop = child.test(STOP_UPWARD_PROPAGATION);
+ Object value2 = value;
+ if (name.equals("_HScroll") || name.equals("_VScroll"))
+ value2 = N(((Number)value).floatValue() * ((float)child.fontSize()) / (float)fontSize());
if (obscured || !child.inside(x - child.x, y - child.y)) {
- child.propagateDownward(name, value, true);
+ child.propagateDownward(name, value2, true);
} else try {
found = true;
child.clear(STOP_UPWARD_PROPAGATION);
- if (name != null) child.putAndTriggerTrapsAndCatchExceptions(name, value);
- else child.propagateDownward(name, value, obscured);
+ if (name != null) child.putAndTriggerTrapsAndCatchExceptions(name, value2);
+ else child.propagateDownward(name, value2, obscured);
} finally {
if (save_stop) child.set(STOP_UPWARD_PROPAGATION); else child.clear(STOP_UPWARD_PROPAGATION);
}
Scheduler.add(this);
}
+ protected final void HScroll(int pixels) { new Message("_HScroll", new Integer(pixels), root); }
+ protected final void VScroll(int pixels) { new Message("_VScroll", new Integer(pixels), root); }
+ protected final void HScroll(float lines) { new Message("_HScroll", new Float(lines), root); }
+ protected final void VScroll(float lines) { new Message("_VScroll", new Float(lines), root); }
+
/** subclasses should invoke this method when the user resizes the window */
protected final void SizeChange(final int width, final int height) {
if (pendingWidth == width && pendingHeight == height) return;
else if (value.toLowerCase().equals("control")) control = false;
else if (value.toLowerCase().equals("shift")) shift = false;
this.value = value;
+ } else if (name.equals("_HScroll") || name.equals("_VScroll")) {
+ // FIXME: technically points != pixels
+ if (value instanceof Integer)
+ value = new Float(((Integer)value).intValue() * root.fontSize());
}
try {
boxContainingMouse.putAndTriggerTrapsAndCatchExceptions(name, value);
SInt32 delta;
r = WC(GetEventParameter)(e,kEventParamMouseWheelAxis,typeMouseWheelAxis,NULL,sizeof(axis),NULL,&axis);
checkStatus(r,"GetEventParameter");
- if(axis != kEventMouseWheelAxisY) break;
r = WC(GetEventParameter)(e,kEventParamMouseWheelDelta,typeSInt32,NULL,sizeof(delta),NULL,&delta);
checkStatus(r,"GetEventParameter");
- fprintf(stderr,"kEventMouseWheelMoved: delta: %d",delta);
- // surface->MouseWheelMoved(...) IMPROVMENT: mouse wheel support in ibex
+ switch(axis) {
+ case kEventMouseWheelAxisX: surface->HScroll(40 * delta); break;
+ case kEventMouseWheelAxisY: surface->VScroll(40 * delta); break;
+ }
return noErr;
}
}
// disable the focus manager so we can intercept the tab key
String versionString = System.getProperty("java.version", "");
int secondDecimal = versionString.substring(versionString.indexOf('.') + 1).indexOf('.');
- if (secondDecimal != -1) versionString = versionString.substring(0, secondDecimal);
+ if (secondDecimal != -1) versionString = versionString.substring(0, versionString.indexOf('.') + 1 + secondDecimal);
double version = Double.parseDouble(versionString);
if (version >= 1.4) {
isJava14 = true;
}
public void mouseWheelMoved(MouseWheelEvent m) {
- // TODO: Uncomment this once Scroll is implemented in the core
- //if(m.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { Scroll(m.getUnitsToScroll()); }
+ if (m.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL)
+ VScroll(m.getUnitsToScroll());
}
}
switch(iMsg) {
case WM_DEVMODECHANGE: break; // FEATURE: color depth changed
case WM_DISPLAYCHANGE: break; // FEATURE: screen size changed
- case WM_MOUSEWHEEL: break; // FEATURE: Mouse Wheel
+ case WM_MOUSEWHEEL:
+ VScroll(((jfloat)((wParam & 0xffff0000) >> 16)) / (jfloat)120);
+ break;
case WM_SYSKEYDOWN: if (GetKeyState(VK_MENU) >> (sizeof(SHORT) * 8 - 1) == 0) return 0;
case WM_KEYDOWN:
} else if (e->type == ButtonPress) {
XButtonEvent* xbe = (XButtonEvent*)(e);
+ switch(xbe->button) {
+ case 4: VScroll((jfloat)-1.0); return;
+ case 5: VScroll((jfloat)1.0); return;
+ case 6: HScroll((jfloat)-1.0); return;
+ case 7: HScroll((jfloat)1.0); return;
+ }
if (xbe->button == 2) xbe->button = 3;
else if (xbe->button == 3) xbe->button = 2;
Press(xbe->button);