You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>WireIt uses a convention to simplify extending widgets:<br/>
441
+
<bstyle="font-size: 120%;">wires, terminals and containers are instantiated from the class specified by the <i>xtype</i> property</b>.</p>
442
+
443
+
<p>It lets you create specialized widgets by creating a subclass and using it simply from your language definition.</p>
444
+
445
+
<pclass="advanced">This choice was made to transport the definition using JSON.</p>
446
+
447
+
<aname="customizingWiresAndTerminals"><h2>3.2 Customizing Wires and Terminals</h2></a>
448
+
449
+
<p>Many options are available to customize Wires and Terminals, but the general pattern is simple: you create a subclass of the Wire named <i>WeirdWire</i>, you use it using the xtype property :</p>
<p>The code above overrides the default Wire configuration for <b>all</b> terminals on the page.</p>
456
+
457
+
<p>If you want to use this configuration only on specified wires, you can make it default for "some" terminals. You need to subclass the terminal to set your new config as default. An exemple is actually included in the library.</p>
458
+
459
+
<p>For a concrete example, let's see how the TerminalOutput works :</p>
<p>Simple enough. What this says is: Create a TerminalOutput class which extends the Terminal widget, set the direction from top to bottom, and connect only to "input" terminals. The <i>alwaysSrc</i> option force this terminal as being the "source" terminal in the wire definition.</p>
477
+
478
+
479
+
<p><b>How do we handle the wire creation ? What are the options ?</b></p>
480
+
481
+
<p>The idea is to create a Drag'n Drop proxy element (we do not move the original Terminal, but a copy of it).</p>
482
+
483
+
<p>When we start dragging the proxy element, a <i>fake</i> terminal is created within, which we can move around. A wire is added between those two terminals.</p>
484
+
485
+
<p>You can change the default wiring config using the <i>editingWireConfig</i> property :</p>
<pclass="advanced">For a complete list of the properties, please refer to the API documentation for <ahref="api/WireIt.Terminal.html">Terminal</a>, <ahref="api/WireIt.Wire.html">Wire</a> or <ahref="api/WireIt.Container.html">Container</a>.</p>
503
+
504
+
505
+
<aname="visualLanguageDefinition"><h2>3.3 Visual Language Definition</h2></a>
506
+
507
+
<p>Your visual language is defined by a JSON object :</p>
508
+
509
+
<preclass="brush:js">
510
+
var myLanguageDef = {
511
+
512
+
// Set a unique name for your language
443
513
languageName: "myLanguage",
444
514
515
+
516
+
// modules: list of module type definitions
445
517
modules: [
446
-
// List of module type definitions ...
518
+
{
519
+
name: "module1",
520
+
container: {"xtype":"WireIt.InOutContainer", ...}
521
+
},
522
+
...
447
523
]
448
524
};
449
525
</pre>
@@ -453,15 +529,15 @@ <h3>1.4.3 Other plugins</h3>
453
529
<preclass="brush:js">
454
530
YAHOO.util.Event.onDOMReady( function() {
455
531
try {
456
-
logicGates = new WireIt.WiringEditor(myLanguage);
532
+
logicGates = new WireIt.WiringEditor(myLanguageDef);
<p>Here is the skeleton of a module definition :</p>
467
543
@@ -490,7 +566,7 @@ <h3>1.4.3 Other plugins</h3>
490
566
<p>Of course, you can use containers provided in WireIt (ImageContainer, FormContainer, InOutContainer), or a <ahref="#containers">custom container</a>.</p>
491
567
492
568
493
-
<aname="BaseContainer"><h2>3.3 Using the basic Container</h2></a>
569
+
<aname="BaseContainer"><h2>3.5 Using the basic Container</h2></a>
494
570
495
571
496
572
<p>Set "xtype": "WireIt.Container" (optional). The parameters are :</p>
@@ -519,7 +595,7 @@ <h3>1.4.3 Other plugins</h3>
519
595
<pclass="advanced">All other Container classes inherits from this base class, and therefore share the above options.</p>
520
596
521
597
522
-
<aname="InOutContainer"><h2>3.4 Using InOutContainer</h2></a>
598
+
<aname="InOutContainer"><h2>3.6 Using InOutContainer</h2></a>
523
599
524
600
<p>Set "xtype": "WireIt.InOutContainer". Additional parameters are :</p>
525
601
@@ -542,7 +618,7 @@ <h3>1.4.3 Other plugins</h3>
542
618
</pre>
543
619
544
620
545
-
<aname="FormContainer"><h2>3.5 Using FormContainer</h2></a>
621
+
<aname="FormContainer"><h2>3.7 Using FormContainer</h2></a>
546
622
547
623
<p>Set "xtype": "WireIt.FormContainer". Additional parameters are all those used in inputEx.Group. (see <ahref="http://neyric.github.com/inputex/">inputEx</a>)</p>
548
624
@@ -571,7 +647,7 @@ <h3>1.4.3 Other plugins</h3>
571
647
</pre>
572
648
573
649
574
-
<aname="ImageContainer"><h2>3.6 Using ImageContainer</h2></a>
650
+
<aname="ImageContainer"><h2>3.8 Using ImageContainer</h2></a>
575
651
576
652
<p>Set "xtype": "WireIt.ImageContainer". Additional parameters are :</p>
577
653
@@ -598,7 +674,7 @@ <h3>1.4.3 Other plugins</h3>
598
674
599
675
600
676
601
-
<aname="propertiesForm"><h2>3.7 Edit the "Properties" form</h2></a>
677
+
<aname="propertiesForm"><h2>3.9 Edit the "Properties" form</h2></a>
602
678
603
679
<p>To add properties to the <i>Wirings</i>, we configure the <i>propertiesFields</i> property of the language definition.<br/>
604
680
This property defines the fields as they will appear in the "Properties" form on the right in the WiringEditor.</p>
Copy file name to clipboardExpand all lines: js/Terminal.js
+2-4Lines changed: 2 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -238,7 +238,8 @@ WireIt.Terminal.prototype = {
238
238
},
239
239
240
240
/**
241
-
* TODO
241
+
* Set the position of the terminal with the given pos
242
+
* @param {Object | Array} pos The position. It can be used in two ways: setPosition({left: 10, top: 10}) or setPosition([10, 10]) or setPosition({bottom: 10, right: 10})
0 commit comments