[yast-commit] r42665 - in /trunk/ncurses/src: NCDialog.cc NCDialog.h NCPushButton.cc NCPushButton.h
Author: kmachalkova Date: Tue Dec 4 15:58:52 2007 New Revision: 42665 URL: http://svn.opensuse.org/viewcvs/yast?rev=42665&view=rev Log: Set dialog's default button correctly Modified: trunk/ncurses/src/NCDialog.cc trunk/ncurses/src/NCDialog.h trunk/ncurses/src/NCPushButton.cc trunk/ncurses/src/NCPushButton.h Modified: trunk/ncurses/src/NCDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCDialog.cc?rev=42665&r1=42664&r2=42665&view=diff ============================================================================== --- trunk/ncurses/src/NCDialog.cc (original) +++ trunk/ncurses/src/NCDialog.cc Tue Dec 4 15:58:52 2007 @@ -62,6 +62,7 @@ : YDialog ( dialogType, colorMode ) , pan ( 0 ) , dlgstyle ( 0 ) + , defaultButton( 0 ) , inMultiDraw_i( 0 ) , active ( false ) , wActive ( this ) @@ -84,6 +85,7 @@ : YDialog ( dialogType, YDialogNormalColor ) , pan ( 0 ) , dlgstyle ( 0 ) + , defaultButton( 0 ) , inMultiDraw_i( 0 ) , active ( false ) , wActive ( this ) @@ -232,6 +234,37 @@ /////////////////////////////////////////////////////////////////// // // +// METHOD NAME : NCDialog::setDefaultButton +// METHOD TYPE : void +// +// DESCRIPTION : Set default button of this dialog (move keyboard +// focus on it) +// +void NCDialog::setDefaultButton( NCPushButton *newButton ) +{ + if ( newButton && defaultButton && (newButton != defaultButton )) + { + UIWAR << "Too many default push buttons: " << + " only one allowed." << endl; + defaultButton->setDefaultButton( false ); + } + + defaultButton = newButton; + + if (defaultButton) + { + UIDBG << "New default button: " << endl; + defaultButton->setKeyboardFocus(); + } + + YDialog::setDefaultButton( 0 ); + YDialog::setDefaultButton( defaultButton ); + +} + +/////////////////////////////////////////////////////////////////// +// +// // METHOD NAME : NCDialog::initDialog // METHOD TYPE : void // @@ -256,8 +289,6 @@ // void NCDialog::showDialog() { - NCMIL << "SHOW" << endl; - dumpWidgetTree(); IODBG << "sd+ " << this << endl; if ( pan && pan->hidden() ) { getVisible(); Modified: trunk/ncurses/src/NCDialog.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCDialog.h?rev=42665&r1=42664&r2=42665&view=diff ============================================================================== --- trunk/ncurses/src/NCDialog.h (original) +++ trunk/ncurses/src/NCDialog.h Tue Dec 4 15:58:52 2007 @@ -23,6 +23,7 @@ #include "YDialog.h" #include "NCWidget.h" +#include "NCPushButton.h" class NCDialog; @@ -61,6 +62,7 @@ NCursesUserPanel<NCDialog> * pan; NCstyle::StyleSet mystyleset; const NCstyle::Style * dlgstyle; + NCPushButton *defaultButton; unsigned inMultiDraw_i; @@ -147,6 +149,8 @@ **/ virtual void setSize( int newWidth, int newHeight ); + virtual void setDefaultButton( NCPushButton *newButton ); + protected: enum NCDopts { Modified: trunk/ncurses/src/NCPushButton.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCPushButton.cc?rev=42665&r1=42664&r2=42665&view=diff ============================================================================== --- trunk/ncurses/src/NCPushButton.cc (original) +++ trunk/ncurses/src/NCPushButton.cc Tue Dec 4 15:58:52 2007 @@ -17,6 +17,8 @@ /-*/ #include "Y2Log.h" +#include "YDialog.h" +#include "NCDialog.h" #include "NCurses.h" #include "NCPushButton.h" @@ -145,6 +147,33 @@ /////////////////////////////////////////////////////////////////// // // +// METHOD NAME : NCPushButton::setDefaultButton +// METHOD TYPE : void +// +// DESCRIPTION : Mark this button as default within current dialog +// +void NCPushButton::setDefaultButton( bool def ) +{ + YDialog *ydialog = findDialog(); + NCDialog *dlg = 0; + + if (ydialog) + { + dlg = dynamic_cast<NCDialog *> (ydialog); + YUI_CHECK_PTR( dlg ); + } + + YPushButton::setDefaultButton( def ); + + //if this is the default button, let's focus it + if (dlg && def) + dlg->setDefaultButton( this ); + +} + +/////////////////////////////////////////////////////////////////// +// +// // METHOD NAME : NCPushButton::wRedraw // METHOD TYPE : void // Modified: trunk/ncurses/src/NCPushButton.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCPushButton.h?rev=42665&r1=42664&r2=42665&view=diff ============================================================================== --- trunk/ncurses/src/NCPushButton.h (original) +++ trunk/ncurses/src/NCPushButton.h Tue Dec 4 15:58:52 2007 @@ -67,6 +67,8 @@ virtual NCursesEvent wHandleInput( wint_t key ); virtual void setLabel( const string & nlabel ); + + virtual void setDefaultButton( bool def); virtual void setEnabled( bool do_bv ); @@ -75,6 +77,7 @@ return YWidget::setKeyboardFocus(); return true; } + }; /////////////////////////////////////////////////////////////////// -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
kmachalkova@svn.opensuse.org