Button_t Class Reference

Button object, which can present a text label or an image. More...

#include <UTButton.h>

Inheritance diagram for Button_t:
View_t LinkedListNode_t< View_t > Drawable_t

List of all members.

Public Member Functions

 Button_t (const String_t &label)
virtual ~Button_t ()
virtual void SetMinMaxSize (float min_width, float max_width, float min_height, float max_height)
const String_tLabel () const
void SetLabel (const String_t &label)
void SetAction (Message_t *message_to_send, const AbstractMessageDestination_t &destination)
void Disable ()
bool IsEnabled () const
const Message_tActionMessage () const
virtual void MouseChanged (const Point_t &point, bool mouse_inside_view, bool left_mouse_button_down, bool left_mouse_button_double_clicked, bool right_mouse_button_down_if_present)

Protected Member Functions

virtual void LBoundsChanged (const Rect_t &old_lbounds, const Rect_t &new_lbounds)
virtual void Paint (const Region_t &clip_to)

Detailed Description

Non-core library: UTgui

Button object, which can present a text label or an image

Definition at line 48 of file UTButton.h.

Constructor & Destructor Documentation

Button_t::Button_t ( const String_t label  ) 

Button constructor which displays a text label in a button with the target platform's look for buttons. The minimum size will be set to something appropriate to accommodate the label with the normal style for a button on the target platform. The maximum height will equal the minimum width. The maximum width will be -1, meaning unlimited.

virtual Button_t::~Button_t (  )  [virtual]

Button destructor.

Member Function Documentation

virtual void Button_t::SetMinMaxSize ( float  min_width,
float  max_width,
float  min_height,
float  max_height 
) [virtual]

Use of this function is prohibited for buttons, since the minimum size can change at any time due to user theme changes, and on some platforms, the minimum size is only a guess until the button is realized by showing the root level window in which it is contained. SetPFrame can be used instead by a custom container if needed, acting upon min/max size information delivered by ChildMinMaxSizeChanged when the size requirements become available or change.

If you are tempted to use SetMinMaxSize in order to make several buttons in a layout have the same width, there is a better way. Instead, LayoutView_t::SetColumnsUseSameMinWidth can be used to force the columns containing the buttons to have the same width. If the columns also have a weight of zero, the buttons will not grow larger than the largest minimum size of the set of buttons.

Reimplemented from View_t.

const String_t & Button_t::Label (  )  const [inline]

Returns the label of the button.

Definition at line 195 of file UTButton.h.

void Button_t::SetLabel ( const String_t label  ) 

Sets the label. The minimum width and height will be reset as described for the Button_t constructor.

void Button_t::SetAction ( Message_t message_to_send,
const AbstractMessageDestination_t destination 

Sets the action to be taken when the button is clicked by the user, and enables the button.

void Button_t::Disable (  ) 

Disables the button, deleting the action message and clearing the action destination to which the message would have been sent.

bool Button_t::IsEnabled (  )  const [inline]

Returns whether the button is enabled, which is the case if it has a valid action and target.

const Message_t* Button_t::ActionMessage (  )  const [inline]

Returns the action message if the item is enabled, or NULL if it is disabled.

virtual void Button_t::MouseChanged ( const Point_t point,
bool  mouse_inside_view,
bool  left_mouse_button_down,
bool  left_mouse_button_double_clicked,
bool  right_mouse_button_down_if_present 
) [virtual]

Virtual function invoked when the mouse is moving over the view, but not over any of its children. If a child view has a parent view (as opposed to being the root window) and needs to propogate this call up though, it can of course convert the point to its parent's coordinate system and call the parent's MouseChanged function. MouseChanged will be called whenever mouse button states change. Note that the right mouse button might not be physically present, especially on Apple hardware. That being the case, any functions that would be accessed through the right button MUST be available by other means. For example, all context menu options available by right clicking on something should also be available from the main menu. This is important on other operating systems as well, because the availability of a context menu might not be obvious to all users. MouseChanged will be called once after thex mouse has left the view, either by moving outside its lbounds or onto another window that is higher in the Z-order and overlapping with this view in X and Y. A view may not delete itself inside this call. If a button subclass needs to respond to the MouseChanged event in that way, it must do so asynchronously (by sending a message to a MessageReceiver_t in the App_t nessage loop, probably itself).

Reimplemented from View_t.

virtual void Button_t::LBoundsChanged ( const Rect_t old_lbounds,
const Rect_t new_lbounds 
) [protected, virtual]

Called when the view's lbounds has changed. This due to the view having been resized. The upper left corner will always be at x=0, y=0.

Reimplemented from View_t.

virtual void Button_t::Paint ( const Region_t clip_to  )  [protected, virtual]

Called when the button should be painted.

Because a view's edges are specified in coordinates for which integers are at the middle of a pixel which is deemed to be included in the view, the view bounds are, for painting purposes, expanded by a half pixel. This is reflected in the clip_to region. If a view had bounds of (10, 10, 20, 20) and were to be entirely painted, the clip_to region would be comprised of a single rectangle whose coordinates would be (9.5, 9.5, 20.5, 20.5).

Reimplemented from View_t.

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

Generated on Tue Dec 14 22:35:06 2010 for UT library by  doxygen 1.6.1