svghmi/widget_customhtml.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Fri, 10 Sep 2021 14:44:20 +0200
branchwxPython4
changeset 3312 2c0511479b18
parent 3241 fe945f1f48b7
permissions -rw-r--r--
IDE/windows: Avoid exception on quit caused by runtime being killed without disconnecting.
3064
4b44d09c48a7 - New widget customHtml which allows to insert block of html code
usveticic
parents: 3062
diff changeset
     1
// widget_customhtml.ysl2
2944
2a20038fbea9 Added button and circular bar widgets.
dgaberscek
parents:
diff changeset
     2
3241
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     3
widget_desc("CustomHtml") {
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     4
    longdesc
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     5
    ||
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     6
    CustomHtml widget allows insertion of HTML code in a svg:foreignObject.
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     7
    Widget content is replaced by foreignObject. HTML code is obtained from
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     8
    "code" labeled text content. HTML insert position and size is given with
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     9
    "container" labeled element.
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    10
    ||
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    11
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    12
    shortdesc > Custom HTML insert
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    13
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    14
    // TODO: support reload and POST based on variable content
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    15
}
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    16
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3064
diff changeset
    17
widget_class("CustomHtml"){
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
    18
    ||
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
    19
        frequency = 5;
3064
4b44d09c48a7 - New widget customHtml which allows to insert block of html code
usveticic
parents: 3062
diff changeset
    20
        widget_size = undefined;
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
    21
3056
827bf284feec Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents: 3024
diff changeset
    22
        dispatch(value) {
3059
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3058
diff changeset
    23
            this.request_animate();
3056
827bf284feec Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents: 3024
diff changeset
    24
        }
827bf284feec Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents: 3024
diff changeset
    25
3059
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3058
diff changeset
    26
        animate(){
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3058
diff changeset
    27
        }
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
    28
3059
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3058
diff changeset
    29
        init() {
3064
4b44d09c48a7 - New widget customHtml which allows to insert block of html code
usveticic
parents: 3062
diff changeset
    30
            this.widget_size = this.container_elt.getBBox();
4b44d09c48a7 - New widget customHtml which allows to insert block of html code
usveticic
parents: 3062
diff changeset
    31
            this.element.innerHTML ='<foreignObject x="'+
4b44d09c48a7 - New widget customHtml which allows to insert block of html code
usveticic
parents: 3062
diff changeset
    32
                this.widget_size.x+'" y="'+this.widget_size.y+
4b44d09c48a7 - New widget customHtml which allows to insert block of html code
usveticic
parents: 3062
diff changeset
    33
                '" width="'+this.widget_size.width+'" height="'+this.widget_size.height+'"> '+
4b44d09c48a7 - New widget customHtml which allows to insert block of html code
usveticic
parents: 3062
diff changeset
    34
                this.code_elt.textContent+
4b44d09c48a7 - New widget customHtml which allows to insert block of html code
usveticic
parents: 3062
diff changeset
    35
                ' </foreignObject>';
3059
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3058
diff changeset
    36
        }
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
    37
    ||
3024
Edouard Tisserant
parents: 3018
diff changeset
    38
}
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
    39
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
    40
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3064
diff changeset
    41
widget_defs("CustomHtml") {
3064
4b44d09c48a7 - New widget customHtml which allows to insert block of html code
usveticic
parents: 3062
diff changeset
    42
    labels("container code");
3000
a9a45977bac0 SVGHMI: prefer apply_hmi_value() to change_hmi_value() when possible
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2976
diff changeset
    43
}