libyui-ncurses  2.44.1
 All Classes Functions Variables
NCPopup.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: NCPopup.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #define YUILogComponent "ncurses"
26 #include <yui/YUILog.h>
27 #include "NCPopup.h"
28 
29 
30 NCPopup::NCPopup( const wpos at, const bool boxed )
31  : NCDialog( YPopupDialog, at, boxed )
32 {
33 }
34 
35 
36 NCPopup::~NCPopup()
37 {
38 }
39 
40 
41 void NCPopup::popupDialog()
42 {
43  initDialog();
44  showDialog();
45  activate( true );
46 
47  while ( !( postevent = userInput() ) )
48  ;
49 
50  activate( false );
51 }
52 
53 
54 void NCPopup::popdownDialog()
55 {
56  closeDialog();
57 }
58 
59 
60 NCursesEvent NCPopup::wHandleInput( wint_t ch )
61 {
62  if ( ch == 27 ) // ESC
63  return NCursesEvent::cancel;
64 
65  return NCDialog::wHandleInput( ch );
66 }
67 
68 
69 int NCPopup::post( NCursesEvent * returnevent )
70 {
71  postevent = NCursesEvent();
72 
73  do
74  {
75  popupDialog();
76  }
77  while ( postAgain() );
78 
79  popdownDialog();
80 
81  if ( returnevent )
82  *returnevent = postevent;
83 
84  yuiDebug() << "Return event.detail: " << postevent.detail << std::endl;
85 
86  return postevent.detail;
87 }
virtual void activate()
Definition: NCDialog.cc:312
Definition: position.h:109