Manages internal element sizes for a BaseUI-derived object. TraitsUI provides a foundation for any BaseUI class to have a set of parameters that define a default size for the UI element as well as every single internal element within the overall element. The TraitsUI class provides a set of hash maps that let any size value needed to draw the window be accessed via a text string, allowing great flexibility and extensibility.
TraitsUI handles user-initiated resizes of every UI element by resetting itself back to its default state and then applying the resize percentage to every element in its size hash map, thus ensuring a linear size change for every element when the UI element is drawn. By applying the same change percentage to every element, it allows the relative sizes of the UI element to preserved, the goal being that the UI element looks good at any size.
TraitsUI.h
Manages internal element sizes for a BaseUI-derived object. | |
Returns the size value for the given key. | |
Returns the color value for the given key. | |
Returns the font value for the given key. | |
Determines the best sized font for a given height. | |
Resizes all values in the size hash. | |
The TraitsUI constructor. | |
The size hash. | |
Unchangeable integer data hash. | |
The color hash. | |
The font hash. | |
Resets the TraitsUI size hash back to default values. |
|
Returns the size value for the given key. First checks for the key in the constant hash. Then checks in the size hash, and finally throws an error message to the screen if the key does not exist.
| key | The key for the size hash map. |
The size value associated with the key.
|
Determines the best sized font for a given height. Given a font value, a height, and the number of lines of text, determines the size of the font that will fit that number of lines of text into the given height, and then sets the font point size to it.
| dc | The device context the text is being drawn in. |
| font | The key of the font in the font hash. |
| height | The total height the font has to fit in. |
| num | The number of lines within the total height. |
| TraitsUI() |
The TraitsUI constructor. Sets default size fields of Width and Height, since all UI elements have at least a width and a height. Sets default constants for wxCurve and winCurve, for elements to know how much “roundness” to have on their edges. Sets default colors for background, outline, and font color, so that all UI elements have a common look and feel. Sets the default font for all UI elements, for the same reason.
|
|
|
|
|
| TraitsUI() |
| IntHash mSizes |
| IntHash mConstants |
| ColourHash mColours |
| FontHash mFonts |
| virtual void Reset()=0 |