Article Preview
Buy Now
COLUMN
Integumentary Customization, Part IV
Using "Skins" in REALbasic Applications
Issue: 2.1 (August/September 2003)
Author: Toby Rush
Author Bio: Toby Rush is a music instructor, consultant, freelance programmer, web designer, husband, and Dad in Greeley, Colorado.
Article Description: No description available.
Article Length (in bytes): 10,970
Starting Page Number: 44
Article Number: 2122
Resource File(s):
2122.zip Updated: 2013-03-10 14:49:44
Related Link(s): None
Excerpt of article text...
Last time, we discussed the concepts behind the creation of a Level IV skinning implementation: a program which can dynamically create its own interface based on a "skin" file imported at startup. In a Level IV implementation, the skin file may specify not only the attributes and placement of controls, but also how many of them are created. In the last column we discussed the concept of control templates which can be subclassed to create the actual buttons, editFields, checkboxes, and so on that make up the program's interface.
Having devised a list of controls we want to make available to the skin designer, the first step is to implement these as subclasses. For example, the time display control we described in the last column would be a subclass of a StaticText object. In a new, empty REALbasic project, create a new class, set the super to StaticText, and name it timeDisplayClass. Since this object inherits the properties of StaticText, we do not need to add properties for text color, font, size, or style; they are already built into the control. In keeping with the specifications we set up last time, we do need to add a timeFormat property. To keep the example simple, we will allow the skin designer to choose between a short time format (6:10 PM) or a long time format (6:10:34 PM). To do this, create a new property for the subclass and define it as "useLongTime as boolean". A value of true in this property indicates that the control should display the long time; otherwise the control will display the short time.
We could leave the creation of the control to the window, but object-oriented programming techniques dictate that the control should beresponsible for its own creation. By setting up a constructor method that takes a line of XML as a parameter, we can do just that. Create a new method in the timeDisplayClass, name it "construct", and enter "dataLine as string" as the parameter. Enter the following code into this newly created method:
Sub construct(data as string)
// this method sets the characteristics of the control
...End of Excerpt. Please purchase the magazine to read the full article.