25 #define YUILogComponent "ncurses"
26 #include <yui/YUILog.h>
27 #include "NCPopupInfo.h"
30 #include <yui/YMenuButton.h>
31 #include <yui/YDialog.h>
32 #include "NCLayoutBox.h"
33 #include "NCSpacing.h"
38 const std::string idOk(
"ok" );
39 const std::string idCancel(
"cancel" );
43 NCPopupInfo::NCPopupInfo(
const wpos at,
44 const std::string & headline,
45 const std::string & text,
46 std::string okButtonLabel,
47 std::string cancelButtonLabel )
56 createLayout( headline, text, okButtonLabel, cancelButtonLabel );
60 NCPopupInfo::~NCPopupInfo()
65 void NCPopupInfo::createLayout(
const std::string & headline,
66 const std::string & text,
67 std::string okButtonLabel,
68 std::string cancelButtonLabel )
70 std::string old_textdomain = textdomain( NULL );
71 setTextdomain(
"ncurses" );
77 new NCLabel( split, headline,
true,
false );
84 if ( okButtonLabel !=
"" && cancelButtonLabel !=
"" )
86 new NCSpacing( hSplit, YD_HORIZ,
true, 0.4 );
89 if ( okButtonLabel !=
"" )
93 okButton->setFunctionKey( 10 );
96 if ( cancelButtonLabel !=
"" )
98 new NCSpacing( hSplit, YD_HORIZ,
true, 0.4 );
101 cancelButton =
new NCPushButton( hSplit, cancelButtonLabel );
102 cancelButton->setFunctionKey( 9 );
104 new NCSpacing( hSplit, YD_HORIZ,
true, 0.4 );
109 if ( cancelButtonLabel ==
"" && okButton )
113 if ( okButtonLabel ==
"" && cancelButton )
117 setTextdomain( old_textdomain.c_str() );
129 while ( postAgain() );
137 void NCPopupInfo::popup()
146 void NCPopupInfo::popdown()
154 int NCPopupInfo::preferredWidth()
158 if ( hDim >= NCurses::cols() )
159 horDim = NCurses::cols() - 10;
165 int NCPopupInfo::preferredHeight()
169 if ( vDim >= NCurses::lines() )
170 vertDim = NCurses::lines() - 5;
177 NCPopupInfo::wHandleInput( wint_t ch )
180 return NCursesEvent::cancel;
182 if ( ch == KEY_RETURN )
183 return NCursesEvent::button;
185 return NCDialog::wHandleInput( ch );
189 bool NCPopupInfo::postAgain()
191 if ( ! postevent.widget )
194 if ( okButton && cancelButton )
196 if ( postevent.widget == cancelButton )
198 yuiMilestone() <<
"Cancel button pressed" << std::endl;
200 postevent = NCursesEvent::cancel;
206 if ( postevent == NCursesEvent::button || postevent == NCursesEvent::cancel )
virtual void activate()
Activate this dialog: Make sure that it is shown as the topmost dialog of this application and that i...