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 )
74 new NCLabel( split, headline,
true,
false );
81 if ( okButtonLabel !=
"" && cancelButtonLabel !=
"" )
83 new NCSpacing( hSplit, YD_HORIZ,
true, 0.4 );
86 if ( okButtonLabel !=
"" )
90 okButton->setFunctionKey( 10 );
93 if ( cancelButtonLabel !=
"" )
95 new NCSpacing( hSplit, YD_HORIZ,
true, 0.4 );
98 cancelButton =
new NCPushButton( hSplit, cancelButtonLabel );
99 cancelButton->setFunctionKey( 9 );
101 new NCSpacing( hSplit, YD_HORIZ,
true, 0.4 );
106 if ( cancelButtonLabel ==
"" && okButton )
110 if ( okButtonLabel ==
"" && cancelButton )
123 while ( postAgain() );
131 void NCPopupInfo::popup()
140 void NCPopupInfo::popdown()
148 int NCPopupInfo::preferredWidth()
152 if ( hDim >= NCurses::cols() )
153 horDim = NCurses::cols() - 10;
159 int NCPopupInfo::preferredHeight()
163 if ( vDim >= NCurses::lines() )
164 vertDim = NCurses::lines() - 5;
171 NCPopupInfo::wHandleInput( wint_t ch )
174 return NCursesEvent::cancel;
176 if ( ch == KEY_RETURN )
177 return NCursesEvent::button;
179 return NCDialog::wHandleInput( ch );
183 bool NCPopupInfo::postAgain()
185 if ( ! postevent.widget )
188 if ( okButton && cancelButton )
190 if ( postevent.widget == cancelButton )
192 yuiMilestone() <<
"Cancel button pressed" << std::endl;
194 postevent = NCursesEvent::cancel;
200 if ( postevent == NCursesEvent::button || postevent == NCursesEvent::cancel )