libyui
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes

YDialog Class Reference

Inheritance diagram for YDialog:
YSingleChildContainerWidget YWidget

List of all members.

Public Member Functions

virtual const char * widgetClass () const
void open ()
bool isOpen () const
YEventwaitForEvent (int timeout_millisec=0)
YEventpollEvent ()
bool isTopmostDialog () 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

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 string &text, bool richText=false)
static bool showHelpText (YWidget *widget)

Protected Member Functions

 YDialog (YDialogType dialogType, YDialogColorMode colorMode=YDialogNormalColor)
virtual ~YDialog ()
virtual void openInternal ()=0
virtual YEventwaitForEventInternal (int timeout_millisec)=0
virtual YEventpollEventInternal ()=0
YEventfilterInvalidEvents (YEvent *event)
YEventcallEventFilters (YEvent *event)
void deleteEventFilters ()

Static Protected Attributes

static std::stack< YDialog * > _dialogStack

Constructor & Destructor Documentation

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 ( ) [protected, virtual]

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


Member Function Documentation

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.

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.

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

Call the installed event filters.

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.

YDialogColorMode YDialog::colorMode ( ) const

Return this dialog's color mode.

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.

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.

void YDialog::deleteAllDialogs ( ) [static]

Delete all open dialogs.

void YDialog::deleteEvent ( YEvent event)

Delete an event.

void YDialog::deleteEventFilters ( ) [protected]

Delete all (remaining) event filters.

void YDialog::deleteTo ( YDialog dialog) [static]

Delete all dialogs from the topmost to the one specified.

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.

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.

YDialogType YDialog::dialogType ( ) const

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

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.

virtual void YDialog::highlight ( YWidget child) [inline, virtual]

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.

bool YDialog::isMainDialog ( )

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

bool YDialog::isOpen ( ) const

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

bool YDialog::isTopmostDialog ( ) const

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

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.

int YDialog::openDialogsCount ( ) [static]

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

virtual void YDialog::openInternal ( ) [protected, pure 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.

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.

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

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.

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.

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.

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.

bool YDialog::shortcutCheckPostponed ( ) const

Return whether or not shortcut checking is currently postponed.

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.

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

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

static YDialog* YDialog::topmostDialog ( bool  doThrow = true) [inline, static]

Alias for currentDialog().

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.

virtual YEvent* YDialog::waitForEventInternal ( int  timeout_millisec) [protected, pure virtual]

Wait for a user event.

Derived classes are required to implement this.

virtual const char* YDialog::widgetClass ( ) const [inline, virtual]

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

Reimplemented from YWidget.


Member Data Documentation

std::stack< YDialog * > YDialog::_dialogStack [static, protected]

Stack holding all currently existing dialogs.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Friends