Next: Display Items and Up: Display Items Previous: Display Items

 

Advantages of Display Items 

It is easy to see the advantages of seperating the display items from their host widgets. First, the display items are easy to learn. Since they are the same across different types of widgets. Once you learn about a type of display items, you will know how to use them in all Tix widgets that support display items (currently these include TixHList, TixTList and the spreadsheet widget TixGrid, but the number is growing). In contrast, if you want to create a text item for the Tk widgets, you will find out that the listbox, text, canvas and entry widget each have a different method of creating and manipulating text items, and it is quite annoying to learn each of them individually.

Second, the hosts widgets that use display items are extensible. Because of the separation of task, the host widgets are not involved in the implementation details of the display items. Therefore, if you add a new type of display items, such as a animation type that displays live video, the host widgets will gladly take them in and display them. You don't need to modify the existing host widgets at all. In contrast, if you want to display graphical images in the existing Tk listbox widgets, you'd better set aside 100 hours to rewrite it completely!

Third, display items are good for writers of host widgets. Because now they just need to implement the arrangement policy of the host widgets. They don't need to worry about drawing at all because it is all handled by the display items. This is a significant saving in code because a widget that does not use display items has to spend 30%of its C code to do the drawing.


http://tix.sourceforge.net