Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
Public Types | Public Member Functions | Static Public Member Functions | List of all members
hdi::core::PopupMenu Class Reference

Popup menu widget, allowing for a single preset entry to be chosen at a time. More...

#include <hdicorePopupMenu.h>

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

Public Types

typedef std::vector< ListEntryEntryVector
 
- 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.
 
typedef std::auto_ptr< ImageIDsImageIDsAP
 

Public Member Functions

 PopupMenu ()
 Constructs an empty PopupMenu object. More...
 
 PopupMenu (const PopupMenu &popup_)
 Constructs a new PopupMenu object from an existing PopupMenu object (copy constructor) More...
 
 PopupMenu (const Point &loc_, const double width_)
 Constructs an empty PopupMenu widget at a given location of a given width. More...
 
 PopupMenu (const Point &loc_, const double width_, const EntryVector &entries_, const int32_t initialIndex_)
 Constructs a PopupMenu widget with a list of entries and an initial index selection. More...
 
 PopupMenu (const Point &loc_, const double width_, const EntryVector &entries_, const std::string &initialID_)
 Constructs a PopupMenu widget with a list of entries and an initial ID selection. More...
 
virtual ~PopupMenu ()
 PopupMenu destructor. More...
 
virtual PopupMenuoperator= (const PopupMenu &rhs_)
 Allows one PopupMenu object to be assigned from another. More...
 
virtual PopupMenuclone () const
 Convenience method to clone a PopupMenu object on the heap. More...
 
virtual PopupMenuduplicate () const
 Convenience method to duplicate a PopupMenu object, creating a new and identical UI element to the target (but not belonging to the same containing window) More...
 
virtual void selectUnknownEntry ()
 In the case of a mixed popup state, this will create and select a blank entry. More...
 
virtual void deselectUnknownEntry ()
 In the case of a (prior) mixed popup state, this will deselect and destroy the blank entry. More...
 
virtual int32_t currentIndex () const
 Gets the index of the currently selected entry. More...
 
virtual bool setCurrentIndex (const int32_t index_)
 Sets the currently selected entry by index. More...
 
virtual std::string currentID () const
 Gets the ID of the currently selected entry. More...
 
virtual bool setCurrentID (const std::string &id_)
 Sets the currently selected entry by ID. More...
 
virtual std::string currentValue () const
 Gets the string value of the currently selected entry. More...
 
virtual bool setCurrentValue (const std::string &value_)
 Sets the currently selected entry by string value. More...
 
virtual std::auto_ptr< ListEntrycurrentEntry () const
 Gets the current entry object. More...
 
virtual bool currentUserData (void *&data__) const
 Gets the user data for the current entry. More...
 
virtual const std::vector< ListEntry * > *const entries () const
 Gets the entries vector. More...
 
virtual void setEntries (const EntryVector &entries_)
 Allows the entries in an popup menu to be changed out entirely. More...
 
virtual bool hasEntry (const std::string &id_) const
 Gets whether the entries vector already contains an entry, based on its ID. More...
 
virtual bool pushEntry (const ListEntry &entry_)
 Pushes an entry onto the list (i.e. at the end) More...
 
virtual bool popEntry (ListEntry &entry__)
 Pops an entry off the list (i.e. from the end) More...
 
virtual bool insertEntry (const std::string &id_, const ListEntry &entry_)
 Inserts an entry into the list of entries at a given position. More...
 
virtual bool removeEntry (const std::string &id_, ListEntry &entry__)
 Removes a specific entry from the list of entries. More...
 
virtual void clearEntries ()
 Clears all entries contained by the widget. More...
 
virtual void valueChanged ()
 Simulates the popup menu having its value changed. More...
 
virtual Callback *const valueChangedCallback () const
 Gets the value changed callback for the popup menu. More...
 
virtual void setValueChangedCallback (const Callback &callback_)
 Sets the value changed callback. More...
 
virtual void update ()
 Force the popup menu to update its entries. More...
 
- Public Member Functions inherited from hdi::core::Widget
(virtual) - ~Widget
 Destructs a Widget. More...
 
(virtual PlatformWidgetPtr) - platformWidget
 Gets the platform-specific widget, around which the target object is wrapped. More...
 
(virtual bool) - isEmpty
 Gets whether the target Widget object is empty (constructed with the default ctor) More...
 
(virtual bool) - operator==
 Tests whether a given Widget object is the same as another. More...
 
(virtual bool) - operator!=
 Tests whether a given Widget object is not the same as another. More...
 
(virtual Type- type
 Gets the type of the widget. More...
 
(virtual Window *const) - window
 Gets the parent window of the widget. More...
 
(virtual Rect- frame
 Gets the widget frame. More...
 
(virtual void) - setFrame
 Sets the widget frame. More...
 
(virtual void) - offset
 Offsets the widget from its current location by the given amounts. More...
 
(virtual std::string) - text
 Gets the current text value of the widget. More...
 
(virtual void) - setText
 Sets the current text value of the widget. More...
 
(virtual bool) - enabled
 Gets whether the widget is enabled. More...
 
(virtual void) - setEnabled
 Enables or disables the widget. More...
 
(virtual bool) - visible
 Gets whether the widget is visible. More...
 
(virtual void) - setVisible
 Shows or hides the widget. More...
 
(virtual void) - setOrigin
 Convenience method to set just the origin of the target widget's frame. More...
 
(virtual void) - setSize
 Convenience method to set just the size of the target widget's frame. More...
 
(virtual void) - setWidth
 Convenience method to set just the width of the target widget's frame. More...
 
(virtual void) - setHeight
 Convenience method to set just the height of the target widget's frame. More...
 
(virtual bool) - hasFocus
 Gets whether the widget currently has focus. More...
 
(virtual void) - focus
 Forces the widget to have focus, taking it from any other focused widget of the same window. More...
 
(virtual void) - blur
 Removes focus from the widget. More...
 
(virtual std::string) - tooltip
 Gets the tool tip string for the widget. More...
 
(virtual void) - setTooltip
 Sets the tool tip string for the widget. More...
 

Static Public Member Functions

static PopupMenu FontMenu (const Point &loc_, const double width_, const Font &font_)
 Static named constructor for creating a font menu with a preselected font object. More...
 
- Static Public Member Functions inherited from hdi::core::Widget
(static bool) + isCoreWidget
 Gets whether the given platform widget is a hdi_core widget. More...
 
(static std::auto_ptr< Widget >) + lastClickedWidget
 Gets the last widget that received a click event (either by the user or programmatically) More...
 
(static std::auto_ptr< Widget >) + lastValueChangingWidget
 Gets the last widget that received a value changing event (either by the user or programmatically) More...
 
(static std::auto_ptr< Widget >) + lastValueChangedWidget
 Gets the last widget that received a value changed event (either by the user or programmatically) More...
 
(static bool) + forceIdeographicFontSize
 Gets whether widgets should use an ideographically appropriate font size for widget text on Windows (whether or not the Illustrator locale dictates one should be used) More...
 
(static void) + setForceIdeographicFontSize
 Sets whether widgets should use an ideographically appropriate font size for widget text on Windows (whether or not the Illustrator locale dictates one should be used) More...
 

Additional Inherited Members

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

Detailed Description

Popup menu widget, allowing for a single preset entry to be chosen at a time.

Constructor & Destructor Documentation

hdi::core::PopupMenu::PopupMenu ( )

Constructs an empty PopupMenu object.

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

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

Author
GW
Date
09/2013
Parameters
popup_Existing PopupMenu object
hdi::core::PopupMenu::PopupMenu ( const Point loc_,
const double  width_ 
)

Constructs an empty PopupMenu widget at a given location of a given width.

Author
GW
Date
09/2013
Parameters
loc_Position of the popup
width_Width of the popup
hdi::core::PopupMenu::PopupMenu ( const Point loc_,
const double  width_,
const EntryVector &  entries_,
const int32_t  initialIndex_ 
)

Constructs a PopupMenu widget with a list of entries and an initial index selection.

Author
GW
Date
09/2013
Parameters
loc_Position of the popup
width_Width of the popup
entries_Vector of string entries, whose order in the popup will match the vector
initialIndex_Initial index to select (must exist in entries_, and must not be a separator)
hdi::core::PopupMenu::PopupMenu ( const Point loc_,
const double  width_,
const EntryVector &  entries_,
const std::string &  initialID_ 
)

Constructs a PopupMenu widget with a list of entries and an initial ID selection.

Author
GW
Date
09/2013
Parameters
loc_Position of the popup
width_Width of the popup
entries_Vector of string entries, whose order in the popup will match that in the vector
initialID_Initial ID to select, as UTF-8 (must exist in entries_, and must not be a separator)
virtual hdi::core::PopupMenu::~PopupMenu ( )
virtual

PopupMenu destructor.

Author
GW
Date
09/2013

Member Function Documentation

virtual void hdi::core::PopupMenu::clearEntries ( )
virtual

Clears all entries contained by the widget.

Author
GW
Date
09/2013
virtual PopupMenu* hdi::core::PopupMenu::clone ( ) const
virtual

Convenience method to clone a PopupMenu object on the heap.

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

Implements hdi::core::Widget.

virtual std::auto_ptr<ListEntry> hdi::core::PopupMenu::currentEntry ( ) const
virtual

Gets the current entry object.

Author
GW
Date
09/2013
Returns
The ListEntry object for the currently selected item
virtual std::string hdi::core::PopupMenu::currentID ( ) const
virtual

Gets the ID of the currently selected entry.

Author
GW
Date
09/2013
Returns
UTF-8 ID string of the currently selected entry, or "" if no entry is currently selected
virtual int32_t hdi::core::PopupMenu::currentIndex ( ) const
virtual

Gets the index of the currently selected entry.

Author
GW
Date
09/2013
Returns
The index number of the currently selected entry, or -1 if no entry is selected
virtual bool hdi::core::PopupMenu::currentUserData ( void *&  data__) const
virtual

Gets the user data for the current entry.

Author
GW
Date
09/2013
Parameters
data__Return-by-reference for the current user data; ignore if false is returned
Returns
true if the method succeeds in acquiring the contained entry data, false otherwise
virtual std::string hdi::core::PopupMenu::currentValue ( ) const
virtual

Gets the string value of the currently selected entry.

Author
GW
Date
09/2013
Returns
Value string of the popup menu, as UTF-8
virtual void hdi::core::PopupMenu::deselectUnknownEntry ( )
virtual

In the case of a (prior) mixed popup state, this will deselect and destroy the blank entry.

Author
GW
Date
09/2013
virtual PopupMenu* hdi::core::PopupMenu::duplicate ( ) const
virtual

Convenience method to duplicate a PopupMenu 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 PopupMenu object (and new UI element)
Note
The new popup menu will have copies of all entries present in the target, but be aware that copies of the user data in each entry cannot be made (because they are simply void* variables). As such, the user data in the copies will simply be set to NULL by this method. This does not apply to PopupMenu objects previously created with the FontMenu() named constructor.
Warning
The caller must manage the memory for the returned PopupMenu object.

Implements hdi::core::Widget.

virtual const std::vector< ListEntry* >* const hdi::core::PopupMenu::entries ( ) const
virtual

Gets the entries vector.

Author
GW
Date
09/2013
Returns
The entries vector for the target widget, containing all currently known entries
Note
Modifying any value in an entry will not cause the widget to update automatically; call update() to update the UI for changes made to entry data.
static PopupMenu hdi::core::PopupMenu::FontMenu ( const Point loc_,
const double  width_,
const Font font_ 
)
static

Static named constructor for creating a font menu with a preselected font object.

Author
GW
Date
09/2013
Parameters
loc_Position of the popup
width_Width of the popup
font_Font face to select by default
Returns
A PopupMenu object, filled with all fonts available to Illustrator
Note
The ListEntry objects, with which the PopupMenu is filled, themselves contain pointers to Font objects
virtual bool hdi::core::PopupMenu::hasEntry ( const std::string &  id_) const
virtual

Gets whether the entries vector already contains an entry, based on its ID.

Author
GW
Date
09/2013
Parameters
id_ID of the entry to search for, as UTF-8
Returns
true if the widget already contains an entry with the given ID, false otherwise
virtual bool hdi::core::PopupMenu::insertEntry ( const std::string &  id_,
const ListEntry entry_ 
)
virtual

Inserts an entry into the list of entries at a given position.

Author
GW
Date
09/2013
Parameters
id_Existing entry immediately before the position at which the new entry will be inserted, as UTF-8
entry_New entry object to insert into the list of entries
Returns
true if the entry is inserted successfully, false otherwise
Note
If the entry for id_ doesn't exist in the list, the new entry will not be inserted.
If the passed entry is already present in the list (based on its ID), it will not be inserted.
virtual PopupMenu& hdi::core::PopupMenu::operator= ( const PopupMenu rhs_)
virtual

Allows one PopupMenu 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 PopupMenu object, but with its value updated to match that of rhs_
virtual bool hdi::core::PopupMenu::popEntry ( ListEntry entry__)
virtual

Pops an entry off the list (i.e. from the end)

Author
GW
Date
09/2013
Parameters
entry__Return-by-reference for the popped entry, so the caller can inspect which one was removed
Returns
true if an entry was popped and acquired, false otherwise
Warning
If you created the target PopupMenu object with the FontMenu named constructor, then the ListEntry object will contain a Font object pointer for which the caller will become responsible (i.e. the caller must cast the user data void* to a Font* and delete the Font object when the ListEntry object is no longer needed).
virtual bool hdi::core::PopupMenu::pushEntry ( const ListEntry entry_)
virtual

Pushes an entry onto the list (i.e. at the end)

Author
GW
Date
09/2013
Parameters
entry_New entry object to insert into the list of entries
Returns
true if the entry is pushed successfully, false otherwise
Note
If the entry is already present in the list (based on its ID), it will not be inserted.
virtual bool hdi::core::PopupMenu::removeEntry ( const std::string &  id_,
ListEntry entry__ 
)
virtual

Removes a specific entry from the list of entries.

Author
GW
Date
09/2013
Parameters
id_ID of the entry to be removed, as UTF-8
entry__Return-by-reference for the removed entry, so the caller can inspect which one was removed
Returns
true if an entry was removed and acquired, false otherwise
Warning
If you created the target PopupMenu object with the FontMenu named constructor, then the ListEntry object will contain a Font object pointer for which the caller will become responsible (i.e. the caller must cast the user data void* to a Font* and delete the Font object when the ListEntry object is no longer needed).
virtual void hdi::core::PopupMenu::selectUnknownEntry ( )
virtual

In the case of a mixed popup state, this will create and select a blank entry.

Author
GW
Date
09/2013
virtual bool hdi::core::PopupMenu::setCurrentID ( const std::string &  id_)
virtual

Sets the currently selected entry by ID.

Author
GW
Date
09/2013
Parameters
id_ID of new value to select in the popup menu, as UTF-8
Returns
true if the entry with the given ID was selected, or false if invalid
virtual bool hdi::core::PopupMenu::setCurrentIndex ( const int32_t  index_)
virtual

Sets the currently selected entry by index.

Author
GW
Date
09/2013
Parameters
index_New index to select
Returns
true if the selection occurred successfully, or false if e.g. out of range
virtual bool hdi::core::PopupMenu::setCurrentValue ( const std::string &  value_)
virtual

Sets the currently selected entry by string value.

Author
GW
Date
09/2013
Parameters
value_New value to set for the popup menu (if it exists as an entry), as UTF-8
Returns
true if the value was set, false otherwise
virtual void hdi::core::PopupMenu::setEntries ( const EntryVector &  entries_)
virtual

Allows the entries in an popup menu to be changed out entirely.

Author
GW
Date
09/2013
Parameters
entries_New set of entries that the widget will contain
virtual void hdi::core::PopupMenu::setValueChangedCallback ( const Callback callback_)
virtual

Sets the value changed callback.

Author
GW
Date
09/2013
Parameters
callback_New callback for when the popup menu's value has changed
virtual void hdi::core::PopupMenu::update ( )
virtual

Force the popup menu to update its entries.

Author
GW
Date
12/2013

Reimplemented from hdi::core::Widget.

virtual void hdi::core::PopupMenu::valueChanged ( )
virtual

Simulates the popup menu having its value changed.

Author
GW
Date
09/2013
virtual Callback* const hdi::core::PopupMenu::valueChangedCallback ( ) const
virtual

Gets the value changed callback for the popup menu.

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