MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions
MFM::AbstractButton Class Referenceabstract

#include <AbstractButton.h>

Inheritance diagram for MFM::AbstractButton:
MFM::Panel MFM::AbstractCheckbox MFM::AbstractGUIDriver< GC >::AbstractGridButton MFM::AbstractCheckboxExternal MFM::AbstractGUIDriver< GC >::ClearButton MFM::AbstractGUIDriver< GC >::ClearGridButton MFM::AbstractGUIDriver< GC >::GridStepCheckbox MFM::AbstractGUIDriver< GC >::NukeButton MFM::AbstractGUIDriver< GC >::PauseTileButton MFM::AbstractGUIDriver< GC >::QuitButton MFM::AbstractGUIDriver< GC >::ReloadButton MFM::AbstractGUIDriver< GC >::SaveButton MFM::AbstractGUIDriver< GC >::ScreenshotButton MFM::AbstractGUIDriver< GC >::TileViewButton MFM::AbstractGUIDriver< GC >::XRayButton

Public Member Functions

 AbstractButton ()
 
 AbstractButton (const char *text)
 
 AbstractButton (SDL_Surface *icon)
 
 AbstractButton (const char *text, SDL_Surface *icon)
 
 ~AbstractButton ()
 
void SetLocation (const SPoint &location)
 
void SetIcon (SDL_Surface *icon)
 
SDL_Surface * GetIcon ()
 
void SetDimensions (const SPoint &dimensions)
 
void SetEnabled (bool isEnabled)
 
void SetText (const char *text)
 
const char * GetText ()
 
bool IsEnabled () const
 
bool Contains (SPoint &pt)
 
virtual bool Handle (MouseButtonEvent &event)
 
virtual void HandleResize (const UPoint &parentSize)
 
bool PaintClickHighlight (Drawing &d)
 
virtual void PaintComponentNonClick (Drawing &d)
 
virtual void PaintComponent (Drawing &d)
 
virtual void OnClick (u8 button)=0
 
virtual void OnPress (u8 button)
 
- Public Member Functions inherited from MFM::Panel
 Panel (u32 width=0, u32 height=0)
 
void Insert (Panel *child, Panel *afterOrNull)
 
PanelPop ()
 
void Remove (Panel *child)
 
void SetVisibility (bool value)
 
void ToggleVisibility ()
 
bool IsVisible ()
 
u32 GetWidth () const
 
u32 GetHeight () const
 
void SetDimensions (u32 width, u32 height)
 
void SetDesiredSize (u32 width, u32 height)
 
const UPointGetDimensions () const
 
const UPointGetDesiredSize () const
 
void SetRenderPoint (const SPoint &renderPt)
 
const SPointGetRenderPoint () const
 
const char * GetName () const
 
void SetName (const char *name)
 
void Print (ByteSink &sink, u32 indent=0) const
 
u32 GetBackground () const
 
u32 SetBackground (const u32 color)
 
u32 GetBorder () const
 
u32 SetBorder (const u32 color)
 
u32 GetForeground () const
 
u32 SetForeground (const u32 color)
 
TTF_Font * GetFont () const
 
TTF_Font * SetFont (TTF_Font *newFont)
 
SPoint GetAbsoluteLocation ()
 
virtual void Paint (Drawing &config)
 
virtual void PaintUpdateVisibility (Drawing &config)
 
virtual void PaintBorder (Drawing &config)
 
virtual void PaintChildren (Drawing &config)
 
virtual bool Dispatch (MouseEvent &event, const Rect &rect)
 
virtual bool Handle (MouseMotionEvent &event)
 
virtual void OnMouseExit ()
 
void SetAnchor (const GUIAnchor anchor)
 
SPoint GetTextSize (TTF_Font *font, const char *text)
 

Additional Inherited Members

- Static Protected Member Functions inherited from MFM::Panel
static void Indent (ByteSink &sink, u32 count)
 
- Protected Attributes inherited from MFM::Panel
OString16 m_name
 
Rect m_rect
 
u32 m_bdColor
 
u32 m_bgColor
 
u32 m_fgColor
 
TTF_Font * m_font
 
UPoint m_desiredSize
 
SPoint m_desiredLocation
 
Panelm_parent
 
Panelm_top
 
Panelm_forward
 
Panelm_backward
 
Panelm_focusedChild
 
bool m_visible
 

Detailed Description

A Panel which behaves as a button, built with abstract behavior upon clicks.

Constructor & Destructor Documentation

MFM::AbstractButton::AbstractButton ( )

Constructs an AbstractButton with default parameters and default coloring scheme.

MFM::AbstractButton::AbstractButton ( const char *  text)

Constructs an AbstractButton with given text to be rendered upon it and default coloring scheme.

Parameters
textThe text to render on top of this AbstractButton upon rendering.
MFM::AbstractButton::AbstractButton ( SDL_Surface *  icon)

Constructs an AbstractButton with a given icon to be rendered instead of the default rendering scheme.

Parameters
iconA pointer to the SDL_Surface which will be rendered upon rendering of this AbstactButton.
MFM::AbstractButton::AbstractButton ( const char *  text,
SDL_Surface *  icon 
)

Constructs an AbstractButton with a given string and a given icon. Upon rendering, The icon will be rendered, then the string will be rendered on top of it.

Parameters
textThe string to render on top of this AbstractButton upon rendering.
iconThe icon which will render as this AbstractButton upon rendering.
MFM::AbstractButton::~AbstractButton ( )

Deconstructs this AbstractButton.

Member Function Documentation

bool MFM::AbstractButton::Contains ( SPoint pt)

Checks to see whether or not a given SPoint lies within the bounds of this AbstractButton. This is used during mouse hit processing to see whether or not this AbstractButton has been clicked on.

Parameters
ptThe SPoint in question of existing within the bounds of this AbstractButton.
SDL_Surface* MFM::AbstractButton::GetIcon ( )
inline

Gets the icon that is currently being rendered by this AbstractButton .

Returns
The icon that is currently being rendered by this AbstractButton .
const char* MFM::AbstractButton::GetText ( )
inline

Gets the text that is currently being rendered on top of this AbstractButton upon rendering.

Returns
The text that is currently being rendered on top of this AbstractButton upon rendering.
virtual bool MFM::AbstractButton::Handle ( MouseButtonEvent event)
inlinevirtual

Respond to a MouseButtonEvent (this includes scroll wheel events).

Returns
true if the event should be considered handled. The default implementation does nothing and returns false.

Reimplemented from MFM::Panel.

virtual void MFM::AbstractButton::HandleResize ( const UPoint parentSize)
inlinevirtual

Respond to the resizing of this panel's parent.

Reimplemented from MFM::Panel.

bool MFM::AbstractButton::IsEnabled ( ) const
inline

Checks to see whether or not this AbstractButton is enabled and is therefore responding to mouse hits.

Returns
true if this AbstractButton is enabled and is therefore responding to mouse hits, else false .
virtual void MFM::AbstractButton::OnClick ( u8  button)
pure virtual

Pure abstract behavior method. This is called if this AbstractButton is enabled and has decided that it has been clicked on . Overriding this method allows the subclass of this AbstractButton to behave in any way it pleases upon being clicked.

Parameters
buttonThe SDL mouse button that has been pressed to generate this mouse hit, i.e. SDL_BUTTON_LEFT , SDL_BUTTON_MIDDLE, or SDL_BUTTON_RIGHT .

Implemented in MFM::AbstractGUIDriver< GC >::PauseTileButton, MFM::AbstractGUIDriver< GC >::ReloadButton, MFM::AbstractGUIDriver< GC >::QuitButton, MFM::AbstractGUIDriver< GC >::ScreenshotButton, MFM::AbstractGUIDriver< GC >::SaveButton, MFM::AbstractGUIDriver< GC >::TileViewButton, MFM::AbstractGUIDriver< GC >::GridStepCheckbox, MFM::AbstractGUIDriver< GC >::XRayButton, MFM::AbstractGUIDriver< GC >::NukeButton, MFM::AbstractGUIDriver< GC >::ClearGridButton, MFM::AbstractGUIDriver< GC >::ClearButton, and MFM::AbstractCheckbox.

virtual void MFM::AbstractButton::OnPress ( u8  button)
inlinevirtual

This is called when this AbstractButton is enabled and has decided the button is pressed on it . Overriding this method allows the subclass of this AbstractButton to behave in any way it pleases upon button down.

Parameters
buttonThe SDL mouse button that has been pressed to generate this mouse hit, i.e. SDL_BUTTON_LEFT , SDL_BUTTON_MIDDLE, or SDL_BUTTON_RIGHT .
void MFM::AbstractButton::PaintComponent ( Drawing config)
virtual

Paint the component itself, excluding its border and any children it may have. The default implementation (which may be accessed, if overridden, via this->Panel::PaintComponent) sets the drawing foreground and background colors to the panel colors, and Clear()s the Panel.

Reimplemented from MFM::Panel.

Reimplemented in MFM::AbstractCheckbox.

void MFM::AbstractButton::SetDimensions ( const SPoint dimensions)
inline

Sets the size of this AbstractButton which will affect how it is rendered on the screen and how mouse hits are processed.

Parameters
dimensionsThe new size of this AbstractButton .
void MFM::AbstractButton::SetEnabled ( bool  isEnabled)
inline

Sets whether or not this AbstractButton will be enabled, and therefore whether or not it will respond to mouse hits.

Parameters
isEnabledIf true , will allow this AbstractButton to respond to mouse hits. If false , will disable this feature.
void MFM::AbstractButton::SetIcon ( SDL_Surface *  icon)
inline

Sets the icon of this AbstractButton which will render in its place upon rendering.

Parameters
iconA pointer to the SDL_Surface which will render upon rendering of this AbstractButton.
void MFM::AbstractButton::SetLocation ( const SPoint location)
inline

Sets the location of this AbstractButton, relative to the Panel which it is located inside of, at which to render this AbstractButton and process mouse hits.

Parameters
locationThe new location that this AbstractButton will reside at.
void MFM::AbstractButton::SetText ( const char *  text)
inline

Sets the text that will be rendered on top of this AbstractButton upon rendering.

Parameters
textThe new text that will be rendered on top of this AbstractButton upon rendering.

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