GG::Button Class Reference

This is a basic button control. More...

#include <Button.h>

Inheritance diagram for GG::Button:

GG::TextControl GG::Control GG::Wnd GG::ColorDlg::ColorButton List of all members.

Signal Types

typedef boost::signal< void()> ClickedSignalType

Slot Types

typedef ClickedSignalType::slot_type ClickedSlotType

Accessors

ClickedSignalType ClickedSignal
ButtonState State () const
const SubTextureUnpressedGraphic () const
const SubTexturePressedGraphic () const
const SubTextureRolloverGraphic () const

Structors

 Button (int x, int y, int w, int h, const std::string &str, const boost::shared_ptr< Font > &font, Clr color, Clr text_color=CLR_BLACK, Flags< WndFlag > flags=CLICKABLE)

Mutators

virtual void Render ()
virtual void LButtonDown (const Pt &pt, Flags< ModKey > mod_keys)
virtual void LDrag (const Pt &pt, const Pt &move, Flags< ModKey > mod_keys)
virtual void LButtonUp (const Pt &pt, Flags< ModKey > mod_keys)
virtual void LClick (const Pt &pt, Flags< ModKey > mod_keys)
virtual void MouseHere (const Pt &pt, Flags< ModKey > mod_keys)
virtual void MouseLeave ()
virtual void SetColor (Clr c)
void SetState (ButtonState state)
void SetUnpressedGraphic (const SubTexture &st)
void SetPressedGraphic (const SubTexture &st)
void SetRolloverGraphic (const SubTexture &st)
virtual void DefineAttributes (WndEditor *editor)

Structors

 Button ()

Mutators

virtual void RenderUnpressed ()
virtual void RenderPressed ()
virtual void RenderRollover ()

Public Types

enum  ButtonState {
  BN_PRESSED,
  BN_UNPRESSED,
  BN_ROLLOVER
}

Detailed Description

This is a basic button control.

Has three states: BN_UNPRESSED, BN_PRESSED, and BN_ROLLOVER. BN_ROLLOVER is when the cursor "rolls over" the button, without depressing it, allowing rollover effects on the button. To create a bitmap button, simply set the unpressed, pressed, and/or rollover graphics to the desired SubTextures.

See also:
GG::SubTexture

Definition at line 44 of file Button.h.


Member Typedef Documentation

typedef boost::signal<void ()> GG::Button::ClickedSignalType

Emitted when the button is clicked by the user.

Definition at line 55 of file Button.h.

typedef ClickedSignalType::slot_type GG::Button::ClickedSlotType

Type of functor(s) invoked on a ClickedSignalType.

Definition at line 59 of file Button.h.


Member Enumeration Documentation

enum GG::Button::ButtonState

the states of being for a GG::Button

Enumerator:
BN_PRESSED  The button is being pressed by the user, and the cursor is over the button.
BN_UNPRESSED  The button is unpressed.
BN_ROLLOVER  The button has the cursor over it, but is unpressed.

Definition at line 48 of file Button.h.


Constructor & Destructor Documentation

GG::Button::Button ( int  x,
int  y,
int  w,
int  h,
const std::string &  str,
const boost::shared_ptr< Font > &  font,
Clr  color,
Clr  text_color = CLR_BLACK,
Flags< WndFlag >  flags = CLICKABLE 
)

ctor

GG::Button::Button (  )  [protected]

default ctor


Member Function Documentation

ButtonState GG::Button::State (  )  const

Returns button state.

See also:
ButtonState

const SubTexture& GG::Button::UnpressedGraphic (  )  const

Returns the SubTexture to be used as the image of the button when unpressed.

const SubTexture& GG::Button::PressedGraphic (  )  const

Returns the SubTexture to be used as the image of the button when pressed.

const SubTexture& GG::Button::RolloverGraphic (  )  const

Returns the SubTexture to be used as the image of the button when it contains the cursor, but is not pressed.

virtual void GG::Button::Render (  )  [virtual]

draws this Wnd.

Note that Wnds being dragged for a drag-and-drop operation are rendered twice -- once in-place as normal, once in the location of the drag operation, attached to the cursor. Such Wnds may wish to render themselves differently in those two cases. To determine which render is being performed, they can call GUI::GetGUI()->RenderingDragDropWnds().

Reimplemented from GG::TextControl.

virtual void GG::Button::LButtonDown ( const Pt pt,
Flags< ModKey >  mod_keys 
) [virtual]

respond to left button down msg.

A window receives this whenever any input device button changes from up to down while over the window.

Note:
If this Wnd was created with the REPEAT_BUTTON_DOWN flag, this method may be called multiple times during a single button press-release cycle.
See also:
GG::GUI

Reimplemented from GG::Wnd.

virtual void GG::Button::LDrag ( const Pt pt,
const Pt move,
Flags< ModKey >  mod_keys 
) [virtual]

respond to left button drag msg (even if this Wnd is not dragable).

Drag messages are only sent to the window over which the button was pressed at the beginning of the drag. A window receives this whenever any input device button is down and the cursor is moving while over the window. The window will also receive drag messages when the mouse is being dragged outside the window's area.

Reimplemented from GG::Wnd.

virtual void GG::Button::LButtonUp ( const Pt pt,
Flags< ModKey >  mod_keys 
) [virtual]

respond to release of left mouse button outside this Wnd, if it was originally depressed over this Wnd.

A Wnd will receive an LButtonUp() message whenever a drag that started over its area ends, even if the cursor is not currently over the window when this happens.

Reimplemented from GG::Wnd.

virtual void GG::Button::LClick ( const Pt pt,
Flags< ModKey >  mod_keys 
) [virtual]

respond to release of left mouse button over this Wnd, if it was also originally depressed over this Wnd.

A Wnd will receive an LButtonUp() message whenever a drag that started over its area ends over its area as well.

Reimplemented from GG::Wnd.

virtual void GG::Button::MouseHere ( const Pt pt,
Flags< ModKey >  mod_keys 
) [virtual]

respond to cursor moving about within the Wnd, or to cursor lingering within the Wnd for a long period of time.

A MouseHere() message will not be generated the first time the cursor enters the window's area. In that case, a MouseEnter() message is generated.

Reimplemented from GG::Wnd.

virtual void GG::Button::MouseLeave (  )  [virtual]

respond to cursor leaving window's coords

Reimplemented from GG::Wnd.

virtual void GG::Button::SetColor ( Clr  c  )  [virtual]

Sets the control's color; does not affect the text color.

Reimplemented from GG::TextControl.

Referenced by GG::Spin< T >::SetColor().

void GG::Button::SetState ( ButtonState  state  ) 

Sets button state programmatically.

See also:
ButtonState

void GG::Button::SetUnpressedGraphic ( const SubTexture st  ) 

Sets the SubTexture to be used as the image of the button when unpressed.

void GG::Button::SetPressedGraphic ( const SubTexture st  ) 

Sets the SubTexture to be used as the image of the button when pressed.

void GG::Button::SetRolloverGraphic ( const SubTexture st  ) 

Sets the SubTexture to be used as the image of the button when it contains the cursor, but is not pressed.

virtual void GG::Button::DefineAttributes ( WndEditor *  editor  )  [virtual]

provides the attributes of this object that are appropriate for a user to edit in a WndEditor; see WndEditor for details.

Reimplemented from GG::TextControl.

virtual void GG::Button::RenderUnpressed (  )  [protected, virtual]

Draws the button unpressed. If an unpressed graphic has been supplied, it is used.

Reimplemented in GG::ColorDlg::ColorButton.

virtual void GG::Button::RenderPressed (  )  [protected, virtual]

Draws the button pressed. If an pressed graphic has been supplied, it is used.

Reimplemented in GG::ColorDlg::ColorButton.

virtual void GG::Button::RenderRollover (  )  [protected, virtual]

Draws the button rolled-over. If an rollover graphic has been supplied, it is used.

Reimplemented in GG::ColorDlg::ColorButton.


Member Data Documentation

ClickedSignalType GG::Button::ClickedSignal [mutable]

The clicked signal object for this Button.

Definition at line 75 of file Button.h.


The documentation for this class was generated from the following file:
Generated on Wed Mar 26 14:35:42 2008 for GG by  doxygen 1.5.2