ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
Public Member Functions | Protected Attributes | List of all members
Widget Class Referenceabstract

Baseclass for all Widgets. More...

#include <widget.h>

Inheritance diagram for Widget:
Label List Button FileList ListItem FileListItem

Public Member Functions

 Widget (Canvas *const canvas)
 Constructor with Canvas. More...
 
 Widget (Widget *const parent=nullptr)
 Constructor with parent Widget. More...
 
virtual ~Widget () ROLAND_DEFAULT virtual void draw()=0
 Standarddestructor. More...
 
virtual void onMouseMotion (SDL_MouseMotionEvent *event)
 Catch MouseMotion events. More...
 
virtual void onMouseButton (SDL_MouseButtonEvent *event)
 Catch MouseButton events. More...
 
virtual bool onKeyboard (SDL_KeyboardEvent *event)
 Catch Keyboard events. More...
 
virtual bool onUser (SDL_UserEvent *event)
 Catch UserEvents. More...
 
virtual void setPos (int x, int y)
 Sets the Position. More...
 
virtual void setSize (int width, int height)
 Sets the Size. More...
 
virtual void setCanvas (Canvas *const canvas)
 Sets the Canvas to draw on. More...
 
void setParent (Widget *const parent)
 Sets the parent Widget. More...
 
const Widgetparent () const
 Returns the parent. More...
 
void setColor (const Color &color)
 Sets the Color of the Widget by Color. More...
 
void setColor (int r, int g, int b, int a=255)
 Sets the Color of the Widget by RGB(A) More...
 
Color color () const
 Returns the Color of the Widget. More...
 
void setEnabled (bool val)
 Set Widget enabled. More...
 
void setWantEvents (bool val)
 Sets whether to catch Events. More...
 
void setMouseOver (bool val)
 Sets whehther to catch MouseOver. More...
 
bool enabled () const
 Returns whether the Widget is enabled. More...
 
bool wantEvents () const
 Returns whether the Widget wants Events. More...
 
bool mouseOver () const
 Returns whether the Widget receives MouseOver. More...
 
bool hasMouseGrab () const
 Returns whether the Widget has MouseGrab. More...
 
Sint16 x () const
 Returns the x position of the upper left corner. More...
 
Sint16 y () const
 Returns the y position of the upper left corner. More...
 
Point pos () const
 Returns the position of the upper left corner. More...
 
Uint16 width () const
 Returns the width of the Widget. More...
 
Uint16 height () const
 Returns the height of the Widget. More...
 
Size size () const
 Returns the Size of the Widget. More...
 
Point relativePos (Sint16 x, Sint16 y) const
 
void relativePos (Sint16 x, Sint16 y, Point &target) const
 
const Rectrect () const
 
const Rectcanvasrect () const
 

Protected Attributes

CanvasmCanvas
 
WidgetmParent
 
Rect mRect
 
Rect mCanvasRect
 
Color mColor
 
bool mEnabled
 
bool mMouseOver
 
bool mMouseGrab
 
bool mWantEvents
 

Detailed Description

Baseclass for all Widgets.

Constructor & Destructor Documentation

Widget ( Canvas *const  canvas)

Constructor with Canvas.

References Widget::mColor, Widget::mRect, Color::set(), and Rect::set().

Widget ( Widget *const  parent = nullptr)

Constructor with parent Widget.

References Widget::mColor, Widget::mRect, Color::set(), and Rect::set().

virtual ~Widget ( )
pure virtual

Standarddestructor.

Draw thes widget

Member Function Documentation

const Rect& canvasrect ( ) const
inline

References Widget::mCanvasRect.

Color color ( ) const
inline
bool enabled ( ) const
inline

Returns whether the Widget is enabled.

References Widget::mEnabled.

Referenced by mainloop(), and ListItem::onMouseButton().

bool hasMouseGrab ( ) const
inline

Returns whether the Widget has MouseGrab.

References Widget::mMouseGrab.

Uint16 height ( ) const
inline

Returns the height of the Widget.

References Rect::height(), and Widget::mRect.

Referenced by List::add(), List::draw(), initGui(), and List::reposition().

bool mouseOver ( ) const
inline

Returns whether the Widget receives MouseOver.

References Widget::mMouseOver.

virtual bool onKeyboard ( SDL_KeyboardEvent *  event)
inlinevirtual

Catch Keyboard events.

Reimplemented in List, and FileList.

Referenced by Gui::checkEvent().

virtual void onMouseButton ( SDL_MouseButtonEvent *  event)
inlinevirtual

Catch MouseButton events.

Reimplemented in List, Label, Button, and ListItem.

virtual void onMouseMotion ( SDL_MouseMotionEvent *  event)
inlinevirtual

Catch MouseMotion events.

Reimplemented in Label, and Button.

virtual bool onUser ( SDL_UserEvent *  event)
inlinevirtual

Catch UserEvents.

Reimplemented in List.

const Widget* parent ( ) const
inline

Returns the parent.

References Widget::mParent.

Referenced by ListItem::onMouseButton(), and Widget::setParent().

Point pos ( ) const
inline

Returns the position of the upper left corner.

References Widget::mRect, and Rect::pos().

const Rect& rect ( ) const
inline

References Widget::mRect.

Point relativePos ( Sint16  x,
Sint16  y 
) const
inline

References Widget::mRect, Rect::x(), and Rect::y.

Referenced by Label::moveInit().

void relativePos ( Sint16  x,
Sint16  y,
Point target 
) const
inline

References Widget::mRect, Rect::x(), and Rect::y.

void setCanvas ( Canvas *const  canvas)
virtual

Sets the Canvas to draw on.

References Widget::mCanvas.

Referenced by Gui::add(), and Widget::setSize().

void setColor ( const Color color)
inline

Sets the Color of the Widget by Color.

References Widget::color(), and Widget::mColor.

Referenced by initGui(), and ListItem::ListItem().

void setColor ( int  r,
int  g,
int  b,
int  a = 255 
)
inline

Sets the Color of the Widget by RGB(A)

References Widget::mColor, and Color::set().

void setEnabled ( bool  val)
inline

Set Widget enabled.

References Widget::mEnabled.

Referenced by display(), FileList::FileList(), initGui(), and mainloop().

void setMouseOver ( bool  val)
inline

Sets whehther to catch MouseOver.

References Widget::mMouseOver.

void setParent ( Widget *const  parent)
inline

Sets the parent Widget.

References Widget::mParent, and Widget::parent().

Referenced by List::add().

virtual void setPos ( int  x,
int  y 
)
inlinevirtual

Sets the Position.

Reimplemented in Label.

References Widget::mRect, Rect::setX(), and Rect::setY().

Referenced by FileList::FileList().

virtual void setSize ( int  width,
int  height 
)
inlinevirtual
void setWantEvents ( bool  val)
inline

Sets whether to catch Events.

References Widget::mWantEvents.

Referenced by initGui().

Size size ( ) const
inline

Returns the Size of the Widget.

References Widget::mRect, and Rect::size.

bool wantEvents ( ) const
inline

Returns whether the Widget wants Events.

References Widget::mWantEvents.

Uint16 width ( ) const
inline

Returns the width of the Widget.

References Widget::mRect, and Rect::width().

Referenced by List::add(), and initGui().

Sint16 x ( ) const
inline

Returns the x position of the upper left corner.

References Widget::mRect, and Rect::x().

Referenced by List::add().

Sint16 y ( ) const
inline

Returns the y position of the upper left corner.

References Widget::mRect, and Rect::y.

Referenced by List::add(), and List::reposition().

Member Data Documentation

Canvas* mCanvas
protected
Rect mCanvasRect
protected
Color mColor
protected
bool mEnabled
protected
bool mMouseGrab
protected
bool mMouseOver
protected
Widget* mParent
protected
Rect mRect
protected
bool mWantEvents
protected

The documentation for this class was generated from the following files: