libyui
3.3.1
|
A window in the desktop environment. More...
#include <YDialog.h>
Public Member Functions | |
virtual const char * | widgetClass () const |
Return a descriptive name of this widget class for logging, debugging etc. | |
void | open () |
Open a newly created dialog: Finalize it and make it visible on the screen. More... | |
bool | isOpen () const |
Return 'true' if open() has already been called for this dialog. | |
YEvent * | waitForEvent (int timeout_millisec=0) |
Wait for a user event. More... | |
YEvent * | pollEvent () |
Check if a user event is pending. More... | |
bool | isTopmostDialog () const |
Return 'true' if this dialog is the topmost dialog. | |
bool | destroy (bool doThrow=true) |
Close and delete this dialog (and all its children) if it is the topmost dialog. More... | |
void | setInitialSize () |
Set the initial dialog size, depending on dialogType: YMainDialog dialogs get the UI's "default main window" size, YPopupDialog dialogs use their content's preferred size. | |
void | recalcLayout () |
Recalculate the layout of the dialog and of all its children after children have been added or removed or if any of them changed its preferred width of height. More... | |
YDialogType | dialogType () const |
Return this dialog's type (YMainDialog / YPopupDialog /YWizardDialog). | |
bool | isMainDialog () |
Return 'true' if this dialog is a dialog of main dialog size: YMainDialog or YWizardDialog. | |
YDialogColorMode | colorMode () const |
Return this dialog's color mode. | |
void | checkShortcuts (bool force=false) |
Checks the keyboard shortcuts of widgets in this dialog unless shortcut checks are postponed or 'force' is 'true'. More... | |
void | postponeShortcutCheck () |
From now on, postpone keyboard shortcut checks - i.e. More... | |
bool | shortcutCheckPostponed () const |
Return whether or not shortcut checking is currently postponed. | |
YPushButton * | defaultButton () const |
Return this dialog's default button: The button that is activated when the user hits [Return] anywhere in this dialog. More... | |
void | deleteEvent (YEvent *event) |
Delete an event. | |
void | addEventFilter (YEventFilter *eventFilter) |
Add an event filter. More... | |
void | removeEventFilter (YEventFilter *eventFilter) |
Remove an event filter. More... | |
virtual void | highlight (YWidget *child) |
Highlight a child widget of this dialog. More... | |
virtual void | setDefaultButton (YPushButton *defaultButton) |
Set this dialog's default button (the button that is activated when the user hits [Return] anywhere in this dialog). More... | |
virtual void | activate ()=0 |
Activate this dialog: Make sure that it is shown as the topmost dialog of this application and that it can receive input. More... | |
![]() | |
virtual | ~YSingleChildContainerWidget () |
Destructor. | |
virtual int | preferredWidth () |
Preferred width of the widget. More... | |
virtual int | preferredHeight () |
Preferred height of the widget. More... | |
virtual void | setSize (int newWidth, int newHeight) |
Set the new size of the widget. More... | |
virtual bool | stretchable (YUIDimension dim) const |
Returns 'true' if this widget is stretchable in the specified dimension. More... | |
![]() | |
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... | |
virtual const YPropertySet & | propertySet () |
Return this class's property set. 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... | |
bool | hasChildren () const |
Returns 'true' if this widget has any children. | |
YWidget * | firstChild () const |
Returns the first child or 0 if there is none. More... | |
YWidget * | lastChild () 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. | |
YWidget * | parent () 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. | |
YDialog * | findDialog () |
Traverse up the widget hierarchy and find the dialog this widget belongs to. More... | |
YWidget * | findWidget (YWidgetID *id, bool doThrow=true) const |
Recursively find a widget by its ID. More... | |
virtual int | preferredSize (YUIDimension dim) |
Preferred size of the widget in the specified dimension. 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. | |
YWidgetID * | id () 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. | |
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 void | setFunctionKey (int fkey_no) |
Assign a function key to this widget (1 for F1, 2 for F2, etc. More... | |
virtual bool | setKeyboardFocus () |
Set the keyboard focus to this widget. More... | |
virtual std::string | shortcutString () const |
Get the string of this widget that holds the keyboard shortcut, if any. More... | |
virtual void | setShortcutString (const std::string &str) |
Set the string of this widget that holds the keyboard shortcut, if any. 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 () |
Static Public Member Functions | |
static bool | deleteTopmostDialog (bool doThrow=true) |
Delete the topmost dialog. More... | |
static void | deleteAllDialogs () |
Delete all open dialogs. | |
static void | deleteTo (YDialog *dialog) |
Delete all dialogs from the topmost to the one specified. | |
static int | openDialogsCount () |
Returns the number of currently open dialogs (from 1 on), i.e., the depth of the dialog stack. | |
static YDialog * | currentDialog (bool doThrow=true) |
Return the current (topmost) dialog. More... | |
static YDialog * | topmostDialog (bool doThrow=true) |
Alias for currentDialog(). | |
static void | showText (const std::string &text, bool richText=false) |
Show the specified text in a pop-up dialog with a local event loop. More... | |
static bool | showHelpText (YWidget *widget) |
Show the help text for the specified widget. More... | |
static bool | showRelNotesText () |
Show the release notes. More... | |
Protected Member Functions | |
YDialog (YDialogType dialogType, YDialogColorMode colorMode=YDialogNormalColor) | |
Constructor. More... | |
virtual | ~YDialog () |
Destructor. More... | |
virtual void | openInternal ()=0 |
Internal open() method. More... | |
virtual YEvent * | waitForEventInternal (int timeout_millisec)=0 |
Wait for a user event. More... | |
virtual YEvent * | pollEventInternal ()=0 |
Check if a user event is pending. More... | |
YEvent * | filterInvalidEvents (YEvent *event) |
Filter out invalid events: Return 0 if the event does not belong to this dialog or the unchanged event if it does. More... | |
YEvent * | callEventFilters (YEvent *event) |
Call the installed event filters. | |
void | deleteEventFilters () |
Delete all (remaining) event filters. | |
![]() | |
YSingleChildContainerWidget (YWidget *parent) | |
Constructor. | |
![]() | |
YWidget (YWidget *parent) | |
Constructor. | |
YWidgetChildrenManager * | childrenManager () 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. | |
Static Protected Attributes | |
static std::stack< YDialog * > | _dialogStack |
Stack holding all currently existing dialogs. | |
A window in the desktop environment.
A YPopupDialog always has a dedicated window but YMainDialog may be stacked in a single window.
|
protected |
Constructor.
'dialogType' is one of YMainDialog or YPopupDialog.
'colorMode' can be set to YDialogWarnColor to use very bright "warning" colors or YDialogInfoColor to use more prominent, yet not quite as bright as "warning" colors. Use both only very rarely.
Definition at line 150 of file YDialog.cc.
|
protectedvirtual |
Destructor.
Don't delete a dialog directly, use YDialog::deleteTopmostDialog() or YDialog::destroy().
Definition at line 167 of file YDialog.cc.
|
pure virtual |
Activate this dialog: Make sure that it is shown as the topmost dialog of this application and that it can receive input.
Derived classes are required to implement this.
void YDialog::addEventFilter | ( | YEventFilter * | eventFilter | ) |
Add an event filter.
This can be useful to catch certain types of events before they are delivered to the application. All event filters are called (in unspecified order) in waitForEvent(). Each one may consume an event, pass it through unchanged, or replace it with a newly created event.
Normally, an YEventFilter should be created on the heap with 'new'. In that case, the dialog's destructor will take care of deleting it.
In rare cases it might make sense to create an YEventFilter on the stack (as a local variable) and rely on that variable to go out of scope and be destroyed before the dialog gets destroyed. But that may be risky.
Notice that applications never need to call this function: YEventFilter does it automatically in its constructor.
Definition at line 600 of file YDialog.cc.
void YDialog::checkShortcuts | ( | bool | force = false | ) |
Checks the keyboard shortcuts of widgets in this dialog unless shortcut checks are postponed or 'force' is 'true'.
A forced shortcut check resets postponed checking.
Definition at line 319 of file YDialog.cc.
|
static |
Return the current (topmost) dialog.
If there is none, throw a YUINoDialogException if 'doThrow' is 'true' and return 0 if 'doThrow' is false.
Definition at line 531 of file YDialog.cc.
YPushButton * YDialog::defaultButton | ( | ) | const |
Return this dialog's default button: The button that is activated when the user hits [Return] anywhere in this dialog.
Note that this is not the same as the button that currently has the keyboard focus.
This might return 0 if there is no default button.
Definition at line 337 of file YDialog.cc.
|
static |
Delete the topmost dialog.
Will throw a YUINoDialogException if there is no dialog and 'doThrow' is 'true'.
This is equivalent to YDialog::currentDialog()->destroy().
Returns 'true' if there is another open dialog after deleting, 'false' if there is none.
Definition at line 545 of file YDialog.cc.
bool YDialog::destroy | ( | bool | doThrow = true | ) |
Close and delete this dialog (and all its children) if it is the topmost dialog.
If this is not the topmost dialog, this will throw an exception if 'doThrow' is true (default).
Remember that all pointers to the dialog and its children will be invalid after this operation.
This is intentionally not named close() since close() would not imply that the dialog and its children are deleted.
Returns 'true' upon success, 'false' upon failure.
Definition at line 252 of file YDialog.cc.
Filter out invalid events: Return 0 if the event does not belong to this dialog or the unchanged event if it does.
Silently discard events from widgets that have become invalid.
This may legitimately happen if some widget triggered an event yet nobody cared for that event (i.e. called UserInput() or PollInput() ) and the widget has been destroyed meanwhile.
Silently discard events from all but the current (topmost) dialog.
This may happen even here even though the specific UI should have taken care about that: Events may still be in the queue. They might have been valid (i.e. belonged to the topmost dialog) when they arrived, but maybe simply nobody has evaluated them.
Definition at line 444 of file YDialog.cc.
|
inlinevirtual |
Highlight a child widget of this dialog.
This is meant for debugging: YDialogSpy and similar uses.
No more than one widget can be highlighted at any one time in the same dialog. Highlighting another widget un-highlights a previously highlighted widget. 0 means 'unhighlight the last highlighted widget, but don't highlight any other'.
This default implementation does nothing.
Definition at line 312 of file YDialog.h.
void YDialog::open | ( | ) |
Open a newly created dialog: Finalize it and make it visible on the screen.
Applications should call this once after all children are created. If the application doesn't do this, it will be done automatically upon the next call of YDialog::waitForEvent() (or related). This is OK if YDialog::waitForEvent() is called immediately after creating the dialog anyway. If it is not, the application might appear sluggish to the user.
Derived classes are free to reimplement this, but they should call this base class method in the new implementation.
Definition at line 203 of file YDialog.cc.
|
protectedpure virtual |
YEvent * YDialog::pollEvent | ( | ) |
Check if a user event is pending.
If there is one, return it. If there is none, do not wait for one - return 0.
If open() has not been called for this dialog until now, it is called now.
The dialog retains ownership of the event and will delete it upon the next call to waitForEvent() or pollEvent() or when the dialog is deleted. This also means that the return value of this function can safely be ignored without fear of memory leaks.
If this dialog is not the topmost dialog, an exception is thrown.
Definition at line 419 of file YDialog.cc.
|
protectedpure virtual |
Check if a user event is pending.
If there is one, return it. If there is none, do not wait for one - return 0.
Derived classes are required to implement this.
void YDialog::postponeShortcutCheck | ( | ) |
From now on, postpone keyboard shortcut checks - i.e.
normal (not forced) checkKeyboardShortcuts() will do nothing. Reset this mode by forcing a shortcut check with checkKeyboardShortcuts( true ).
Definition at line 305 of file YDialog.cc.
void YDialog::recalcLayout | ( | ) |
Recalculate the layout of the dialog and of all its children after children have been added or removed or if any of them changed its preferred width of height.
This is a very expensive operation. Call it only when really necessary. YDialog::open() includes a call to YDialog::setInitialSize() which does the same.
The basic idea behind this function is to call it when the dialog changed after it (and its children hierarchy) was initially created.
Definition at line 370 of file YDialog.cc.
void YDialog::removeEventFilter | ( | YEventFilter * | eventFilter | ) |
Remove an event filter.
Notice that applications never need to call this function: YEventFilter does it automatically in its destructor.
Definition at line 622 of file YDialog.cc.
|
virtual |
Set this dialog's default button (the button that is activated when the user hits [Return] anywhere in this dialog).
0 means no default button.
There should be no more than one default button in a dialog.
Derived classes are free to overwrite this method, but they should call this base class method in the new implementation.
Definition at line 344 of file YDialog.cc.
|
static |
Show the help text for the specified widget.
If it doesn't have one, traverse up the widget hierarchy until there is one.
If there is a help text, it is displayed in a pop-up dialog with a local event loop.
This returns 'true' on success (there was a help text) and 'false' on failure (no help text).
Definition at line 700 of file YDialog.cc.
|
static |
Show the release notes.
If there are release notes, they are displayed in a pop-up dialog with a local event loop.
This returns 'true' on success (there were relnotes) and 'false' on failure (no relnotes).
Definition at line 731 of file YDialog.cc.
|
static |
Show the specified text in a pop-up dialog with a local event loop.
This is useful for help texts. 'richText' indicates if YRichText formatting should be applied.
Definition at line 654 of file YDialog.cc.
YEvent * YDialog::waitForEvent | ( | int | timeout_millisec = 0 | ) |
Wait for a user event.
In most cases, this means waiting until the user has clicked on a button in this dialog. If any widget has its 'notify' flag set (opt(
notify) in YCP, setNotify( true ) in C++), an action on such a widget will also make waitForEvent() return.
If the specified timeout elapses without any user event, a YTimeoutEvent will be returned. 0 means no timeout (wait forever).
If open() has not been called for this dialog until now, it is called now.
The dialog retains ownership of the event and will delete it upon the next call to waitForEvent() or pollEvent() or when the dialog is deleted. This also means that the return value of this function can safely be ignored without fear of memory leaks.
Applications can create YEventFilters to act upon some events before they are delivered to the application. Each event filter of this dialog is called (in undefined order) in waitForEvent(). An event filter can consume an event (in which case waitForEvent() will return to its internal event loop), pass it through unchanged, or even replace it with a new event. Refer to the YEventFilter documentation for more details.
If this dialog is not the topmost dialog, an exception is thrown.
Definition at line 379 of file YDialog.cc.
|
protectedpure virtual |
Wait for a user event.
Derived classes are required to implement this.