diff options
Diffstat (limited to 'src/Java/binnie/craftgui/controls/page')
-rw-r--r-- | src/Java/binnie/craftgui/controls/page/ControlPage.java | 36 | ||||
-rw-r--r-- | src/Java/binnie/craftgui/controls/page/ControlPages.java | 57 |
2 files changed, 93 insertions, 0 deletions
diff --git a/src/Java/binnie/craftgui/controls/page/ControlPage.java b/src/Java/binnie/craftgui/controls/page/ControlPage.java new file mode 100644 index 0000000000..0e5c89492e --- /dev/null +++ b/src/Java/binnie/craftgui/controls/page/ControlPage.java @@ -0,0 +1,36 @@ +package binnie.craftgui.controls.page; + +import binnie.craftgui.controls.core.Control; +import binnie.craftgui.controls.core.IControlValue; +import binnie.craftgui.core.IWidget; + +public class ControlPage<T> + extends Control + implements IControlValue<T> +{ + T value; + + public ControlPage(IWidget parent, T value) + { + this(parent, 0.0F, 0.0F, parent.w(), parent.h(), value); + } + + public ControlPage(IWidget parent, float x, float y, float w, float h, T value) + { + super(parent, x, y, w, h); + setValue(value); + if (((parent instanceof IControlValue)) && (((IControlValue)parent).getValue() == null)) { + ((IControlValue)parent).setValue(value); + } + } + + public T getValue() + { + return this.value; + } + + public void setValue(T value) + { + this.value = value; + } +} diff --git a/src/Java/binnie/craftgui/controls/page/ControlPages.java b/src/Java/binnie/craftgui/controls/page/ControlPages.java new file mode 100644 index 0000000000..43a205e874 --- /dev/null +++ b/src/Java/binnie/craftgui/controls/page/ControlPages.java @@ -0,0 +1,57 @@ +package binnie.craftgui.controls.page; + +import binnie.craftgui.controls.core.Control; +import binnie.craftgui.controls.core.IControlValue; +import binnie.craftgui.controls.core.IControlValues; +import binnie.craftgui.core.IWidget; +import binnie.craftgui.events.EventValueChanged; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class ControlPages<T> + extends Control + implements IControlValues<T>, IControlValue<T> +{ + public boolean isChildVisible(IWidget child) + { + if (child == null) { + return false; + } + return this.value == ((IControlValue)child).getValue(); + } + + public ControlPages(IWidget parent, float x, float y, float w, float h) + { + super(parent, x, y, w, h); + } + + T value = null; + + public void onAddChild(IWidget widget) {} + + public T getValue() + { + return this.value; + } + + public void setValue(T value) + { + if (this.value != value) + { + this.value = value; + callEvent(new EventValueChanged(this, value)); + } + } + + public Collection<T> getValues() + { + List<T> list = new ArrayList(); + for (IWidget child : getWidgets()) { + list.add(((IControlValue)child).getValue()); + } + return list; + } + + public void setValues(Collection<T> values) {} +} |