aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/craftgui/controls
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-02-19 17:38:35 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-02-19 17:38:35 +1000
commit7011e367ac5ccc34473283d6245bc2cec93b835e (patch)
treecc5675471f1101631bec2cde9713cb9c0004cc8f /src/Java/binnie/craftgui/controls
parentc68c67d74f39c3eb075ac29e88936a1976ef089b (diff)
downloadGT5-Unofficial-7011e367ac5ccc34473283d6245bc2cec93b835e.tar.gz
GT5-Unofficial-7011e367ac5ccc34473283d6245bc2cec93b835e.tar.bz2
GT5-Unofficial-7011e367ac5ccc34473283d6245bc2cec93b835e.zip
Removed Hard dependency on gregtech as another Project and added dev versions of all requires libs.
Also started work on GT-EU EnderIO conduits, adding @Optional annotations where possible and a few other nice things.
Diffstat (limited to 'src/Java/binnie/craftgui/controls')
-rw-r--r--src/Java/binnie/craftgui/controls/ControlCheckbox.java75
-rw-r--r--src/Java/binnie/craftgui/controls/ControlText.java50
-rw-r--r--src/Java/binnie/craftgui/controls/ControlTextCentered.java15
-rw-r--r--src/Java/binnie/craftgui/controls/ControlTextEdit.java154
-rw-r--r--src/Java/binnie/craftgui/controls/IControlSelection.java10
-rw-r--r--src/Java/binnie/craftgui/controls/IControlSelectionOption.java6
-rw-r--r--src/Java/binnie/craftgui/controls/button/ControlButton.java70
-rw-r--r--src/Java/binnie/craftgui/controls/button/ControlEnumButton.java61
-rw-r--r--src/Java/binnie/craftgui/controls/button/ControlToggleButton.java21
-rw-r--r--src/Java/binnie/craftgui/controls/core/Control.java85
-rw-r--r--src/Java/binnie/craftgui/controls/core/IControlIndexed.java8
-rw-r--r--src/Java/binnie/craftgui/controls/core/IControlValue.java11
-rw-r--r--src/Java/binnie/craftgui/controls/core/IControlValues.java11
-rw-r--r--src/Java/binnie/craftgui/controls/listbox/ControlList.java146
-rw-r--r--src/Java/binnie/craftgui/controls/listbox/ControlListBox.java76
-rw-r--r--src/Java/binnie/craftgui/controls/listbox/ControlOption.java73
-rw-r--r--src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java37
-rw-r--r--src/Java/binnie/craftgui/controls/page/ControlPage.java36
-rw-r--r--src/Java/binnie/craftgui/controls/page/ControlPages.java57
-rw-r--r--src/Java/binnie/craftgui/controls/scroll/ControlScroll.java22
-rw-r--r--src/Java/binnie/craftgui/controls/scroll/ControlScrollBar.java94
-rw-r--r--src/Java/binnie/craftgui/controls/scroll/ControlScrollableContent.java134
-rw-r--r--src/Java/binnie/craftgui/controls/scroll/IControlScrollable.java17
-rw-r--r--src/Java/binnie/craftgui/controls/tab/ControlTab.java128
-rw-r--r--src/Java/binnie/craftgui/controls/tab/ControlTabBar.java86
25 files changed, 0 insertions, 1483 deletions
diff --git a/src/Java/binnie/craftgui/controls/ControlCheckbox.java b/src/Java/binnie/craftgui/controls/ControlCheckbox.java
deleted file mode 100644
index edfeab631c..0000000000
--- a/src/Java/binnie/craftgui/controls/ControlCheckbox.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package binnie.craftgui.controls;
-
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.controls.core.IControlValue;
-import binnie.craftgui.core.Attribute;
-import binnie.craftgui.core.CraftGUI;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.geometry.IArea;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.core.geometry.TextJustification;
-import binnie.craftgui.core.renderer.Renderer;
-import binnie.craftgui.events.EventHandler.Origin;
-import binnie.craftgui.events.EventMouse.Down;
-import binnie.craftgui.events.EventMouse.Down.Handler;
-import binnie.craftgui.events.EventValueChanged;
-import binnie.craftgui.resource.minecraft.CraftGUITexture;
-
-public class ControlCheckbox
- extends Control
- implements IControlValue<Boolean>
-{
- boolean value;
- String text;
-
- public ControlCheckbox(IWidget parent, float x, float y, boolean bool)
- {
- this(parent, x, y, 0.0F, "", bool);
- }
-
- public ControlCheckbox(IWidget parent, float x, float y, float w, String text, boolean bool)
- {
- super(parent, x, y, w > 16.0F ? w : 16.0F, 16.0F);
- this.text = text;
- this.value = bool;
- if (w > 16.0F) {
- new ControlText(this, new IArea(16.0F, 1.0F, w - 16.0F, 16.0F), text, TextJustification.MiddleCenter).setColour(4473924);
- }
- addAttribute(Attribute.MouseOver);
- addEventHandler(new EventMouse.Down.Handler()
- {
- public void onEvent(EventMouse.Down event)
- {
- ControlCheckbox.this.toggleValue();
- }
- }.setOrigin(EventHandler.Origin.Self, this));
- }
-
- protected void onValueChanged(boolean value) {}
-
- public Boolean getValue()
- {
- return Boolean.valueOf(this.value);
- }
-
- public void setValue(Boolean value)
- {
- this.value = value.booleanValue();
- onValueChanged(value.booleanValue());
- callEvent(new EventValueChanged(this, value));
- }
-
- public void toggleValue()
- {
- setValue(Boolean.valueOf(!getValue().booleanValue()));
- }
-
- public void onRenderBackground()
- {
- Object texture = getValue().booleanValue() ? CraftGUITexture.CheckboxChecked : CraftGUITexture.Checkbox;
- if (isMouseOver()) {
- texture = getValue().booleanValue() ? CraftGUITexture.CheckboxCheckedHighlighted : CraftGUITexture.CheckboxHighlighted;
- }
- CraftGUI.Render.texture(texture, IPoint.ZERO);
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/ControlText.java b/src/Java/binnie/craftgui/controls/ControlText.java
deleted file mode 100644
index 4df9c04db1..0000000000
--- a/src/Java/binnie/craftgui/controls/ControlText.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package binnie.craftgui.controls;
-
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.controls.core.IControlValue;
-import binnie.craftgui.core.CraftGUI;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.geometry.IArea;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.core.geometry.TextJustification;
-import binnie.craftgui.core.renderer.Renderer;
-
-public class ControlText
- extends Control
- implements IControlValue<String>
-{
- private String text;
- private TextJustification align;
-
- public ControlText(IWidget parent, IPoint pos, String text)
- {
- this(parent, new IArea(pos, new IPoint(500.0F, 0.0F)), text, TextJustification.TopLeft);
- }
-
- public ControlText(IWidget parent, String text, TextJustification align)
- {
- this(parent, parent.getArea(), text, align);
- }
-
- public ControlText(IWidget parent, IArea area, String text, TextJustification align)
- {
- super(parent, area.pos().x(), area.pos().y(), area.size().x(), area.size().y());
- setValue(text);
- this.align = align;
- }
-
- public void onRenderBackground()
- {
- CraftGUI.Render.text(getArea(), this.align, this.text, getColour());
- }
-
- public void setValue(String text)
- {
- this.text = text;
- }
-
- public String getValue()
- {
- return this.text;
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/ControlTextCentered.java b/src/Java/binnie/craftgui/controls/ControlTextCentered.java
deleted file mode 100644
index 12434528db..0000000000
--- a/src/Java/binnie/craftgui/controls/ControlTextCentered.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package binnie.craftgui.controls;
-
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.geometry.IArea;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.core.geometry.TextJustification;
-
-public class ControlTextCentered
- extends ControlText
-{
- public ControlTextCentered(IWidget parent, float y, String text)
- {
- super(parent, new IArea(new IPoint(0.0F, y), new IPoint(parent.size().x(), 0.0F)), text, TextJustification.TopCenter);
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/ControlTextEdit.java b/src/Java/binnie/craftgui/controls/ControlTextEdit.java
deleted file mode 100644
index 8c07a12d7c..0000000000
--- a/src/Java/binnie/craftgui/controls/ControlTextEdit.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package binnie.craftgui.controls;
-
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.controls.core.IControlValue;
-import binnie.craftgui.core.Attribute;
-import binnie.craftgui.core.CraftGUI;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.core.renderer.Renderer;
-import binnie.craftgui.events.EventHandler.Origin;
-import binnie.craftgui.events.EventKey.Down;
-import binnie.craftgui.events.EventKey.Down.Handler;
-import binnie.craftgui.events.EventMouse.Down;
-import binnie.craftgui.events.EventMouse.Down.Handler;
-import binnie.craftgui.events.EventTextEdit;
-import binnie.craftgui.events.EventWidget.GainFocus;
-import binnie.craftgui.events.EventWidget.GainFocus.Handler;
-import binnie.craftgui.events.EventWidget.LoseFocus;
-import binnie.craftgui.events.EventWidget.LoseFocus.Handler;
-import binnie.craftgui.minecraft.GuiCraftGUI;
-import binnie.craftgui.minecraft.Window;
-import binnie.craftgui.resource.minecraft.CraftGUITexture;
-import net.minecraft.client.gui.GuiTextField;
-
-public class ControlTextEdit
- extends Control
- implements IControlValue<String>
-{
- GuiTextField field;
-
- public ControlTextEdit(IWidget parent, float x, float y, float width, float height)
- {
- super(parent, x, y, width, height);
-
- this.field = new GuiTextField(getWindow().getGui().getFontRenderer(), 0, 0, 10, 10);
- addAttribute(Attribute.CanFocus);
- addAttribute(Attribute.MouseOver);
- this.field.setEnableBackgroundDrawing(false);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- addEventHandler(new EventKey.Down.Handler()
- {
- public void onEvent(EventKey.Down event)
- {
- ControlTextEdit.this.field.textboxKeyTyped(event.getCharacter(), event.getKey());
- String text = ControlTextEdit.this.getValue();
- if (!text.equals(ControlTextEdit.this.cachedValue))
- {
- ControlTextEdit.this.cachedValue = text;
- ControlTextEdit.this.callEvent(new EventTextEdit(ControlTextEdit.this, ControlTextEdit.this.cachedValue));
- ControlTextEdit.this.onTextEdit(ControlTextEdit.this.cachedValue);
- }
- }
- }.setOrigin(EventHandler.Origin.Self, this));
-
-
-
-
- addEventHandler(new EventMouse.Down.Handler()
- {
- public void onEvent(EventMouse.Down event)
- {
- ControlTextEdit.this.field.mouseClicked((int)ControlTextEdit.this.getRelativeMousePosition().x(), (int)ControlTextEdit.this.getRelativeMousePosition().y(), event.getButton());
- }
- }.setOrigin(EventHandler.Origin.Self, this));
-
-
-
- addEventHandler(new EventWidget.GainFocus.Handler()
- {
- public void onEvent(EventWidget.GainFocus event)
- {
- ControlTextEdit.this.field.setFocused(true);
- }
- }.setOrigin(EventHandler.Origin.Self, this));
-
-
-
- addEventHandler(new EventWidget.LoseFocus.Handler()
- {
- public void onEvent(EventWidget.LoseFocus event)
- {
- ControlTextEdit.this.field.setFocused(false);
- }
- }.setOrigin(EventHandler.Origin.Self, this));
- }
-
- public String getValue()
- {
- return this.field.getText() == null ? "" : this.field.getText();
- }
-
- public void setValue(String value)
- {
- if (!getValue().equals(value))
- {
- this.field.setText(value);
- this.field.setCursorPosition(0);
- }
- }
-
- private String cachedValue = "";
-
- public void onUpdateClient() {}
-
- protected void onTextEdit(String value) {}
-
- public void onRenderBackground()
- {
- CraftGUI.Render.texture(CraftGUITexture.Slot, getArea());
- renderTextField();
- }
-
- protected void renderTextField()
- {
- this.field.width = ((int)w());
- this.field.height = ((int)h());
- this.field.xPosition = ((int)((h() - 8.0F) / 2.0F));
- this.field.yPosition = ((int)((h() - 8.0F) / 2.0F));
- this.field.drawTextBox();
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/IControlSelection.java b/src/Java/binnie/craftgui/controls/IControlSelection.java
deleted file mode 100644
index 4648f49290..0000000000
--- a/src/Java/binnie/craftgui/controls/IControlSelection.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package binnie.craftgui.controls;
-
-public abstract interface IControlSelection<T>
-{
- public abstract T getSelectedValue();
-
- public abstract void setSelectedValue(T paramT);
-
- public abstract boolean isSelected(IControlSelectionOption<T> paramIControlSelectionOption);
-}
diff --git a/src/Java/binnie/craftgui/controls/IControlSelectionOption.java b/src/Java/binnie/craftgui/controls/IControlSelectionOption.java
deleted file mode 100644
index 9074a55541..0000000000
--- a/src/Java/binnie/craftgui/controls/IControlSelectionOption.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package binnie.craftgui.controls;
-
-public abstract interface IControlSelectionOption<T>
-{
- public abstract T getValue();
-}
diff --git a/src/Java/binnie/craftgui/controls/button/ControlButton.java b/src/Java/binnie/craftgui/controls/button/ControlButton.java
deleted file mode 100644
index b41cb65116..0000000000
--- a/src/Java/binnie/craftgui/controls/button/ControlButton.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package binnie.craftgui.controls.button;
-
-import binnie.craftgui.controls.ControlText;
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.core.Attribute;
-import binnie.craftgui.core.CraftGUI;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.geometry.TextJustification;
-import binnie.craftgui.core.renderer.Renderer;
-import binnie.craftgui.events.EventButtonClicked;
-import binnie.craftgui.events.EventHandler.Origin;
-import binnie.craftgui.events.EventMouse.Down;
-import binnie.craftgui.events.EventMouse.Down.Handler;
-import binnie.craftgui.resource.minecraft.CraftGUITexture;
-
-public class ControlButton
- extends Control
-{
- private ControlText textWidget;
- private String text;
-
- public ControlButton(IWidget parent, float x, float y, float width, float height)
- {
- super(parent, x, y, width, height);
-
- addAttribute(Attribute.MouseOver);
-
- addEventHandler(new EventMouse.Down.Handler()
- {
- public void onEvent(EventMouse.Down event)
- {
- ControlButton.this.callEvent(new EventButtonClicked(ControlButton.this.getWidget()));
- ControlButton.this.onMouseClick(event);
- }
- }.setOrigin(EventHandler.Origin.Self, this));
- }
-
- protected void onMouseClick(EventMouse.Down event) {}
-
- public ControlButton(IWidget parent, float x, float y, float width, float height, String text)
- {
- this(parent, x, y, width, height);
-
- this.text = text;
- this.textWidget = new ControlText(this, getArea(), text, TextJustification.MiddleCenter);
- }
-
- public void onUpdateClient()
- {
- if (this.textWidget != null) {
- this.textWidget.setValue(getText());
- }
- }
-
- public String getText()
- {
- return this.text;
- }
-
- public void onRenderBackground()
- {
- Object texture = CraftGUITexture.ButtonDisabled;
- if (isMouseOver()) {
- texture = CraftGUITexture.ButtonHighlighted;
- } else if (isEnabled()) {
- texture = CraftGUITexture.Button;
- }
- CraftGUI.Render.texture(texture, getArea());
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/button/ControlEnumButton.java b/src/Java/binnie/craftgui/controls/button/ControlEnumButton.java
deleted file mode 100644
index 924bd8c110..0000000000
--- a/src/Java/binnie/craftgui/controls/button/ControlEnumButton.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package binnie.craftgui.controls.button;
-
-import binnie.craftgui.controls.core.IControlValue;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.events.EventMouse.Down;
-import binnie.craftgui.events.EventValueChanged;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ControlEnumButton<T>
- extends ControlButton
- implements IControlValue<T>
-{
- public static final String eventEnumChanged = "eventEnumButtonChanged";
- private T currentSelection;
-
- public String getText()
- {
- return this.currentSelection.toString();
- }
-
- public void onMouseClick(EventMouse.Down event)
- {
- int index = this.enumConstants.indexOf(this.currentSelection);
- if (index < this.enumConstants.size() - 1) {
- index++;
- } else {
- index = 0;
- }
- T newEnum = this.enumConstants.get(index);
-
- setValue(newEnum);
- }
-
- public void setValue(T selection)
- {
- if (this.currentSelection != selection)
- {
- this.currentSelection = selection;
- callEvent(new EventValueChanged(this, getValue()));
- }
- }
-
- private List<T> enumConstants = new ArrayList();
-
- public ControlEnumButton(IWidget parent, float x, float y, float width, float height, T[] values)
- {
- super(parent, x, y, width, height, "");
- for (T value : values) {
- this.enumConstants.add(value);
- }
- if (values.length > 0) {
- this.currentSelection = values[0];
- }
- }
-
- public T getValue()
- {
- return this.currentSelection;
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/button/ControlToggleButton.java b/src/Java/binnie/craftgui/controls/button/ControlToggleButton.java
deleted file mode 100644
index 1a06801fbd..0000000000
--- a/src/Java/binnie/craftgui/controls/button/ControlToggleButton.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package binnie.craftgui.controls.button;
-
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.events.EventMouse.Down;
-import binnie.craftgui.events.EventToggleButtonClicked;
-
-public class ControlToggleButton
- extends ControlButton
-{
- boolean toggled;
-
- public void onMouseClick(EventMouse.Down event)
- {
- callEvent(new EventToggleButtonClicked(this, this.toggled));
- }
-
- public ControlToggleButton(IWidget parent, int x, int y, int width, int height)
- {
- super(parent, x, y, width, height);
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/core/Control.java b/src/Java/binnie/craftgui/controls/core/Control.java
deleted file mode 100644
index f5f7bddabb..0000000000
--- a/src/Java/binnie/craftgui/controls/core/Control.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package binnie.craftgui.controls.core;
-
-import binnie.craftgui.core.Attribute;
-import binnie.craftgui.core.ITooltip;
-import binnie.craftgui.core.ITooltipHelp;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.Tooltip;
-import binnie.craftgui.core.Widget;
-import binnie.craftgui.core.geometry.IArea;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.minecraft.Window;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Control
- extends Widget
- implements ITooltipHelp, ITooltip
-{
- public Control(IWidget parent, float x, float y, float w, float h)
- {
- super(parent);
- setPosition(new IPoint(x, y));
- setSize(new IPoint(w, h));
- initialise();
- }
-
- public Control(IWidget parent, IArea area)
- {
- this(parent, area.x(), area.y(), area.w(), area.h());
- }
-
- List<String> helpStrings = new ArrayList();
- List<String> tooltipStrings = new ArrayList();
-
- protected void initialise() {}
-
- public void onUpdateClient() {}
-
- public void addHelp(String string)
- {
- this.helpStrings.add(string);
- }
-
- public void addHelp(String[] strings)
- {
- for (String string : strings) {
- addHelp(string);
- }
- }
-
- public void addTooltip(String string)
- {
- addAttribute(Attribute.MouseOver);
- this.tooltipStrings.add(string);
- }
-
- public void addTooltip(String[] strings)
- {
- for (String string : strings) {
- addTooltip(string);
- }
- }
-
- public int extraLevel = 0;
-
- public int getLevel()
- {
- return this.extraLevel + super.getLevel();
- }
-
- public void getHelpTooltip(Tooltip tooltip)
- {
- tooltip.add(this.helpStrings);
- }
-
- public void getTooltip(Tooltip tooltip)
- {
- tooltip.add(this.tooltipStrings);
- }
-
- public Window getWindow()
- {
- return (Window)getSuperParent();
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/core/IControlIndexed.java b/src/Java/binnie/craftgui/controls/core/IControlIndexed.java
deleted file mode 100644
index a30bceb76c..0000000000
--- a/src/Java/binnie/craftgui/controls/core/IControlIndexed.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package binnie.craftgui.controls.core;
-
-public abstract interface IControlIndexed
-{
- public abstract int getIndex();
-
- public abstract void setIndex(int paramInt);
-}
diff --git a/src/Java/binnie/craftgui/controls/core/IControlValue.java b/src/Java/binnie/craftgui/controls/core/IControlValue.java
deleted file mode 100644
index 9d44b8ad17..0000000000
--- a/src/Java/binnie/craftgui/controls/core/IControlValue.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package binnie.craftgui.controls.core;
-
-import binnie.craftgui.core.IWidget;
-
-public abstract interface IControlValue<T>
- extends IWidget
-{
- public abstract T getValue();
-
- public abstract void setValue(T paramT);
-}
diff --git a/src/Java/binnie/craftgui/controls/core/IControlValues.java b/src/Java/binnie/craftgui/controls/core/IControlValues.java
deleted file mode 100644
index 92bb5d1f13..0000000000
--- a/src/Java/binnie/craftgui/controls/core/IControlValues.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package binnie.craftgui.controls.core;
-
-import java.util.Collection;
-
-public abstract interface IControlValues<T>
- extends IControlValue<T>
-{
- public abstract Collection<T> getValues();
-
- public abstract void setValues(Collection<T> paramCollection);
-}
diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlList.java b/src/Java/binnie/craftgui/controls/listbox/ControlList.java
deleted file mode 100644
index d1b6be8821..0000000000
--- a/src/Java/binnie/craftgui/controls/listbox/ControlList.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package binnie.craftgui.controls.listbox;
-
-import binnie.core.util.IValidator;
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.controls.core.IControlValue;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.events.EventValueChanged;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-public class ControlList<T>
- extends Control
- implements IControlValue<T>
-{
- ControlListBox<T> parent;
-
- protected ControlList(ControlListBox<T> parent, float x, float y, float w, float h)
- {
- super(parent, x, y, w, h);
- this.parent = parent;
- }
-
- T value = null;
- Map<T, IWidget> allOptions = new LinkedHashMap();
- Map<T, IWidget> optionWidgets = new LinkedHashMap();
-
- public T getValue()
- {
- return this.value;
- }
-
- public void setValue(T value)
- {
- if (value == this.value) {
- return;
- }
- this.value = value;
- if ((value != null) && (this.optionWidgets.containsKey(value)))
- {
- IWidget child = (IWidget)this.optionWidgets.get(value);
- this.parent.ensureVisible(child.y(), child.y() + child.h(), h());
- }
- getParent().callEvent(new EventValueChanged(getParent(), value));
- }
-
- boolean creating = false;
- IValidator<IWidget> validator;
-
- public void setOptions(Collection<T> options)
- {
- deleteAllChildren();
- this.allOptions.clear();
- int i = 0;
- for (T option : options)
- {
- IWidget optionWidget = ((ControlListBox)getParent()).createOption(option, 0);
- if (optionWidget != null) {
- this.allOptions.put(option, optionWidget);
- }
- i++;
- }
- filterOptions();
- }
-
- public void filterOptions()
- {
- int height = 0;
- this.optionWidgets.clear();
- for (Map.Entry<T, IWidget> entry : this.allOptions.entrySet()) {
- if (isValidOption((IWidget)entry.getValue()))
- {
- ((IWidget)entry.getValue()).show();
- this.optionWidgets.put(entry.getKey(), entry.getValue());
- ((IWidget)entry.getValue()).setPosition(new IPoint(0.0F, height));
- height = (int)(height + ((IWidget)entry.getValue()).getSize().y());
- }
- else
- {
- ((IWidget)entry.getValue()).hide();
- }
- }
- this.creating = true;
- setValue(getValue());
- setSize(new IPoint(getSize().x(), height));
- }
-
- public Collection<T> getOptions()
- {
- return this.optionWidgets.keySet();
- }
-
- public Collection<T> getAllOptions()
- {
- return this.allOptions.keySet();
- }
-
- public int getIndexOf(T value)
- {
- int index = 0;
- for (T option : getOptions())
- {
- if (option.equals(value)) {
- return index;
- }
- index++;
- }
- return -1;
- }
-
- public int getCurrentIndex()
- {
- return getIndexOf(getValue());
- }
-
- public void setIndex(int currentIndex)
- {
- int index = 0;
- for (T option : getOptions())
- {
- if (index == currentIndex)
- {
- setValue(option);
- return;
- }
- index++;
- }
- setValue(null);
- }
-
- private boolean isValidOption(IWidget widget)
- {
- return this.validator == null ? true : this.validator.isValid(widget);
- }
-
- public void setValidator(IValidator<IWidget> validator)
- {
- if (this.validator != validator)
- {
- this.validator = validator;
- filterOptions();
- }
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java b/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java
deleted file mode 100644
index e9370daa3d..0000000000
--- a/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package binnie.craftgui.controls.listbox;
-
-import binnie.core.util.IValidator;
-import binnie.craftgui.controls.core.IControlValue;
-import binnie.craftgui.controls.scroll.ControlScrollableContent;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.events.EventKey.Down;
-import binnie.craftgui.events.EventKey.Down.Handler;
-import java.util.Collection;
-
-public class ControlListBox<T>
- extends ControlScrollableContent<ControlList<T>>
- implements IControlValue<T>
-{
- public ControlListBox(IWidget parent, float x, float y, float w, float h, float scrollBarSize)
- {
- super(parent, x, y, w, h, scrollBarSize);
- }
-
- public void initialise()
- {
- setScrollableContent(new ControlList(this, 1.0F, 1.0F, w() - 2.0F - this.scrollBarSize, h() - 2.0F));
-
- addEventHandler(new EventKey.Down.Handler()
- {
- public void onEvent(EventKey.Down event)
- {
- EventKey.Down eventKey = event;
- if (ControlListBox.this.calculateIsMouseOver())
- {
- int currentIndex = ((ControlList)ControlListBox.this.getContent()).getCurrentIndex();
- if (eventKey.getKey() == 208)
- {
- currentIndex++;
- if (currentIndex >= ((ControlList)ControlListBox.this.getContent()).getOptions().size()) {
- currentIndex = 0;
- }
- }
- else if (eventKey.getKey() == 200)
- {
- currentIndex--;
- if (currentIndex < 0) {
- currentIndex = ((ControlList)ControlListBox.this.getContent()).getOptions().size() - 1;
- }
- }
- ((ControlList)ControlListBox.this.getContent()).setIndex(currentIndex);
- }
- }
- });
- }
-
- public final T getValue()
- {
- return ((ControlList)getContent()).getValue();
- }
-
- public final void setValue(T value)
- {
- ((ControlList)getContent()).setValue(value);
- }
-
- public void setOptions(Collection<T> options)
- {
- ((ControlList)getContent()).setOptions(options);
- }
-
- public IWidget createOption(T value, int y)
- {
- return new ControlOption((ControlList)getContent(), value, y);
- }
-
- public void setValidator(IValidator<IWidget> validator)
- {
- ((ControlList)getContent()).setValidator(validator);
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlOption.java b/src/Java/binnie/craftgui/controls/listbox/ControlOption.java
deleted file mode 100644
index 7a643101cf..0000000000
--- a/src/Java/binnie/craftgui/controls/listbox/ControlOption.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package binnie.craftgui.controls.listbox;
-
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.controls.core.IControlValue;
-import binnie.craftgui.core.Attribute;
-import binnie.craftgui.core.CraftGUI;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.core.renderer.Renderer;
-import binnie.craftgui.events.EventMouse.Down;
-import binnie.craftgui.events.EventMouse.Down.Handler;
-import binnie.craftgui.resource.minecraft.CraftGUITexture;
-
-public class ControlOption<T>
- extends Control
- implements IControlValue<T>
-{
- T value;
-
- public void onUpdateClient()
- {
- if (getValue() == null) {
- return;
- }
- int colour = 10526880;
- if (isCurrentSelection()) {
- colour = 16777215;
- }
- setColour(colour);
- }
-
- public ControlOption(ControlList<T> controlList, T option)
- {
- this(controlList, option, 16);
- }
-
- public ControlOption(ControlList<T> controlList, T option, int height)
- {
- super(controlList, 0.0F, height, controlList.getSize().x(), 20.0F);
- this.value = option;
- if (this.value != null) {
- addAttribute(Attribute.MouseOver);
- }
- addSelfEventHandler(new EventMouse.Down.Handler()
- {
- public void onEvent(EventMouse.Down event)
- {
- ((IControlValue)ControlOption.this.getParent()).setValue(ControlOption.this.getValue());
- }
- });
- }
-
- public T getValue()
- {
- return this.value;
- }
-
- public void setValue(T value)
- {
- this.value = value;
- }
-
- public boolean isCurrentSelection()
- {
- return (getValue() != null) && (getValue().equals(((IControlValue)getParent()).getValue()));
- }
-
- public void onRenderForeground()
- {
- if (isCurrentSelection()) {
- CraftGUI.Render.texture(CraftGUITexture.Outline, getArea());
- }
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java b/src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java
deleted file mode 100644
index 6a47ec5d41..0000000000
--- a/src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package binnie.craftgui.controls.listbox;
-
-import binnie.craftgui.controls.ControlText;
-import binnie.craftgui.core.geometry.TextJustification;
-import binnie.craftgui.events.EventHandler.Origin;
-import binnie.craftgui.events.EventWidget.ChangeColour;
-import binnie.craftgui.events.EventWidget.ChangeColour.Handler;
-
-public class ControlTextOption<T>
- extends ControlOption<T>
-{
- public ControlTextOption(ControlList<T> controlList, T option, String optionName, int y)
- {
- super(controlList, option, y);
- this.textWidget = new ControlText(this, getArea(), optionName, TextJustification.MiddleCenter);
-
- addEventHandler(new EventWidget.ChangeColour.Handler()
- {
- public void onEvent(EventWidget.ChangeColour event)
- {
- ControlTextOption.this.textWidget.setColour(ControlTextOption.this.getColour());
- }
- }.setOrigin(EventHandler.Origin.Self, this));
- }
-
- public ControlTextOption(ControlList<T> controlList, T option, int y)
- {
- this(controlList, option, option.toString(), y);
- }
-
- protected ControlText textWidget = null;
-
- public String getText()
- {
- return this.textWidget.getValue();
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/page/ControlPage.java b/src/Java/binnie/craftgui/controls/page/ControlPage.java
deleted file mode 100644
index 0e5c89492e..0000000000
--- a/src/Java/binnie/craftgui/controls/page/ControlPage.java
+++ /dev/null
@@ -1,36 +0,0 @@
-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
deleted file mode 100644
index 43a205e874..0000000000
--- a/src/Java/binnie/craftgui/controls/page/ControlPages.java
+++ /dev/null
@@ -1,57 +0,0 @@
-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) {}
-}
diff --git a/src/Java/binnie/craftgui/controls/scroll/ControlScroll.java b/src/Java/binnie/craftgui/controls/scroll/ControlScroll.java
deleted file mode 100644
index 1d03f5fbc7..0000000000
--- a/src/Java/binnie/craftgui/controls/scroll/ControlScroll.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package binnie.craftgui.controls.scroll;
-
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.core.IWidget;
-
-public class ControlScroll
- extends Control
-{
- private IControlScrollable scrollWidget;
-
- public ControlScroll(IWidget parent, float x, float y, float width, float height, IControlScrollable scrollWidget)
- {
- super(parent, x, y, width, height);
- this.scrollWidget = scrollWidget;
- new ControlScrollBar(this);
- }
-
- public IControlScrollable getScrollableWidget()
- {
- return this.scrollWidget;
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/scroll/ControlScrollBar.java b/src/Java/binnie/craftgui/controls/scroll/ControlScrollBar.java
deleted file mode 100644
index a94705767d..0000000000
--- a/src/Java/binnie/craftgui/controls/scroll/ControlScrollBar.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package binnie.craftgui.controls.scroll;
-
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.core.Attribute;
-import binnie.craftgui.core.CraftGUI;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.geometry.IArea;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.core.renderer.Renderer;
-import binnie.craftgui.events.EventMouse.Down;
-import binnie.craftgui.events.EventMouse.Down.Handler;
-import binnie.craftgui.events.EventMouse.Drag;
-import binnie.craftgui.events.EventMouse.Drag.Handler;
-import binnie.craftgui.resource.minecraft.CraftGUITexture;
-
-public class ControlScrollBar
- extends Control
-{
- protected final IControlScrollable scrollable;
-
- public ControlScrollBar(ControlScroll parent)
- {
- this(parent, 0.0F, 0.0F, parent.getSize().x(), parent.getSize().y(), parent.getScrollableWidget());
- }
-
- public ControlScrollBar(IWidget parent, float x, float y, float w, float h, IControlScrollable scrollable2)
- {
- super(parent, x, y, w, h);
- this.scrollable = scrollable2;
- addAttribute(Attribute.MouseOver);
-
- addSelfEventHandler(new EventMouse.Drag.Handler()
- {
- public void onEvent(EventMouse.Drag event)
- {
- ControlScrollBar.this.scrollable.movePercentage(event.getDy() / (ControlScrollBar.this.h() - ControlScrollBar.this.getBarHeight()));
- }
- });
- addSelfEventHandler(new EventMouse.Down.Handler()
- {
- public void onEvent(EventMouse.Down event)
- {
- float shownPercentage = ControlScrollBar.this.scrollable.getPercentageShown();
- float percentageIndex = ControlScrollBar.this.scrollable.getPercentageIndex();
- float minPercent = (1.0F - shownPercentage) * percentageIndex;
- float maxPercent = minPercent + shownPercentage;
- float clickedPercentage = ControlScrollBar.this.getRelativeMousePosition().y() / (ControlScrollBar.this.h() - 2.0F);
- clickedPercentage = Math.max(Math.min(clickedPercentage, 1.0F), 0.0F);
- if (clickedPercentage > maxPercent) {
- ControlScrollBar.this.scrollable.setPercentageIndex((clickedPercentage - shownPercentage) / (1.0F - shownPercentage));
- }
- if (clickedPercentage < minPercent) {
- ControlScrollBar.this.scrollable.setPercentageIndex(clickedPercentage / (1.0F - shownPercentage));
- }
- }
- });
- }
-
- public void onUpdateClient() {}
-
- public boolean isEnabled()
- {
- return this.scrollable.getPercentageShown() < 0.99F;
- }
-
- public float getBarHeight()
- {
- return h() * this.scrollable.getPercentageShown();
- }
-
- protected IArea getRenderArea()
- {
- float height = getBarHeight();
- if (height < 6.0F) {
- height = 6.0F;
- }
- float yOffset = ((int)h() - (int)getBarHeight()) * this.scrollable.getPercentageIndex();
-
- return new IArea(0.0F, yOffset, getSize().x(), height);
- }
-
- public void onRenderBackground()
- {
- IArea renderArea = getRenderArea();
-
- Object texture = CraftGUITexture.ScrollDisabled;
- if (isMouseOver()) {
- texture = CraftGUITexture.ScrollHighlighted;
- } else if (isEnabled()) {
- texture = CraftGUITexture.Scroll;
- }
- CraftGUI.Render.texture(texture, renderArea);
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/scroll/ControlScrollableContent.java b/src/Java/binnie/craftgui/controls/scroll/ControlScrollableContent.java
deleted file mode 100644
index 442c9d3226..0000000000
--- a/src/Java/binnie/craftgui/controls/scroll/ControlScrollableContent.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package binnie.craftgui.controls.scroll;
-
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.geometry.IArea;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.events.EventMouse.Wheel;
-import binnie.craftgui.events.EventMouse.Wheel.Handler;
-import binnie.craftgui.events.EventWidget.ChangeSize;
-import binnie.craftgui.events.EventWidget.ChangeSize.Handler;
-
-public class ControlScrollableContent<T extends IWidget>
- extends Control
- implements IControlScrollable
-{
- protected T controlChild;
- protected float scrollBarSize;
-
- public ControlScrollableContent(IWidget parent, float x, float y, float w, float h, float scrollBarSize)
- {
- super(parent, x, y, w, h);
- if (scrollBarSize != 0.0F) {
- new ControlScroll(this, getSize().x() - scrollBarSize, 0.0F, scrollBarSize, getSize().y(), this);
- }
- addEventHandler(new EventMouse.Wheel.Handler()
- {
- public void onEvent(EventMouse.Wheel event)
- {
- if ((ControlScrollableContent.this.getRelativeMousePosition().x() > 0.0F) && (ControlScrollableContent.this.getRelativeMousePosition().y() > 0.0F) && (ControlScrollableContent.this.getRelativeMousePosition().x() < ControlScrollableContent.this.getSize().x()) && (ControlScrollableContent.this.getRelativeMousePosition().y() < ControlScrollableContent.this.getSize().y()))
- {
- if (ControlScrollableContent.this.getMovementRange() == 0.0F) {
- return;
- }
- float percentageMove = 0.8F / ControlScrollableContent.this.getMovementRange();
- ControlScrollableContent.this.movePercentage(percentageMove * -event.getDWheel());
- }
- }
- });
- this.scrollBarSize = scrollBarSize;
- }
-
- public void setScrollableContent(T child)
- {
- this.controlChild = child;
- if (child == null) {
- return;
- }
- child.setCroppedZone(this, new IArea(1.0F, 1.0F, getSize().x() - 2.0F - this.scrollBarSize, getSize().y() - 2.0F));
- child.addSelfEventHandler(new EventWidget.ChangeSize.Handler()
- {
- public void onEvent(EventWidget.ChangeSize event)
- {
- ControlScrollableContent.this.controlChild.setOffset(new IPoint(0.0F, -ControlScrollableContent.this.percentageIndex * ControlScrollableContent.this.getMovementRange()));
- if (ControlScrollableContent.this.getMovementRange() == 0.0F) {
- ControlScrollableContent.this.percentageIndex = 0.0F;
- }
- }
- });
- }
-
- public T getContent()
- {
- return this.controlChild;
- }
-
- public float getPercentageShown()
- {
- if ((this.controlChild == null) || (this.controlChild.getSize().y() == 0.0F)) {
- return 1.0F;
- }
- float shown = getSize().y() / this.controlChild.getSize().y();
- return Math.min(shown, 1.0F);
- }
-
- float percentageIndex = 0.0F;
-
- public float getPercentageIndex()
- {
- return this.percentageIndex;
- }
-
- public void movePercentage(float percentage)
- {
- if (this.controlChild == null) {
- return;
- }
- this.percentageIndex += percentage;
- if (this.percentageIndex > 1.0F) {
- this.percentageIndex = 1.0F;
- } else if (this.percentageIndex < 0.0F) {
- this.percentageIndex = 0.0F;
- }
- if (getMovementRange() == 0.0F) {
- this.percentageIndex = 0.0F;
- }
- this.controlChild.setOffset(new IPoint(0.0F, -this.percentageIndex * getMovementRange()));
- }
-
- public void setPercentageIndex(float index)
- {
- movePercentage(index - this.percentageIndex);
- }
-
- public float getMovementRange()
- {
- if (this.controlChild == null) {
- return 0.0F;
- }
- float range = this.controlChild.getSize().y() - getSize().y();
- return Math.max(range, 0.0F);
- }
-
- public void onUpdateClient()
- {
- setPercentageIndex(getPercentageIndex());
- }
-
- public void ensureVisible(float minY, float maxY, float totalY)
- {
- minY /= totalY;
- maxY /= totalY;
-
- float shownPercentage = getPercentageShown();
- float percentageIndex = getPercentageIndex();
- float minPercent = (1.0F - shownPercentage) * percentageIndex;
- float maxPercent = minPercent + shownPercentage;
- if (maxY > maxPercent) {
- setPercentageIndex((maxY - shownPercentage) / (1.0F - shownPercentage));
- }
- if (minY < minPercent) {
- setPercentageIndex(minY / (1.0F - shownPercentage));
- }
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/scroll/IControlScrollable.java b/src/Java/binnie/craftgui/controls/scroll/IControlScrollable.java
deleted file mode 100644
index 39154815e5..0000000000
--- a/src/Java/binnie/craftgui/controls/scroll/IControlScrollable.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package binnie.craftgui.controls.scroll;
-
-import binnie.craftgui.core.IWidget;
-
-public abstract interface IControlScrollable
- extends IWidget
-{
- public abstract float getPercentageShown();
-
- public abstract float getPercentageIndex();
-
- public abstract void movePercentage(float paramFloat);
-
- public abstract void setPercentageIndex(float paramFloat);
-
- public abstract float getMovementRange();
-}
diff --git a/src/Java/binnie/craftgui/controls/tab/ControlTab.java b/src/Java/binnie/craftgui/controls/tab/ControlTab.java
deleted file mode 100644
index e05b7ed01a..0000000000
--- a/src/Java/binnie/craftgui/controls/tab/ControlTab.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package binnie.craftgui.controls.tab;
-
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.controls.core.IControlValue;
-import binnie.craftgui.core.Attribute;
-import binnie.craftgui.core.CraftGUI;
-import binnie.craftgui.core.ITooltip;
-import binnie.craftgui.core.Tooltip;
-import binnie.craftgui.core.geometry.IArea;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.core.geometry.Position;
-import binnie.craftgui.core.renderer.Renderer;
-import binnie.craftgui.events.EventMouse.Down;
-import binnie.craftgui.events.EventMouse.Down.Handler;
-import binnie.craftgui.events.EventValueChanged;
-import binnie.craftgui.minecraft.control.ControlItemDisplay;
-import binnie.craftgui.minecraft.control.ControlTabIcon;
-import binnie.craftgui.resource.Texture;
-import binnie.craftgui.resource.minecraft.CraftGUITexture;
-import java.util.List;
-
-public class ControlTab<T>
- extends Control
- implements ITooltip, IControlValue<T>
-{
- private ControlTabBar<T> tabBar;
- protected T value;
-
- public ControlTab(ControlTabBar<T> parent, float x, float y, float w, float h, T value)
- {
- super(parent, x, y, w, h);
- setValue(value);
- this.tabBar = parent;
- addAttribute(Attribute.MouseOver);
-
- addSelfEventHandler(new EventMouse.Down.Handler()
- {
- public void onEvent(EventMouse.Down event)
- {
- ControlTab.this.callEvent(new EventValueChanged(ControlTab.this.getWidget(), ControlTab.this.getValue()));
- }
- });
- }
-
- public void getTooltip(Tooltip tooltip)
- {
- String name = getName();
- if ((name != null) && (!name.isEmpty())) {
- tooltip.add(getName());
- }
- if ((this.value instanceof ITooltip)) {
- ((ITooltip)this.value).getTooltip(tooltip);
- }
- }
-
- public T getValue()
- {
- return this.value;
- }
-
- public void setValue(T value)
- {
- this.value = value;
- }
-
- public boolean isCurrentSelection()
- {
- return (getValue() != null) && (getValue().equals(this.tabBar.getValue()));
- }
-
- public Position getTabPosition()
- {
- return this.tabBar.position;
- }
-
- public String getName()
- {
- return this.value.toString();
- }
-
- public void onRenderBackground()
- {
- Object texture = CraftGUITexture.TabDisabled;
- if (isMouseOver()) {
- texture = CraftGUITexture.TabHighlighted;
- } else if (isCurrentSelection()) {
- texture = CraftGUITexture.Tab;
- }
- Texture lTexture = CraftGUI.Render.getTexture(texture);
- Position position = getTabPosition();
-
- Texture iTexture = lTexture.crop(position, 8.0F);
-
-
- IArea area = getArea();
- if (texture == CraftGUITexture.TabDisabled) {
- if ((position == Position.Top) || (position == Position.Left))
- {
- area.setPosition(area.getPosition().sub(new IPoint(4 * position.x(), 4 * position.y())));
- area.setSize(area.getSize().add(new IPoint(4 * position.x(), 4 * position.y())));
- }
- else
- {
- area.setSize(area.getSize().sub(new IPoint(4 * position.x(), 4 * position.y())));
- }
- }
- CraftGUI.Render.texture(iTexture, area);
- if ((this instanceof ControlTabIcon))
- {
- ControlTabIcon icon = (ControlTabIcon)this;
- ControlItemDisplay item = (ControlItemDisplay)getWidgets().get(0);
- if (texture == CraftGUITexture.TabDisabled) {
- item.setColour(-1431655766);
- } else {
- item.setColour(-1);
- }
- if (icon.hasOutline())
- {
- iTexture = CraftGUI.Render.getTexture(CraftGUITexture.TabOutline);
- iTexture = iTexture.crop(position, 8.0F);
-
- CraftGUI.Render.colour(icon.getOutlineColour());
-
- CraftGUI.Render.texture(iTexture, area.inset(2));
- }
- }
- }
-}
diff --git a/src/Java/binnie/craftgui/controls/tab/ControlTabBar.java b/src/Java/binnie/craftgui/controls/tab/ControlTabBar.java
deleted file mode 100644
index d209887994..0000000000
--- a/src/Java/binnie/craftgui/controls/tab/ControlTabBar.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package binnie.craftgui.controls.tab;
-
-import binnie.craftgui.controls.core.Control;
-import binnie.craftgui.controls.core.IControlValue;
-import binnie.craftgui.core.IWidget;
-import binnie.craftgui.core.geometry.IPoint;
-import binnie.craftgui.core.geometry.Position;
-import binnie.craftgui.events.EventHandler.Origin;
-import binnie.craftgui.events.EventValueChanged;
-import binnie.craftgui.events.EventValueChanged.Handler;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-public class ControlTabBar<T>
- extends Control
- implements IControlValue<T>
-{
- T value;
- Position position;
-
- public ControlTabBar(IWidget parent, float x, float y, float width, float height, Position position)
- {
- super(parent, x, y, width, height);
- this.position = position;
-
- addEventHandler(new EventValueChanged.Handler()
- {
- public void onEvent(EventValueChanged event)
- {
- ControlTabBar.this.setValue(event.getValue());
- }
- }.setOrigin(EventHandler.Origin.DirectChild, this));
- }
-
- public void setValues(Collection<T> values)
- {
- for (int i = 0; i < getWidgets().size();) {
- deleteChild((IWidget)getWidgets().get(0));
- }
- float length = values.size();
- int tabDimension = (int)(getSize().y() / length);
- if ((this.position == Position.Top) || (this.position == Position.Bottom)) {
- tabDimension = (int)(getSize().x() / length);
- }
- int i = 0;
- for (T value : values)
- {
- IWidget tab;
- IWidget tab;
- if ((this.position == Position.Top) || (this.position == Position.Bottom)) {
- tab = createTab(i * tabDimension, 0.0F, tabDimension, getSize().y(), value);
- } else {
- tab = createTab(0.0F, i * tabDimension, getSize().x(), tabDimension, value);
- }
- i++;
- }
- if ((this.value == null) && (!values.isEmpty())) {
- setValue(values.iterator().next());
- }
- }
-
- public ControlTab<T> createTab(float x, float y, float w, float h, T value)
- {
- return new ControlTab(this, x, y, w, h, value);
- }
-
- public T getValue()
- {
- return this.value;
- }
-
- public void setValue(T value)
- {
- boolean change = this.value != value;
- this.value = value;
- if (change) {
- callEvent(new EventValueChanged(this, value));
- }
- }
-
- public Position getDirection()
- {
- return this.position;
- }
-}