Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Region Class Reference

OpenGL User interace base class. More...

#include <Region.h>

Inherits DynamicObject.

Inherited by Frame, FrameCounter, Label, and Widget.

Inheritance diagram for Region:

Inheritance graph
[legend]
Collaboration diagram for Region:

Collaboration graph
[legend]
List of all members.

Public Methods

 Region (int i=0)
 Default constructor. More...

void setId (int i)
 Sets the id of the Region.

short getX ()
 Returns the x position.

short getY ()
 Returns the y position.

short centerX ()
 Returns the center x position.

short centerY ()
 Returns the center y position.

short getWidth ()
 Returns the Region width.

short getHeight ()
 Returns the Region height.

void setParent (Region *p)
 Sets the parent (owner) of the region.

bool isParentOf (Region *p)
 Returns true iff 'this' is owned by p. More...

void setPosition (short w, short h)
 Set the Region position relative to parent. More...

void setSize (short w, short h)
 Sets the Region size.

void center ()
 Center the Region within parent. More...

void open (const string &name)
 Opens and reads a ObjectFile. More...

Region * getFocus ()
 Grabs the keyboard focus.

Region * grabMouse ()
 Grabs the mouse focus.

void releaseMouse ()
 Releases the mouse focus.

void drawCross ()
 Draws a cross within the region. More...

virtual bool accepts (Event &event)
 Returns true iff region will accept the event. More...

virtual Region * find (int id)
 Finds and returns the region with id. More...

virtual void refresh ()
 Repaints the region. More...

virtual void move (short dx, short dy)
 Move the region. More...

virtual void resize (unsigned short w, unsigned short h)
 Resizes the region. More...

virtual bool event (int regionId, int evnt)
 Handle events from child Regions. More...

virtual bool handleEvent (Event &event)
 Handle window-system events. More...

void parseSymbol (Token &t, ObjectFile &file)
 Reads a single parameter sections inside the body of the object description. More...

void writeParams (ostream &stream)
 Writes all parameter sections inside the body of the object description. More...


Static Public Attributes

Region * focusWindow = 0
 Pointer to the Region with keyboard focus or NULL.

Region * grabWindow = 0
 Pointer to the Region with mouse focus or NULL.


Protected Methods

void foreGround ()
 Renders the foreground color.

void backGround ()
 Renders the background color.

void darkBorder ()
 Renders the dark border color.

void lightBorder ()
 Renders the light border color.

void entryBackGround ()
 Renders the entry background color.

void drawBorder (short x, short y, short w, short h, bool sunken=true)
 Draws a border inside the region. More...

void createSymbols ()
 Creates all parameter symbols that are used within the body of the object description.


Protected Attributes

Region * parent
 Parent region.

int id
 Region id.

short x
 X position.

short y
 Y position.

short width
 Region Width.

short height
 Region Height.


Static Protected Attributes

const int lineWidth = 4
 Default line width.


Detailed Description

OpenGL User interace base class.

The Region is a rectangular region on the screen. Its main purpose is to handle keyboard and mouse inputs (Event). The Region class hierarchy implements an OpenGL widget set.

Format: (see DynamicObject)

    PARAM ::= ID | SIZE | POSITION | CENTER
    ID ::= "id" <int>
    SIZE ::= "size" <width> <height>
    POSITION ::= "position" <x position> <y position>
    CENTER ::= "center"

    Example:
    Region {
      id 5;
      size 640 480;
      position 10 5;
      center;
    }
    


Constructor & Destructor Documentation

Region::Region int    i = 0
 

Default constructor.

Constructs a new Region with id 'i'. The id must be unique in the current scope.

Parameters:
i  int to be used as id.
Postcondition:
Region is initialized.


Member Function Documentation

bool Region::accepts Event   event [virtual]
 

Returns true iff region will accept the event.

Region::accepts implementation checks if the events falls within the region boundary.

Parameters:
event  A keyboard or mouse Event.
Returns:
true iff the event falls within the region boundary.

Reimplemented in Dialog.

void Region::center  
 

Center the Region within parent.

This method calculated the center position of its parent and positions itself in the middle of its parent.

Precondition:
The region has a parent.
Postcondition:
The region has been centered.

void Region::drawBorder short    x,
short    y,
short    w,
short    h,
bool    sunken = true
[protected]
 

Draws a border inside the region.

This method draws a rectangle within the region. The rectangle is defined by its top left position and its width and height. The rectangle is drawn in dark and light colors so that it appears to be higher or lower than its surroundings. The standard way of doing this is to assume that light comes from the top left of the screen.

Parameters:
x  The x position of the rectangle.
y  The y position of the rectangle.
w  The wudth of the rectangle.
h  The height of the rectangle.
sunken  true iff rectangle must appear to be sunker.
Precondition:
An OpenGL context has been created and activated to render in.
Postcondition:
Rectangle has been rendered.

void Region::drawCross  
 

Draws a cross within the region.

Renders a cross or 'X' inside the region. The cross is made to fit the region.

See also:
lineWidth
Precondition:
An OpenGL context has been created and activated to render in.
Postcondition:
A cross has been rendered in lineWidth.

bool Region::event int    regionId,
int    evnt
[virtual]
 

Handle events from child Regions.

The event method is used as a simple notification method to signal activations and state changes of regions. These event are handled bottom up until they are consumed (used). Events that are not accepted by this region are passed to the parent region. If no parent exists the event remains unconsumed.

Parameters:
regionId  Id of the region.
evnt  Id of the event, the semantics of this id is region dependent.
Postcondition:
The event is consumed to passed to parent.
Returns:
true iff the event is consumed.

Reimplemented in ColorPick.

Region * Region::find int    i [virtual]
 

Finds and returns the region with id.

This method searches the underlying region hierarchy to find a region with id 'i'.

Parameters:
i  Id of the region to find.
Returns:
Pointer to the Region found or NULL.

Reimplemented in Frame.

bool Region::handleEvent Event   event [virtual]
 

Handle window-system events.

This method handles keyboard or mouse event from the window system. Window events are handled top down, events that are not consumed are passed to child regions that are willing to accept the event.

See also:
accepts
Parameters:
event  The Event that occured.
Postcondition:
The event is consumed or passed to child regions.
Returns:
true iff the Event is consumed.

Reimplemented in Button.

bool Region::isParentOf Region *    p
 

Returns true iff 'this' is owned by p.

This function walks though the list of parents of p, starting with p. It returns true if 'this' is a parent. By definition 'this' is a parent of 'this'.

Parameters:
p  Pointer to a region.
Returns:
true iff 'this' is a direct or indirect parent of p.

void Region::move short    dx,
short    dy
[virtual]
 

Move the region.

Moved the region by (dx, dy) including all child regions.

Parameters:
dx  the x offset to move.
dy  the y offset to move.
Postcondition:
The region and child regions are moved by (dx, dy).

Reimplemented in Frame.

void Region::open const string &    name
 

Opens and reads a ObjectFile.

Reads a Region definition from ObjectFile. In DynamicObject terms it read the PARAM_LIST. This function first checks if name is a proper file name that can be accessed, if not it tries to access (EXPORT_PATH)/ui/name.

Parameters:
name  File name to read
Precondition:
name is a proper filename either absoluut, relative or relative to (EXPORT_PATH)/ui/.
Postcondition:
All parameters from the file have been read.
Exceptions:
runtime_error  When file could not be accessed.

void Region::parseSymbol Token   t,
ObjectFile   file
[virtual]
 

Reads a single parameter sections inside the body of the object description.

Each object has a set of parameter names associated with it, called symbols. Symbols are declared inside the createSymbols method. The method parseSymbol expects the Token t to be such a symbol and reads the corresponding parameters. Unknown symbols are passed to its super class.

Parameters:
t  Token that is the current parameter symbol.
file  ObjectFile from which to read.
Precondition:
The file is opened for reading and is positioned just after the parameter name.
Postcondition:
The parameter section is read including the terminating semicolon (';').

Reimplemented from DynamicObject.

Reimplemented in Button.

void Region::refresh   [virtual]
 

Repaints the region.

This method is called whenever the screen is repainted. The repaint method uses OpenGL calls to render the region. Currently it is assumed that regions are refreshed automatically so that no refresh notification has to be done when the region changes state i.e. no refresh has to be forced by the region. Region rendering is done back to front.

Precondition:
An OpenGL context has been created and activated to render in.
Postcondition:
The region is redrawn.

Reimplemented in Button.

void Region::resize unsigned short    w,
unsigned short    h
[virtual]
 

Resizes the region.

Virtual method to change the size of the Region.

Parameters:
w  New width.
h  New height.
Postcondition:
The region has been resized to (w, h).

Reimplemented in ColorPick.

void Region::setPosition short    xx,
short    yy
 

Set the Region position relative to parent.

Todo:
Use move() to set the actual position, so that children are also moved?

If there s a parent the (xx, yy) position is added to the position of the parent otherwise the position is just set. Child windows are not moved.

Parameters:
xx  New x position.
yy  New y position.
Postcondition:
Region position is set.

void Region::writeParams ostream &    stream [virtual]
 

Writes all parameter sections inside the body of the object description.

This method writes all object parameters to ostream. Inhereting classes will always call super::writeParams().

Parameters:
stream  ostream to which to write.
Precondition:
stream is opened for writing.
Postcondition:
All object parameters are written.

Reimplemented from DynamicObject.

Reimplemented in Button.


The documentation for this class was generated from the following files:
This documentation was generated using doxygen. If you have any comments or additions please mail me.