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

Wraps around an application menu item to allow for selection callbacks, en/disabling, setting text, etc. More...

#include <hdicoreMenuItem.h>

Public Member Functions

 MenuItem ()
 Constructs an empty MenuItem object.
 
 MenuItem (const MenuItem &m_)
 Constructs a new MenuItem object from an existing MenuItem object (copy constructor)
 
 MenuItem (const BuiltinMenuGroup group_, const std::string &text_, const Callback &callback_)
 Constructs a new MenuItem object.
 
 MenuItem (const MenuGroup &group_, const std::string &text_, const Callback &callback_)
 Constructs a new MenuItem object.
 
virtual ~MenuItem ()
 Destructs a MenuItem object.
 
virtual void destroy ()
 Destroys the UI menu item, converting the target object to an empty MenuItem object (see the default constructor for more info on empty MenuItem objects)
 
virtual MenuItemoperator= (const MenuItem &rhs_)
 Assigns one MenuItem object to another.
 
virtual bool operator== (const MenuItem &rhs_) const
 Tests whether a given MenuItem object is the same as another.
 
virtual bool operator!= (const MenuItem &rhs_) const
 Tests whether a given MenuItem object is not the same as another.
 
virtual AIMenuItemHandle aiMenuItemHandle () const
 Gets the menu item handle around which the target object is wrapped.
 
virtual bool isEmpty () const
 Gets whether the target MenuItem object is empty (constructed with the default ctor)
 
virtual bool isDivider () const
 Gets whether the target MenuItem is a divider.
 
virtual std::unique_ptr< MenuGroupparent () const
 Gets the parent of the target menu item.
 
virtual bool enabled () const
 Gets whether the menu item is enabled.
 
virtual void setEnabled (const bool enabled_)
 Sets the menu item as enabled or disabled.
 
virtual bool checked () const
 Gets whether the menu item is checked.
 
virtual void setChecked (const bool checked_)
 Sets the menu item as checked or unchecked.
 
virtual std::string text () const
 Gets the text of the menu item itself.
 
virtual void setText (const std::string &text_)
 Sets the text of the menu item itself.
 
virtual Callback *const callback () const
 Gets the registered callback for the menu item.
 
virtual void setCallback (const Callback &cb_)
 Sets the callback for the menu item.
 

Static Public Member Functions

static MenuItem Divider (const BuiltinMenuGroup group_)
 Constructs a new MenuItem object as a divider.
 
static MenuItem Divider (const MenuGroup &group_)
 Constructs a new MenuItem object as a divider.
 

Friends

MenuItem __accessCtor (AIMenuItemHandle)
 

Detailed Description

Wraps around an application menu item to allow for selection callbacks, en/disabling, setting text, etc.

Constructor & Destructor Documentation

◆ MenuItem() [1/4]

hdi::core::MenuItem::MenuItem ( )

Constructs an empty MenuItem object.

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

◆ MenuItem() [2/4]

hdi::core::MenuItem::MenuItem ( const MenuItem m_)

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

Author
GW
Date
08/2013
Parameters
m_Existing MenuItem object

◆ MenuItem() [3/4]

hdi::core::MenuItem::MenuItem ( const BuiltinMenuGroup  group_,
const std::string &  text_,
const Callback callback_ 
)

Constructs a new MenuItem object.

Author
GW
Date
08/2013
Parameters
group_Built-in app menu group to contain the new MenuItem
text_String that will show in the menu item, as UTF-8
callback_Callback to perform when the menu item is selected
Note
For Photoshop, the menu item will always be appended to the group.

◆ MenuItem() [4/4]

hdi::core::MenuItem::MenuItem ( const MenuGroup group_,
const std::string &  text_,
const Callback callback_ 
)

Constructs a new MenuItem object.

Author
GW
Date
08/2013
Parameters
group_User-created menu group to contain the new MenuItem
text_String that will show in the menu item, as UTF-8
callback_Callback to perform when the menu item is selected

◆ ~MenuItem()

virtual hdi::core::MenuItem::~MenuItem ( )
virtual

Destructs a MenuItem object.

Author
GW
Date
08/2013

Member Function Documentation

◆ aiMenuItemHandle()

virtual AIMenuItemHandle hdi::core::MenuItem::aiMenuItemHandle ( ) const
virtual

Gets the menu item handle around which the target object is wrapped.

Author
GW
Date
11/2013
Returns
AIMenuItemHandle for this object
Note
Generally, you shouldn't need to call this method. Only use it if you know what you're doing. If a specific piece of functionality provided by Illustrator is not handled by this class (or related classes), then it should probably be added to the hdi_core library.

◆ callback()

virtual Callback *const hdi::core::MenuItem::callback ( ) const
virtual

Gets the registered callback for the menu item.

Author
GW
Date
08/2013
Returns
Currently registered menu item callback

◆ checked()

virtual bool hdi::core::MenuItem::checked ( ) const
virtual

Gets whether the menu item is checked.

Author
GW
Date
08/2013
Returns
true if the item is checked, false otherwise

◆ destroy()

virtual void hdi::core::MenuItem::destroy ( )
virtual

Destroys the UI menu item, converting the target object to an empty MenuItem object (see the default constructor for more info on empty MenuItem objects)

Author
GW
Date
10/2013
Note
This method must be called for any existing menu items by the time the plugin is shutting down. If you no longer retain any of your own references to a menu item then the lib will call this method for you as it is shutting down.

◆ Divider() [1/2]

static MenuItem hdi::core::MenuItem::Divider ( const BuiltinMenuGroup  group_)
static

Constructs a new MenuItem object as a divider.

Author
GW
Date
11/2013
Parameters
group_Built-in app menu group to contain the new MenuItem
Returns
A new MenuItem object that's a divider
Note
For Photoshop, the menu item will always be appended to the group.

◆ Divider() [2/2]

static MenuItem hdi::core::MenuItem::Divider ( const MenuGroup group_)
static

Constructs a new MenuItem object as a divider.

Author
GW
Date
11/2013
Parameters
group_User-created menu group to contain the new MenuItem
Returns
A new MenuItem object that's a divider

◆ enabled()

virtual bool hdi::core::MenuItem::enabled ( ) const
virtual

Gets whether the menu item is enabled.

Author
GW
Date
08/2013
Returns
true if the item is enabled, false otherwise

◆ isDivider()

virtual bool hdi::core::MenuItem::isDivider ( ) const
virtual

Gets whether the target MenuItem is a divider.

Author
GW
Date
09/2014
Returns
true if the menu item is a divider/separate, false otherwise

◆ isEmpty()

virtual bool hdi::core::MenuItem::isEmpty ( ) const
virtual

Gets whether the target MenuItem object is empty (constructed with the default ctor)

Author
GW
Date
08/2013
Returns
true if the target MenuItem object is empty, false otherwise

◆ operator!=()

virtual bool hdi::core::MenuItem::operator!= ( const MenuItem rhs_) const
virtual

Tests whether a given MenuItem object is not the same as another.

Author
GW
Date
08/2013
Parameters
rhs_MenuItem to compare against (righthand side of inequality operator)
Returns
true for the target and rhs_ being different menu items, false otherwise

◆ operator=()

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

Assigns one MenuItem object to another.

Author
GW
Date
08/2013
Parameters
rhs_Existing MenuItem object to copy values from
Returns
The target MenuItem object, but with its values updated to match that of the rhs_ argument

◆ operator==()

virtual bool hdi::core::MenuItem::operator== ( const MenuItem rhs_) const
virtual

Tests whether a given MenuItem object is the same as another.

Author
GW
Date
08/2013
Parameters
rhs_MenuItem to compare against (righthand side of equality operator)
Returns
true for the target and rhs_ being the same menu item, false otherwise

◆ parent()

virtual std::unique_ptr< MenuGroup > hdi::core::MenuItem::parent ( ) const
virtual

Gets the parent of the target menu item.

Author
GW
Date
09/2014
Returns
The parent menu group, or NULL for none/error

◆ setCallback()

virtual void hdi::core::MenuItem::setCallback ( const Callback cb_)
virtual

Sets the callback for the menu item.

Author
GW
Date
08/2013
Parameters
cb_New callback to be performed when the menu item is selected

◆ setChecked()

virtual void hdi::core::MenuItem::setChecked ( const bool  checked_)
virtual

Sets the menu item as checked or unchecked.

Author
GW
Date
08/2013
Parameters
checked_true to check the menu item, false to uncheck

◆ setEnabled()

virtual void hdi::core::MenuItem::setEnabled ( const bool  enabled_)
virtual

Sets the menu item as enabled or disabled.

Author
GW
Date
08/2013
Parameters
enabled_true to enable the item, false to disable

◆ setText()

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

Sets the text of the menu item itself.

Author
GW
Date
08/2013
Parameters
text_New text value for the menu item, as UTF-8

◆ text()

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

Gets the text of the menu item itself.

Author
GW
Date
08/2013
Returns
Current text value of the menu item, as UTF-8