From 869c206c4fcc8001bd2e1d66f704290331813835 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Wed, 20 Jan 2016 14:24:34 +1000 Subject: Initial Commit --- .../binnie/craftgui/controls/page/ControlPage.java | 36 ++++++++++++++ .../craftgui/controls/page/ControlPages.java | 57 ++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 src/Java/binnie/craftgui/controls/page/ControlPage.java create mode 100644 src/Java/binnie/craftgui/controls/page/ControlPages.java (limited to 'src/Java/binnie/craftgui/controls/page') 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 + extends Control + implements IControlValue +{ + 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 + extends Control + implements IControlValues, IControlValue +{ + 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 getValues() + { + List list = new ArrayList(); + for (IWidget child : getWidgets()) { + list.add(((IControlValue)child).getValue()); + } + return list; + } + + public void setValues(Collection values) {} +} -- cgit