libyui
YDialog.h
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.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YDialog_h
27 #define YDialog_h
28 
29 #include "YSingleChildContainerWidget.h"
30 #include <stack>
31 #include <map>
32 
33 class YShortcutManager;
34 class YPushButton;
35 class YDialogPrivate;
36 class YEvent;
37 class YEventFilter;
38 
39 // See YTypes.h for enum YDialogType and enum YDialogColorMode
40 
41 
48 {
49 protected:
60  YDialogColorMode colorMode = YDialogNormalColor );
61 
67  virtual ~YDialog();
68 
69 public:
74  virtual const char * widgetClass() const { return "YDialog"; }
75 
89  void open();
90 
94  bool isOpen() const;
95 
122  YEvent * waitForEvent( int timeout_millisec = 0 );
123 
138  YEvent * pollEvent();
139 
143  bool isTopmostDialog() const;
144 
157  void requestMultiPassLayout();
158 
165  int layoutPass() const;
166 
180  bool destroy( bool doThrow = true );
181 
193  static bool deleteTopmostDialog( bool doThrow = true );
194 
198  static void deleteAllDialogs();
199 
203  static void deleteTo( YDialog * dialog );
204 
209  static int openDialogsCount();
210 
217  static YDialog * currentDialog( bool doThrow = true );
218 
222  static YDialog * topmostDialog( bool doThrow = true )
223  { return currentDialog( doThrow ); }
224 
230  void setInitialSize();
231 
244  void recalcLayout();
245 
249  YDialogType dialogType() const;
250 
255  bool isMainDialog();
256 
260  YDialogColorMode colorMode() const;
261 
268  void checkShortcuts( bool force = false );
269 
275  void postponeShortcutCheck();
276 
280  bool shortcutCheckPostponed() const;
281 
289  YPushButton * defaultButton() const;
290 
294  void deleteEvent( YEvent * event );
295 
313  void addEventFilter( YEventFilter * eventFilter );
314 
321  void removeEventFilter( YEventFilter * eventFilter );
322 
334  virtual void highlight( YWidget * child ) {}
335 
346  virtual void setDefaultButton( YPushButton * defaultButton );
347 
354  virtual void activate() = 0;
355 
356 
357  //
358  // Dialog helpers - see source file YDialogHelpers.cc
359  //
360 
366  static void showText( const std::string & text, bool richText = false );
367 
378  static bool showHelpText( YWidget * widget );
379 
389  static bool showRelNotesText();
390 
391 
392 protected:
393 
401  virtual void openInternal() = 0;
402 
406  void doLayout();
407 
413  virtual YEvent * waitForEventInternal( int timeout_millisec ) = 0;
414 
421  virtual YEvent * pollEventInternal() = 0;
422 
427  YEvent * filterInvalidEvents( YEvent * event );
428 
432  YEvent * callEventFilters( YEvent * event );
433 
437  void deleteEventFilters();
438 
442  static std::stack<YDialog *> _dialogStack;
443 
444 private:
445 
447 };
448 
449 
450 #endif // YDialog_h
void deleteEvent(YEvent *event)
Definition: YDialog.cc:516
static bool showHelpText(YWidget *widget)
Definition: YDialogHelpers.cc:102
void deleteEventFilters()
Definition: YDialog.cc:223
virtual void setDefaultButton(YPushButton *defaultButton)
Definition: YDialog.cc:330
YDialogType
Definition: YTypes.h:66
Definition: YShortcutManager.h:38
void postponeShortcutCheck()
Definition: YDialog.cc:291
static bool deleteTopmostDialog(bool doThrow=true)
Definition: YDialog.cc:553
Definition: YEventFilter.h:62
Definition: YEvent.h:43
YEvent * filterInvalidEvents(YEvent *event)
Definition: YDialog.cc:452
void requestMultiPassLayout()
Definition: YDialog.cc:662
bool isTopmostDialog() const
Definition: YDialog.cc:210
void checkShortcuts(bool force=false)
Definition: YDialog.cc:305
void doLayout()
Definition: YDialog.cc:364
Definition: YSingleChildContainerWidget.h:34
void removeEventFilter(YEventFilter *eventFilter)
Definition: YDialog.cc:630
YDialogColorMode colorMode() const
Definition: YDialog.cc:284
Definition: YDialog.cc:45
Definition: YPushButton.h:37
virtual const char * widgetClass() const
Definition: YDialog.h:74
virtual void openInternal()=0
static void deleteAllDialogs()
Definition: YDialog.cc:570
bool isOpen() const
Definition: YDialog.cc:203
virtual YEvent * pollEventInternal()=0
static YDialog * currentDialog(bool doThrow=true)
Definition: YDialog.cc:539
bool shortcutCheckPostponed() const
Definition: YDialog.cc:298
YEvent * callEventFilters(YEvent *event)
Definition: YDialog.cc:642
virtual void highlight(YWidget *child)
Definition: YDialog.h:334
void open()
Definition: YDialog.cc:189
void addEventFilter(YEventFilter *eventFilter)
Definition: YDialog.cc:608
static std::stack< YDialog * > _dialogStack
Definition: YDialog.h:442
YDialog(YDialogType dialogType, YDialogColorMode colorMode=YDialogNormalColor)
Definition: YDialog.cc:136
void setInitialSize()
Definition: YDialog.cc:344
static void deleteTo(YDialog *dialog)
Definition: YDialog.cc:580
static bool showRelNotesText()
Definition: YDialogHelpers.cc:134
YDialogType dialogType() const
Definition: YDialog.cc:259
virtual void activate()=0
static void showText(const std::string &text, bool richText=false)
Definition: YDialogHelpers.cc:56
static int openDialogsCount()
Definition: YDialog.cc:601
virtual ~YDialog()
Definition: YDialog.cc:153
void recalcLayout()
Definition: YDialog.cc:356
YPushButton * defaultButton() const
Definition: YDialog.cc:323
Definition: YDialog.h:47
virtual YEvent * waitForEventInternal(int timeout_millisec)=0
int layoutPass() const
Definition: YDialog.cc:380
YEvent * pollEvent()
Definition: YDialog.cc:427
Definition: YWidget.h:54
static YDialog * topmostDialog(bool doThrow=true)
Definition: YDialog.h:222
bool destroy(bool doThrow=true)
Definition: YDialog.cc:238
YEvent * waitForEvent(int timeout_millisec=0)
Definition: YDialog.cc:387
bool isMainDialog()
Definition: YDialog.cc:266