SR Technology WTK Repo
Check-in [d092328cde]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Start of private SAPUI5 branch edits.
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1: d092328cde6167b91b087d52f1334bfdd400992f
User & Date: gerald 2013-03-07 04:11:32
Context
2013-03-07
04:11
Start of private SAPUI5 branch edits. Leaf check-in: d092328cde user: gerald tags: trunk
2013-03-05
00:01
De-snitted a lot of the event handlers Added a new "options_dict" method for introspecting options. The odie way of handling properties collapsed horribly if there happened to be an option named -options (as we see in the combobox...) Added "my variable" to methods that were relying on the "variable" keyword in the class definition magically working Developed a TclOO implementation of traced variable event linking Updated to the latest ODIE, which adds mutexes, fixes a few bugs with properties, etc. (See odie fossil timeline) check-in: 9a05a8cffa user: seandeelywoods tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to index.html.

9
10
11
12
13
14
15





16
17
18
19
20
21
22
<h1>wtk (web Tk) demo</h1>

<h2>Demo wtk applications</h2>
<ul>
  <li><a href="demo.tcl">demo.tcl</a> (click link to run widget demo app)
  <li><a href="sketch.tcl">sketch.tcl</a> (click link to run freehand sketch on canvas demo)
</ul>






<h2>Code overview</h2>
<table>
<tr><td><a href="src.html?f=index.html">index.html</a></td><td>This page.</td></tr>
<tr><td><a href="src.html?f=server.tcl">server.tcl</a></td><td>Main demo application; it manages the webserver communication and creates wtk interpreters which
	actually run demos for a client.</td></tr>
<tr><td><a href="src.html?f=lib/wtkcoreapp.html">lib/wtkcoreapp.html</a></td><td>Web page for an application, which initializes the Javascript side of wtk and connects to the






>
>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<h1>wtk (web Tk) demo</h1>

<h2>Demo wtk applications</h2>
<ul>
  <li><a href="demo.tcl">demo.tcl</a> (click link to run widget demo app)
  <li><a href="sketch.tcl">sketch.tcl</a> (click link to run freehand sketch on canvas demo)
</ul>

<h2>SAPUI5 demo</h2>
<ul>
  <li><a href="sapui5.html">Hello World</a>
</ul>

<h2>Code overview</h2>
<table>
<tr><td><a href="src.html?f=index.html">index.html</a></td><td>This page.</td></tr>
<tr><td><a href="src.html?f=server.tcl">server.tcl</a></td><td>Main demo application; it manages the webserver communication and creates wtk interpreters which
	actually run demos for a client.</td></tr>
<tr><td><a href="src.html?f=lib/wtkcoreapp.html">lib/wtkcoreapp.html</a></td><td>Web page for an application, which initializes the Javascript side of wtk and connects to the

Changes to lib/wtk-base.tcl.

39
40
41
42
43
44
45

46
47





48

49
50
51
52
53
54
55
56
57
58
        init $_sender
        return ""
    }

    proc toclient {cmd} {uplevel #0 $::wtk::_sender [list $cmd]}

    proc fromclient {cmd} {

        switch -exact -- [lindex $cmd 0] {
            "EVENT" {





                [getwidget [lindex $cmd 1]] wtk_event {*}[lrange $cmd 2 end]

            }
            "LOG" {
                ::log::log [lindex $cmd 1] [lrange $cmd 2 end]
            }
        }
    }

    # 'Generic' widget object, which handles routines common to all widgets like
    # assigning it an id, keeping track of whether or not its been created, etc.
    # Purely for convenience, we also include some code here that manages widgets






>
|

>
>
>
>
>

>


|







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
        init $_sender
        return ""
    }

    proc toclient {cmd} {uplevel #0 $::wtk::_sender [list $cmd]}

    proc fromclient {cmd} {
        set lcmd [split $cmd]
        switch -exact -- [lindex $lcmd 0] {
            "EVENT" {
<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<<<<<
                [getwidget [lindex $lcmd 1]] _event {*}[lrange $lcmd 2 end]
======= COMMON ANCESTOR content follows ============================
                [getwidget [lindex $cmd 1]] _event {*}[lrange $cmd 2 end]
======= MERGED IN content follows ==================================
                [getwidget [lindex $cmd 1]] wtk_event {*}[lrange $cmd 2 end]
>>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
            }
            "LOG" {
                ::log::log [lindex $lcmd 1] [join [lrange $lcmd 2 end]]
            }
        }
    }

    # 'Generic' widget object, which handles routines common to all widgets like
    # assigning it an id, keeping track of whether or not its been created, etc.
    # Purely for convenience, we also include some code here that manages widgets

Changes to lib/wtkcoreapp.html.


1
2
3
4
5
6
7
8
9
10
11
12








13
14



15
16
17
18



19
20
<html>
<head>
%%%FAVICON%%%


<style type="text/css">
* {outline:none;  appearance: none; -moz-appearance: none; border-radius: 5px;}
::-moz-focus-inner { border: 2px; outline: none;-moz-apperance:none;}

</style>
<script src="lib/jquery.min.js"></script>
<script src="widgets/wtk.js"></script>








</head>
<body>



<div id=obj0></div>
<script>
$(document).ready(function() {wtk.init(%%%SESSIONID%%%)});
</script>



</body>
</html>
>


|

<
|
<
<

<
|
|
>
>
>
>
>
>
>
>

<
>
>
>




>
>
>


1
2
3
4
5

6


7

8
9
10
11
12
13
14
15
16
17
18

19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html>
<html>
<head>
    %%%FAVICON%%%


    <meta http-equiv="X-UA-Compatible" content="IE=edge" />




    <script src="lib/jquery.min.js"></script>
    <script src="widgets/wtk.js"></script>

    <script id="sap-ui-bootstrap"
        type="text/javascript"
        src="resources/sap-ui-core.js"
        data-sap-ui-theme="sap_goldreflection"
        data-sap-ui-libs="sap.ui.commons">
    </script>

</head>


<body class="sapUiBody">

<div id=obj0></div>
<script>
$(document).ready(function() {wtk.init(%%%SESSIONID%%%)});
</script>

<div id="uiArea"></div>

</body>
</html>

Changes to widgets/wtk.js.

66
67
68
69
70
71
72


73
74
75
76
77
78
79
..
89
90
91
92
93
94
95

















96
97

98






99
100
101
102
103
104
105
...
106
107
108
109
110
111
112

113

114
115
116
117
118
119
120

    },

    server_log :function(logLevel,msg) {
        wtk.sendto('LOG '+logLevel+' '+wtk.sessionid+' '+msg);
    },



    poller : function() {$.ajax({type:'GET', url:'wtkpoll.html?sessionid='+wtk.sessionid, dataType:'script',
                                complete: function() {setTimeout(wtk.poller,100);},
                                error: function(jqXHR, textStatus, errorThrown) {
																	//alert("AJAX server connection interrupted\nPress OK to reconnect.");
																	console.log('AJAX server connecton interrupted '+textStatus+' '+errorThrown);
																	setTimeout(location.reload(1),200);}
................................................................................
		},

    /*
     * Generic widget creation; each widget is an HTML element of a certain type, and is given an
     * id by the wtk code on the server side which is used to uniquely identify it.
     */
    CreateWidget : function(id,type,txt,attr) {

















        var w = document.createElement(type);
        w.id = id;

        if(txt!='') {if (attr=='innerHTML') {w.innerHTML=txt;} else {w.value=txt;};}






        wtk.widgets[id] = w;
        return w;
    },

    /*
     * Buttons, labels and entries, oh my!
     */
................................................................................


		createMisc   : function(id, type, txt, attr) {
			wtk.CreateWidget(id, type, txt, attr).onclick = function() {wtk.miscClicked(id);};
			},
		miscClicked : function(id) { wtk.sendto('EVENT '+id+' pressed'+' value '+wtk.widgets[id].value); },


    createButton  : function(id,txt) { wtk.CreateWidget(id,'button',txt,'innerHTML').onclick = function() {wtk.buttonClicked(id);}; },

    buttonClicked : function(id) { wtk.sendto('EVENT '+id+' pressed'); },

    createCombobox  : function(id,txt) {
    	  wtk.CreateWidget(id,'select',txt,'value').onchange = function() {wtk.comboboxClicked(id);};
    },
    comboboxClicked : function(id) { wtk.sendto('EVENT '+id+' value '+wtk.widgets[id].value); },







>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
|
>
>
>
>
>
>







 







>
|
>







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148

    },

    server_log :function(logLevel,msg) {
        wtk.sendto('LOG '+logLevel+' '+wtk.sessionid+' '+msg);
    },



    poller : function() {$.ajax({type:'GET', url:'wtkpoll.html?sessionid='+wtk.sessionid, dataType:'script',
                                complete: function() {setTimeout(wtk.poller,100);},
                                error: function(jqXHR, textStatus, errorThrown) {
																	//alert("AJAX server connection interrupted\nPress OK to reconnect.");
																	console.log('AJAX server connecton interrupted '+textStatus+' '+errorThrown);
																	setTimeout(location.reload(1),200);}
................................................................................
		},

    /*
     * Generic widget creation; each widget is an HTML element of a certain type, and is given an
     * id by the wtk code on the server side which is used to uniquely identify it.
     */
    CreateWidget : function(id,type,txt,attr) {
        wtk.server_log('debug','Type = "'+type+'". Id = "'+id+'". Index is: '+id.indexOf('sapui5'));
        if (type == "button") {
            wtk.server_log('debug','Attempting to create an SAPUI5 button with id of {' + id +'} and label of {' + txt +'}');
            //var w = document.createElement('div');
            //w.id = 'div_' + id;
            var o = new sap.ui.commons.Button(id);
            wtk.server_log('debug','Created SAPUI5 button "'+id+'"!');
            o.setText(txt);
            //o.placeAt('div_' + id);
            wtk.server_log('debug','Text set, calling render.');
            o.rerender();
            var w = o.getDomRef();
            wtk.server_log('debug','w = ' + w);
            wtk.server_log('debug','type of = ' +  typeof(w));
            wtk.server_log('debug','w.tagName = ' + w.tagName);
            wtk.server_log('debug','w.nodeName = ' + w.nodeName);
        } else {
            var w = document.createElement(type);
            w.id = id;
            if(txt!='') {
                if (attr=='innerHTML') {
                    w.innerHTML=txt;
                } else {
                    w.value=txt;
                }
            ;};
        };
        wtk.widgets[id] = w;
        return w;
    },

    /*
     * Buttons, labels and entries, oh my!
     */
................................................................................


		createMisc   : function(id, type, txt, attr) {
			wtk.CreateWidget(id, type, txt, attr).onclick = function() {wtk.miscClicked(id);};
			},
		miscClicked : function(id) { wtk.sendto('EVENT '+id+' pressed'+' value '+wtk.widgets[id].value); },

    createButton  : function(id,txt) {
        wtk.CreateWidget(id,'button',txt,'innerHTML').onclick = function() {wtk.buttonClicked(id);};
    },
    buttonClicked : function(id) { wtk.sendto('EVENT '+id+' pressed'); },

    createCombobox  : function(id,txt) {
    	  wtk.CreateWidget(id,'select',txt,'value').onchange = function() {wtk.comboboxClicked(id);};
    },
    comboboxClicked : function(id) { wtk.sendto('EVENT '+id+' value '+wtk.widgets[id].value); },