DirectX does not provide visual controls the way that other development platforms like Java, C++ Builder, or MFC do. Instead we will need to create our own classes, and we will want to make classes that can easily be reused. To begin with we will be making simple controls that are essentially hot spots on the screen that respond to mouse clicks. As time allows we will look at more complicated controls that give visual feedback and are more complicated (like selection lists and scrollbars).
Here are some of the important data members that you should include in your Control class:
You will need to provide get and set methods for those data items. For now you will not want to set the height and width directly, but get them from the image object to keep things simple.
Some other methods that you will want to provide are:
The doMouse method will get the mouse state information and use it to find the command (if there is one) that should be executed if there is a mouse click in the control.
Question This approach assumes that the control knows its position on the screen. What would be an alternative approach? What are the advantages and disadvantages of each approach?
Future Enhancements Later we will want to make controls that change their visual state in response to mouse actions. For example, we might want a button that looks like it is being pushed in, or that is highlighted when the mouse is pointing to it. What will need to change to accomodate those enhancements?