svghmi/widget_multistate.ysl2
branchsvghmi
changeset 3241 fe945f1f48b7
parent 3232 7bdb766c2a4d
child 3577 6c7a7b22bec9
equal deleted inserted replaced
3238:8a9d4c794cba 3241:fe945f1f48b7
     1 // widget_multistate.ysl2
     1 // widget_multistate.ysl2
       
     2 
       
     3 widget_defs("MultiState") {
       
     4 
       
     5     longdesc
       
     6     ||
       
     7     Mutlistateh widget hides all subelements whose label do not match given
       
     8     variable value representation. For exemple if given variable type
       
     9     is HMI_INT and value is 1, then elements with label '1' will be displayed.
       
    10     Label can have comments, so '1#some comment' would also match. If matching
       
    11     variable of type HMI_STRING, then double quotes must be used. For exemple,
       
    12     '"hello"' or '"hello"#another comment' match HMI_STRING 'hello'.
       
    13 
       
    14     Click on widget changes variable value to next value in given list, or to
       
    15     first one if not initialized to value already part of the list.
       
    16     ||
       
    17 
       
    18     shortdesc > Show elements whose label match value.
       
    19 
       
    20     // TODO: add optional format/precision argument to support floating points
       
    21 
       
    22     path name="value" accepts="HMI_INT,HMI_STRING" > value to compare to labels
       
    23     
       
    24 }
     2 
    25 
     3 widget_class("MultiState")
    26 widget_class("MultiState")
     4     ||
    27     ||
     5         frequency = 5;
    28         frequency = 5;
     6         state = 0;
    29         state = 0;
    41             this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)");
    64             this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)");
    42         }
    65         }
    43     ||
    66     ||
    44 
    67 
    45 widget_defs("MultiState") {
    68 widget_defs("MultiState") {
    46     param "hmi_element";
       
    47     |     choices: [
    69     |     choices: [
    48     const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+|false|true)(#.*)?$'"!;
    70     const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+|false|true)(#.*)?$'"!;
    49     foreach "$result_svg_ns//*[@id = $hmi_element/@id]//*[regexp:test(@inkscape:label,$regex)]" {
    71     foreach "$result_svg_ns//*[@id = $hmi_element/@id]//*[regexp:test(@inkscape:label,$regex)]" {
    50         const "literal", "regexp:match(@inkscape:label,$regex)[2]";
    72         const "literal", "regexp:match(@inkscape:label,$regex)[2]";
    51     |         {
    73     |         {