libyui-ncurses  2.44.1
 All Classes Functions Variables
NCDialog.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: NCDialog.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #ifndef NCDialog_h
26 #define NCDialog_h
27 
28 #include <iosfwd>
29 
30 #include <yui/YDialog.h>
31 #include "NCWidget.h"
32 #include "NCPushButton.h"
33 
34 
35 class NCDialog;
36 class NCPopupInfo;
37 
38 
39 class NCDialog : public YDialog, public NCWidget
40 {
41 private:
42 
43  friend std::ostream & operator<<( std::ostream & STREAM, const NCDialog & OBJ );
44  friend std::ostream & operator<<( std::ostream & STREAM, const NCDialog * OBJ );
45 
46  NCDialog & operator=( const NCDialog & );
47  NCDialog( const NCDialog & );
48 
49  typedef tnode<NCWidget *> * ( tnode<NCWidget *>::* SeekDir )( const bool );
50 
51  NCWidget & GetNormal( NCWidget & startwith, SeekDir Direction );
52  void Activate( SeekDir Direction );
53 
54  void _init();
55  void _init_size();
56 
57 protected:
58 
59  virtual const char * location() const { return "NCDialog"; }
60 
61 private:
62 
64  NCstyle::StyleSet mystyleset;
65  const NCstyle::Style * dlgstyle;
66 
67  unsigned inMultiDraw_i;
68 
69  bool active;
70  NCWidget *const wActive;
71 
72  NCursesEvent pendingEvent;
73  YEvent::EventReason eventReason;
74 
75  // wrapper for wHandle... calls in processInput()
76  NCursesEvent getInputEvent( wint_t ch );
77  NCursesEvent getHotkeyEvent( wint_t key );
78 
79  void grabActive( NCWidget * nactive );
80  virtual void grabNotify( NCWidget * mgrab );
81  virtual bool wantFocus( NCWidget & ngrab );
82 
83  virtual void wCreate( const wrect & newrect );
84  virtual void wMoveTo( const wpos & newpos );
85  virtual void wDelete();
86  virtual void wRedraw();
87  virtual void wRecoded();
88  virtual void wUpdate( bool forced_br = false );
89  void doUpdate() { wUpdate( true ); }
90 
91  NCWidget & GetNextNormal( NCWidget & startwith );
92  NCWidget & GetPrevNormal( NCWidget & startwith );
93 
94  bool Activate( NCWidget & nactive );
95  void Activate();
96  void Deactivate();
97  void ActivateNext();
98  void ActivatePrev();
99 
100  bool ActivateByKey( int key );
101 
102  void processInput( int timeout_millisec );
103 
104  std::map<int, std::string> describeFunctionKeys();
105 
106  wint_t getinput(); // get the input (respect terminal encoding)
107 
108  bool flushTypeahead();
109 
110 protected:
111 
112  wint_t getch( int timeout_millisec = -1 );
113 
114  virtual NCursesEvent wHandleInput( wint_t ch );
115  virtual NCursesEvent wHandleHotkey( wint_t key );
116 
117  virtual void startMultipleChanges();
118  virtual void doneMultipleChanges();
119 
120  /**
121  * Internal open() method: Initialize what is left over to initialize after
122  * all dialog children have been created.
123  * YDialog::setInitialSize() is already called before this in
124  * YDailog::open(), so don't call it here again (very expensive!).
125  *
126  * This function is called (exactly once during the life time of the
127  * dialog) in YDialog::open().
128  *
129  * Implemented from YDialog.
130  **/
131  virtual void openInternal();
132 
133  /**
134  * Wait for a user event.
135  *
136  * Implemented from YDialog.
137  **/
138  virtual YEvent * waitForEventInternal( int timeout_millisec );
139 
140  /**
141  * Check if a user event is pending. If there is one, return it.
142  * If there is none, do not wait for one - return 0.
143  *
144  * Implemented from YDialog.
145  **/
146  virtual YEvent * pollEventInternal();
147 
148 
149 public:
150 
151  NCDialog( YDialogType dialogType,
152  YDialogColorMode colorMode = YDialogNormalColor );
153  virtual ~NCDialog();
154 
155  void showDialog();
156  void closeDialog();
157 
158  void activate( const bool newactive );
159  bool isActive() const { return active; }
160 
161  void idleInput();
162 
163  NCursesEvent userInput( int timeout_millisec = -1 );
164  NCursesEvent pollInput();
165 
166  virtual int preferredWidth();
167  virtual int preferredHeight();
168 
169  virtual void setSize( int newWidth, int newHeight );
170 
171  void setStatusLine();
172 
173  /**
174  * Activate this dialog: Make sure that it is shown as the topmost dialog
175  * of this application and that it can receive input.
176  *
177  * Implemented from YDialog.
178  **/
179  virtual void activate();
180 
181 protected:
182 
183  enum NCDopts
184  {
185  DEFAULT = 0x00,
186  POPUP = 0x01,
187  NOBOX = 0x10
188  };
189 
190  typedef unsigned NCDoptflag;
191 
192  NCDoptflag ncdopts;
193  wpos popedpos;
194  bool hshaddow;
195  bool vshaddow;
196 
197  NCDialog( YDialogType dialogType, const wpos at, const bool boxed = true );
198 
199  bool isPopup() const { return ( ncdopts & POPUP ); }
200 
201  bool isBoxed() const { return !( ncdopts & NOBOX ); }
202 
203  virtual void initDialog();
204 
205  virtual const NCstyle::Style & wStyle() const
206  {
207  return dlgstyle ? *dlgstyle : NCurses::style()[NCstyle::DefaultStyle];
208  }
209 
210  virtual void setEnabled( bool do_bv ) {}
211 
212 private:
213 
214  friend class NCurses;
215  bool getInvisible();
216  bool getVisible();
217  void resizeEvent();
218 };
219 
220 
221 #endif // NCDialog_h
virtual void openInternal()
Definition: NCDialog.cc:229
virtual void activate()
Definition: NCDialog.cc:312
virtual void setEnabled(bool do_bv)
Definition: NCDialog.h:210
virtual YEvent * pollEventInternal()
Definition: NCDialog.cc:1004
Definition: position.h:109
virtual YEvent * waitForEventInternal(int timeout_millisec)
Definition: NCDialog.cc:988