ui::Component Class Reference

Inheritance diagram for ui::Component:

Inheritance graph
[legend]
Collaboration diagram for ui::Component:

Collaboration graph
[legend]
List of all members.

Detailed Description

Basic Component. Defines basic functionality for all Components used in this Graphical User Interface ToolKit.


Public Types

enum  ComponentDepth { NORMAL = 8, NORMAL_MODAL = 4, POPUP = 2, POPUP_MODAL = 1 }
enum  CONSTANTS { LEFT, RIGHT, CENTER }

Public Member Functions

 Component ()
 Component (const Component &rhs)
Componentoperator= (const Component &rhs)
virtual ~Component ()
void swap (Component &rhs) throw ()
virtual void setEnabled (bool enable)
bool isEnabled () const
void setVisible (bool visible)
bool isVisible () const
virtual void invalidate ()
virtual void validate ()
bool isValid () const
void setParent (Component *parent)
ComponentgetParent () const
void paint (Graphics &g)
const util::PaintgetForeground () const
void setForeground (util::Paint *c)
const util::PaintgetBackground () const
void setBackground (util::Paint *c)
void setTheme (theme::ThemeComponent *theme)
void resetTheme ()
void setThemeName (const std::string &name)
const std::string & getThemeName () const
const theme::ThemeComponent * getTheme () const
void setLocation (int x, int y)
void setLocation (const util::Point &p)
const util::Point getLocation () const
const util::Point getLocationOnScreen () const
void setBounds (int x, int y, int width, int height)
void setBounds (const util::Rectangle &rhs)
const util::RectanglegetBounds () const
virtual const util::DimensiongetPreferredSize () const
void setPreferredSize (const util::Dimension &d)
void setSize (int width, int height)
void setSize (const util::Dimension &rhs)
void setDepth (int type)
int getDepth () const
virtual bool isContainer () const
virtual bool isRootContainer () const
const ComponentList & getChildren () const
void setBorderPainted (bool enable)
bool isBorderPainted () const
bool hasBorder () const
void setBorder (border::Border *b)
border::BordergetBorder () const
void setInsets (const util::Insets &i)
const util::InsetsgetInsets () const
void setFont (Font *font)
FontgetFont () const
void processMouseEvent (const event::MouseEvent &e)
bool hasMouseListener () const
void addMouseListener (event::MouseListener *l)
void removeMouseListener (event::MouseListener *l)
void removeMouseListeners ()
bool hasFocus () const
void setFocus (bool enable)
void processFocusEvent (const event::FocusEvent &e)
void addFocusListener (event::FocusListener *l)
void removeFocusListener (event::FocusListener *l)
void removeFocusListeners ()
const event::FocusListenerList getFocusListeners () const
bool hasFocusListener () const
virtual bool canHoldPermanentFocus () const
void addKeyListener (event::KeyListener *l)
void removeKeyListener (event::KeyListener *l)
void removeKeyListeners ()
const event::KeyListenerList getKeyListeners () const
bool hasKeyListener () const
void processKeyEvent (const event::KeyEvent &e)
void processPropertyEvent (const event::PropertyEvent &e)
void addPropertyListener (event::PropertyListener *l)
void removePropertyListener (event::PropertyListener *l)
void removePropertyListeners ()
const event::PropertyListenerList getPropertyListeners () const
bool hasPropertyListener () const
virtual void updateComponent (float deltaTime)
void addInterpolator (util::Interpolator *i)
void removeInterpolator (util::Interpolator *i)
void removeInterpolators ()
void setTransparency (float f)
float getTransparency () const
void setRotation (float r)
float getRotation () const

Protected Member Functions

virtual void paintComponent (Graphics &g)
virtual void paintChildren (Graphics &g)
void paintBorder (Graphics &g)
virtual void paintSelectionComponent (Graphics &g)
virtual void validateTree ()

Protected Attributes

float depth
ComponentList componentList
util::Dimension preferredSize


Member Enumeration Documentation

enum ui::Component::ComponentDepth
 

Component depth values. The actual float depth is 1/ComponentDepth.

Enumeration values:
NORMAL  Depth for all normal Components.
NORMAL_MODAL  Depth for normal modal Components
POPUP  Depth for popup Components.
POPUP_MODAL  Depth for modal popup Components.

enum ui::Component::CONSTANTS
 

Constants for general use in Components.

Enumeration values:
LEFT  Defines left.
RIGHT  Defines right.
CENTER  Defines center.


Constructor & Destructor Documentation

ui::Component::Component  ) 
 

Default constructor

ui::Component::Component const Component rhs  ) 
 

Copy constructor.

Parameters:
rhs the Component from which to construct a new Component.

ui::Component::~Component  )  [virtual]
 

Destructor. This constructor is virtual so classes inheriting from Component can correctly free their memory.


Member Function Documentation

Component & ui::Component::operator= const Component rhs  ) 
 

Assignment operator.

Parameters:
rhs the Component assigned to this object.
Returns:
the new Component.

void ui::Component::swap Component rhs  )  throw ()
 

Swaps two Components. Guaranteed not to throw.

void ui::Component::setEnabled bool  enable  )  [virtual]
 

Enables or disables this Component. Disabling the Component makes this Component ignore any user input (that is, mouse and key events generated by a user).

Reimplemented in ui::Container.

bool ui::Component::isEnabled  )  const
 

Returns whether or not this Component is enabled.

void ui::Component::setVisible bool  visible  ) 
 

Renders the Component invisible or visible. Default value for Components is visible, except the Frame.

Parameters:
visible variable to render the widget visible (true) or invisible (false).

bool ui::Component::isVisible  )  const
 

Method that returns the current visibility state of the current Component.

Returns:
true if the Component is visible, false if it's invisible.
Note:
If an Component is set to invisible, noone of it's children components are painted.
See also:
setVisible

void ui::Component::invalidate  )  [virtual]
 

Invalidates this Component. This forces the Component and it's parent to do a layout call.

void ui::Component::validate  )  [virtual]
 

Validates this Component.

Reimplemented in ui::Container.

bool ui::Component::isValid  )  const
 

Returns whether or not this Component is valid. If this returns true, that means all of it's children (in case it's an Container) are also valid.

Returns:
true if the Component is valid, false otherwise.

void ui::Component::setParent Component parent  ) 
 

Sets the parent for this Component. Can be NULL (0) if no parent is present.

Parameters:
parent the Component to use as parent.

Component * ui::Component::getParent  )  const
 

Returns the parent for this Component.

Returns:
returns a pointer to this Components parent. The parent might be NULL (0), in case the Component is a root container (which has no parent).

void ui::Component::paint Graphics g  ) 
 

Paint method called by the Component's parent. Do not call this method manually, as it's used by the Component to paint itself (together with the look and feel manager - which is currently not implemented)

Parameters:
g Graphics reference used for painting.

void ui::Component::paintComponent Graphics g  )  [protected, virtual]
 

Custom Component painting. Overload to implement custom drawing.

Parameters:
g Graphics reference used for painting.

Reimplemented in ui::Container.

void ui::Component::paintChildren Graphics g  )  [protected, virtual]
 

Paint this Components children.

Parameters:
g Graphics reference used for painting.

Reimplemented in ui::Container, and ui::Window.

void ui::Component::paintBorder Graphics g  )  [protected]
 

Paints this Components border, if one is present.

Parameters:
g Graphics reference used for painting.

void ui::Component::paintSelectionComponent Graphics g  )  [protected, virtual]
 

This method paints a unique colored rectangle to the screen for use by the picking engine. You can override this method to do custom selection rendering, for example for pictures.

Parameters:
g Graphics reference used for painting.

Reimplemented in ui::GLCanvas.

virtual void ui::Component::validateTree  )  [inline, protected, virtual]
 

Validate the Component tree. This validates this Components and all of it's children. Most likely by invoking their LayoutManagers.

const util::Paint * ui::Component::getForeground  )  const
 

Returns the current foreground color for this Component.

Returns:
Color object holding the color values.
See also:
Color setForeground

void ui::Component::setForeground util::Paint c  ) 
 

Sets the Component's foreground color.

Parameters:
c Color object holding the color variables.

const util::Paint * ui::Component::getBackground  )  const
 

Returns the current background color for this Component.

Returns:
Color object holding the color values.
See also:
Color setBackground

void ui::Component::setBackground util::Paint c  ) 
 

Sets the Component's background color.

Parameters:
c Color object holding the color variables.

void ui::Component::setTheme theme::ThemeComponent *  theme  ) 
 

Sets the theme for this Component. The theme can be viewed as the View in MVC. It decides how this particular component is rendered.

Parameters:
theme New theme to be used by this Component.

void ui::Component::resetTheme  ) 
 

Reset all theme values by calling deinstallTheme and installTheme in succession.

void ui::Component::setThemeName const std::string &  name  ) 
 

Sets the theme name, this is the identifier used to decide which ThemeComponent to choose when requesting a theme. This is for internal use only, or if you're writing your own custom Components.

const std::string & ui::Component::getThemeName  )  const
 

Returns the theme name.

const theme::ThemeComponent * ui::Component::getTheme  )  const
 

Returns the active theme.

void ui::Component::setLocation int  x,
int  y
 

Sets the Components location without modifying it's height and width.

Parameters:
x Component horizontal position.
y Component vertical position.

void ui::Component::setLocation const util::Point p  ) 
 

Sets the Components relative location without modifying it's height and width. The relative location is the location inside the Components Container (it's parent).

Parameters:
p Point containing the new x and y positions.

const util::Point ui::Component::getLocation  )  const
 

Returns the current location as a Point.

Returns:
Return the current location inside it's container.
Note:
Note that this does not return the screen location for this Component. To get the current screenlocation, use getLocationOnScreen().
See also:
getLocationOnScreen

const util::Point ui::Component::getLocationOnScreen  )  const
 

Returns the Component location in screen coordinates.

Note:
to get the coordinates relative to the Components Container, use getLocation.
See also:
getLocation

void ui::Component::setBounds int  x,
int  y,
int  width,
int  height
 

Set all the Components Rectangle properties.

Parameters:
x Component horizontal position.
y Component vertical position.
width Component width.
height Component height.

void ui::Component::setBounds const util::Rectangle rhs  ) 
 

Set the new bounds for this Component.

Parameters:
rhs the Rectangle to use as dimension and position.

const util::Rectangle & ui::Component::getBounds  )  const
 

Returns the current Rectangle from this Component.

Returns:
Rectangle holding the current position and size values.
See also:
Rectangle

const util::Dimension & ui::Component::getPreferredSize  )  const [virtual]
 

Returns the Components preferred size.

Returns:
The preferredSize of this Component as Dimension.
Note:
The actual width and height of the Component might differ from the preferredSize. Use getBounds to receive the real values.
See also:
setPreferredSize getBounds setBounds

Reimplemented in ui::Container.

void ui::Component::setPreferredSize const util::Dimension d  ) 
 

Sets the preferred size. The prefferedSize is a hint to the layoutmanager, which might or might not respect this hint.

Parameters:
d the preferredSize for this Component.

void ui::Component::setSize int  width,
int  height
 

Sets the Components width and height without modifying it's location.

Parameters:
width Component width.
height Component height.

void ui::Component::setSize const util::Dimension rhs  ) 
 

Sets the Components width and height without modifying it's location.

Parameters:
rhs new Component dimension.

void ui::Component::setDepth int  type  ) 
 

Sets the depth for this Component. Different depths are used to paint popup menus and such. This allows us to use the normal Component hierarchy and still be able to do special painting for Components.

Parameters:
type the depth type to use for this Component.
See also:
ComponentDepth

int ui::Component::getDepth  )  const
 

Retreives the current Component depth.

Returns:
returns the current depth.

bool ui::Component::isContainer  )  const [virtual]
 

Wether the Component is a Container.

Returns:
false

Reimplemented in ui::Container.

bool ui::Component::isRootContainer  )  const [virtual]
 

Returns wether this Component is a Root level container.

Returns:
true if this is a root container, false otherwise.

Reimplemented in ui::Container, and ui::Window.

const ComponentList & ui::Component::getChildren  )  const
 

Returns the Components children as a stl list object.

Note:
this method will always return a list of size null, unless the Component is a Container.
See also:
Container
Returns:
the componentList containing all the children.

void ui::Component::setBorderPainted bool  enable  ) 
 

Enable or disable drawing of the Components border, if any.

Parameters:
enable true to paint the borders, false to ignore them.
Note:
this will only affect the visual aspect, not borders size calculation.

bool ui::Component::isBorderPainted  )  const
 

Returns true if the border is painted.

Returns:
true if the border is being painted, false otherwise.

bool ui::Component::hasBorder  )  const
 

Check to see if the Component has a border.

Returns:
true if the Component has a border, false otherwise.

void ui::Component::setBorder border::Border b  ) 
 

Replaces the Components border with the specified border. This also replaces the Components Insets with the borders Insets.

Parameters:
b border to use for this Component.
See also:
Insets, Border

border::Border * ui::Component::getBorder  )  const
 

Returns the active border.

void ui::Component::setInsets const util::Insets i  ) 
 

Sets the Insets for the Component.

Note:
Note that these might be replaces when a border is added to the Component.
See also:
Insets
Parameters:
i the inset to be used as new inset.

const util::Insets & ui::Component::getInsets  )  const
 

Returns the current Components Insets.

Returns:
The Components current Insets.

void ui::Component::setFont Font font  ) 
 

Sets the Font for this Component.

Parameters:
font Font to be used for this Component.
See also:
Font Character

Font * ui::Component::getFont  )  const
 

Returns the current Font for this Component.

Returns:
the Font used by this Component.

void ui::Component::processMouseEvent const event::MouseEvent e  ) 
 

Receives a MouseEvent for this Component and forwards it to all registered MouseListeners.

Parameters:
e the MouseEvent to process.

bool ui::Component::hasMouseListener  )  const
 

Check wether the Component has a MouseListener.

Returns:
true if the Component has a MouseListener, false otherwise.

void ui::Component::addMouseListener event::MouseListener l  ) 
 

Add a event::MouseListener to the Component.

Parameters:
l MouseListener to be registered for the Component.

void ui::Component::removeMouseListener event::MouseListener l  ) 
 

Remove the selected MouseListener.

Parameters:
l the MouseListener to be removed from the Component.

void ui::Component::removeMouseListeners  ) 
 

Removes all MouseListeners for this Component.

bool ui::Component::hasFocus  )  const
 

Check to see if the Component has focus.

Returns:
true if the Component has focus, false otherwise.

void ui::Component::setFocus bool  enable  ) 
 

Set the focus to the Component.

Parameters:
enable true if the Component is in focus, false to loose focus.

void ui::Component::processFocusEvent const event::FocusEvent e  ) 
 

Process the focus event and forward it to the specified component.

Parameters:
e the FocusEvent to be processed by this Component.

void ui::Component::addFocusListener event::FocusListener l  ) 
 

Add a event::FocusListener to the Component.

Parameters:
l FocusListener to be registered for the Component.

void ui::Component::removeFocusListener event::FocusListener l  ) 
 

Remove the selected FocusListener

Parameters:
l the FocusListener to be removed from this Component.

void ui::Component::removeFocusListeners  ) 
 

Removes all FocusListeners from this Component.

const event::FocusListenerList ui::Component::getFocusListeners  )  const
 

Returns all FocusListeners registered by this Component.

Returns:
return a list of all registered FocusListeners.

bool ui::Component::hasFocusListener  )  const
 

Check wether the Component has a FocusListener.

Returns:
true if the Component has a FocusListener, false otherwise.

bool ui::Component::canHoldPermanentFocus  )  const [virtual]
 

Returns wether or not this Component can be a permanent focus owner. This is true by default, except for things like MenuItems, where a menu is the permanent focus owner and a menuitem merely a focus owner.

Reimplemented in ui::Menu, and ui::MenuItem.

void ui::Component::addKeyListener event::KeyListener l  ) 
 

Add a event::KeyListener to the Component.

Parameters:
l KeyListener to be registered for the Component.

void ui::Component::removeKeyListener event::KeyListener l  ) 
 

Remove the selected KeyListener

Parameters:
l the KeyListener to be removed from the Component.

void ui::Component::removeKeyListeners  ) 
 

Removes all KeyListeners from this Component.

const event::KeyListenerList ui::Component::getKeyListeners  )  const
 

Returns all KeyListeners registered by this Component.

Returns:
returns a list of all registered KeyListeners for this Component.

bool ui::Component::hasKeyListener  )  const
 

Check wether the Component has a KeyListener.

Returns:
true if the Component has a KeyListener, false otherwise.

void ui::Component::processKeyEvent const event::KeyEvent e  ) 
 

Forward the KeyEvent to all registered Listeners.

Parameters:
e the KeyEvent to be processed by this Component.

void ui::Component::processPropertyEvent const event::PropertyEvent e  ) 
 

Forward the PropertyEvent to all registered Listeners.

Parameters:
e the PropertyEvent to be processed by this Component.

void ui::Component::addPropertyListener event::PropertyListener *  l  ) 
 

Add a event::PropertyListener to the Component.

Parameters:
l PropertyListener to be registered for the Component.

void ui::Component::removePropertyListener event::PropertyListener *  l  ) 
 

Remove the selected PropertyListener

Parameters:
l the PropertyListener to be removed from the Component.

void ui::Component::removePropertyListeners  ) 
 

Removes all KeyListeners from this Component.

const event::PropertyListenerList ui::Component::getPropertyListeners  )  const
 

Returns all PropertyListeners registered by this Component.

Returns:
returns a list of all registered PropertyListeners for this Component.

bool ui::Component::hasPropertyListener  )  const
 

Check wether the Component has a PropertyListener.

Returns:
true if the Component has a PropertyListener, false otherwise.

void ui::Component::updateComponent float  deltaTime  )  [virtual]
 

Update, for time based motion.

Parameters:
deltaTime time between two sequential frames. This can be used for calculating frame rate independant motion.

Reimplemented in ui::Container, and ui::Window.

void ui::Component::addInterpolator util::Interpolator i  ) 
 

Add an interpolator to this Component.

See also:
Interpolator

void ui::Component::removeInterpolator util::Interpolator i  ) 
 

Remove a specified interpolator from this Component.

Parameters:
i the Interpolator to be removed from this Component.

void ui::Component::removeInterpolators  ) 
 

Remove all interpolators from this Component.

void ui::Component::setTransparency float  f  ) 
 

Sets the transparency for this Component and it's children. Note that the transparency can range from 0.0 to 1.0.

Parameters:
f Transparency value for this Component and it's children.

float ui::Component::getTransparency  )  const
 

Returns the current transparency level for this Component and it's children.

Returns:
the current transparency value.

void ui::Component::setRotation float  r  ) 
 

Sets the rotation for this Component in degrees. Rotation is clockwise.

Parameters:
r The degrees by which to rotate.

float ui::Component::getRotation  )  const
 

Returns the rotation for this Component in degrees.

See also:
setRotation


Member Data Documentation

float ui::Component::depth [protected]
 

Depth value for this Component.

ComponentList ui::Component::componentList [protected]
 

A container containing Components. we already declare this here, so it's available to every Component.

util::Dimension ui::Component::preferredSize [mutable, protected]
 

Cache values for the Dimension so we do not have to recalculate it at every frame (although that works fine too). This variable is made mutable so we can change it in const members. As preferredSize is a cache value, it does not affect the object state towards the user.


Generated on Mon Jun 20 19:41:41 2005 for UI by doxygen 1.3.1 using KingsTools