libyui  3.3.2
YDialog.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YDialog.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #include <list>
27 #include <algorithm>
28 
29 #define YUILogComponent "ui"
30 #include "YUILog.h"
31 
32 #include "YDialog.h"
33 #include "YEvent.h"
34 #include "YShortcutManager.h"
35 #include "YPushButton.h"
36 #include "YButtonBox.h"
37 
38 #include "YUI.h"
39 #include "YApplication.h"
40 #include "YWidgetFactory.h"
41 #include "YOptionalWidgetFactory.h"
42 #include "YLayoutBox.h"
43 #include "YRichText.h"
44 #include "YAlignment.h"
45 #include "YUIException.h"
46 #include "YEventFilter.h"
47 #include "YWidgetID.h"
48 #include "YDumbTab.h"
49 
50 // needed in order to read release notes
51 #include <sys/types.h>
52 #include <dirent.h>
53 #include <fstream>
54 
55 #define VERBOSE_DIALOGS 0
56 #define VERBOSE_DISCARDED_EVENTS 0
57 #define VERBOSE_EVENTS 0
58 
59 
60 typedef std::list<YEventFilter *> YEventFilterList;
61 
62 
64 {
65  YDialogPrivate( YDialogType dialogType, YDialogColorMode colorMode )
66  : dialogType( dialogType )
67  , colorMode( colorMode )
68  , shortcutCheckPostponed( false )
69  , defaultButton( 0 )
70  , isOpen( false )
71  , lastEvent( 0 )
72  {}
73 
74  YDialogType dialogType;
75  YDialogColorMode colorMode;
76  bool shortcutCheckPostponed;
77  YPushButton * defaultButton;
78  bool isOpen;
79  YEvent * lastEvent;
80  YEventFilterList eventFilterList;
81 };
82 
83 
84 
85 /**
86  * Helper class: Event filter that handles "Help" buttons.
87  **/
89 {
90 public:
91  YHelpButtonHandler( YDialog * dialog )
92  : YEventFilter( dialog )
93  {}
94 
95  virtual ~YHelpButtonHandler() {}
96 
97  YEvent * filter( YEvent * event )
98  {
99  if ( event && event->widget() )
100  {
101  YPushButton * button = dynamic_cast<YPushButton *> ( event->widget() );
102 
103  if ( button && button->isHelpButton() )
104  {
105  if ( YDialog::showHelpText( button ) )
106  {
107  event = 0; // consume event
108  }
109  }
110  }
111 
112  return event;
113  }
114 };
115 
116 /**
117  * Helper class: Event filter that handles "ReleaseNotes" buttons.
118  **/
120 {
121 public:
122  YRelNotesButtonHandler( YDialog * dialog )
123  : YEventFilter( dialog )
124  {}
125 
126  virtual ~YRelNotesButtonHandler() {}
127 
128  YEvent * filter( YEvent * event )
129  {
130  if ( event && event->widget() )
131  {
132  YPushButton * button = dynamic_cast<YPushButton *> ( event->widget() );
133 
134  if ( button && button->isRelNotesButton() )
135  {
137  {
138  event = 0; // consume event
139  }
140  }
141  }
142 
143  return event;
144  }
145 };
146 
147 
148 
149 
150 YDialog::YDialog( YDialogType dialogType, YDialogColorMode colorMode )
152  , priv( new YDialogPrivate( dialogType, colorMode ) )
153 {
154  YUI_CHECK_NEW( priv );
155 
156  _dialogStack.push( this );
157 
158 #if VERBOSE_DIALOGS
159  yuiDebug() << "New " << this << std::endl;
160 #endif
161 
162  new YHelpButtonHandler( this );
163  new YRelNotesButtonHandler( this );
164 }
165 
166 
168 {
169 #if VERBOSE_DIALOGS
170  yuiDebug() << "Destroying " << this << std::endl;
171 #endif
172 
173  // Inform attached classes that this dialog is in the process of being
174  // destroyed. This also happens in the base class destructor, but that
175  // might be too late.
177 
178  if ( priv->lastEvent )
179  deleteEvent( priv->lastEvent );
180 
181  // The base class also deletes all children, but this should be done before
182  // the event filters are deleted to prevent duplicate event filter deletion
183  // from (a) child widget destructors and (b) here.
184  deleteChildren();
185 
186  // Delete the remaining event filters: Those installed by this dialog and
187  // those installed by some child widget that are not deleted yet.
189 
190  if ( ! _dialogStack.empty() && _dialogStack.top() == this )
191  {
192  _dialogStack.pop();
193 
194  if ( ! _dialogStack.empty() )
195  _dialogStack.top()->activate();
196  }
197  else
198  yuiError() << "Not top of dialog stack: " << this << std::endl;
199 }
200 
201 
202 void
204 {
205  if ( priv->isOpen )
206  return;
207 
208  checkShortcuts();
209  setInitialSize();
210  openInternal(); // Make sure this is only called once!
211 
212  priv->isOpen = true;
213 }
214 
215 
216 bool
218 {
219  return priv->isOpen;
220 }
221 
222 
223 bool
225 {
226  if ( _dialogStack.empty() )
227  {
228  yuiError() << "Dialog stack empty, but dialog existing: " << this << std::endl;
229  return false;
230  }
231 
232  return _dialogStack.top() == this;
233 }
234 
235 
236 void
238 {
239  while ( ! priv->eventFilterList.empty() )
240  {
241  YEventFilter * filter = priv->eventFilterList.back();
242 
243 #if VERBOSE_DIALOGS
244  yuiDebug() << "Deleting event filter " << std::std::hex << filter << std::dec << std::endl;
245 #endif
246  delete filter;
247  }
248 }
249 
250 
251 bool
252 YDialog::destroy( bool doThrow )
253 {
254  YUI_CHECK_WIDGET( this );
255 
256  if ( isTopmostDialog() )
257  {
258  delete this;
259 
260  return true;
261  }
262  else
263  {
264  if ( doThrow )
265  YUI_THROW( YUIDialogStackingOrderException() );
266 
267  return false;
268  }
269 }
270 
271 
274 {
275  return priv->dialogType;
276 }
277 
278 
279 bool
281 {
282  switch ( priv->dialogType )
283  {
284  case YMainDialog: return true;
285  case YWizardDialog: return true;
286  case YPopupDialog: return false;
287 
288  // Intentionally omitting the 'default' case so the compiler can
289  // catch unhandled enum values
290  }
291 
292  /*NOTREACHED*/
293  return false;
294 }
295 
296 
297 YDialogColorMode
299 {
300  return priv->colorMode;
301 }
302 
303 
304 void
306 {
307  priv->shortcutCheckPostponed = true;
308 }
309 
310 
311 bool
313 {
314  return priv->shortcutCheckPostponed;
315 }
316 
317 
318 void
320 {
321  if ( priv->shortcutCheckPostponed && ! force )
322  {
323  yuiDebug() << "Shortcut check postponed" << std::endl;
324  }
325  else
326  {
327 
328  YShortcutManager shortcutManager( this );
329  shortcutManager.checkShortcuts();
330 
331  priv->shortcutCheckPostponed = false;
332  }
333 }
334 
335 
336 YPushButton *
338 {
339  return priv->defaultButton;
340 }
341 
342 
343 void
345 {
346  if ( newDefaultButton && priv->defaultButton ) // already have one?
347  {
348  yuiError() << "Too many `opt(`default) PushButtons: ["
349  << newDefaultButton->label()
350  << "]" << std::endl;
351  }
352 
353  priv->defaultButton = newDefaultButton;
354 }
355 
356 
357 void
359 {
360 #if VERBOSE_DIALOGS
361  yuiDebug() << "Setting initial size for " << this << std::endl;
362 #endif
363 
364  // Trigger geometry management
366 }
367 
368 
369 void
371 {
372  yuiDebug() << "Recalculating layout for " << this << std::endl;
373 
375 }
376 
377 
378 YEvent *
379 YDialog::waitForEvent( int timeout_millisec )
380 {
381  if ( ! isTopmostDialog() )
382  YUI_THROW( YUIDialogStackingOrderException() );
383 
384  if ( timeout_millisec < 0 )
385  timeout_millisec = 0;
386 
387  if ( ! isOpen() )
388  open();
389 
390  if ( shortcutCheckPostponed() )
391  {
392  yuiError() << "Performing missing keyboard shortcut check now in "
393  << this << std::endl;
394 
395  checkShortcuts( true );
396  }
397 
398  deleteEvent( priv->lastEvent );
399  YEvent * event = 0;
400 
401  do
402  {
403  event = filterInvalidEvents( waitForEventInternal( timeout_millisec ) );
404  event = callEventFilters( event );
405 
406  // If there was no event, if filterInvalidEvents() discarded an invalid
407  // event, or if one of the event filters consumed an event, go back and
408  // get the next event.
409 
410  } while ( ! event );
411 
412  priv->lastEvent = event;
413 
414  return event;
415 }
416 
417 
418 YEvent *
420 {
421  if ( ! isTopmostDialog() )
422  YUI_THROW( YUIDialogStackingOrderException() );
423 
424  if ( ! isOpen() )
425  open();
426 
428 
429  if ( event ) // Optimization (calling with 0 wouldn't hurt)
430  event = callEventFilters( event );
431 
432  priv->lastEvent = event;
433 
434  // Nevermind if filterInvalidEvents() discarded an invalid event.
435  // pollInput() is normally called very often (in a loop), and most of the
436  // times it returns 0 anyway, so there is no need to care for just another
437  // 0 that is returned in this exotic case.
438 
439  return event;
440 }
441 
442 
443 YEvent *
445 {
446  if ( ! event )
447  return 0;
448 
449  YWidgetEvent * widgetEvent = dynamic_cast<YWidgetEvent *> (event);
450 
451  if ( widgetEvent && widgetEvent->widget() )
452  {
453  if ( ! widgetEvent->widget()->isValid() )
454  {
455  /**
456  * Silently discard events from widgets that have become invalid.
457  *
458  * This may legitimately happen if some widget triggered an event yet
459  * nobody cared for that event (i.e. called UserInput() or PollInput() )
460  * and the widget has been destroyed meanwhile.
461  **/
462 
463  // yuiDebug() << "Discarding event for widget that has become invalid" << std::endl;
464 
465  deleteEvent( widgetEvent );
466  return 0;
467  }
468 
469  if ( widgetEvent->widget()->findDialog() != this )
470  {
471  /**
472  * Silently discard events from all but the current (topmost) dialog.
473  *
474  * This may happen even here even though the specific UI should have
475  * taken care about that: Events may still be in the queue. They might
476  * have been valid (i.e. belonged to the topmost dialog) when they
477  * arrived, but maybe simply nobody has evaluated them.
478  **/
479 
480  // Yes, really yuiDebug() - this may legitimately happen.
481  yuiDebug() << "Discarding event from widget from foreign dialog" << std::endl;
482 
483 #if VERBOSE_DISCARDED_EVENTS
484  yuiDebug() << "Expected: " << this
485  << ", received: " << widgetEvent->widget()->findDialog()
486  << std::endl;
487 
488  yuiDebug() << "Event widget: " << widgetEvent->widget() << std::endl;
489  yuiDebug() << "From:" << std::endl;
490  widgetEvent->widget()->findDialog()->dumpWidgetTree();
491  yuiDebug() << "Current dialog:" << std::endl;
492  dumpWidgetTree();
493 #endif
494 
495  activate(); // try to force this dialog to the foreground
496 
497  deleteEvent( widgetEvent );
498  return 0;
499  }
500 
501  }
502 
503  return event;
504 }
505 
506 
507 void
509 {
510  if ( event == priv->lastEvent )
511  priv->lastEvent = 0;
512 
513  if ( event )
514  {
515  if ( event->isValid() )
516  {
517 #if VERBOSE_EVENTS
518  yuiDebug() << "Deleting " << event << std::endl;
519 #endif
520  delete event;
521  }
522  else
523  {
524  yuiError() << "Attempt to delete invalid event " << event << std::endl;
525  }
526  }
527 }
528 
529 
530 YDialog *
531 YDialog::currentDialog( bool doThrow )
532 {
533  if ( _dialogStack.empty() )
534  {
535  if ( doThrow )
536  YUI_THROW( YUINoDialogException() );
537  return 0;
538  }
539  else
540  return _dialogStack.top();
541 }
542 
543 
544 bool
546 {
547  if ( _dialogStack.empty() )
548  {
549  if ( doThrow )
550  YUI_THROW( YUINoDialogException() );
551  }
552  else
553  {
554  delete _dialogStack.top();
555  }
556 
557  return ! _dialogStack.empty();
558 }
559 
560 
561 void
563 {
564  while ( ! _dialogStack.empty() )
565  {
566  delete _dialogStack.top();
567  }
568 }
569 
570 
571 void
572 YDialog::deleteTo( YDialog * targetDialog )
573 {
574  YUI_CHECK_WIDGET( targetDialog );
575 
576  while ( ! _dialogStack.empty() )
577  {
578  YDialog * dialog = _dialogStack.top();
579 
580  delete dialog;
581 
582  if ( dialog == targetDialog )
583  return;
584  }
585 
586  // If we ever get here, targetDialog was nowhere in the dialog stack.
587 
588  YUI_THROW( YUIDialogStackingOrderException() );
589 }
590 
591 
592 int
594 {
595  return _dialogStack.size();
596 }
597 
598 
599 void
601 {
602  YUI_CHECK_PTR( eventFilter );
603 
604  if ( find( priv->eventFilterList.begin(), priv->eventFilterList.end(),
605  eventFilter ) != priv->eventFilterList.end() )
606  {
607  yuiError() << "event filter " << std::hex << eventFilter << std::dec
608  << " already added to " << this
609  << std::endl;
610  }
611  else
612  {
613 #if VERBOSE_DIALOGS
614  yuiDebug() << "Adding event filter " << std::hex << eventFilter << std::dec << std::endl;
615 #endif
616  priv->eventFilterList.push_back( eventFilter );
617  }
618 }
619 
620 
621 void
623 {
624  YUI_CHECK_PTR( eventFilter );
625 
626 #if VERBOSE_DIALOGS
627  yuiDebug() << "Removing event filter " << std::hex << eventFilter << std::dec << std::endl;
628 #endif
629  priv->eventFilterList.remove( eventFilter );
630 }
631 
632 
633 YEvent *
635 {
636  YEventFilterList::const_iterator it = priv->eventFilterList.begin();
637 
638  while ( it != priv->eventFilterList.end() && event )
639  {
640  YEvent * oldEvent = event;
641  event = (*it)->filter( event );
642 
643  if ( oldEvent != event ) // event filter consumed or changed the old event?
644  deleteEvent( oldEvent ); // get rid of the old one
645 
646  ++it;
647  }
648 
649  return event;
650 }
651 
652 
653 void
654 YDialog::showText( const std::string & text, bool useRichText )
655 {
656 
657  // set help text dialog size to 80% of topmost dialog, respectively 45x15 (default)
658 
659  unsigned int dialogWidth = 45;
660  unsigned int dialogHeight = 15;
661 
662  if ( ! _dialogStack.empty() )
663  {
664  YDialog * dialog = _dialogStack.top();
665  dialogWidth = (unsigned int) ( (float) dialog->preferredWidth() * 0.8 );
666  dialogHeight = (unsigned int) ( (float) dialog->preferredHeight() * 0.8 );
667  }
668 
669  // limit dialog to a reasonable size
670  if ( dialogWidth > 80 || dialogHeight > 25 )
671  {
672  dialogWidth = 80;
673  dialogHeight = 25;
674  }
675 
676  try
677  {
678  YDialog * dialog = YUI::widgetFactory()->createPopupDialog();
679  YAlignment * minSize = YUI::widgetFactory()->createMinSize( dialog, dialogWidth, dialogHeight );
680  YLayoutBox * vbox = YUI::widgetFactory()->createVBox( minSize );
681  YUI::widgetFactory()->createRichText( vbox, text, ! useRichText );
682  YButtonBox * buttonBox = YUI::widgetFactory()->createButtonBox( vbox );
683  YPushButton * okButton = YUI::widgetFactory()->createPushButton( buttonBox, "&OK" );
684  okButton->setRole( YOKButton );
685  okButton->setDefaultButton();
686 
687  dialog->waitForEvent();
688  dialog->destroy();
689  }
690  catch ( YUIException exception )
691  {
692  // Don't let the application die just because help couldn't be displayed.
693 
694  YUI_CAUGHT( exception );
695  }
696 }
697 
698 
699 bool
701 {
702  std::string helpText;
703 
704  while ( widget )
705  {
706  if ( ! widget->helpText().empty() )
707  {
708  yuiDebug() << "Found help text for " << widget << std::endl;
709  helpText = widget->helpText();
710  }
711 
712  widget = widget->parent();
713  }
714 
715  if ( ! helpText.empty() )
716  {
717  yuiMilestone() << "Showing help text" << std::endl;
718  showText( helpText, true );
719 
720  yuiMilestone() << "Help dialog closed" << std::endl;
721  }
722  else // No help text
723  {
724  yuiWarning() << "No help text" << std::endl;
725  }
726 
727  return ! helpText.empty();
728 }
729 
730 bool
732 {
733  yuiMilestone() <<"Showing Release Notes" << std::endl;
734 
735  // set help text dialog size to 80% of topmost dialog, respectively 45x15 (default)
736 
737  unsigned int dialogWidth = 45;
738  unsigned int dialogHeight = 15;
739 
740  if ( ! _dialogStack.empty() )
741  {
742  YDialog * dialog = _dialogStack.top();
743  dialogWidth = (unsigned int) ( (float) dialog->preferredWidth() * 0.8 );
744  dialogHeight = (unsigned int) ( (float) dialog->preferredHeight() * 0.8 );
745  }
746 
747  // limit dialog to a reasonable size
748  if ( dialogWidth > 80 || dialogHeight > 25 )
749  {
750  dialogWidth = 80;
751  dialogHeight = 25;
752  }
753 
754  try
755  {
756  std::map<std::string,std::string> relnotes = YUI::application()->releaseNotes();
757  if ( relnotes.size() == 0)
758  {
759  return false;
760  }
761  std::vector<std::string> keys;
762  for(std::map<std::string,std::string>::iterator it = relnotes.begin(); it != relnotes.end(); ++it) {
763  keys.push_back(it->first);
764  }
765  YDialog * dialog = YUI::widgetFactory()->createPopupDialog();
766  YAlignment * minSize = YUI::widgetFactory()->createMinSize( dialog, dialogWidth, dialogHeight );
767  YLayoutBox * vbox = YUI::widgetFactory()->createVBox( minSize );
768  YDumbTab * rnTab = 0;
769  YRichText * richtext = 0;
770 
771  // both QT and NCurses do support DumbTab
772  if (relnotes.size() > 1 && YUI::optionalWidgetFactory()->hasDumbTab())
773  {
774  rnTab = YUI::optionalWidgetFactory()->createDumbTab( vbox );
775  int index = 0;
776  for(std::map<std::string,std::string>::const_iterator it = relnotes.begin(); it != relnotes.end(); it++)
777  {
778  YItem * item = new YItem((*it).first );
779  item->setIndex( index++ );
780  rnTab->addItem( item );
781  }
782  richtext = YUI::widgetFactory()->createRichText( rnTab, (*(relnotes.begin())).second, YUI::app()->isTextMode() );
783  }
784  else
785  {
786  richtext = YUI::widgetFactory()->createRichText( vbox, (*(relnotes.begin())).second, YUI::app()->isTextMode() );
787  }
788  YButtonBox * buttonBox = YUI::widgetFactory()->createButtonBox( vbox );
789  YPushButton * okButton = YUI::widgetFactory()->createPushButton( buttonBox, "&OK" );
790  okButton->setRole( YOKButton );
791  okButton->setDefaultButton();
792 
793  while(true) {
794  YEvent* event = dialog->waitForEvent();
795  if ( event && event->eventType() == YEvent::MenuEvent && event->item())
796  {
797  YItem * item = dynamic_cast<YItem *> ( event->item());
798  richtext->setValue( relnotes[keys[item->index()]] );
799  }
800  else if ( event && event->widget() )
801  {
802  YPushButton * button = dynamic_cast<YPushButton *> ( event->widget() );
803  if ( button )
804  {
805  if ( button->role() == YOKButton)
806  {
807  break;
808  }
809  }
810  }
811  }
812  dialog->destroy();
813  }
814  catch ( YUIException exception )
815  {
816  // Don't let the application die just because RN couldn't be displayed.
817 
818  YUI_CAUGHT( exception );
819  }
820 
821  return true;
822 
823 }
void deleteEvent(YEvent *event)
Delete an event.
Definition: YDialog.cc:508
static bool showHelpText(YWidget *widget)
Show the help text for the specified widget.
Definition: YDialog.cc:700
static YWidgetFactory * widgetFactory()
Return the widget factory that provides all the createXY() methods for standard (mandatory, i.e.
Definition: YUI.cc:126
void deleteEventFilters()
Delete all (remaining) event filters.
Definition: YDialog.cc:237
Helper class: Event filter that handles "Help" buttons.
Definition: YDialog.cc:88
std::string helpText() const
Return the help text for this widget.
Definition: YWidget.cc:340
A vertical or horizontal stacking of widgets, implementing HBox and VBox.
Definition: YLayoutBox.h:37
virtual void setDefaultButton(YPushButton *defaultButton)
Set this dialog&#39;s default button (the button that is activated when the user hits [Return] anywhere i...
Definition: YDialog.cc:344
bool isHelpButton() const
Returns &#39;true&#39; if this is a "Help" button.
Definition: YPushButton.cc:127
YDialogType
Type of dialog: Main / Popup / Wizard.
Definition: YTypes.h:66
DumbTab: A very simple tab widget that can display and switch between a number of tabs...
Definition: YDumbTab.h:40
void setIndex(int index)
Set this item&#39;s index.
Definition: YItem.h:119
bool isValid() const
Check if this event is valid.
Definition: YEvent.cc:53
static YApplication * application()
Aliases for YUI::app()
Definition: YUI.h:112
Helper class to manage keyboard shortcuts within one dialog and resolve keyboard shortcut conflicts...
void postponeShortcutCheck()
From now on, postpone keyboard shortcut checks - i.e.
Definition: YDialog.cc:305
static bool deleteTopmostDialog(bool doThrow=true)
Delete the topmost dialog.
Definition: YDialog.cc:545
std::string label() const
Get the label (the text on the button).
Definition: YPushButton.cc:86
virtual void setDefaultButton(bool def=true)
Make this button the default button.
Definition: YPushButton.cc:98
Abstract base class to filter events.
Definition: YEventFilter.h:62
void dumpWidgetTree(int indentationLevel=0)
Debugging function: Dump the widget tree from here on to the log file.
Definition: YWidget.cc:669
Abstract base class for events to be returned upon UI::UserInput() and related functions.
Definition: YEvent.h:43
YWidget * parent() const
Return this widget&#39;s parent or 0 if it doesn&#39;t have a parent.
Definition: YWidget.cc:269
void deleteChildren()
Delete all children and remove them from the children manager&#39;s list.
Definition: YWidget.cc:200
virtual void setValue(const std::string &newValue)
Change the text content of the RichText widget.
Definition: YRichText.cc:71
YEvent * filterInvalidEvents(YEvent *event)
Filter out invalid events: Return 0 if the event does not belong to this dialog or the unchanged even...
Definition: YDialog.cc:444
int index() const
Return the index of this item (as set with setIndex() ).
Definition: YItem.h:124
bool isTopmostDialog() const
Return &#39;true&#39; if this dialog is the topmost dialog.
Definition: YDialog.cc:224
void checkShortcuts(bool force=false)
Checks the keyboard shortcuts of widgets in this dialog unless shortcut checks are postponed or &#39;forc...
Definition: YDialog.cc:319
Container widget class that manages one child.
virtual int preferredWidth()
Preferred width of the widget.
void removeEventFilter(YEventFilter *eventFilter)
Remove an event filter.
Definition: YDialog.cc:622
YDialogColorMode colorMode() const
Return this dialog&#39;s color mode.
Definition: YDialog.cc:298
YDialog * findDialog()
Traverse up the widget hierarchy and find the dialog this widget belongs to.
Definition: YWidget.cc:374
A push button; may have an icon, and a F-key shortcut.
Definition: YPushButton.h:37
virtual void addItem(YItem *item)
Add an item (a tab page).
Definition: YDumbTab.cc:66
bool isValid() const
Checks whether or not this object is valid.
Definition: YWidget.cc:242
virtual void openInternal()=0
Internal open() method.
static void deleteAllDialogs()
Delete all open dialogs.
Definition: YDialog.cc:562
virtual void setRole(YButtonRole role)
Set a predefined role for this button.
Definition: YPushButton.cc:154
bool isOpen() const
Return &#39;true&#39; if open() has already been called for this dialog.
Definition: YDialog.cc:217
Implementation of all the alignment widgets:
Definition: YAlignment.h:41
virtual YEvent * pollEventInternal()=0
Check if a user event is pending.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
static YDialog * currentDialog(bool doThrow=true)
Return the current (topmost) dialog.
Definition: YDialog.cc:531
bool shortcutCheckPostponed() const
Return whether or not shortcut checking is currently postponed.
Definition: YDialog.cc:312
YEvent * callEventFilters(YEvent *event)
Call the installed event filters.
Definition: YDialog.cc:634
void checkShortcuts(bool autoResolve=true)
Check the keyboard shortcuts of all children of this dialog (not for sub-dialogs!).
void setBeingDestroyed()
Set the "being destroyed" flag, i.e.
Definition: YWidget.cc:262
YButtonRole role() const
Return the role of this button.
Definition: YPushButton.cc:178
Helper class: Event filter that handles "ReleaseNotes" buttons.
Definition: YDialog.cc:119
void open()
Open a newly created dialog: Finalize it and make it visible on the screen.
Definition: YDialog.cc:203
void addEventFilter(YEventFilter *eventFilter)
Add an event filter.
Definition: YDialog.cc:600
Simple item class for SelectionBox, ComboBox, MultiSelectionBox etc.
Definition: YItem.h:49
static YOptionalWidgetFactory * optionalWidgetFactory()
Return the widget factory that provides all the createXY() methods for optional ("special") widgets a...
Definition: YUI.cc:141
YDialog(YDialogType dialogType, YDialogColorMode colorMode=YDialogNormalColor)
Constructor.
Definition: YDialog.cc:150
void setInitialSize()
Set the initial dialog size, depending on dialogType: YMainDialog dialogs get the UI&#39;s "default main ...
Definition: YDialog.cc:358
static void deleteTo(YDialog *dialog)
Delete all dialogs from the topmost to the one specified.
Definition: YDialog.cc:572
static bool showRelNotesText()
Show the release notes.
Definition: YDialog.cc:731
YDialogType dialogType() const
Return this dialog&#39;s type (YMainDialog / YPopupDialog /YWizardDialog).
Definition: YDialog.cc:273
virtual void activate()=0
Activate this dialog: Make sure that it is shown as the topmost dialog of this application and that i...
static void showText(const std::string &text, bool richText=false)
Show the specified text in a pop-up dialog with a local event loop.
Definition: YDialog.cc:654
static int openDialogsCount()
Returns the number of currently open dialogs (from 1 on), i.e., the depth of the dialog stack...
Definition: YDialog.cc:593
virtual ~YDialog()
Destructor.
Definition: YDialog.cc:167
Text formatted with simple HTML-like tags, with "links" generating events.
Definition: YRichText.h:39
static YApplication * app()
Return the global YApplication object.
Definition: YUI.cc:156
std::map< std::string, std::string > releaseNotes() const
Get the current release notes map.
void recalcLayout()
Recalculate the layout of the dialog and of all its children after children have been added or remove...
Definition: YDialog.cc:370
YPushButton * defaultButton() const
Return this dialog&#39;s default button: The button that is activated when the user hits [Return] anywher...
Definition: YDialog.cc:337
bool isRelNotesButton() const
Returns &#39;true&#39; if this is a "Release Notes" button.
Definition: YPushButton.cc:139
A window in the desktop environment.
Definition: YDialog.h:47
virtual YEvent * waitForEventInternal(int timeout_millisec)=0
Wait for a user event.
Container widget for dialog buttons that abstracts the button order depending on the desktop environm...
Definition: YButtonBox.h:148
YEvent * filter(YEvent *event)
The heart of the matter: The event filter function.
Definition: YDialog.cc:128
YEvent * pollEvent()
Check if a user event is pending.
Definition: YDialog.cc:419
virtual YWidget * widget() const
Returns the widget that caused this event or 0 if there is none.
Definition: YEvent.h:93
YEvent * filter(YEvent *event)
The heart of the matter: The event filter function.
Definition: YDialog.cc:97
Abstract base class of all UI widgets.
Definition: YWidget.h:54
Base class for UI Exceptions.
Definition: YUIException.h:297
bool destroy(bool doThrow=true)
Close and delete this dialog (and all its children) if it is the topmost dialog.
Definition: YDialog.cc:252
static std::stack< YDialog * > _dialogStack
Stack holding all currently existing dialogs.
Definition: YDialog.h:410
YEvent * waitForEvent(int timeout_millisec=0)
Wait for a user event.
Definition: YDialog.cc:379
virtual YWidget * widget() const
Returns the widget that caused this event.
Definition: YEvent.h:180
virtual int preferredHeight()
Preferred height of the widget.
bool isMainDialog()
Return &#39;true&#39; if this dialog is a dialog of main dialog size: YMainDialog or YWizardDialog.
Definition: YDialog.cc:280