Components now can be clicked
[Mograsim.git] / LogicUI / src / era / mi / components / gui / BasicGUIComponent.java
1 package era.mi.components.gui;
2
3 import era.mi.logic.wires.WireArray;
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          * Returns the bounds of this component.
16          * Used for calculating which component is clicked.
17          */
18         public Rectangle getBounds();
19         /**
20          * Called when this component is clicked. Relative coordinates of the click are given.
21          */
22         public default boolean clicked(double x, double y)
23         {
24                 return false;
25         }
26
27         //TODO this code will be replaced by code in BasicComponent.
28         /**
29          * Returns how many wire arrays are connected to this component.
30          * (Connections are static - they can't be removed and no new ones can be added)
31          */
32         public int getConnectedWireArraysCount();
33         /**
34          * Returns the n-th wire array connected to this component.
35          */
36         public WireArray getConnectedWireArray(int connectionIndex);
37         /**
38          * Returns relative coordinates where the n-th wire array is connected to this component.
39          */
40         public Point getWireArrayConnectionPoint(int connectionIndex);
41 }