We are now going to add a simple window to our application. This is done
by instantiating the cWindow class:
Line 11 instantiates the window and sets its size to 250x100. The flag kCurrentWorkspace indicates that we want this window to be located on the current workspace. If we wanted to have this window positioned on the third workspace for example, we would have to put the value 3 instead. Line 12 and 13 sets the window's title and the window's position respectively.
The result of the above code can be seen below. The source code can be downloaded here:
The philosophy behind the GUI development with Zinzala SDK is based on message passing. Every component of the user interface has the ability to send, receive and process messages. For example, when a button is pressed, a message is sent to the window that contains it. This message has been specified earlier by the developer and will be the basis for determining what response the user will receive. The developer can then perform processing accordingly.
The class cMessage implements a bundle of data that is exchanged between widgets and windows or even between applications. It provides a way of storing and retreiving typed and named information.
Next, we will derive the class cWindow. This derived class is necessary to process messages such as the one from a Compute button of the user interface:
The protected method MessageReceived performs the processing of the messages received by the window. If there is nothing to be done with the message received, identified by its iWhat field, the parent method needs to be called, otherwise the window will not work correctly.
Now, we will modify the main of our application to use this class cCalcWindow
The result of this simple application is the same as earlier. The source code can be downloaded here.
Let's now add the widgets for the user interface of the calculator. Zinzala SDK offers a complete range of widgets for the developer to choose from. Most of these widgets are based on the ones which already exist in Photon. For our example, we are going to use the following:
cGroupView, allows the grouping of widgets inside a containercFloatEntryView, allows the user to enter a float valuecComboBoxView, allows the user to select an item from a drop listcStringView, displays a string