this.height = height;
}
- /**
- * Request full repaint on next screen refresh.
- */
- protected final void setRepaint() {
- window.getApplication().setRepaint();
- }
-
/**
* Get this TWidget's parent TApplication.
*
public final void drawChildren() {
// Set my clipping rectangle
assert (window != null);
- assert (window.getScreen() != null);
- Screen screen = window.getScreen();
+ assert (getScreen() != null);
+ Screen screen = getScreen();
screen.setClipRight(width);
screen.setClipBottom(height);
- int absoluteRightEdge = window.getAbsoluteX() + screen.getWidth();
- int absoluteBottomEdge = window.getAbsoluteY() + screen.getHeight();
+ int absoluteRightEdge = window.getAbsoluteX() + window.getWidth();
+ int absoluteBottomEdge = window.getAbsoluteY() + window.getHeight();
if (!(this instanceof TWindow) && !(this instanceof TVScroller)) {
absoluteRightEdge -= 1;
}
screen.setClipRight(0);
} else if (myRightEdge > absoluteRightEdge) {
screen.setClipRight(screen.getClipRight()
- - myRightEdge - absoluteRightEdge);
+ - (myRightEdge - absoluteRightEdge));
}
if (getAbsoluteY() > absoluteBottomEdge) {
// I am offscreen
screen.setClipBottom(0);
} else if (myBottomEdge > absoluteBottomEdge) {
screen.setClipBottom(screen.getClipBottom()
- - myBottomEdge - absoluteBottomEdge);
+ - (myBottomEdge - absoluteBottomEdge));
}
// Set my offset
this(parent, true);
}
+ /**
+ * Protected constructor.
+ *
+ * @param parent parent widget
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param width width of widget
+ * @param height height of widget
+ */
+ protected TWidget(final TWidget parent, final int x, final int y,
+ final int width, final int height) {
+
+ this(parent, true, x, y, width, height);
+ }
+
/**
* Protected constructor used by subclasses that are disabled by default.
*
parent.addChild(this);
}
+ /**
+ * Protected constructor used by subclasses that are disabled by default.
+ *
+ * @param parent parent widget
+ * @param enabled if true assume enabled
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param width width of widget
+ * @param height height of widget
+ */
+ protected TWidget(final TWidget parent, final boolean enabled,
+ final int x, final int y, final int width, final int height) {
+
+ this.enabled = enabled;
+ this.parent = parent;
+ this.window = parent.window;
+ children = new LinkedList<TWidget>();
+ parent.addChild(this);
+
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
/**
* Add a child widget to my list of children. We set its tabOrder to 0
* and increment the tabOrder of all other children.
activeChild.active = false;
children.get(tabOrder).active = true;
activeChild = children.get(tabOrder);
-
- // Refresh
- window.getApplication().setRepaint();
}
/**
if ((children.size() == 0)
// TODO
// || (cast(TTreeView)this)
- // || (cast(TText)this)
+ || (this instanceof TText)
) {
// Defaults:
// If I have any buttons on me AND this is an Alt-key that matches
// its mnemonic, send it an Enter keystroke
for (TWidget widget: children) {
- /*
- TODO
-
- if (TButton button = cast(TButton)w) {
- if (button.enabled &&
- !keypress.key.isKey &&
- keypress.key.alt &&
- !keypress.key.ctrl &&
- (toLowercase(button.mnemonic.shortcut) == toLowercase(keypress.key.ch))) {
-
- w.handleEvent(new TKeypressEvent(kbEnter));
+ if (widget instanceof TButton) {
+ TButton button = (TButton) widget;
+ if (button.getEnabled()
+ && !keypress.getKey().getIsKey()
+ && keypress.getKey().getAlt()
+ && !keypress.getKey().getCtrl()
+ && (Character.toLowerCase(button.getMnemonic().getShortcut())
+ == Character.toLowerCase(keypress.getKey().getCh()))
+ ) {
+
+ widget.handleEvent(new TKeypressEvent(kbEnter));
return;
}
}
- */
}
// Dispatch the keypress to an active widget
for (TWidget widget: children) {
if (widget.active) {
- window.getApplication().setRepaint();
widget.handleEvent(keypress);
return;
}