Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
hdi::core::Button Class Reference

Button widget, which can be either the default button, cancel button, or normal button in a dialog, and optionally contain an image. More...

#include <hdicoreButton.h>

Inheritance diagram for hdi::core::Button:
Inheritance graph
[legend]
Collaboration diagram for hdi::core::Button:
Collaboration graph
[legend]

Public Types

enum  StyleType { UnknownStyle = 0 , CancelStyle = 10 , DefaultStyle = 20 , NormalStyle = 30 }
 Describes the style of the button (see descriptions for each)
 
- Public Types inherited from hdi::core::Widget
enum  Type {
  UnknownType = 0 , BoxType = 10 , ButtonType = 20 , CheckboxType = 30 ,
  ColumnViewType = 40 , ComboBoxType = 50 , ColorWellType = 60 , CustomType = 70 ,
  DividerType = 80 , HierarchicalColumnViewType = 85 , HierarchicalViewType = 90 , LabelType = 100 ,
  ListViewType = 110 , PopupMenuType = 120 , RadioButtonType = 130 , SliderType = 140 ,
  StepperType = 150 , TextFieldType = 160 , TextViewType = 170 , WebViewType = 180
}
 Supported widget types.
 

Public Member Functions

 Button ()
 Constructs an empty Button object.
 
 Button (const Button &button_)
 Constructs a new Button object from an existing Button object (copy constructor)
 
 Button (const Point &loc_, const std::string &title_, const WindowType containerType_)
 Constructs a button using a location and window container type; height is fixed.
 
 Button (const Point &loc_, const std::string &title_, const double width_)
 Constructs a button using a location and width; height is fixed.
 
 Button (const Rect &frame_, const std::string &title_)
 Constructs a text button of a specific size.
 
 Button (const Rect &frame_, const ImageWithRolloverIDs &imageIDs_)
 Constructs an image button of a certain size.
 
 Button (const Rect &frame_, const SVGWithRolloverIDs &svgIDs_, const Size &dims_=Size())
 Constructs an image button of a certain size.
 
virtual ~Button ()
 Button destructor.
 
virtual Buttonoperator= (const Button &rhs_)
 Allows one Button object to be assigned from another.
 
virtual Buttonclone () const
 Convenience method to clone a Button object on the heap.
 
virtual Buttonduplicate () const
 Convenience method to duplicate a Button object, creating a new and identical UI element to the target (but not belonging to the same containing window)
 
virtual std::string text () const
 Gets the current text value of the button.
 
virtual void setText (const std::string &text_)
 Sets the current text value of the button.
 
virtual StyleType style () const
 Gets the current button style.
 
virtual void setStyle (const StyleType style_)
 Sets the style of the button as the default, cancel, or normal button.
 
virtual void click ()
 Simulates a click on the button.
 
virtual Callback *const clickCallback () const
 Gets the current click callback for the button.
 
virtual void setClickCallback (const Callback &callback_)
 Sets the click callback for the button.
 
virtual void doubleClick ()
 Simulates a double-click on the button.
 
virtual Callback *const doubleClickCallback () const
 Gets the current double-click callback for the button.
 
virtual void setDoubleClickCallback (const Callback &callback_)
 Sets the double-click callback for the button.
 
virtual ImageWithRolloverIDs imageIDs () const
 Gets the PNGI resource IDs of the widget.
 
virtual void setImageIDs (const ImageWithRolloverIDs &ids_)
 Sets the PNGI resource IDs of the widget.
 
virtual SVGWithRolloverIDs svgIDs () const
 Gets the SVG resource IDs of the widget.
 
virtual void setSVGIDs (const SVGWithRolloverIDs &ids_)
 Sets the SVG resource IDs of the widget.
 
virtual bool backgroundRollover () const
 Gets whether the background of the button should change in appearance upon mouse-over.
 
virtual void setBackgroundRollover (const bool ro_)
 Sets whether the background of the button should change in appearance upon mouse-over.
 
- Public Member Functions inherited from hdi::core::Widget
virtual ~Widget ()
 Destructs a Widget.
 
virtual Widgetclone () const =0
 Convenience method to clone a Widget object in memory, taking its subclass type into account.
 
virtual Widgetduplicate () const =0
 Convenience method to duplicate a Widget object, creating a new and identical UI element to the target (but not belonging to the same containing window)
 
virtual PlatformWidgetPtr platformWidget () const
 Gets the platform-specific widget, around which the target object is wrapped.
 
virtual bool isEmpty () const
 Gets whether the target Widget object is empty (constructed with the default ctor)
 
virtual bool operator== (const Widget &rhs_) const
 Tests whether a given Widget object is the same as another.
 
virtual bool operator!= (const Widget &rhs_) const
 Tests whether a given Widget object is not the same as another.
 
virtual Type type () const
 Gets the type of the widget.
 
virtual Window *const window () const
 Gets the parent window of the widget.
 
virtual Rect frame () const
 Gets the widget frame.
 
virtual void setFrame (const Rect &frame_)
 Sets the widget frame.
 
virtual void offset (const double x_, const double y_)
 Offsets the widget from its current location by the given amounts, in 1x resolution coordinates.
 
virtual std::string text () const
 Gets the current text value of the widget.
 
virtual void setText (const std::string &text_)
 Sets the current text value of the widget.
 
virtual bool enabled ()
 Gets whether the widget is enabled.
 
virtual void setEnabled (const bool enable_)
 Enables or disables the widget.
 
virtual bool visible ()
 Gets whether the widget is visible.
 
virtual void setVisible (const bool visible_)
 Shows or hides the widget.
 
virtual void setOrigin (const Point &p_)
 Convenience method to set just the origin of the target widget's frame.
 
virtual void setSize (const Size &s_)
 Convenience method to set just the size of the target widget's frame.
 
virtual void setWidth (const double w_)
 Convenience method to set just the width of the target widget's frame.
 
virtual void setHeight (const double h_)
 Convenience method to set just the height of the target widget's frame.
 
virtual bool hasFocus () const
 Gets whether the widget currently has focus.
 
virtual void focus () const
 Forces the widget to have focus, taking it from any other focused widget of the same window.
 
virtual Callback *const focusCallback () const
 Gets the current focus callback for the widget.
 
virtual void setFocusCallback (const Callback &callback_)
 Sets the focus callback for the widget.
 
virtual void blur () const
 Removes focus from the widget.
 
virtual Callback *const blurCallback () const
 Gets the current blur callback for the widget.
 
virtual void setBlurCallback (const Callback &callback_)
 Sets the blur callback for the widget.
 
virtual std::string tooltip () const
 Gets the tool tip string for the widget.
 
virtual void setTooltip (const std::string &tip_)
 Sets the tool tip string for the widget.
 
virtual void update ()
 Force the widget to update (i.e. cause it to redraw)
 

Static Public Member Functions

static double idealHeight (const std::string &text_, const double width_, const WindowType containerType_)
 Gets the ideal height for a button, given its title and a known width.
 
static double idealWidth (const std::string &text_, const double height_, const WindowType containerType_)
 Gets the ideal width for a button, given its title and a known height.
 
- Static Public Member Functions inherited from hdi::core::Widget
static bool isCoreWidget (const PlatformWidgetPtr widget_)
 Gets whether the given platform widget is a hdi_core widget.
 
static std::unique_ptr< WidgetlastClickedWidget ()
 Gets the last widget that received a click event (either by the user or programmatically)
 
static std::unique_ptr< WidgetlastValueChangingWidget ()
 Gets the last widget that received a value changing event (either by the user or programmatically)
 
static std::unique_ptr< WidgetlastValueChangedWidget ()
 Gets the last widget that received a value changed event (either by the user or programmatically)
 
static std::unique_ptr< WidgetlastDropWidget ()
 Gets the last widget that received a drag-and-drop drop event (either by the user or programmatically)
 
static std::unique_ptr< WidgetlastPotentialReorderWidget ()
 Gets the last widget that received a potential-reorder event.
 
static std::unique_ptr< WidgetlastReorderWidget ()
 Gets the last widget that received a reorder event.
 

Additional Inherited Members

- Protected Member Functions inherited from hdi::core::Widget
void * _impl () const
 Internal use only.
 
 Widget ()
 Constructs an empty Widget object.
 
 Widget (const Widget &w_)
 Constructs a new Widget object from an existing Widget object (copy constructor)
 
 Widget (pui::Widget *&)
 Internal use only.
 
virtual Widgetoperator= (const Widget &)
 Internal use only.
 
- Protected Attributes inherited from hdi::core::Widget
void * _data
 Private implementation data.
 

Detailed Description

Button widget, which can be either the default button, cancel button, or normal button in a dialog, and optionally contain an image.

Constructor & Destructor Documentation

◆ Button() [1/7]

hdi::core::Button::Button ( )

Constructs an empty Button object.

Author
GW
Date
09/2013
Note
To test if a Button object is empty, call isEmpty() on it
Empty Button objects do not relate to any actual UI widget; they are designed to be "receivers" of some other Button object via the overloaded assignment operator. Empty Button objects are useless until such time (though it is safe to call any of their methods).

◆ Button() [2/7]

hdi::core::Button::Button ( const Button button_)

Constructs a new Button object from an existing Button object (copy constructor)

Author
GW
Date
09/2013
Parameters
button_Existing Button object

◆ Button() [3/7]

hdi::core::Button::Button ( const Point loc_,
const std::string &  title_,
const WindowType  containerType_ 
)

Constructs a button using a location and window container type; height is fixed.

Author
GW
Date
09/2013
Parameters
loc_Top-left location of the button, in 1x resolution coordinates
title_Title of the button, as UTF-8
containerType_Type of window that will contain the widget
Note
The containerType_ argument is necessary for this constructor because it computes the ideal width for the new button from the initial button title string. However, Adobe uses different font sizes for different types of windows, and we can't correctly compute the width without knowing what font size to use.

◆ Button() [4/7]

hdi::core::Button::Button ( const Point loc_,
const std::string &  title_,
const double  width_ 
)

Constructs a button using a location and width; height is fixed.

Author
GW
Date
09/2013
Parameters
loc_Top-left location of the button, in 1x resolution coordinates
title_Title of the button, as UTF-8
width_Width of the button, at 1x resolution

◆ Button() [5/7]

hdi::core::Button::Button ( const Rect frame_,
const std::string &  title_ 
)

Constructs a text button of a specific size.

Author
GW
Date
09/2013
Parameters
frame_Position and size of the button, in 1x resolution coordinates
title_Title of the button, as UTF-8

◆ Button() [6/7]

hdi::core::Button::Button ( const Rect frame_,
const ImageWithRolloverIDs imageIDs_ 
)

Constructs an image button of a certain size.

Author
GW
Date
09/2013
Parameters
frame_Position and size of the button, in 1x resolution coordinates
imageIDs_PNGI resource IDs

◆ Button() [7/7]

hdi::core::Button::Button ( const Rect frame_,
const SVGWithRolloverIDs svgIDs_,
const Size dims_ = Size() 
)

Constructs an image button of a certain size.

Author
GW
Date
12/2018
Parameters
frame_Position and size of the button, in 1x resolution coordinates
svgIDs_SVG resource IDs
dims_1x dimensions to use when rendering the SVG; the default value causes the widget frame dimensions to be used instead

◆ ~Button()

virtual hdi::core::Button::~Button ( )
virtual

Button destructor.

Author
GW
Date
09/2013

Member Function Documentation

◆ backgroundRollover()

virtual bool hdi::core::Button::backgroundRollover ( ) const
virtual

Gets whether the background of the button should change in appearance upon mouse-over.

Author
GW
Date
03/2015
Returns
true for showing a rollover effect, false otherwise

◆ click()

virtual void hdi::core::Button::click ( )
virtual

Simulates a click on the button.

Author
GW
Date
09/2013

◆ clickCallback()

virtual Callback *const hdi::core::Button::clickCallback ( ) const
virtual

Gets the current click callback for the button.

Author
GW
Date
09/2013
Returns
A pointer to the currently registered click callback

◆ clone()

virtual Button * hdi::core::Button::clone ( ) const
virtual

Convenience method to clone a Button object on the heap.

Author
GW
Date
10/2013
Returns
A pointer to the new Button object
Note
If you subclass Button, you MUST overload this method yourself! If you don't and/or your clone() method does not return an instance of your Button subclass, you will experience "object slicing" when adding the widget to a window.
Warning
The caller must manage the memory for the returned Button object.

Implements hdi::core::Widget.

◆ doubleClick()

virtual void hdi::core::Button::doubleClick ( )
virtual

Simulates a double-click on the button.

Author
GW
Date
03/2015

◆ doubleClickCallback()

virtual Callback *const hdi::core::Button::doubleClickCallback ( ) const
virtual

Gets the current double-click callback for the button.

Author
GW
Date
03/2015
Returns
A pointer to the currently registered double-click callback

◆ duplicate()

virtual Button * hdi::core::Button::duplicate ( ) const
virtual

Convenience method to duplicate a Button object, creating a new and identical UI element to the target (but not belonging to the same containing window)

Author
GW
Date
11/2013
Returns
A pointer to the new Button object (and new UI element)
Warning
The caller must manage the memory for the returned Button object.

Implements hdi::core::Widget.

◆ idealHeight()

static double hdi::core::Button::idealHeight ( const std::string &  text_,
const double  width_,
const WindowType  containerType_ 
)
static

Gets the ideal height for a button, given its title and a known width.

Author
GW
Date
09/2013
Parameters
text_Button title, as UTF-8
width_Known width into which the button must fit
containerType_Type of window for the widget (because font sizes differ)
Returns
Ideal height for the given text to fit into the given width, at 1x resolution

◆ idealWidth()

static double hdi::core::Button::idealWidth ( const std::string &  text_,
const double  height_,
const WindowType  containerType_ 
)
static

Gets the ideal width for a button, given its title and a known height.

Author
GW
Date
09/2013
Parameters
text_Button title, as UTF-8
height_Known height into which the button must fit
containerType_Type of window for the widget (because font sizes differ)
Returns
Ideal width for the given text to fit into the given height, at 1x resolution

◆ imageIDs()

virtual ImageWithRolloverIDs hdi::core::Button::imageIDs ( ) const
virtual

Gets the PNGI resource IDs of the widget.

Author
GW
Date
03/2015
Returns
The IDs of the PNGI image resources

◆ operator=()

virtual Button & hdi::core::Button::operator= ( const Button rhs_)
virtual

Allows one Button object to be assigned from another.

Author
GW
Date
10/2013
Parameters
rhs_Righthand side of the = operator; the object to copy values from
Returns
The target Button object, but with its value updated to match that of rhs_

◆ setBackgroundRollover()

virtual void hdi::core::Button::setBackgroundRollover ( const bool  ro_)
virtual

Sets whether the background of the button should change in appearance upon mouse-over.

Author
GW
Date
03/2015
Parameters
ro_true to show a rollover effect, false otherwise

◆ setClickCallback()

virtual void hdi::core::Button::setClickCallback ( const Callback callback_)
virtual

Sets the click callback for the button.

Author
GW
Date
09/2013
Parameters
callback_New callback for when the button is clicked

◆ setDoubleClickCallback()

virtual void hdi::core::Button::setDoubleClickCallback ( const Callback callback_)
virtual

Sets the double-click callback for the button.

Author
GW
Date
03/2015
Parameters
callback_New callback for when the button is double-clicked

◆ setImageIDs()

virtual void hdi::core::Button::setImageIDs ( const ImageWithRolloverIDs ids_)
virtual

Sets the PNGI resource IDs of the widget.

Author
GW
Date
03/2015
Parameters
ids_New PNGI image resource IDs

◆ setStyle()

virtual void hdi::core::Button::setStyle ( const StyleType  style_)
virtual

Sets the style of the button as the default, cancel, or normal button.

Author
GW
Date
09/2013
Parameters
style_New button style

◆ setSVGIDs()

virtual void hdi::core::Button::setSVGIDs ( const SVGWithRolloverIDs ids_)
virtual

Sets the SVG resource IDs of the widget.

Author
GW
Date
12/2018
Parameters
ids_New SVG image resource IDs

◆ setText()

virtual void hdi::core::Button::setText ( const std::string &  text_)
virtual

Sets the current text value of the button.

Author
GW
Date
09/2013
Parameters
text_New text value, as UTF-8
Note
If the widget is an image button, the function will bail early

Reimplemented from hdi::core::Widget.

◆ style()

virtual StyleType hdi::core::Button::style ( ) const
virtual

Gets the current button style.

Author
GW
Date
09/2013
Returns
StyleType enum describing the style

◆ svgIDs()

virtual SVGWithRolloverIDs hdi::core::Button::svgIDs ( ) const
virtual

Gets the SVG resource IDs of the widget.

Author
GW
Date
12/2018
Returns
The IDs of the SVG image resources

◆ text()

virtual std::string hdi::core::Button::text ( ) const
virtual

Gets the current text value of the button.

Author
GW
Date
09/2013
Returns
The current text value, as UTF-8
Note
If the widget is an image button, this returns ""

Reimplemented from hdi::core::Widget.