X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fcomponents%2FSimpleRectangularSubmodelComponent.java;h=ec233625ffeb4ab566bf3e074fd0538e971e9988;hb=67c7e16eac6ef555f7ebe0cbe6048598d7f1187e;hp=7a7bb9d52b569bd810a1d96d71d0d532abfed8ee;hpb=c223a9de7b0ef783bcb4f7612da350583ca29abd;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SimpleRectangularSubmodelComponent.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SimpleRectangularSubmodelComponent.java index 7a7bb9d5..ec233625 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SimpleRectangularSubmodelComponent.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SimpleRectangularSubmodelComponent.java @@ -8,12 +8,16 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.eclipse.swt.graphics.Color; + import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Font; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.ui.model.ViewModelModifiable; +import net.mograsim.logic.ui.model.wires.MovablePin; import net.mograsim.logic.ui.model.wires.Pin; +import net.mograsim.preferences.Preferences; public class SimpleRectangularSubmodelComponent extends SubmodelComponent { @@ -69,7 +73,7 @@ public class SimpleRectangularSubmodelComponent extends SubmodelComponent String pinName = newPinNames[i]; int oldPinIndex = pinNamesListThisSide.indexOf(pinName); if (oldPinIndex == -1) - super.addSubmodelInterface(pinName, logicWidth, relX, pinDistance / 2 + i * pinDistance); + super.addSubmodelInterface(new MovablePin(this, pinName, logicWidth, relX, pinDistance / 2 + i * pinDistance)); else getSupermodelMovablePin(pinName).setRelPos(relX, pinDistance / 2 + i * pinDistance); } @@ -96,6 +100,9 @@ public class SimpleRectangularSubmodelComponent extends SubmodelComponent Font oldFont = gc.getFont(); gc.setFont(new Font(oldFont.getName(), labelFontHeight, oldFont.getStyle())); Point textExtent = gc.textExtent(label); + Color textColor = Preferences.current().getColor("net.mograsim.logic.ui.color.text"); + if (textColor != null) + gc.setForeground(textColor); gc.drawText(label, getPosX() + (getWidth() - textExtent.x) / 2, getPosY() + (getHeight() - textExtent.y) / 2, true); gc.setFont(new Font(oldFont.getName(), pinNameFontHeight, oldFont.getStyle())); for (int i = 0; i < inputPinNames.size(); i++) @@ -108,8 +115,8 @@ public class SimpleRectangularSubmodelComponent extends SubmodelComponent { String pinName = outputPinNames.get(i); textExtent = gc.textExtent(pinName); - gc.drawText(pinName, getPosX() + width - textExtent.x - pinNameMargin, getPosY() + i * pinDistance + (pinDistance - textExtent.y) / 2, - true); + gc.drawText(pinName, getPosX() + width - textExtent.x - pinNameMargin, + getPosY() + i * pinDistance + (pinDistance - textExtent.y) / 2, true); } gc.setFont(oldFont); } @@ -117,6 +124,9 @@ public class SimpleRectangularSubmodelComponent extends SubmodelComponent @Override protected void renderOutline(GeneralGC gc, Rectangle visibleRegion) { + Color foreground = Preferences.current().getColor("net.mograsim.logic.ui.color.foreground"); + if (foreground != null) + gc.setForeground(foreground); gc.drawRectangle(getBounds()); } @@ -127,15 +137,15 @@ public class SimpleRectangularSubmodelComponent extends SubmodelComponent ret.type = SimpleRectangularSubmodelComponent.class.getSimpleName(); Map m = new TreeMap<>(); m.put(kLabel, label); - m.put(kInCount, inputPinNames.size()); - m.put(kOutCount, outputPinNames.size()); + m.put(kInCount, inputPinNames.toArray()); + m.put(kOutCount, outputPinNames.toArray()); m.put(kLogicWidth, logicWidth); ret.specialized = m; return ret; } @Override - protected Pin addSubmodelInterface(String name, int logicWidth, double relX, double relY) + protected Pin addSubmodelInterface(MovablePin supermodelPin) { throw new UnsupportedOperationException( "Can't add submodel interfaces to a SimpleRectangularSubmodelComponent directly, call setInputPins / setOutputPins instead");