/
IWidget.java
193 lines (126 loc) · 3.12 KB
/
IWidget.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
package binnie.core.gui;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import binnie.core.gui.events.Event;
import binnie.core.gui.events.EventHandler;
import binnie.core.gui.geometry.Area;
import binnie.core.gui.geometry.Point;
public interface IWidget {
/**
*
* @return the parent of this widget
*/
@Nullable
IWidget getParent();
ITopLevelWidget getTopParent();
/**
* @return true if this widget is the {@link #getTopParent()}
*/
boolean isTopLevel();
/**
* @return the position of this widget
*/
Point getPosition();
Point getOriginalPosition();
Point getAbsolutePosition();
Point getOriginalAbsolutePosition();
void setPosition(Point position);
/**
* @return the size of this widget
*/
Point getSize();
void setSize(Point size);
/**
* @return the offset of this widget
*/
Point getOffset();
void setOffset(final Point p0);
/**
* @return the area of this widget
*/
Area getArea();
/**
* @return the position of the mouse
*/
Point getMousePosition();
Point getRelativeMousePosition();
int getXPos();
int getYPos();
int getWidth();
int getHeight();
int getColor();
void setColor(int color);
@SideOnly(Side.CLIENT)
void render(int guiWidth, int guiHeight);
@SideOnly(Side.CLIENT)
void updateClient();
void enable();
void disable();
void show();
void hide();
boolean calculateIsMouseOver();
boolean isEnabled();
boolean isVisible();
boolean isFocused();
boolean isMouseOver();
boolean isDragged();
boolean canMouseOver();
boolean canFocus();
/* CHILDREN */
boolean isChildVisible(IWidget child);
boolean isChildEnabled(IWidget child);
IWidget addChild(IWidget child);
List<IWidget> getChildren();
void deleteChild(IWidget child);
void deleteAllChildren();
/* EVENTS*/
/**
* Calls an event
*/
void callEvent(Event event);
/**
* Called if this widget receives an event
*/
void receiveEvent(Event event);
/**
* Adds an event handler to this widget
*/
<E extends Event> void addEventHandler(EventHandler<E> eventHandler);
/**
* Adds an event handler to this widget and sets his origin to self
*/
<E extends Event> void addSelfEventHandler(EventHandler<E> eventHandler);
@SideOnly(Side.CLIENT)
void onUpdateClient();
void delete();
void onDelete();
@Nullable
<T> T getWidget(final Class<T> widgetClass);
@Nullable
Area getCroppedZone();
void setCroppedZone(final IWidget p0, final Area p1);
boolean isCroppedWidet();
IWidget getCropWidget();
boolean isMouseOverWidget(final Point p0);
int getLevel();
boolean isDescendant(final IWidget p0);
/* ATTRIBUTES */
/**
* @return a list with all attributes that this widget has.
*/
List<IWidgetAttribute> getAttributes();
/**
*
* @return true if this widget has this attribute
*/
boolean hasAttribute(IWidgetAttribute attribute);
/**
* Adds an attribute to this widget
*/
boolean addAttribute(IWidgetAttribute attribute);
boolean contains(Point point);
@SideOnly(Side.CLIENT)
void onRender(RenderStage stage, int guiWidth, int guiHeight);
}