|
GEOS SDK TechDocs
|
|
5 A UI Example
|
5.2 What TicTac Does
The TicTac sample application can teach you several things about how the visible world works and about how to manage visible objects in an application. It is simple but illustrates the following concepts:
-
Drawing Visible Objects
Every visible object must be able to draw itself.
VisClass
does not have any inherent code to make visible objects visible; instead, subclasses of
VisClass
must handle
MSG_VIS_DRAW
.
-
Changing an Object's Position
The pieces of the TicTac game allow the user to move them around the screen using the mouse. This entails tracking the mouse and then changing the object's position in the document.
-
Sending Messages Up and Down the Visible Tree
The pieces must interact with the VisContent object to ensure they stay on the game board, and the VisContent must notify the pieces when the "New Game" button has been pressed. Therefore, messages must be passed both up and down the visible tree.
-
Handling Input Events
In order for the user to move the pieces around the board, the pieces must be able to receive mouse events. Several different types of mouse events are handled to show the pieces moving around the board and to handle input properly.
-
Drawing Background Graphics
Because the game board does not change at all, its background is drawn by the content object. The content could change its drawing behavior if necessary, but background graphics are most easily drawn by the content.
-
Visible Tree Structure
A simple, two-layer visible tree is used in the TicTac application: The VisContent is the root of the tree, and each of the pieces is a leaf.
|
GEOS SDK TechDocs
|
|
5 A UI Example
|
5.2 What TicTac Does