WTK for APWTCL Paper Chapter 4

  • The Client Side

The client side is responsible for creating and displaying the GUI elements like a button or a label.

The implementation of the GUI part started with the iPhone version; the Java version was done some time later.

Some details of the client side:

  • The client side is implemented as a class with methods for the GUI elements and other parts. There is one object of that class instantiated at the beginning, and when starting the application the implementation of the toclient and fromclient methods is defined.
  • Toclient encodes the message and uses the instantiated client object as the object and calls the decode message implemented there.
  • A reference to the fromclient method is set by an appropriate setter call to the client object.
  • The client side decode method decodes and interprets the messages sent via the message interface

For example for this message:.

 * M53:9:wtkclient11:createLabel4:obj120:label: Hello Chicago

After decoding we get a Tcl like list with the following contents:

 * {wtkclient createLabel obj1 {label: Hello Chicago}}

The first two parts build the client objects method to be called (after some mangling): wtkclientCreateLabel and there are two parameters: obj1 and {label: Hello Chicago} for that message.

As iOS and Java both can call class method using a text string with reflection/selectors this is the technique used. Method wtkclientCreateLabel is responsible for creating a GUI element label with the text: “label: Hello Chicago”

First approach for creating GUI elements was to use the native GUI elements available on iPhone , namely the UI* classes. Using that approach, there is a rather limited implementation of a button and label support. Rather limited in that respect only means there is no completely compatible environment available as for a Tk Button.

Instead of a mouse click there is the possibility to hit the button using a touch screen event. When this event fires a native method is called, which in turn can call another method (in our case come method inside the client class. This method is implemented to forward that “event” to the Tcl wtk part in calling the fromclient method with parameters.

Via that way the notification for an event is reaching the Tcl part, which in turn can handle the administrative part of the event and eventually is sending back some other message to be handled, for example to change the text of a button when the button is hit.