2d27685bb3b17f1899e8f18f83f6161a07479f54
[Mograsim.git] / LogicUI / src / era / mi / gui / components / BasicGUIComponent.java
1 package era.mi.gui.components;
2
3 import era.mi.logic.wires.Wire.ReadEnd;
4 import net.haspamelodica.swt.helper.gcs.GeneralGC;
5 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
6 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
7
8 public interface BasicGUIComponent
9 {
10         /**
11          * Render this component to the given gc, at coordinates (0, 0).
12          */
13         public void render(GeneralGC gc);
14
15         /**
16          * Returns the bounds of this component. Used for calculating which component is clicked.
17          */
18         public Rectangle getBounds();
19
20         /**
21          * Called when this component is clicked. Relative coordinates of the click are given. Returns true if this component has to be redrawn.
22          */
23         public default boolean clicked(double x, double y)
24         {
25                 return false;
26         }
27
28         // TODO this code will be replaced by code in BasicComponent.
29         /**
30          * Returns how many wire arrays are connected to this component. (Connections are static - they can't be removed and no new ones can be
31          * added)
32          */
33         public int getConnectedWireEndsCount();
34
35         /**
36          * Returns the n-th wire array connected to this component.
37          */
38         public ReadEnd getConnectedWireEnd(int connectionIndex);
39
40         /**
41          * Returns relative coordinates where the n-th wire array is connected to this component.
42          */
43         public Point getWireEndConnectionPoint(int connectionIndex);
44 }