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

ONE::gui::Console Class Reference

Inheritance diagram for ONE::gui::Console:

Inheritance graph
[legend]
List of all members.

Detailed Description

a Component that allows command line style interaction with the system core

The console displays an input field and a command history. It may be connected to the core via the two way listener interface similar to

 Console* c;
 ...
 core->addListener(c->getInputListener());
 c->addListener(core);
Systems that use the Console with ONE 's standard scripting host may also use the facilities provided by the ConsoleManager.

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
typedef TextListener * LPtr

Public Member Functions

virtual void add (Component *, const LayoutConstraint *)
void addTextListener (const LPtr &l)
virtual void clear ()
bool clearsInputOnExecute () const
 see CommandField::clearsOnExecute
 Console (const ListModelPtr &mdl=new ListModel())
 creates a Console with the given model used for the history list.
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.
 EventDispatcher ()
void fireEvent (TextEvent &e) const
 notifies all registered listeners
Color getBackground () const
 accesses the color that should be used to render the object's background.
const BoundsgetBounds () const
 accesses this object's bounds
int getChildCount () const
ChildConstItrSP getChildren () const
ChildItrSP getChildren ()
const ListModelPtrgetConsoleModel () const
virtual const IMSPgetDefaultInputMap () const
 accesses this widget's default input map
const UIDSPgetDelegate () const
DelegateID getDelegateID () const
 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
const FntSPgetFont () const
Color getForeground () const
 accesses the color that should be used to render the object's foreground.
TextListenergetInputListener ()
 accesses the input listener
const IMSPgetInputMap () const
WidgetgetParent () const
const PointgetPosition () const
 accesses this object's position
Size getPreferredSize () const
 determines this object's preferred size.
const SizegetSize () const
 accesses this object's size
bool hasChildren () const
bool hasFocus () const
 checks if this component has the input focus
bool isEchoEnabled () const
 checks if the console echos commands entered into the input field.
bool isEnabled () const
 checks if this widget is enabled
bool isMuted () const
 reflects this dispatcher's muted state.
bool isOpaque () const
 checks this object's opacity
virtual bool isUnder (const Point &) const
virtual bool isVisible () const
 acesses the visibility property
void layout ()
 lays out this component's internal elements
void processKeyEvent (KeyEvent &)
 notifies the widget of a key event
void processMouseMotion (MouseEvent &)
 notifies the widget of a mouse motion
void processMousePress (MouseEvent &)
 notifies the widget of a pressed mouse button
void processMouseRelease (MouseEvent &)
 notifies the widget of a released mouse button
void releaseFocus () const
 drops the input focus
virtual void remove (Component *)
void removeTextListener (const LPtr &l)
bool requestFocus ()
 requests the input focus for this component.
bool requestFocusForInput ()
 requests the focus for the console's input field
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 setClearInputOnExecute (bool c)
 see CommandField::setClearOnExecute
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
void setEchoEnabled (bool e)
 enables command echo
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 setFont (const FntSP &fnt, bool laf=true)
void setForeground (const Color &c, bool laf=true)
 changes this object's foreground color
void setInputMap (const IMSP &im, bool laf=true)
void setMuted (bool mute)
 mutes or un-mutes the dispatcher
void setOpaque (bool o, bool laf=true)
 changes this object's opacity
void setParent (Widget *p)
 changes this component's parent
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)
void updateUI ()
 ~Console ()

Protected Types

typedef unsigned int bits

Protected Member Functions

void add (const LPtr &l)
 registers a listener
void doDraw (Renderer2D *, const int &, const int &, const int &, const int &)
 performs subclass-specific drawing
bool getBit (const bits &bit) const
void remove (const LPtr &l)
 de-registers a listener.
void setBit (const bits &bit, bool val)

Protected Attributes

Size prefSize

Static Protected Attributes

static const bits ECHO
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

Classes

class  ConsoleListener
class  InputListener


Member Typedef Documentation

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

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

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

typedef ONE::util::Iterator<Widget*> ONE::gui::Widget::ChildItr [inherited]
 

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

typedef TextListener * ONE::util::EventDispatcher< TextEvent , TextListener , struct TextRelay >::LPtr [inherited]
 


Constructor & Destructor Documentation

ONE::gui::Console::Console const ListModelPtr mdl = new ListModel()  ) 
 

creates a Console with the given model used for the history list.

If no model is given, a new one will be created automatically.

Parameters:
mdl a (possibly shared) list model

ONE::gui::Console::~Console  ) 
 


Member Function Documentation

void ONE::util::EventDispatcher< TextEvent , TextListener , struct TextRelay >::add const LPtr l  )  [protected, inherited]
 

registers a listener

Parameters:
l a listener

virtual void ONE::gui::Component::add Component ,
const LayoutConstraint
[virtual, inherited]
 

the default implementation of this function does nothing

Implements ONE::gui::Widget.

Reimplemented in ONE::gui::Panel.

void ONE::util::TextDispatcher::addTextListener const LPtr l  )  [inline, inherited]
 

virtual void ONE::gui::Component::clear  )  [virtual, inherited]
 

the default implementation of this function does nothing

Implements ONE::gui::Widget.

Reimplemented in ONE::gui::Panel.

bool ONE::gui::Console::clearsInputOnExecute  )  const
 

see CommandField::clearsOnExecute

void ONE::gui::Console::doDraw Renderer2D ,
const int &  ,
const int &  ,
const int &  ,
const int & 
[protected, virtual]
 

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

Implements ONE::gui::Displayable.

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.

ONE::util::EventDispatcher< TextEvent , TextListener , struct TextRelay >::EventDispatcher  )  [inherited]
 

void ONE::util::EventDispatcher< TextEvent , TextListener , struct TextRelay >::fireEvent TextEvent e  )  const [inherited]
 

notifies all registered listeners

The listeners are called in the order in which they were added.
This function is provided primarily for use by subclasses. However, it may also be called from the outside in order to inject events into the system. Note that great care should be taken when doing so. For example, listeners generally rely on the event's source being identical to the instance that passes them around, i.e. this event dispatcher.

Parameters:
e the event to forward to each listener

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

int ONE::gui::Console::getChildCount  )  const [virtual]
 

the default implementation of this function returns 0

Reimplemented from ONE::gui::Component.

ChildConstItrSP ONE::gui::Console::getChildren  )  const [virtual]
 

the default implementation of this function returns 0

Reimplemented from ONE::gui::Component.

ChildItrSP ONE::gui::Console::getChildren  )  [virtual]
 

the default implementation of this function returns 0

Reimplemented from ONE::gui::Component.

const ListModelPtr& ONE::gui::Console::getConsoleModel  )  const
 

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

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]
 

DelegateID ONE::gui::Console::getDelegateID  )  const [virtual]
 

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

Implements ONE::gui::Displayable.

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

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, inherited]
 

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, inherited]
 

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

Returns:
a color

const FntSP& ONE::gui::Console::getFont  )  const
 

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

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

Returns:
a color

TextListener* ONE::gui::Console::getInputListener  ) 
 

accesses the input listener

This listener is used to feed lines into the console history. It is the main line of communication from the core to the Console.

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

Widget* ONE::gui::Component::getParent  )  const [virtual, inherited]
 

Returns:
this object's parent

Implements ONE::gui::Widget.

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

accesses this object's position

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

Size ONE::gui::Console::getPreferredSize  )  const [virtual]
 

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.

Implements ONE::gui::Displayable.

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

accesses this object's size

Returns:
the size of this object's bounding rectangle

bool ONE::gui::Console::hasChildren  )  const [virtual]
 

the default implementation of this function returns false

Reimplemented from ONE::gui::Component.

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

checks if this component has the input focus

This function queries the FocusManager.

Returns:
true if this component is focused

Implements ONE::gui::Control.

bool ONE::gui::Console::isEchoEnabled  )  const
 

checks if the console echos commands entered into the input field.

Returns:
true if executed commands are appended to the history, false otherwise

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

checks if this widget is enabled

Returns:
true if is enabled, false otherwise

Implements ONE::gui::Control.

bool ONE::util::EventDispatcher< TextEvent , TextListener , struct TextRelay >::isMuted  )  const [inherited]
 

reflects this dispatcher's muted state.

Returns:
true if the dispatcher is muted, false otherwise

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, inherited]
 

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

void ONE::gui::Console::layout  )  [virtual]
 

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.

Implements ONE::gui::Displayable.

void ONE::gui::Console::processKeyEvent KeyEvent  )  [virtual]
 

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.

Implements ONE::gui::Control.

void ONE::gui::Console::processMouseMotion MouseEvent  )  [virtual]
 

notifies the widget of a mouse motion

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

Implements ONE::gui::Control.

void ONE::gui::Console::processMousePress MouseEvent  )  [virtual]
 

notifies the widget of a pressed mouse button

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

Implements ONE::gui::Control.

void ONE::gui::Console::processMouseRelease MouseEvent  )  [virtual]
 

notifies the widget of a released mouse button

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

Implements ONE::gui::Control.

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

drops the input focus

Implements ONE::gui::Control.

void ONE::util::EventDispatcher< TextEvent , TextListener , struct TextRelay >::remove const LPtr l  )  [protected, inherited]
 

de-registers a listener.

This listener will no longer notify l of events, unless l is registered more than once. If so, a call to this function will only remove the first occurence of l.

Parameters:
l a listener

virtual void ONE::gui::Component::remove Component  )  [virtual, inherited]
 

the default implementation of this function does nothing

Implements ONE::gui::Widget.

Reimplemented in ONE::gui::Panel.

void ONE::util::TextDispatcher::removeTextListener const LPtr l  )  [inline, inherited]
 

bool ONE::gui::Component::requestFocus  )  [virtual, inherited]
 

requests the input focus for this component.

The FocusManager may deny the request, see FocusManager::requestFocus() for details.

Returns:
if the request was granted

Implements ONE::gui::Control.

bool ONE::gui::Console::requestFocusForInput  ) 
 

requests the focus for the console's input field

Returns:
if the request was granted

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::Console::setClearInputOnExecute bool  c  ) 
 

see CommandField::setClearOnExecute

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

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
[inherited]
 

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

void ONE::gui::Console::setEchoEnabled bool  e  ) 
 

enables command echo

This property may also be controlled by typing the ECHO_ON_CMD or the ECHO_OFF_CMD command into the input field.

Parameters:
e true to append executed commands to the history, false to disable this

void ONE::gui::Console::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.

Reimplemented from ONE::gui::Widget.

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

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::Console::setFont const FntSP fnt,
bool  laf = true
 

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
[inherited]
 

void ONE::util::EventDispatcher< TextEvent , TextListener , struct TextRelay >::setMuted bool  mute  )  [inherited]
 

mutes or un-mutes the dispatcher

Muted dispatchers no longer notify their listeners.

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::Component::setParent Widget p  )  [inherited]
 

changes this component's parent

If a previous parent was set, this component will be removed from it.

Parameters:
p the new parent

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, inherited]
 

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

Reimplemented from ONE::gui::Displayable.

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

Updates the super class and the widget's InputMap.

Reimplemented from ONE::gui::Widget.


Member Data Documentation

const bits ONE::gui::Console::ECHO [static, protected]
 

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

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:16 2005 for ONEngine by  doxygen 1.4.3