libyui-ncurses
Loading...
Searching...
No Matches
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
35class NCDialog;
36class NCPopupInfo;
37
38
39class NCDialog : public YDialog, public NCWidget
40{
41private:
42
43 friend std::ostream & operator<<( std::ostream & str, const NCDialog & obj );
44 friend std::ostream & operator<<( std::ostream & str, const NCDialog * obj );
45
46 NCDialog & operator=( const NCDialog & );
47 NCDialog( const NCDialog & );
48
49 typedef tnode<NCWidget *> * ( tnode<NCWidget *>::* SeekDir )( bool );
50
51 NCWidget & GetNormal( NCWidget & startwith, SeekDir Direction );
52 void Activate( SeekDir Direction );
53
54 void _init();
55 void _init_size();
56
57protected:
58
59 virtual const char * location() const { return "NCDialog"; }
60
61 wint_t getinput(); // get the input (respect terminal encoding)
62
63private:
64
65 NCursesUserPanel<NCDialog> * pan;
66 NCstyle::StyleSet mystyleset;
67 const NCstyle::Style * dlgstyle;
68
69 unsigned inMultiDraw_i;
70
71 bool active;
72 NCWidget *const wActive;
73
74 NCursesEvent pendingEvent;
75 YEvent::EventReason eventReason;
76
77 // wrapper for wHandle... calls in processInput()
78 NCursesEvent getInputEvent( wint_t ch );
79 NCursesEvent getHotkeyEvent( wint_t key );
80
81 void grabActive( NCWidget * nactive );
82 virtual void grabNotify( NCWidget * mgrab );
83 virtual bool wantFocus( NCWidget & ngrab );
84
85 virtual void wCreate( const wrect & newrect );
86 virtual void wMoveTo( const wpos & newpos );
87 virtual void wDelete();
88 virtual void wRedraw();
89 virtual void wRecoded();
90 virtual void wUpdate( bool forced_br = false );
91 void doUpdate() { wUpdate( true ); }
92
93 NCWidget & GetNextNormal( NCWidget & startwith );
94 NCWidget & GetPrevNormal( NCWidget & startwith );
95
96 bool Activate( NCWidget & nactive );
97 void Activate();
98 void Deactivate();
99 void ActivateNext();
100 void ActivatePrev();
101
102 bool ActivateByKey( int key );
103
104 void processInput( int timeout_millisec );
105
106 std::map<int, NCstring> describeFunctionKeys();
107
108 bool flushTypeahead();
109
110protected:
111
112 virtual 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
131 virtual void openInternal();
132
138 virtual YEvent * waitForEventInternal( int timeout_millisec );
139
146 virtual YEvent * pollEventInternal();
147
148
149public:
150
151 NCDialog( YDialogType dialogType,
152 YDialogColorMode colorMode = YDialogNormalColor );
153 virtual ~NCDialog();
154
155 void showDialog();
156 void closeDialog();
157
158 void activate( 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
179 virtual void activate();
180
181 // Get the pending event, only for special cases (REST API)
182 NCursesEvent getPendingEvent() { return pendingEvent;}
183 // Set the pending event, makes sense only when simulating the user actions (REST API)
184 void setPendingEvent(NCursesEvent event) { pendingEvent = event;}
185
186protected:
187
188 enum NCDopts
189 {
190 DEFAULT = 0x00,
191 POPUP = 0x01,
192 NOBOX = 0x10
193 };
194
195 typedef unsigned NCDoptflag;
196
197 NCDoptflag ncdopts;
198 wpos popedpos;
199 bool hshaddow;
200 bool vshaddow;
201
202 NCDialog( YDialogType dialogType, const wpos & at, bool boxed = true );
203
204 bool isPopup() const { return ( ncdopts & POPUP ); }
205
206 bool isBoxed() const { return !( ncdopts & NOBOX ); }
207
208 virtual void initDialog();
209
210 virtual const NCstyle::Style & wStyle() const
211 {
212 return dlgstyle ? *dlgstyle : NCurses::style()[NCstyle::DefaultStyle];
213 }
214
215 virtual void setEnabled( bool do_bv ) {}
216
217private:
218
219 friend class NCurses;
220 bool getInvisible();
221 bool getVisible();
222 void resizeEvent();
223 void showHotkeyHelp();
224};
225
226
227#endif // NCDialog_h
Definition NCDialog.h:40
virtual void activate()
Definition NCDialog.cc:311
virtual void setEnabled(bool do_bv)
Definition NCDialog.h:215
virtual YEvent * pollEventInternal()
Definition NCDialog.cc:1002
virtual void openInternal()
Definition NCDialog.cc:228
virtual YEvent * waitForEventInternal(int timeout_millisec)
Definition NCDialog.cc:986
Definition NCPopupInfo.h:49
Definition NCWidget.h:46
Definition NCstyle.h:525
Definition NCurses.h:73
Definition NCurses.h:144
Screen position pair in the order line, column: (L, C)
Definition position.h:110
A rectangle is defined by its position and size: wpos Pos, wsze Sze.
Definition position.h:194