libyui  3.3.2
YPushButton Class Reference

A push button; may have an icon, and a F-key shortcut. More...

#include <YPushButton.h>

Inheritance diagram for YPushButton:
Collaboration diagram for YPushButton:

Public Member Functions

virtual ~YPushButton ()
 Destructor.
 
virtual const char * widgetClass () const
 Return a descriptive name of this widget class for logging, debugging etc.
 
std::string label () const
 Get the label (the text on the button).
 
virtual void setLabel (const std::string &label)
 Set the label (the text on the button). More...
 
virtual void setIcon (const std::string &iconName)
 Set this button's icon from an icon file in the UI's default icon directory. More...
 
bool isDefaultButton () const
 Returns 'true' if this is the dialog's default button, i.e. More...
 
virtual void setDefaultButton (bool def=true)
 Make this button the default button. More...
 
virtual void setRole (YButtonRole role)
 Set a predefined role for this button. More...
 
YButtonRole role () const
 Return the role of this button.
 
virtual void setFunctionKey (int fkey_no)
 Assign a function key to this widget (1 for F1, 2 for F2, etc. More...
 
bool isHelpButton () const
 Returns 'true' if this is a "Help" button. More...
 
virtual void setHelpButton (bool helpButton=true)
 Make this button a help button. More...
 
bool isRelNotesButton () const
 Returns 'true' if this is a "Release Notes" button. More...
 
virtual void setRelNotesButton (bool relNotesButton=true)
 Make this button a release notes button. More...
 
virtual bool setProperty (const std::string &propertyName, const YPropertyValue &val)
 Set a property. More...
 
virtual YPropertyValue getProperty (const std::string &propertyName)
 Get a property. More...
 
virtual const YPropertySetpropertySet ()
 Return this class's property set. More...
 
virtual std::string shortcutString () const
 Get the string of this widget that holds the keyboard shortcut. More...
 
virtual void setShortcutString (const std::string &str)
 Set the string of this widget that holds the keyboard shortcut. More...
 
- Public Member Functions inherited from YWidget
virtual ~YWidget ()
 Destructor.
 
virtual std::string debugLabel () const
 Returns a descriptive label of this widget instance. More...
 
std::string helpText () const
 Return the help text for this widget.
 
void setHelpText (const std::string &helpText)
 Set a help text for this widget. More...
 
bool hasChildren () const
 Returns 'true' if this widget has any children.
 
YWidgetfirstChild () const
 Returns the first child or 0 if there is none. More...
 
YWidgetlastChild () const
 Returns the last child or 0 if there is none.
 
YWidgetListIterator childrenBegin () const
 Return an iterator that points to the first child or to childrenEnd() if there are no children.
 
YWidgetListIterator childrenEnd () const
 Return an interator that points after the last child.
 
YWidgetListConstIterator childrenConstBegin () const
 Return a const iterator that points to the first child or to childrenEnd() if there are no children.
 
YWidgetListConstIterator childrenConstEnd () const
 Return a const interator that points after the last child.
 
YWidgetListIterator begin ()
 A helper for the range-based "for" loop. More...
 
YWidgetListIterator end ()
 A helper for the range-based "for" loop. More...
 
int childrenCount () const
 Returns the current number of children.
 
bool contains (YWidget *child) const
 Checks if 'child' is a (direct!) child of this widget.
 
virtual void addChild (YWidget *child)
 Add a new child. More...
 
virtual void removeChild (YWidget *child)
 Remove a child. More...
 
void deleteChildren ()
 Delete all children and remove them from the children manager's list.
 
YWidgetparent () const
 Return this widget's parent or 0 if it doesn't have a parent.
 
bool hasParent () const
 Return 'true' if this widget has a parent, 'false' if not.
 
void setParent (YWidget *newParent)
 Set this widget's parent.
 
YDialogfindDialog ()
 Traverse up the widget hierarchy and find the dialog this widget belongs to. More...
 
YWidgetfindWidget (YWidgetID *id, bool doThrow=true) const
 Recursively find a widget by its ID. More...
 
virtual int preferredWidth ()=0
 Preferred width of the widget. More...
 
virtual int preferredHeight ()=0
 Preferred height of the widget. More...
 
virtual int preferredSize (YUIDimension dim)
 Preferred size of the widget in the specified dimension. More...
 
virtual void setSize (int newWidth, int newHeight)=0
 Set the new size of the widget. More...
 
bool isValid () const
 Checks whether or not this object is valid. More...
 
bool beingDestroyed () const
 Check if this widget is in the process of being destroyed.
 
void * widgetRep () const
 Return a pointer to the underlying toolkit's (Qt, ...) widget representing this abstract UI widget.
 
void setWidgetRep (void *toolkitWidgetRep)
 Set the pointer to the underlying toolkit's (Qt, ...) widget representing this abstract UI widget. More...
 
bool hasId () const
 Returns 'true' if this widget has an ID.
 
YWidgetIDid () const
 Returns this widget's ID.
 
void setId (YWidgetID *newId_disown)
 Set this widget's ID. More...
 
virtual void setEnabled (bool enabled=true)
 Enable or disable this widget, i.e. More...
 
void setDisabled ()
 Disable this widget (overloaded for better readability).
 
virtual bool isEnabled () const
 Returns 'true' if this widget is enabled.
 
virtual bool stretchable (YUIDimension dim) const
 This is a boolean value that determines whether the widget is resizable beyond its preferred size in the specified dimension. More...
 
void setStretchable (YUIDimension dim, bool newStretch)
 Set the stretchable state to "newStretch" regardless of any hstretch or vstretch options.
 
void setDefaultStretchable (YUIDimension dim, bool newStretch)
 Set the stretchable state to "newStretch". More...
 
virtual int weight (YUIDimension dim)
 The weight is used in situations where all widgets can get their preferred size and yet space is available. More...
 
bool hasWeight (YUIDimension dim)
 Return whether or not the widget has a weight in the specified dimension.
 
void setWeight (YUIDimension dim, int weight)
 Set a weight in the specified dimension.
 
void setNotify (bool notify=true)
 Sets the Notify property.
 
bool notify () const
 Returns whether the widget will notify, i.e. More...
 
void setNotifyContextMenu (bool notifyContextMenu=true)
 Sets the notifyContextMenu property.
 
bool notifyContextMenu () const
 Returns whether the widget will send an event when the user clicks selects the context menu e.g. More...
 
bool sendKeyEvents () const
 Returns 'true' if this widget should send key events, i.e. More...
 
void setSendKeyEvents (bool doSend)
 Specify whether or not this widget should send key events.
 
bool autoShortcut () const
 Returns 'true' if a keyboard shortcut should automatically be assigned to this widget - without complaints in the log file.
 
void setAutoShortcut (bool _newAutoShortcut)
 Sets the 'autoShortcut' flag.
 
int functionKey () const
 Return a function key number that is assigned to this widget. More...
 
bool hasFunctionKey () const
 Check if a function key is assigned to this widget.
 
virtual bool setKeyboardFocus ()
 Set the keyboard focus to this widget. More...
 
virtual const char * userInputProperty ()
 The name of the widget property that will return user input, if there is any. More...
 
void dumpWidgetTree (int indentationLevel=0)
 Debugging function: Dump the widget tree from here on to the log file.
 
void dumpDialogWidgetTree ()
 Debugging function: Dump the widget tree from this widget's dialog parent. More...
 
void setChildrenEnabled (bool enabled)
 Enable or disable all widgets in this widget tree.
 
virtual void saveUserInput (YMacroRecorder *macroRecorder)
 Recursively save the user input of all child widgets to a macro recorder: More...
 
void * operator new (size_t size)
 Overloaded operator new to ensure widgets are always created on the heap, never on the stack. More...
 
virtual void startMultipleChanges ()
 In some UIs updating the screen content is an expensive operation. More...
 
virtual void doneMultipleChanges ()
 

Protected Member Functions

 YPushButton (YWidget *parent, const std::string &label)
 Constructor.
 
- Protected Member Functions inherited from YWidget
 YWidget (YWidget *parent)
 Constructor.
 
YWidgetChildrenManagerchildrenManager () const
 Returns this widget's children manager.
 
void setChildrenManager (YWidgetChildrenManager *manager)
 Sets a new children manager for this widget. More...
 
void setBeingDestroyed ()
 Set the "being destroyed" flag, i.e. More...
 
void dumpWidget (YWidget *w, int indentationLevel)
 Helper function for dumpWidgetTree(): Dump one widget to the log file.
 

Detailed Description

A push button; may have an icon, and a F-key shortcut.

Definition at line 37 of file YPushButton.h.

Member Function Documentation

◆ getProperty()

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

Get a property.

Reimplemented from YWidget.

This method may throw YUIPropertyExceptions.

Reimplemented from YWidget.

Definition at line 245 of file YPushButton.cc.

Here is the call graph for this function:

◆ isDefaultButton()

bool YPushButton::isDefaultButton ( ) const

Returns 'true' if this is the dialog's default button, i.e.

the one button that gets activated if the user hits the [Return] key anywhere in the dialog.

Definition at line 92 of file YPushButton.cc.

◆ isHelpButton()

bool YPushButton::isHelpButton ( ) const

Returns 'true' if this is a "Help" button.

When activated, a help button will traverse up its widget hierarchy and search for the topmost widget with a helpText() set and display that help text in a pop-up dialog (with a local event loop).

NOTE that this is only done during YDialog::waitForEvent() (i.e. in YCP UI::WaitForEvent(), UI::UserInput(), UI::TimeoutUserInput() ) and not during YDialog::pollEvent() (i.e. YCP UI::PollInput()) since displaying the help text will block the application until the user closes the help text.

Definition at line 127 of file YPushButton.cc.

◆ isRelNotesButton()

bool YPushButton::isRelNotesButton ( ) const

Returns 'true' if this is a "Release Notes" button.

NOTE that this is only done during YDialog::waitForEvent() (i.e. in YCP UI::WaitForEvent(), UI::UserInput(), UI::TimeoutUserInput() ) and not during YDialog::pollEvent() (i.e. YCP UI::PollInput()) since displaying the release notes will block the application until the user closes the text.

Definition at line 139 of file YPushButton.cc.

◆ propertySet()

const YPropertySet & YPushButton::propertySet ( )
virtual

Return this class's property set.

This also initializes the property upon the first call.

Reimplemented from YWidget.

Reimplemented from YWidget.

Definition at line 212 of file YPushButton.cc.

Here is the call graph for this function:

◆ setDefaultButton()

void YPushButton::setDefaultButton ( bool  def = true)
virtual

Make this button the default button.

Derived classes should reimplement this, but call this base class function in the overwritten function.

Definition at line 98 of file YPushButton.cc.

Here is the call graph for this function:

◆ setFunctionKey()

void YPushButton::setFunctionKey ( int  fkey_no)
virtual

Assign a function key to this widget (1 for F1, 2 for F2, etc.

; 0 for none)

Reimplemented from YWidget to map function keys to button roles.

Derived classes may want to overwrite this function, but they should call this base class function in the new function.

Reimplemented from YWidget.

Definition at line 186 of file YPushButton.cc.

Here is the call graph for this function:

◆ setHelpButton()

void YPushButton::setHelpButton ( bool  helpButton = true)
virtual

Make this button a help button.

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

Definition at line 133 of file YPushButton.cc.

◆ setIcon()

virtual void YPushButton::setIcon ( const std::string &  iconName)
inlinevirtual

Set this button's icon from an icon file in the UI's default icon directory.

Clear the icon if the name is empty.

This default implementation does nothing. UIs that can handle icons can choose to overwrite this method.

Definition at line 77 of file YPushButton.h.

Here is the call graph for this function:

◆ setLabel()

void YPushButton::setLabel ( const std::string &  label)
virtual

Set the label (the text on the button).

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

Definition at line 80 of file YPushButton.cc.

Here is the call graph for this function:

◆ setProperty()

bool YPushButton::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.

Definition at line 230 of file YPushButton.cc.

Here is the call graph for this function:

◆ setRelNotesButton()

void YPushButton::setRelNotesButton ( bool  relNotesButton = true)
virtual

Make this button a release notes button.

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

Definition at line 145 of file YPushButton.cc.

◆ setRole()

void YPushButton::setRole ( YButtonRole  role)
virtual

Set a predefined role for this button.

This is important when the button is a child of a YButtonBox so the layout can be arranged according to the conventions of the current UI or desktop environment.

See YButtonBox.h for more details. YButtonRole is defined in YTypes.h

The default is YCustomButton, i.e., no predefined role. setFunctionKey() uses some heuristics to map function keys to buttons:

F10 -> YOkButton
F9  -> YCancelButton
F1  -> YHelpButton

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

Definition at line 154 of file YPushButton.cc.

Here is the call graph for this function:

◆ setShortcutString()

virtual void YPushButton::setShortcutString ( const std::string &  str)
inlinevirtual

Set the string of this widget that holds the keyboard shortcut.

Reimplemented from YWidget.

Reimplemented from YWidget.

Definition at line 215 of file YPushButton.h.

Here is the call graph for this function:

◆ shortcutString()

virtual std::string YPushButton::shortcutString ( ) const
inlinevirtual

Get the string of this widget that holds the keyboard shortcut.

Reimplemented from YWidget.

Reimplemented from YWidget.

Definition at line 208 of file YPushButton.h.

Here is the call graph for this function:

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