X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWidget.java;h=d0c6b8177dac3a818ea8a0554f86d813fb356d3b;hb=928811d8e292801029b7b6605453524f65e9ebd9;hp=e07594997d1b208a4824191030f429a849457dc8;hpb=8dc20d387df1c9344e324d6b8a0d0d7939a47940;p=fanfix.git diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index e075949..d0c6b81 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -33,6 +33,7 @@ package jexer; import java.util.List; import java.util.LinkedList; +import jexer.bits.ColorTheme; import jexer.event.TCommandEvent; import jexer.event.TInputEvent; import jexer.event.TKeypressEvent; @@ -40,6 +41,7 @@ import jexer.event.TMenuEvent; import jexer.event.TMouseEvent; import jexer.event.TResizeEvent; import jexer.io.Screen; +import jexer.menu.TMenu; import static jexer.TKeypress.*; /** @@ -55,6 +57,15 @@ public abstract class TWidget { */ private TWidget parent = null; + /** + * Get parent widget. + * + * @return parent widget + */ + public final TWidget getParent() { + return parent; + } + /** * Backdoor access for TWindow's constructor. ONLY TWindow USES THIS. * @@ -75,11 +86,45 @@ public abstract class TWidget { this.height = height; } + /** + * Request full repaint on next screen refresh. + */ + protected final void setRepaint() { + window.getApplication().setRepaint(); + } + + /** + * Get this TWidget's parent TApplication. + * + * @return the parent TApplication + */ + public TApplication getApplication() { + return window.getApplication(); + } + + /** + * Get the Screen. + * + * @return the Screen + */ + public Screen getScreen() { + return window.getScreen(); + } + /** * Child widgets that this widget contains. */ private List children; + /** + * Get the list of child widgets that this widget contains. + * + * @return the list of child widgets + */ + public List getChildren() { + return children; + } + /** * The currently active child widget that will receive keypress events. */ @@ -104,7 +149,7 @@ public abstract class TWidget { * * @param active if true, this widget will receive events */ - public final void setActive(boolean active) { + public final void setActive(final boolean active) { this.active = active; } @@ -358,6 +403,15 @@ public abstract class TWidget { return parent.getAbsoluteY() + y; } + /** + * Get the global color theme. + * + * @return the ColorTheme + */ + public final ColorTheme getTheme() { + return window.getApplication().getTheme(); + } + /** * Draw my specific widget. When called, the screen rectangle I draw * into is already setup (offset and clipping). @@ -571,7 +625,7 @@ public abstract class TWidget { * * @return widget that is active, or this if no children */ - public final TWidget getActiveChild() { + public TWidget getActiveChild() { if ((this instanceof THScroller) || (this instanceof TVScroller) ) {