libyui-ncurses
2.44.1
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: NCRadioButtonGroup.cc 00020 00021 Author: Michael Andres <ma@suse.de> 00022 00023 /-*/ 00024 00025 #define YUILogComponent "ncurses" 00026 #include <yui/YUILog.h> 00027 #include "NCurses.h" 00028 #include "NCRadioButtonGroup.h" 00029 00030 00031 NCRadioButtonGroup::NCRadioButtonGroup( YWidget * parent ) 00032 : YRadioButtonGroup( parent ) 00033 , NCWidget( parent ) 00034 , focusId( 1 ) 00035 { 00036 yuiDebug() << std::endl; 00037 wstate = NC::WSdumb; 00038 } 00039 00040 00041 NCRadioButtonGroup::~NCRadioButtonGroup() 00042 { 00043 yuiDebug() << std::endl; 00044 } 00045 00046 00047 void NCRadioButtonGroup::setSize( int newwidth, int newheight ) 00048 { 00049 wRelocate( wpos( 0 ), wsze( newheight, newwidth ) ); 00050 YRadioButtonGroup::setSize( newwidth, newheight ); 00051 } 00052 00053 00054 void NCRadioButtonGroup::addRadioButton( YRadioButton *button ) 00055 { 00056 YRadioButtonGroup::addRadioButton( button ); 00057 } 00058 00059 00060 void NCRadioButtonGroup::removeRadioButton( YRadioButton *button ) 00061 { 00062 YRadioButtonGroup::removeRadioButton( button ); 00063 } 00064 00065 00066 void NCRadioButtonGroup::focusNextButton( ) 00067 { 00068 int n = 0; 00069 00070 if ( focusId < radioButtonsCount() ) 00071 focusId++; 00072 else if ( focusId == radioButtonsCount() ) 00073 focusId = 0; 00074 00075 for ( YRadioButtonListConstIterator it = radioButtonsBegin(); 00076 it != radioButtonsEnd(); 00077 ++it ) 00078 { 00079 if ( ++n == focusId ) 00080 { 00081 NCRadioButton * radioButton = dynamic_cast<NCRadioButton *>( *it ); 00082 00083 if ( radioButton ) 00084 radioButton->setKeyboardFocus(); 00085 } 00086 } 00087 } 00088 00089 00090 void NCRadioButtonGroup::focusPrevButton() 00091 { 00092 int n = 0; 00093 00094 if ( focusId > 0 ) 00095 focusId--; 00096 else if ( focusId == 0 ) 00097 focusId = radioButtonsCount() - 1; 00098 00099 for ( YRadioButtonListConstIterator it = radioButtonsBegin(); 00100 it != radioButtonsEnd(); 00101 ++it ) 00102 { 00103 n++; 00104 00105 if ( n == focusId ) 00106 { 00107 NCRadioButton * radioButton = dynamic_cast<NCRadioButton *>( *it ); 00108 00109 if ( radioButton ) 00110 radioButton->setKeyboardFocus(); 00111 } 00112 } 00113 } 00114 00115 00116 void NCRadioButtonGroup::setEnabled( bool do_bv ) 00117 { 00118 for ( YRadioButtonListConstIterator it = radioButtonsBegin(); 00119 it != radioButtonsEnd(); 00120 ++it ) 00121 { 00122 NCRadioButton * radioButton = dynamic_cast<NCRadioButton *>( *it ); 00123 00124 if ( radioButton ) 00125 radioButton->setEnabled( do_bv ); 00126 } 00127 00128 YRadioButtonGroup::setEnabled( do_bv ); 00129 }