WTK for APWTCL Paper Chapter 6

The implementation of OpenGL ES for iOS (iPhone) has a rather simple interface to work with. There is an OpenGL graphic context, which can be used to display OpenGL ES primitives like a screen buffer.

OpenGL ES also offers primitives for drawing lines and polygons and to fill areas. Areas are built using for example triangles (there is no support for rectangles, which can be built using two triangles). Lines and triangles are built using vertices. There is an advanced interface available for using arrays of vertices for building graphics elements.

There were some successful experiments in building a Tk button using two triangles for the inner rectangle part and using a combination of some lines for building borders.

It is possible to add an event handling function to be called when a user fires a touch screen event in hitting at some point on the screen. This event also contains the x and y coordinates, where the event happen, Using that information and knowing where on the screen is the area of the simulated button it is possible, to detect when the touch screen event was fired inside the button rectangle area.

When the touch event happened inside the button area it is possible to emulate the Tk like press and release events of a button in setting different border colors for the four borders built using some lines. That way it is possible to make the button look sunken or raised. Depending on the touch screen event.

Experimenting with that implementation the idea came up to eventually use the ideas behind themed Tk (tile or ttk). Looking at the implementation of ttk it seems to be feasible, to implement some modified version of themed Tk widgets using OpenGL ES as the graphic context for displaying the stuff on the screen. Going that way, it would be rather simple too to rotate elements including text. For displaying text there are still some experiments necessary as there is no real experience yet on how freetype2 fonts are supported on the iPhone (iOS ). There is a port/adaption af freetype fonts called freetype2 from David Petrie for iOS and there if a ftgl library called ftgles also from David Petrie which can be compiled, but I was not yet able to make a demo running also it can be linked and started, but the display stays black. Seems to be a problem of adapting to iOS5, as the original was designed for iOS4.

The implementation of themed Tk functionality itself seems to be straight forward, just a matter of doing the work in Objective-C respectively Java.

During testing the implementation there were some problems in building rounded corners for button corners. There have been implemented some different algorithms, but without final success. There were always problems with rendering in getting something looking nice. There is some more time needed to find something suitable, as it seems to be possible looking at iOS button with rounded corners. It has to be found out, if there is a problem with the algorithms used or with OpenGL ES or how to use the same rendering as iOS UI functions/algorithms are using.