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 | Static Protected Member Functions | Protected Attributes
MFM::Panel Class Reference

#include <Panel.h>

Inheritance diagram for MFM::Panel:
MFM::GridPanel< OurGridConfig > MFM::AbstractButton MFM::AbstractGUIDriver< GC >::ButtonPanel MFM::GridPanel< GC > MFM::MovablePanel MFM::ParameterController< CC > MFM::StdPanel MFM::TextPanel< COLUMNS, LINES > MFM::TextPanel< 120, 100 >

Public Member Functions

 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 PaintComponent (Drawing &config)
 
virtual void PaintBorder (Drawing &config)
 
virtual void PaintChildren (Drawing &config)
 
virtual bool Dispatch (MouseEvent &event, const Rect &rect)
 
virtual bool Handle (MouseButtonEvent &event)
 
virtual bool Handle (MouseMotionEvent &event)
 
virtual void OnMouseExit ()
 
virtual void HandleResize (const UPoint &parentSize)
 
void SetAnchor (const GUIAnchor anchor)
 
SPoint GetTextSize (TTF_Font *font, const char *text)
 

Static Protected Member Functions

static void Indent (ByteSink &sink, u32 count)
 

Protected Attributes

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

The base class for a region of the GUI system used in the MFM simulator.

Member Function Documentation

bool MFM::Panel::Dispatch ( MouseEvent event,
const Rect rect 
)
virtual

Dispatch a mouse event, to the appropriate subpanel depending on the stacking order and the position of the mouse. Panels should override the Handle(MouseButtonEvent) and/or Handle(MouseMotionEvent) method if they wish to handle such events. Returns true if any panel claimed to handle the event.

SPoint MFM::Panel::GetAbsoluteLocation ( )

Gets the absolute location of this Panel from the window that the program is contained in.

Returns
The absolute location of this Panel from the window that the program is contained in.
u32 MFM::Panel::GetBackground ( ) const
inline

Get the current background color.

u32 MFM::Panel::GetBorder ( ) const
inline

Get the current border color.

TTF_Font * MFM::Panel::GetFont ( ) const

Get the default font for this panel. May return null. Text drawing operations will use the prevailing font (Drawing::GetFont()) if this returns null.

u32 MFM::Panel::GetForeground ( ) const
inline

Get the current foreground color.

SPoint MFM::Panel::GetTextSize ( TTF_Font *  font,
const char *  text 
)

Calculates the dimensions of the resulting SDL_Surface generated when rendering a given string using a given TTF_Font .

Parameters
fontThe TTF_Font used to calculate the resulting size of the final SDL_Surface .
textThe string used to calculate the resulting size of the final SDL_Surface .
Returns
A SPoint representing the size of the resulting SDL_Surface generated by rendering text in font font.
bool MFM::Panel::Handle ( MouseButtonEvent event)
virtual

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 in MFM::GridPanel< GC >, MFM::GridPanel< OurGridConfig >, MFM::AbstractButton, MFM::NeighborSelectPanel< CC, R >, MFM::Slider< CC >, MFM::TextPanel< COLUMNS, LINES >, MFM::TextPanel< 120, 100 >, and MFM::MovablePanel.

bool MFM::Panel::Handle ( MouseMotionEvent event)
virtual

Respond to a MouseMotionEvent. Return true if the event should be considered handled. The default implementation does nothing and returns false.

Reimplemented in MFM::GridPanel< GC >, MFM::GridPanel< OurGridConfig >, MFM::Slider< CC >, MFM::TextPanel< COLUMNS, LINES >, MFM::TextPanel< 120, 100 >, and MFM::MovablePanel.

void MFM::Panel::HandleResize ( const UPoint parentSize)
virtual

Respond to the resizing of this panel's parent.

Reimplemented in MFM::AbstractButton.

void MFM::Panel::OnMouseExit ( )
virtual

Called when a MouseMotionEvent happens which is equivalent to the mouse exiting this Panel . This is, for instance, useful if a Panel needs to stop following the mouse

Reimplemented in MFM::Slider< CC >, and MFM::MovablePanel.

void MFM::Panel::PaintBorder ( Drawing config)
virtual

Paint the border of the Panel, if it has one. The default implementation paints a one pixel foreground color border.

Reimplemented in MFM::AbstractGUIDriver< GC >::ButtonPanel, MFM::AbstractGUIDriver< GC >::StatisticsPanel, MFM::Slider< CC >, MFM::AbstractCheckbox, and MFM::HelpPanel.

void MFM::Panel::PaintChildren ( Drawing config)
virtual

Paint the subpanels of the Panel, if it has any. In general this should not be overridden. The default implementation draws each child in turn from the bottom of the stacking order to the top.

void MFM::Panel::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 in MFM::AbstractGUIDriver< GC >::StatisticsPanel, MFM::ToolboxPanel< CC >, MFM::AbstractButton, MFM::NeighborSelectPanel< CC, R >, MFM::Slider< CC >, MFM::GridPanel< GC >, MFM::GridPanel< OurGridConfig >, MFM::AtomViewPanel< GC >, MFM::AtomViewPanel< OurGridConfig >, MFM::AbstractCheckbox, MFM::HelpPanel, MFM::TextPanel< COLUMNS, LINES >, and MFM::TextPanel< 120, 100 >.

void MFM::Panel::PaintUpdateVisibility ( Drawing config)
virtual

Update the visibility of this Panel, if desired, at the beginning of the painting process. The default implementation (which may be accessed, if overridden, via this->Panel::IsVisible) does nothing; overriding implementations may use SetVisibility and/or ToggleVisibility to alter the visibility of this Panel before its painting begins in earnest. Note this method is called only during painting; during dispatching the m_visible variable is checked directly.

See Also
SetVisibility
ToggleVisibility

Reimplemented in MFM::AtomViewPanel< GC >, and MFM::AtomViewPanel< OurGridConfig >.

void MFM::Panel::SetAnchor ( const GUIAnchor  anchor)

Used to tell this Panel to stick to a particular edge of its parent based on a specified GUIAnchor.

Parameters
anchorThe GUIAnchor which specifies the edge of this Panel's bounds to stick to.
u32 MFM::Panel::SetBackground ( const u32  color)
inline

Set the background color. Returns prior value

u32 MFM::Panel::SetBorder ( const u32  color)
inline

Set the border color. Returns prior value

TTF_Font * MFM::Panel::SetFont ( TTF_Font *  newFont)

Set the default font for this panel. Null may be passed in to clear the default font. Returns prior value.

u32 MFM::Panel::SetForeground ( const u32  color)
inline

Set the foreground color. Returns prior value

Field Documentation

UPoint MFM::Panel::m_desiredSize
protected

The size that this Panel wants to be, when given enough room.

TTF_Font* MFM::Panel::m_font
protected

Preferred font for text operations, if any

bool MFM::Panel::m_visible
protected

Whether this Panel is currently being displayed, and analogously, whether it is doing Dispatch processing.


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