Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ONE::gui::Widget Class Reference

Inheritance diagram for ONE::gui::Widget:

Inheritance graph
[legend]
List of all members.

Detailed Description

a Displayable Control

The widget carries an InputMap which may be used to map input events to actions in a LaF specific way.

Author:
Daniel Seibert


Public Types

typedef ONE::util::ConstIterator<
const Widget * > 
ChildConstItr
typedef ONE::util::SmartPointer<
ChildConstItr, ONE::util::DestructiveCopy
ChildConstItrSP
typedef ONE::util::Iterator<
Widget * > 
ChildItr
typedef ONE::util::SmartPointer<
ChildItr, ONE::util::DestructiveCopy
ChildItrSP

Public Member Functions

virtual void add (Component *comp, const LayoutConstraint *cons)=0
 adds a child
virtual void clear ()=0
 removes all children
void draw (Renderer2D *r, const int &x, const int &y, const int &w, const int &h)
 draws a portion of this object
void draw (Renderer2D *)
 draws this object.
Color getBackground () const
 accesses the color that should be used to render the object's background.
const BoundsgetBounds () const
 accesses this object's bounds
virtual int getChildCount () const =0
virtual ChildConstItrSP getChildren () const =0
 accesses this object's children
virtual ChildItrSP getChildren ()=0
 accesses this object's children
virtual const IMSPgetDefaultInputMap () const
 accesses this widget's default input map
const UIDSPgetDelegate () const
virtual DelegateID getDelegateID () const =0
 accesses the ID that identifies the object's UIDelegate type
Color getDisabledBackground () const
 accesses the color that should be used to render the object's background when the object is disabled
Color getDisabledForeground () const
 accesses the color that should be used to render the object's foreground when the object is disabled.
Color getFocus () const
 accesses the color that should be used to render the component focus
Color getForeground () const
 accesses the color that should be used to render the object's foreground.
const IMSPgetInputMap () const
virtual WidgetgetParent () const =0
const PointgetPosition () const
 accesses this object's position
virtual Size getPreferredSize () const =0
 determines this object's preferred size.
const SizegetSize () const
 accesses this object's size
virtual bool hasChildren () const =0
virtual bool hasFocus () const =0
 checks if this object has the keyboard focus
bool isEnabled () const
 checks if this widget is enabled
bool isOpaque () const
 checks this object's opacity
virtual bool isUnder (const Point &) const
virtual bool isVisible () const
 acesses the visibility property
virtual void layout ()=0
 lays out this component's internal elements
virtual void processKeyEvent (KeyEvent &evt)=0
 notifies the widget of a key event
virtual void processMouseMotion (MouseEvent &evt)=0
 notifies the widget of a mouse motion
virtual void processMousePress (MouseEvent &evt)=0
 notifies the widget of a pressed mouse button
virtual void processMouseRelease (MouseEvent &evt)=0
 notifies the widget of a released mouse button
virtual void releaseFocus () const =0
 drops the input focus
virtual void remove (Component *comp)=0
 removes a child
virtual bool requestFocus ()=0
 attempts to get the input focus for this object
void scheduleLayout ()
 schedules a call to layout
void setBackground (const Color &c, bool laf=true)
 changes this object's background color
void setBounds (const int &x, const int &y, const int &w, const int &h)
void setBounds (const Bounds &b)
 changes this object's bounds
void setDisabledBackground (const Color &c, bool laf=true)
 changes this object's disabled background color
void setDisabledForeground (const Color &c, bool laf=true)
 changes this object's disabled foreground color
virtual void setEnabled (bool)
 enables or disables this component
void setFocus (const Color &c, bool laf=true)
 changes the color that will be used to draw the component focus marker
void setForeground (const Color &c, bool laf=true)
 changes this object's foreground color
void setInputMap (const IMSP &im, bool laf=true)
void setOpaque (bool o, bool laf=true)
 changes this object's opacity
void setPosition (const int &x, const int &y)
void setPosition (const Point &p)
 changes this object's position
void setPreferredSize (const Size &s)
 sets the object's preferred size
void setSize (const int &w, const int &h)
void setSize (const Size &s)
 changes this object's size
virtual void setVisible (bool vis)
virtual void updateUI ()
 Widget (bool visible=true)
virtual ~Widget ()

Protected Types

typedef unsigned int bits

Protected Member Functions

virtual void doDraw (Renderer2D *r, const int &x, const int &y, const int &w, const int &h)=0
 performs subclass-specific drawing
bool getBit (const bits &bit) const
void setBit (const bits &bit, bool val)

Protected Attributes

Size prefSize

Static Protected Attributes

static const bits ENABLED
static const bits LSCHED
 set when this object is scheduled to be laid out
static const bits OPQ
 opacity bit
static const bits VIS
 visibility bit


Member Typedef Documentation

typedef unsigned int ONE::gui::Displayable::bits [protected, inherited]
 

typedef ONE::util::ConstIterator<const Widget*> ONE::gui::Widget::ChildConstItr
 

typedef ONE::util::SmartPointer<ChildConstItr,ONE::util::DestructiveCopy> ONE::gui::Widget::ChildConstItrSP
 

typedef ONE::util::Iterator<Widget*> ONE::gui::Widget::ChildItr
 

typedef ONE::util::SmartPointer<ChildItr,ONE::util::DestructiveCopy> ONE::gui::Widget::ChildItrSP
 


Constructor & Destructor Documentation

ONE::gui::Widget::Widget bool  visible = true  ) 
 

virtual ONE::gui::Widget::~Widget  )  [virtual]
 


Member Function Documentation

virtual void ONE::gui::Widget::add Component comp,
const LayoutConstraint cons
[pure virtual]
 

adds a child

Implemented in ONE::gui::Component, ONE::gui::Panel, and ONE::gui::Window.

virtual void ONE::gui::Widget::clear  )  [pure virtual]
 

removes all children

Implemented in ONE::gui::Component, ONE::gui::Panel, and ONE::gui::Window.

virtual void ONE::gui::Displayable::doDraw Renderer2D r,
const int &  x,
const int &  y,
const int &  w,
const int &  h
[protected, pure virtual, inherited]
 

performs subclass-specific drawing

Implementations of this function may assume that this object is visible and that r is in 2D mode.

Parameters:
r the renderer used to draw this object
x the left edge of the drawable area
y the top edge of the drawable are
w the width of the drawable area
h the height of the drawable are

Implemented in ONE::gui::Console, ONE::gui::Frame, ONE::gui::Label, ONE::gui::List, ONE::gui::Panel, ONE::gui::Picture, ONE::gui::ScrollBar, ONE::gui::ScrollBarSlider, ONE::gui::TextField, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

void ONE::gui::Displayable::draw Renderer2D r,
const int &  x,
const int &  y,
const int &  w,
const int &  h
[inherited]
 

draws a portion of this object

This function calls doDraw(Renderer2D*,int,int,int,int) if this object is set to visible. Note that the renderer must be active in 2D mode.

Parameters:
r the renderer used to draw this object
x the left edge of the drawn area
y the top edge of the drawn are
w the width of the drawn area
h the height of the drawn are

void ONE::gui::Displayable::draw Renderer2D  )  [inline, inherited]
 

draws this object.

This function calls draw(Renderer2D*,int,int,int,int) with this object's bounds.

Color ONE::gui::Displayable::getBackground  )  const [inline, inherited]
 

accesses the color that should be used to render the object's background.

Returns:
a color

bool ONE::gui::Displayable::getBit const bits bit  )  const [inline, protected, inherited]
 

const Bounds & ONE::gui::Displayable::getBounds  )  const [inline, inherited]
 

accesses this object's bounds

The Bounds object represents the position of the top left corner as well as the size of this object's bounding rectangle.

Returns:
this object's bounds

virtual int ONE::gui::Widget::getChildCount  )  const [pure virtual]
 

Returns:
the number of child Widget s

Implemented in ONE::gui::Component, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Panel, ONE::gui::ScrollBar, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

virtual ChildConstItrSP ONE::gui::Widget::getChildren  )  const [pure virtual]
 

accesses this object's children

If this object has no children, this function must return 0. If children overlap, the returned iterator must traverse them in front to back order. The returned children may not be modified.

Returns:
an iterator that goes through all of this widget's children in front to back order or 0 if this widget has no children

Implemented in ONE::gui::Component, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Panel, ONE::gui::ScrollBar, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

virtual ChildItrSP ONE::gui::Widget::getChildren  )  [pure virtual]
 

accesses this object's children

If this object has no children, this function must return 0. If children overlap, the returned iterator must traverse them in front to back order. The returned children may be modified.

Returns:
an iterator that goes through all of this widget's children in front to back order or 0 if this widget has no children

Implemented in ONE::gui::Component, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Panel, ONE::gui::ScrollBar, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

virtual const IMSP& ONE::gui::Widget::getDefaultInputMap  )  const [virtual]
 

accesses this widget's default input map

The default implementation returns an empty map. Subclasses may override this function in order to specify a different default map.

Returns:
the widget's default input map

Reimplemented in ONE::gui::AbstractButton, ONE::gui::CommandField, ONE::gui::Frame, ONE::gui::List, and ONE::gui::ScrollBarSlider.

const UIDSP & ONE::gui::Displayable::getDelegate  )  const [inline, inherited]
 

virtual DelegateID ONE::gui::Displayable::getDelegateID  )  const [pure virtual, inherited]
 

accesses the ID that identifies the object's UIDelegate type

Subclasses of this class must override this function in order to receive a proper delegate. See LookAndFeel for details.

Returns:
the delegate id

Implemented in ONE::gui::Button, ONE::gui::CheckBox, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Label, ONE::gui::List, ONE::gui::Panel, ONE::gui::Picture, ONE::gui::RadioButton, ONE::gui::ScrollBar, ONE::gui::ScrollBarSlider, ONE::gui::TextField, ONE::gui::TitleBar, ONE::gui::ToggleButton, ONE::gui::Viewport, and ONE::gui::Window.

Color ONE::gui::Widget::getDisabledBackground  )  const [inline]
 

accesses the color that should be used to render the object's background when the object is disabled

Returns:
a color

Color ONE::gui::Widget::getDisabledForeground  )  const [inline]
 

accesses the color that should be used to render the object's foreground when the object is disabled.

Returns:
a color

Color ONE::gui::Widget::getFocus  )  const [inline]
 

accesses the color that should be used to render the component focus

Returns:
a color

Color ONE::gui::Displayable::getForeground  )  const [inline, inherited]
 

accesses the color that should be used to render the object's foreground.

Returns:
a color

const IMSP & ONE::gui::Widget::getInputMap  )  const [inline]
 

virtual Widget* ONE::gui::Widget::getParent  )  const [pure virtual]
 

Returns:
this object's parent

Implemented in ONE::gui::Component, and ONE::gui::Window.

const Point & ONE::gui::Displayable::getPosition  )  const [inline, inherited]
 

accesses this object's position

Returns:
the position of this object's top left corner

virtual Size ONE::gui::Displayable::getPreferredSize  )  const [pure virtual, inherited]
 

determines this object's preferred size.

If this object has a non-degenerate preferred size (i.e. Size::isZero returns false), that value is returned. Otherwise, this function calculates the optimal size for this object.

Implemented in ONE::gui::Console, ONE::gui::Frame, ONE::gui::Label, ONE::gui::List, ONE::gui::Panel, ONE::gui::Picture, ONE::gui::ScrollBar, ONE::gui::ScrollBarSlider, ONE::gui::TextField, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

const Size & ONE::gui::Displayable::getSize  )  const [inline, inherited]
 

accesses this object's size

Returns:
the size of this object's bounding rectangle

virtual bool ONE::gui::Widget::hasChildren  )  const [pure virtual]
 

Returns:
if this object has children

Implemented in ONE::gui::Component, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Panel, ONE::gui::ScrollBar, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

virtual bool ONE::gui::Control::hasFocus  )  const [pure virtual, inherited]
 

checks if this object has the keyboard focus

Returns:
true if this object has the input focus, false otherwise

Implemented in ONE::gui::Component, and ONE::gui::TopLevel.

bool ONE::gui::Widget::isEnabled  )  const [inline, virtual]
 

checks if this widget is enabled

Returns:
true if is enabled, false otherwise

Implements ONE::gui::Control.

bool ONE::gui::Displayable::isOpaque  )  const [inline, inherited]
 

checks this object's opacity

objects that are set to not opaque (i.e. transparent) should not draw their background display.

Returns:
if this object is set to opaque

virtual bool ONE::gui::Widget::isUnder const Point  )  const [virtual]
 

This implementation checks if the given point is within the widget's bounds and then queries the delegate.

Implements ONE::gui::Control.

Reimplemented in ONE::gui::Picture.

bool ONE::gui::Displayable::isVisible  )  const [inline, virtual, inherited]
 

acesses the visibility property

The default value is true. However, subclasses may choose to change this.

Returns:
true if the object is visible

virtual void ONE::gui::Displayable::layout  )  [pure virtual, inherited]
 

lays out this component's internal elements

This function may not change this object's bounds. Implementations should lay out their internal elements according to the currently set bounds.
The provided implementation de-schedules layouting for this object. Overriding classes must make sure they call Displayable::layout if not the layout function of their immediate superclass.

Implemented in ONE::gui::Console, ONE::gui::Frame, ONE::gui::Label, ONE::gui::List, ONE::gui::Panel, ONE::gui::Picture, ONE::gui::ScrollBar, ONE::gui::ScrollBarSlider, ONE::gui::TextField, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

virtual void ONE::gui::Control::processKeyEvent KeyEvent evt  )  [pure virtual, inherited]
 

notifies the widget of a key event

If this is not a top level container and the widget processes the event, it must call the events consume function. Otherwise evt will also be passed to this object's top level parent.

Implemented in ONE::gui::AbstractButton, ONE::gui::CommandField, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Label, ONE::gui::List, ONE::gui::Panel, ONE::gui::Picture, ONE::gui::ScrollBar, ONE::gui::ScrollBarSlider, ONE::gui::TextField, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

virtual void ONE::gui::Control::processMouseMotion MouseEvent evt  )  [pure virtual, inherited]
 

notifies the widget of a mouse motion

This event may occur both inside and outside of this object's bounds.

Implemented in ONE::gui::AbstractButton, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Label, ONE::gui::List, ONE::gui::Panel, ONE::gui::Picture, ONE::gui::ScrollBar, ONE::gui::ScrollBarSlider, ONE::gui::TextField, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

virtual void ONE::gui::Control::processMousePress MouseEvent evt  )  [pure virtual, inherited]
 

notifies the widget of a pressed mouse button

Implementations may assume that the mouse position is on this widget (i.e. isUnder returned true).

Implemented in ONE::gui::AbstractButton, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Label, ONE::gui::List, ONE::gui::Panel, ONE::gui::Picture, ONE::gui::ScrollBar, ONE::gui::ScrollBarSlider, ONE::gui::TextField, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

virtual void ONE::gui::Control::processMouseRelease MouseEvent evt  )  [pure virtual, inherited]
 

notifies the widget of a released mouse button

This event may occur both inside and outside of this object's bounds.

Implemented in ONE::gui::AbstractButton, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Label, ONE::gui::List, ONE::gui::Panel, ONE::gui::Picture, ONE::gui::ScrollBar, ONE::gui::ScrollBarSlider, ONE::gui::TextField, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.

virtual void ONE::gui::Control::releaseFocus  )  const [pure virtual, inherited]
 

drops the input focus

Implemented in ONE::gui::Component, and ONE::gui::TopLevel.

virtual void ONE::gui::Widget::remove Component comp  )  [pure virtual]
 

removes a child

Implemented in ONE::gui::Component, ONE::gui::Panel, and ONE::gui::Window.

virtual bool ONE::gui::Control::requestFocus  )  [pure virtual, inherited]
 

attempts to get the input focus for this object

The function may not succeed in acquiring the focus in some situations. For example, calling this function on a top level container while a modal Frame is visible will fail.

Returns:
if the request was granted

Implemented in ONE::gui::Component, and ONE::gui::TopLevel.

void ONE::gui::Displayable::scheduleLayout  )  [inherited]
 

schedules a call to layout

This function makes component layout more efficient as several calls to this function within one frame duration result in only one call to layout.

void ONE::gui::Displayable::setBackground const Color c,
bool  laf = true
[inherited]
 

changes this object's background color

The setting is active immediately. If laf is true (the default), the setting is propagated to the GuiManager as an individual setting.

Parameters:
c the new background color
laf if the setting should be propagated to the GuiManager

void ONE::gui::Displayable::setBit const bits bit,
bool  val
[inline, protected, inherited]
 

void ONE::gui::Displayable::setBounds const int &  x,
const int &  y,
const int &  w,
const int &  h
[inline, inherited]
 

void ONE::gui::Displayable::setBounds const Bounds b  )  [inline, inherited]
 

changes this object's bounds

See setSize and setPosition

Parameters:
b the new bounds

void ONE::gui::Widget::setDisabledBackground const Color c,
bool  laf = true
 

changes this object's disabled background color

The setting is active immediately. If laf is true (the default), the setting is propagated to the GuiManager as an individual setting.

Parameters:
c the new background color
laf if the setting should be propagated to the GuiManager

void ONE::gui::Widget::setDisabledForeground const Color c,
bool  laf = true
 

changes this object's disabled foreground color

The setting is active immediately. If laf is true (the default), the setting is propagated to the GuiManager as an individual setting.

Parameters:
c the new foreground color
laf if the setting should be propagated to the GuiManager

virtual void ONE::gui::Widget::setEnabled bool   )  [virtual]
 

enables or disables this component

Disabled components no longer react to user input. If this object has children, they are modified accordingly.

Implements ONE::gui::Control.

Reimplemented in ONE::gui::Button, ONE::gui::Console, ONE::gui::Frame, and ONE::gui::TitleBar.

void ONE::gui::Widget::setFocus const Color c,
bool  laf = true
 

changes the color that will be used to draw the component focus marker

The setting is active immediately. If laf is true (the default), the setting is propagated to the GuiManager as an individual setting.

Parameters:
c the new focus color
laf if the setting should be propagated to the GuiManager

void ONE::gui::Displayable::setForeground const Color c,
bool  laf = true
[inherited]
 

changes this object's foreground color

The setting is active immediately. If laf is true (the default), the setting is propagated to the GuiManager as an individual setting.

Parameters:
c the new foreground color
laf if the setting should be propagated to the GuiManager

void ONE::gui::Widget::setInputMap const IMSP im,
bool  laf = true
 

void ONE::gui::Displayable::setOpaque bool  o,
bool  laf = true
[inherited]
 

changes this object's opacity

The setting is active immediately. If laf is true (the default), the setting is propagated to the GuiManager as an individual setting.

Parameters:
o the new opacity setting
laf if the setting should be propagated to the GuiManager

void ONE::gui::Displayable::setPosition const int &  x,
const int &  y
[inline, inherited]
 

void ONE::gui::Displayable::setPosition const Point p  )  [inline, inherited]
 

changes this object's position

Note that this function does not request a re-layout.

Parameters:
p the new position for the object's top left corner

void ONE::gui::Displayable::setPreferredSize const Size s  )  [inline, inherited]
 

sets the object's preferred size

If the value is set to an empty size object, the component will calculate its preferred size.

Parameters:
s the preferred size or a Size object with either a width or a height of 0

void ONE::gui::Displayable::setSize const int &  w,
const int &  h
[inline, inherited]
 

void ONE::gui::Displayable::setSize const Size s  )  [inline, inherited]
 

changes this object's size

Note that this function does not request a re-layout.

Parameters:
s the new size

void ONE::gui::Widget::setVisible bool  vis  )  [inline, virtual]
 

This function releases the input focus if the widget is set to invisible.

Reimplemented from ONE::gui::Displayable.

virtual void ONE::gui::Widget::updateUI  )  [virtual]
 

Updates the super class and the widget's InputMap.

Reimplemented from ONE::gui::Displayable.

Reimplemented in ONE::gui::AbstractButton, ONE::gui::CheckBox, ONE::gui::CommandField, ONE::gui::Console, ONE::gui::Frame, ONE::gui::Label, ONE::gui::List, ONE::gui::Panel, ONE::gui::RadioButton, ONE::gui::ScrollBar, ONE::gui::TextField, ONE::gui::TitleBar, ONE::gui::Viewport, and ONE::gui::Window.


Member Data Documentation

const bits ONE::gui::Widget::ENABLED [static, protected]
 

const bits ONE::gui::Displayable::LSCHED [static, protected, inherited]
 

set when this object is scheduled to be laid out

const bits ONE::gui::Displayable::OPQ [static, protected, inherited]
 

opacity bit

Size ONE::gui::Displayable::prefSize [protected, inherited]
 

const bits ONE::gui::Displayable::VIS [static, protected, inherited]
 

visibility bit


Generated on Wed Sep 7 19:03:22 2005 for ONEngine by  doxygen 1.4.3