BaseUI

A base class for all main screen UI.  BaseUI implements the UI interface and handles some of the UI interface functions as well as providing another interface set for further derived classes to implement.  Each BaseUI-derived class must have an associated TraitsUI class that provides default values for the shape and size of that BaseUI element as well as a mechanism for dynamically resizing that UI element on the fly.  BaseUI handles all of the lowest level wx event handling for painting and resizing, and provides a flicker-free drawing mechanism for custom drawn UI elements via the classic bitblt strategy.  Each UI element gets a wxMemoryDC to draw itself in, which BaseUI then blasts to the screen all at once with bit blit.

BaseUI also provides a set of anchor points for any derived classes and handles calculating their correct origin on the screen when the main screen is resized, fulfilling that requirement of the UI interface.  BaseUI also handles responding to requests from the user to totally resize every UI element, also fulfilling that requirement of the UI interface.

Derived From

UI

Project

UICore

Include

BaseUI.h

Summary
A base class for all main screen UI.
The anchor point for a UI element.
Calculates the origin of the UI given the screen rectangle.
Handles a user-initiated total UI resize.
The BaseUI constructor.
Sets an offset for the UI from the anchor point.
The wxWidgets event table declaration.
Paints the UI window.
Provides the TraitsUI object for the UI element.
Resizes the UI element.
Erases the button.
Paints the window.
Resizes the window.
The offset anchor for the UI element.
The current offset amount from the offset anchor.
The memory bitmap for flicker free drawing.

Public

Summary
The anchor point for a UI element.
Calculates the origin of the UI given the screen rectangle.
Handles a user-initiated total UI resize.

Enumerations

OffsetAnchor

The anchor point for a UI element.  Provides a way for any UI to anchor itself from one of the four corners of the main screen.  Anchor points are: UpperLeft, UpperRight, LowerLeft, LowerRight.

Virtual Functions

GetPosition

virtual wxPoint GetPosition(const wxRect &rect)

Calculates the origin of the UI given the screen rectangle.  Uses the stored OffsetAnchor and offset size to calculate the correct origin for the UI element.

Parameters

rectA wxRect that is the dimensions of the window the UI resides in.

Returns

A wxPoint that is the origin in window coordinates of the UI element.

TotalUIResize

virtual void TotalUIResize(float fPercent)

Handles a user-initiated total UI resize.  Gets the TraitsUI object for the class, resizes it with the given percentage, and then calls ResizeUI so that the derived class can adjust itself to the new values in the TraitsUI object.

Parameters

fPercentThe percentage of UI resize.  Ranges from 1.0 to 2.0 inclusive.

Protected

Summary
The BaseUI constructor.
Sets an offset for the UI from the anchor point.
The wxWidgets event table declaration.

Constructors

BaseUI

BaseUI(const OffsetAnchor type, 
wxWindow *parent, 
wxWindowID id, 
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0,
const wxString &name = wxPanelNameStr)

The BaseUI constructor.  In every way like a wxWindow constructor except it takes an additional OffsetAnchor parameter, setting the anchor point for the UI.

Parameters

typeThe offset anchor type.
parentThe parent window (must not be NULL).
idThe id for message handling.
posThe starting position.
sizeThe starting size.
styleThe window style, using wxWindow parameters.
nameThe name.

Functions

SetOffset

void SetOffset(const wxSize &offset)

Sets an offset for the UI from the anchor point.  The offset is used in the calculation that determines the correct origin on the screen for the UI.

Parameters

offsetThe offset amount from the anchor point for this UI.

Variables

DECLARE_EVENT_TABLE

The wxWidgets event table declaration.

Private

Summary
Paints the UI window.
Provides the TraitsUI object for the UI element.
Resizes the UI element.
Erases the button.
Paints the window.
Resizes the window.
The offset anchor for the UI element.
The current offset amount from the offset anchor.
The memory bitmap for flicker free drawing.

Pure Virtual Functions

Paint

virtual void Paint(wxMemoryDC &dc)=0

Paints the UI window.  All UI windows are custom-drawn.  Using a memory dc allows for flicker free drawing.  The derived class paints itself into the memory dc, which is then blitted to the screen all at once.

Parameters

dcThe memory dc to draw into.

GetTraitsUI

virtual const TraitsUIPtr &GetTraitsUI()=0

Provides the TraitsUI object for the UI element.

Returns

A const reference to the TraitsUI object.

ResizeUI

virtual void ResizeUI()=0

Resizes the UI element.  Each BaseUI-derived class must be ready to handle a user-initiated event to completely resize every UI element based on the parameters in its TraitsUI object.

Event Message Handling

OnBackground

void OnBackground(wxEraseEvent &event)

Erases the button.  Necessary in order to prevent flickering when redrawing the window.

Parameters

eventThe erase event.

OnPaint

void OnPaint(wxPaintEvent &event)

Paints the window.  Sets up the memory dc and then calls the Paint function for derived classes to do their custom drawing.

Parameters

eventThe paint event.

OnSize

void OnSize(wxSizeEvent &event)

Resizes the window.  Resets the memory bitmap to the proper dimensions.

Parameters

eventThe size event.

Variables

mOffsetAnchor

OffsetAnchor mOffsetAnchor

The offset anchor for the UI element.

mOffset

wxSize mOffset

The current offset amount from the offset anchor.

mMemBitmap

wxBitmap mMemBitmap

The memory bitmap for flicker free drawing.

virtual wxPoint GetPosition(const wxRect &rect)
Calculates the origin of the UI given the screen rectangle.
virtual void TotalUIResize(float fPercent)
Handles a user-initiated total UI resize.
BaseUI(const OffsetAnchor type, 
wxWindow *parent, 
wxWindowID id, 
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0,
const wxString &name = wxPanelNameStr)
The BaseUI constructor.
void SetOffset(const wxSize &offset)
Sets an offset for the UI from the anchor point.
virtual void Paint(wxMemoryDC &dc)=0
Paints the UI window.
virtual const TraitsUIPtr &GetTraitsUI()=0
Provides the TraitsUI object for the UI element.
Manages internal element sizes for a BaseUI-derived object.
virtual void ResizeUI()=0
Resizes the UI element.
void OnBackground(wxEraseEvent &event)
Erases the button.
void OnPaint(wxPaintEvent &event)
Paints the window.
void OnSize(wxSizeEvent &event)
Resizes the window.
OffsetAnchor mOffsetAnchor
The offset anchor for the UI element.
wxSize mOffset
The current offset amount from the offset anchor.
wxBitmap mMemBitmap
The memory bitmap for flicker free drawing.
An interface for custom-drawn main screen UI elements.
UICore provides a set of common UI controls that promote a constant look and feel across all aspects of the UI.