diff options
Diffstat (limited to 'src/Java/binnie/craftgui/controls')
25 files changed, 1483 insertions, 0 deletions
diff --git a/src/Java/binnie/craftgui/controls/ControlCheckbox.java b/src/Java/binnie/craftgui/controls/ControlCheckbox.java new file mode 100644 index 0000000000..edfeab631c --- /dev/null +++ b/src/Java/binnie/craftgui/controls/ControlCheckbox.java @@ -0,0 +1,75 @@ +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 new file mode 100644 index 0000000000..4df9c04db1 --- /dev/null +++ b/src/Java/binnie/craftgui/controls/ControlText.java @@ -0,0 +1,50 @@ +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 new file mode 100644 index 0000000000..12434528db --- /dev/null +++ b/src/Java/binnie/craftgui/controls/ControlTextCentered.java @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000000..8c07a12d7c --- /dev/null +++ b/src/Java/binnie/craftgui/controls/ControlTextEdit.java @@ -0,0 +1,154 @@ +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 new file mode 100644 index 0000000000..4648f49290 --- /dev/null +++ b/src/Java/binnie/craftgui/controls/IControlSelection.java @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000000..9074a55541 --- /dev/null +++ b/src/Java/binnie/craftgui/controls/IControlSelectionOption.java @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000000..b41cb65116 --- /dev/null +++ b/src/Java/binnie/craftgui/controls/button/ControlButton.java @@ -0,0 +1,70 @@ +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 new file mode 100644 index 0000000000..924bd8c110 --- /dev/null +++ b/src/Java/binnie/craftgui/controls/button/ControlEnumButton.java @@ -0,0 +1,61 @@ +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 new file mode 100644 index 0000000000..1a06801fbd --- /dev/null +++ b/src/Java/binnie/craftgui/controls/button/ControlToggleButton.java @@ -0,0 +1,21 @@ +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 new file mode 100644 index 0000000000..f5f7bddabb --- /dev/null +++ b/src/Java/binnie/craftgui/controls/core/Control.java @@ -0,0 +1,85 @@ +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 new file mode 100644 index 0000000000..a30bceb76c --- /dev/null +++ b/src/Java/binnie/craftgui/controls/core/IControlIndexed.java @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000000..9d44b8ad17 --- /dev/null +++ b/src/Java/binnie/craftgui/controls/core/IControlValue.java @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000000..92bb5d1f13 --- /dev/null +++ b/src/Java/binnie/craftgui/controls/core/IControlValues.java @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000000..d1b6be8821 --- /dev/null +++ b/src/Java/binnie/craftgui/controls/listbox/ControlList.java @@ -0,0 +1,146 @@ +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 new file mode 100644 index 0000000000..e9370daa3d --- /dev/null +++ b/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java @@ -0,0 +1,76 @@ +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 new file mode 100644 index 0000000000..7a643101cf --- /dev/null +++ b/src/Java/binnie/craftgui/controls/listbox/ControlOption.java @@ -0,0 +1,73 @@ +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 onUpdateClie |
