gcn::Window Class Reference

#include <window.hpp>

Inheritance diagram for gcn::Window:

gcn::Container gcn::MouseListener gcn::BasicContainer gcn::Widget List of all members.

Detailed Description

A movable window which can conatin another Widget.

Definition at line 71 of file window.hpp.

Public Member Functions

 Window ()
 Constructor.
 Window (const std::string &caption)
 Constructor.
virtual ~Window ()
 Destructor.
virtual void setCaption (const std::string &caption)
 Sets the Window caption.
virtual const std::string & getCaption () const
 Gets the Window caption.
virtual void setAlignment (unsigned int alignment)
 Sets the alignment for the caption.
virtual unsigned int getAlignment () const
 Gets the alignment for the caption.
virtual void setPadding (unsigned int padding)
 Sets the padding of the window which is the distance between the window border and the content.
virtual unsigned int getPadding () const
 Gets the padding.
virtual void setTitleBarHeight (unsigned int height)
 Sets the title bar height.
virtual unsigned int getTitleBarHeight ()
 Gets the title bar height.
virtual void setMovable (bool movable)
 Sets the Window to be moveble.
virtual bool isMovable () const
 Check if the window is movable.
virtual void setOpaque (bool opaque)
 Sets the Window to be opaque.
virtual bool isOpaque ()
 Checks if the Window is opaque.
virtual void resizeToContent ()
 Resizes the container to fit the content exactly.
virtual Rectangle getChildrenArea ()
 Gets the subarea of the BasicContainer that the children occupy.
virtual void draw (Graphics *graphics)
 Draws the Widget.
virtual void drawBorder (Graphics *graphics)
 Draws the Widget border.
virtual void mousePress (int x, int y, int button)
 Called when a mouse button is pressed when the mouse is in the Widget area or if the Widget has focus.
virtual void mouseRelease (int x, int y, int button)
 Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus.
virtual void mouseMotion (int x, int y)
 Called when the mouse moves and the mouse is in the Widget area or if the Widget has focus.

Protected Attributes

std::string mCaption
unsigned int mAlignment
unsigned int mPadding
unsigned int mTitleBarHeight
bool mMouseDrag
int mMouseXOffset
int mMouseYOffset
bool mMovable
bool mOpaque


Constructor & Destructor Documentation

gcn::Window::Window ( const std::string &  caption  ) 

Constructor.

Parameters:
caption the Window caption.

Definition at line 82 of file window.cpp.

References gcn::Widget::addMouseListener(), mMouseDrag, setAlignment(), gcn::Widget::setBorderSize(), setCaption(), setMovable(), setOpaque(), setPadding(), and setTitleBarHeight().


Member Function Documentation

void gcn::Window::draw ( Graphics graphics  )  [virtual]

Draws the Widget.

It is called by the parent widget when it is time for the Widget to draw itself. The graphics object is set up so that all drawing is relative to the Widget, i.e coordinate (0,0) is the top-left corner of the Widget. It is not possible to draw outside of a Widgets dimension.

Parameters:
graphics a Graphics object to draw with.

Reimplemented from gcn::Container.

Definition at line 139 of file window.cpp.

References gcn::Color::a, gcn::BasicContainer::drawChildren(), gcn::Graphics::drawLine(), gcn::Graphics::drawText(), gcn::Graphics::fillRectangle(), getAlignment(), gcn::Widget::getBaseColor(), gcn::Widget::getBorderSize(), getCaption(), getChildrenArea(), gcn::Widget::getFont(), gcn::Widget::getForegroundColor(), gcn::Font::getHeight(), gcn::Widget::getHeight(), getTitleBarHeight(), gcn::Widget::getWidth(), gcn::Rectangle::height, isOpaque(), gcn::Graphics::setColor(), gcn::Graphics::setFont(), gcn::Rectangle::width, gcn::Rectangle::x, and gcn::Rectangle::y.

void gcn::Window::drawBorder ( Graphics graphics  )  [virtual]

Draws the Widget border.

A border is drawn around a Widget. The width and height of the border is therefore the Widgets height+2*bordersize. Think of a painting that has a certain size, the border surrounds the painting.

Parameters:
graphics a Graphics object to draw with.

Reimplemented from gcn::Container.

Definition at line 232 of file window.cpp.

References gcn::Color::a, gcn::Graphics::drawLine(), gcn::Widget::getBaseColor(), gcn::Widget::getBorderSize(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), and gcn::Graphics::setColor().

unsigned int gcn::Window::getAlignment (  )  const [virtual]

Gets the alignment for the caption.

Returns:
alignment of caption.

Definition at line 134 of file window.cpp.

References mAlignment.

Referenced by draw().

const std::string & gcn::Window::getCaption (  )  const [virtual]

Gets the Window caption.

Returns:
the Window caption.

Definition at line 124 of file window.cpp.

References mCaption.

Referenced by draw().

Rectangle gcn::Window::getChildrenArea (  )  [virtual]

Gets the subarea of the BasicContainer that the children occupy.

Returns:
the subarea as a Rectangle.

Reimplemented from gcn::BasicContainer.

Definition at line 289 of file window.cpp.

References gcn::Widget::getHeight(), getPadding(), getTitleBarHeight(), and gcn::Widget::getWidth().

Referenced by draw().

unsigned int gcn::Window::getPadding (  )  const [virtual]

Gets the padding.

Returns:
the padding value.

Definition at line 104 of file window.cpp.

References mPadding.

Referenced by getChildrenArea(), mousePress(), and resizeToContent().

unsigned int gcn::Window::getTitleBarHeight (  )  [virtual]

Gets the title bar height.

Returns:
the title bar height.

Definition at line 114 of file window.cpp.

References mTitleBarHeight.

Referenced by draw(), getChildrenArea(), mousePress(), and resizeToContent().

bool gcn::Window::isMovable (  )  const [virtual]

Check if the window is movable.

Returns:
true or false.

Definition at line 302 of file window.cpp.

References mMovable.

Referenced by mouseMotion(), and mousePress().

bool gcn::Window::isOpaque (  )  [virtual]

Checks if the Window is opaque.

Returns:
true or false.

Definition at line 312 of file window.cpp.

References mOpaque.

Referenced by draw().

void gcn::Window::mouseMotion ( int  x,
int  y 
) [virtual]

Called when the mouse moves and the mouse is in the Widget area or if the Widget has focus.

Parameters:
x the x coordinate of the mouse relative to the Widget itself.
y the y coordinate of the mouse relative to the Widget itself.

Reimplemented from gcn::MouseListener.

Definition at line 280 of file window.cpp.

References gcn::Widget::getX(), gcn::Widget::getY(), isMovable(), mMouseDrag, mMouseXOffset, mMouseYOffset, and gcn::Widget::setPosition().

void gcn::Window::mousePress ( int  x,
int  y,
int  button 
) [virtual]

Called when a mouse button is pressed when the mouse is in the Widget area or if the Widget has focus.

NOTE: A mouse press is NOT equal to a mouse click. Use mouseClickMessage to check for mouse clicks.

Parameters:
x the x coordinate of the mouse relative to the Widget itself.
y the y coordinate of the mouse relative to the Widget itself.
button the button pressed.

Reimplemented from gcn::MouseListener.

Definition at line 256 of file window.cpp.

References getPadding(), gcn::Widget::getParent(), getTitleBarHeight(), gcn::Widget::hasMouse(), isMovable(), mMouseDrag, mMouseXOffset, mMouseYOffset, and gcn::BasicContainer::moveToTop().

void gcn::Window::mouseRelease ( int  x,
int  y,
int  button 
) [virtual]

Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus.

Parameters:
x the x coordinate of the mouse relative to the Widget itself.
y the y coordinate of the mouse relative to the Widget itself.
button the button released.

Reimplemented from gcn::MouseListener.

Definition at line 272 of file window.cpp.

References mMouseDrag.

void gcn::Window::setAlignment ( unsigned int  alignment  )  [virtual]

Sets the alignment for the caption.

Parameters:
alignment Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT.

Definition at line 129 of file window.cpp.

References mAlignment.

Referenced by Window().

void gcn::Window::setCaption ( const std::string &  caption  )  [virtual]

Sets the Window caption.

Parameters:
caption the Window caption.

Definition at line 119 of file window.cpp.

References mCaption.

Referenced by Window().

void gcn::Window::setMovable ( bool  movable  )  [virtual]

Sets the Window to be moveble.

Parameters:
movable true or false.

Definition at line 297 of file window.cpp.

References mMovable.

Referenced by Window().

void gcn::Window::setOpaque ( bool  opaque  )  [virtual]

Sets the Window to be opaque.

If it's not opaque, the content area will not be filled with a color.

Parameters:
opaque true or false.

Reimplemented from gcn::Container.

Definition at line 307 of file window.cpp.

References mOpaque.

Referenced by Window().

void gcn::Window::setPadding ( unsigned int  padding  )  [virtual]

Sets the padding of the window which is the distance between the window border and the content.

Parameters:
padding the padding value.

Definition at line 99 of file window.cpp.

References mPadding.

Referenced by Window().

void gcn::Window::setTitleBarHeight ( unsigned int  height  )  [virtual]

Sets the title bar height.

Parameters:
height the title height value.

Definition at line 109 of file window.cpp.

References mTitleBarHeight.

Referenced by Window().


The documentation for this class was generated from the following files:
Generated on Sat Jul 29 19:38:49 2006 for Guichan by  doxygen 1.4.7