libyui
 
Loading...
Searching...
No Matches
YItemSelector Class Referenceabstract

#include <YItemSelector.h>

Inheritance diagram for YItemSelector:
Collaboration diagram for YItemSelector:

Public Member Functions

 YItemSelector (YWidget *parent, bool enforceSingleSelection=true)
 
 YItemSelector (YWidget *parent, const YItemCustomStatusVector &customStates)
 
virtual ~YItemSelector ()
 
virtual const char * widgetClass () const
 
int visibleItems () const
 
virtual void setVisibleItems (int newVal)
 
virtual void setItemStatus (YItem *item, int status)
 
bool usingCustomStatus () const
 
int customStatusCount () const
 
const YItemCustomStatuscustomStatus (int index)
 
bool validCustomStatusIndex (int index) const
 
int cycleCustomStatus (int oldStatus)
 
virtual bool setProperty (const std::string &propertyName, const YPropertyValue &val)
 
virtual YPropertyValue getProperty (const std::string &propertyName)
 
virtual const YPropertySetpropertySet ()
 
const char * userInputProperty ()
 
virtual void activateItem (YItem *item)=0
 
- Public Member Functions inherited from YSelectionWidget
virtual ~YSelectionWidget ()
 
std::string label () const
 
virtual void setLabel (const std::string &newLabel)
 
virtual void addItem (YItem *item_disown)
 
void addItem (const std::string &itemLabel, bool selected=false)
 
void addItem (const std::string &itemLabel, const std::string &iconName, bool selected=false)
 
virtual void addItems (const YItemCollection &itemCollection)
 
virtual void deleteAllItems ()
 
void setItems (const YItemCollection &itemCollection)
 
YItemIterator itemsBegin ()
 
YItemConstIterator itemsBegin () const
 
YItemIterator itemsEnd ()
 
YItemConstIterator itemsEnd () const
 
bool hasItems () const
 
int itemsCount () const
 
YItemitemAt (int index) const
 
YItemfirstItem () const
 
virtual YItemselectedItem ()
 
virtual YItemCollection selectedItems ()
 
bool hasSelectedItem ()
 
virtual void selectItem (YItem *item, bool selected=true)
 
virtual void deselectAllItems ()
 
void setIconBasePath (const std::string &basePath)
 
std::string iconBasePath () const
 
std::string iconFullPath (const std::string &iconName) const
 
std::string iconFullPath (YItem *item) const
 
bool itemsContain (YItem *item) const
 
YItemfindItem (const std::string &itemLabel) const
 
void dumpItems () const
 
bool enforceSingleSelection () const
 
virtual void shortcutChanged ()
 
virtual std::string shortcutString () const
 
virtual void setShortcutString (const std::string &str)
 
- Public Member Functions inherited from YWidget
virtual ~YWidget ()
 
virtual std::string debugLabel () const
 
std::string helpText () const
 
void setHelpText (const std::string &helpText)
 
bool hasChildren () const
 
YWidgetfirstChild () const
 
YWidgetlastChild () const
 
YWidgetListIterator childrenBegin () const
 
YWidgetListIterator childrenEnd () const
 
YWidgetListConstIterator childrenConstBegin () const
 
YWidgetListConstIterator childrenConstEnd () const
 
YWidgetListIterator begin ()
 
YWidgetListIterator end ()
 
int childrenCount () const
 
bool contains (YWidget *child) const
 
virtual void addChild (YWidget *child)
 
virtual void removeChild (YWidget *child)
 
void deleteChildren ()
 
YWidgetparent () const
 
bool hasParent () const
 
void setParent (YWidget *newParent)
 
YDialogfindDialog ()
 
YWidgetfindWidget (YWidgetID *id, bool doThrow=true) const
 
virtual int preferredWidth ()=0
 
virtual int preferredHeight ()=0
 
virtual int preferredSize (YUIDimension dim)
 
virtual void setSize (int newWidth, int newHeight)=0
 
bool isValid () const
 
bool beingDestroyed () const
 
void * widgetRep () const
 
void setWidgetRep (void *toolkitWidgetRep)
 
bool hasId () const
 
YWidgetIDid () const
 
void setId (YWidgetID *newId_disown)
 
virtual void setEnabled (bool enabled=true)
 
void setDisabled ()
 
virtual bool isEnabled () const
 
virtual bool stretchable (YUIDimension dim) const
 
void setStretchable (YUIDimension dim, bool newStretch)
 
void setDefaultStretchable (YUIDimension dim, bool newStretch)
 
virtual int weight (YUIDimension dim)
 
bool hasWeight (YUIDimension dim)
 
void setWeight (YUIDimension dim, int weight)
 
void setNotify (bool notify=true)
 
bool notify () const
 
void setNotifyContextMenu (bool notifyContextMenu=true)
 
bool notifyContextMenu () const
 
bool sendKeyEvents () const
 
void setSendKeyEvents (bool doSend)
 
bool autoShortcut () const
 
void setAutoShortcut (bool _newAutoShortcut)
 
int functionKey () const
 
bool hasFunctionKey () const
 
virtual void setFunctionKey (int fkey_no)
 
virtual bool setKeyboardFocus ()
 
void dumpWidgetTree (int indentationLevel=0)
 
void dumpDialogWidgetTree ()
 
void setChildrenEnabled (bool enabled)
 
virtual void saveUserInput (YMacroRecorder *macroRecorder)
 
void * operator new (size_t size)
 
void operator delete (void *ptr) noexcept
 
virtual void startMultipleChanges ()
 
virtual void doneMultipleChanges ()
 

Protected Member Functions

virtual void updateCustomStatusIndicator (YItem *item)
 
- Protected Member Functions inherited from YSelectionWidget
 YSelectionWidget (YWidget *parent, const std::string &label, bool enforceSingleSelection, bool recursiveSelection=false)
 
void setEnforceSingleSelection (bool on)
 
void setEnforceInitialSelection (bool on)
 
bool enforceInitialSelection () const
 
bool recursiveSelection () const
 
YItemfindSelectedItem (YItemConstIterator begin, YItemConstIterator end)
 
void findSelectedItems (YItemCollection &selectedItems, YItemConstIterator begin, YItemConstIterator end)
 
void deselectAllItems (YItemIterator begin, YItemIterator end)
 
YItemfindItem (const std::string &wantedItemLabel, YItemConstIterator begin, YItemConstIterator end) const
 
bool itemsContain (YItem *wantedItem, YItemConstIterator begin, YItemConstIterator end) const
 
- Protected Member Functions inherited from YWidget
 YWidget (YWidget *parent)
 
YWidgetChildrenManagerchildrenManager () const
 
void setChildrenManager (YWidgetChildrenManager *manager)
 
void setBeingDestroyed ()
 
void dumpWidget (YWidget *w, int indentationLevel)
 

Detailed Description

Scrollable item selector widget with not only a label for each item, but also a (possible multi-line) description and an optional icon.

This widget supports both 1-of-n or n-of-m selection, i.e. it can act as a (more verbose and more screen space consuming) replacement for YSelectionBox or YMultiSelectionBox.

Constructor & Destructor Documentation

◆ YItemSelector() [1/2]

YItemSelector::YItemSelector ( YWidget * parent,
bool enforceSingleSelection = true )

Standard constructor.

◆ YItemSelector() [2/2]

YItemSelector::YItemSelector ( YWidget * parent,
const YItemCustomStatusVector & customStates )

Constructor for custom item status values.

This makes it possible to set a wider variety of values than just 0 or

  1. The semantics behind the individual status values is purely application defined; the specified customStates description only provides an icon (for graphical UIs) or a text representation (for text-based UIs) and an optional "next" status value that can be used to let the user cycle through different status values. The numeric value of each status is implicitly its index in the vector.

Notice that this constructor is the only way to set custom status value descriptions; they cannot be changed anymore after initializing the widget. This is by design so that any derived widgets in concrete UIs do not have to bother with possibly recreating any subwidgets if this should change; this guarantees that it does not change, neither the fact that there are custom status values nor their number or indicator icons or texts.

This constructor implicitly sets 'enforceSingleSelection' to 'false'.

In this mode, the widget sends YMenuEvents (which include the item that the user changed) if the notify option is set. For anything beyond the simple status transitions that are defined here in 'customStates', it is highly recommended to set that notify option and to handle those YMenuEvents on the application level.

◆ ~YItemSelector()

YItemSelector::~YItemSelector ( )
virtual

Destructor.

Member Function Documentation

◆ activateItem()

virtual void YItemSelector::activateItem ( YItem * item)
pure virtual

Activate selected item. Can be used in tests to simulate user input.

Derived classes are required to implement this.

◆ customStatus()

const YItemCustomStatus & YItemSelector::customStatus ( int index)

Return the custom status with the specified index (counting from 0).

Notice that this may throw a std::out_of_range exception if the index is invalid.

◆ customStatusCount()

int YItemSelector::customStatusCount ( ) const

Return the number of custom status values or 0 if no custom status values are used.

◆ cycleCustomStatus()

int YItemSelector::cycleCustomStatus ( int oldStatus)

Cycle through the custom status values according to the custom status table, i.e. return the 'nextStatus' field of table index 'oldStatus'. This may be -1 if no next status was specified there or if 'oldStatus' is out of range of that table.

◆ getProperty()

YPropertyValue YItemSelector::getProperty ( const std::string & propertyName)
virtual

Get a property. Reimplemented from YWidget.

This method may throw YUIPropertyExceptions.

Reimplemented from YWidget.

◆ propertySet()

const YPropertySet & YItemSelector::propertySet ( )
virtual

Return this class's property set. This also initializes the property upon the first call.

Reimplemented from YWidget.

Reimplemented from YWidget.

◆ setItemStatus()

void YItemSelector::setItemStatus ( YItem * item,
int status )
virtual

Set the status of an item. Unlike YItem::setStatus(), this informs the widget of the change so it can set the corresponding status icon.

Reimplemented from YSelectionWidget.

Reimplemented from YSelectionWidget.

◆ setProperty()

bool YItemSelector::setProperty ( const std::string & propertyName,
const YPropertyValue & val )
virtual

Set a property. Reimplemented from YWidget.

This function may throw YUIPropertyExceptions.

This function returns 'true' if the value was successfully set and 'false' if that value requires special handling (not in error cases: those are covered by exceptions).

Reimplemented from YWidget.

◆ setVisibleItems()

void YItemSelector::setVisibleItems ( int newVal)
virtual

Set the number of visible items. When changing this, make sure to recalculate the layout (YDialog::recalc()) so the change has any effect.

Derived classes are free to reimplement this, but they should call this base class method in the overloaded function.

◆ updateCustomStatusIndicator()

virtual void YItemSelector::updateCustomStatusIndicator ( YItem * item)
inlineprotectedvirtual

Update the status indicator (status icon or text indicator) if this widget is using custom status values.

Derived classes should overwrite this.

◆ userInputProperty()

const char * YItemSelector::userInputProperty ( )
inlinevirtual

The name of the widget property that will return user input. Inherited from YWidget.

Reimplemented from YWidget.

◆ usingCustomStatus()

bool YItemSelector::usingCustomStatus ( ) const

Return 'true' if this widget uses custom status values, 'false' if not (i.e. only 0 or 1).

◆ validCustomStatusIndex()

bool YItemSelector::validCustomStatusIndex ( int index) const

Return 'true' if a custom status index is within the valid range, i.e. 0..customStatusCount()-1, 'false' otherwise.

◆ visibleItems()

int YItemSelector::visibleItems ( ) const

Return the number of visible items (i.e. items that are visible without scrolling). This is used to calculate the preferred height. If the widget gets more or less screen space than desired due to layout constraints, this number is not updated; this is purely the desired value for initializing layout negotiations.

◆ widgetClass()

const char * YItemSelector::widgetClass ( ) const
virtual

Return a descriptive name of this widget class for logging, debugging etc.

Reimplemented from YSelectionWidget.


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