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

#include <YDialog.h>

Inheritance diagram for YDialog:
Collaboration diagram for YDialog:

Public Member Functions

virtual const char * widgetClass () const
 
void open ()
 
bool isOpen () const
 
YEventwaitForEvent (int timeout_millisec=0)
 
YEventpollEvent ()
 
bool isTopmostDialog () const
 
void requestMultiPassLayout ()
 
int layoutPass () const
 
bool destroy (bool doThrow=true)
 
void setInitialSize ()
 
void recalcLayout ()
 
YDialogType dialogType () const
 
bool isMainDialog ()
 
YDialogColorMode colorMode () const
 
void checkShortcuts (bool force=false)
 
void postponeShortcutCheck ()
 
bool shortcutCheckPostponed () const
 
YPushButtondefaultButton () const
 
void deleteEvent (YEvent *event)
 
void addEventFilter (YEventFilter *eventFilter)
 
void removeEventFilter (YEventFilter *eventFilter)
 
virtual void highlight (YWidget *child)
 
virtual void setDefaultButton (YPushButton *defaultButton)
 
virtual void activate ()=0
 
- Public Member Functions inherited from YSingleChildContainerWidget
virtual ~YSingleChildContainerWidget ()
 
virtual int preferredWidth ()
 
virtual int preferredHeight ()
 
virtual void setSize (int newWidth, int newHeight)
 
virtual bool stretchable (YUIDimension dim) const
 
- Public Member Functions inherited from YWidget
virtual ~YWidget ()
 
virtual std::string debugLabel () const
 
std::string helpText () const
 
void setHelpText (const std::string &helpText)
 
virtual const YPropertySetpropertySet ()
 
virtual bool setProperty (const std::string &propertyName, const YPropertyValue &val)
 
virtual YPropertyValue getProperty (const std::string &propertyName)
 
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 preferredSize (YUIDimension dim)
 
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
 
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 ()
 
virtual std::string shortcutString () const
 
virtual void setShortcutString (const std::string &str)
 
virtual const char * userInputProperty ()
 
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 ()
 

Static Public Member Functions

static bool deleteTopmostDialog (bool doThrow=true)
 
static void deleteAllDialogs ()
 
static void deleteTo (YDialog *dialog)
 
static int openDialogsCount ()
 
static YDialogcurrentDialog (bool doThrow=true)
 
static YDialogtopmostDialog (bool doThrow=true)
 
static void showText (const std::string &text, bool richText=false)
 
static bool showHelpText (YWidget *widget)
 
static bool showRelNotesText ()
 

Protected Member Functions

 YDialog (YDialogType dialogType, YDialogColorMode colorMode=YDialogNormalColor)
 
virtual ~YDialog ()
 
virtual void openInternal ()=0
 
void doLayout ()
 
virtual YEventwaitForEventInternal (int timeout_millisec)=0
 
virtual YEventpollEventInternal ()=0
 
YEventfilterInvalidEvents (YEvent *event)
 
YEventcallEventFilters (YEvent *event)
 
void deleteEventFilters ()
 
- Protected Member Functions inherited from YSingleChildContainerWidget
 YSingleChildContainerWidget (YWidget *parent)
 
- Protected Member Functions inherited from YWidget
 YWidget (YWidget *parent)
 
YWidgetChildrenManagerchildrenManager () const
 
void setChildrenManager (YWidgetChildrenManager *manager)
 
void setBeingDestroyed ()
 
void dumpWidget (YWidget *w, int indentationLevel)
 

Static Protected Attributes

static std::stack< YDialog * > _dialogStack
 

Detailed Description

A window in the desktop environment. A YPopupDialog always has a dedicated window but YMainDialog may be stacked in a single window.

Constructor & Destructor Documentation

◆ YDialog()

YDialog::YDialog ( YDialogType dialogType,
YDialogColorMode colorMode = YDialogNormalColor )
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.

◆ ~YDialog()

YDialog::~YDialog ( )
protectedvirtual

Destructor. Don't delete a dialog directly, use YDialog::deleteTopmostDialog() or YDialog::destroy().

Member Function Documentation

◆ activate()

virtual void YDialog::activate ( )
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.

◆ addEventFilter()

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.

◆ callEventFilters()

YEvent * YDialog::callEventFilters ( YEvent * event)
protected

Call the installed event filters.

◆ checkShortcuts()

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.

◆ colorMode()

YDialogColorMode YDialog::colorMode ( ) const

Return this dialog's color mode.

◆ currentDialog()

YDialog * YDialog::currentDialog ( bool doThrow = true)
static

Return the current (topmost) dialog.

If there is none, throw a YUINoDialogException if 'doThrow' is 'true' and return 0 if 'doThrow' is false.

◆ defaultButton()

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.

◆ deleteAllDialogs()

void YDialog::deleteAllDialogs ( )
static

Delete all open dialogs.

◆ deleteEvent()

void YDialog::deleteEvent ( YEvent * event)

Delete an event.

◆ deleteEventFilters()

void YDialog::deleteEventFilters ( )
protected

Delete all (remaining) event filters.

◆ deleteTo()

void YDialog::deleteTo ( YDialog * dialog)
static

Delete all dialogs from the topmost to the one specified.

◆ deleteTopmostDialog()

bool YDialog::deleteTopmostDialog ( bool doThrow = true)
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.

◆ destroy()

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.

◆ dialogType()

YDialogType YDialog::dialogType ( ) const

Return this dialog's type (YMainDialog / YPopupDialog /YWizardDialog).

◆ doLayout()

void YDialog::doLayout ( )
protected

Calculate the layout and set the size of the dialog and all widgets.

◆ filterInvalidEvents()

YEvent * YDialog::filterInvalidEvents ( YEvent * event)
protected

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.

◆ highlight()

virtual void YDialog::highlight ( YWidget * child)
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.

◆ isMainDialog()

bool YDialog::isMainDialog ( )

Return 'true' if this dialog is a dialog of main dialog size: YMainDialog or YWizardDialog.

◆ isOpen()

bool YDialog::isOpen ( ) const

Return 'true' if open() has already been called for this dialog.

◆ isTopmostDialog()

bool YDialog::isTopmostDialog ( ) const

Return 'true' if this dialog is the topmost dialog.

◆ layoutPass()

int YDialog::layoutPass ( ) const

Return the number of the current layout pass: 0: No layout going on right now 1: First pass 2: Second pass of a multi-pass layout

◆ open()

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.

◆ openDialogsCount()

int YDialog::openDialogsCount ( )
static

Returns the number of currently open dialogs (from 1 on), i.e., the depth of the dialog stack.

◆ openInternal()

virtual void YDialog::openInternal ( )
protectedpure virtual

Internal open() method. This is called (exactly once during the life time of the dialog) in open().

Derived classes are required to implement this to do whatever is necessary to make this dialog visible on the screen.

◆ pollEvent()

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.

◆ pollEventInternal()

virtual YEvent * YDialog::pollEventInternal ( )
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.

◆ postponeShortcutCheck()

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 ).

◆ recalcLayout()

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.

◆ removeEventFilter()

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.

◆ requestMultiPassLayout()

void YDialog::requestMultiPassLayout ( )

Request multiple passes of the layout engine.

This is intended for widgets that don't know their preferred width and height immediately because one depends on the other, for example labels with auto-wrapping: They know (roughly) the area they will need, but they can calculate their preferred height only when their width is known.

Once set, this option cannot be unset; it remains set for the life time of the dialog.

◆ setDefaultButton()

void YDialog::setDefaultButton ( YPushButton * defaultButton)
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.

◆ setInitialSize()

void YDialog::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.

◆ shortcutCheckPostponed()

bool YDialog::shortcutCheckPostponed ( ) const

Return whether or not shortcut checking is currently postponed.

◆ showHelpText()

bool YDialog::showHelpText ( YWidget * widget)
static

Show the help text for the specified widget. If it doesn't have one, traverse up the widget hierarchy until there is one.

The found help text, or the empty string, is displayed in a pop-up dialog with a local event loop.

This always returns 'true' (for backward compatibility).

◆ showRelNotesText()

bool YDialog::showRelNotesText ( )
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).

This is called from the YRelNotesButtonHandler event filter (see YDialog.cc) on a very low level when a button has the "release notes" button role (YPushButton::isRelNotesButton()).

Notice that the YQWizard has its own release notes dialog (see QY2RelNotesDialog) that is used only in the Qt UI and only in the YQWizard and only after UI.WizardCommand(ShowReleaseNotesButton, ...).

◆ showText()

void YDialog::showText ( const std::string & text,
bool richText = false )
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.

◆ topmostDialog()

static YDialog * YDialog::topmostDialog ( bool doThrow = true)
inlinestatic

Alias for currentDialog().

◆ waitForEvent()

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 Ruby, 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.

◆ waitForEventInternal()

virtual YEvent * YDialog::waitForEventInternal ( int timeout_millisec)
protectedpure virtual

Wait for a user event.

Derived classes are required to implement this.

◆ widgetClass()

virtual const char * YDialog::widgetClass ( ) const
inlinevirtual

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

Reimplemented from YWidget.

Member Data Documentation

◆ _dialogStack

stack< YDialog * > YDialog::_dialogStack
staticprotected

Stack holding all currently existing dialogs.


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