libyui-ncurses  2.44.1
 All Classes Functions Variables
NCRadioButtonGroup.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: NCRadioButtonGroup.cc
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #define YUILogComponent "ncurses"
26 #include <yui/YUILog.h>
27 #include "NCurses.h"
28 #include "NCRadioButtonGroup.h"
29 
30 
31 NCRadioButtonGroup::NCRadioButtonGroup( YWidget * parent )
32  : YRadioButtonGroup( parent )
33  , NCWidget( parent )
34  , focusId( 1 )
35 {
36  yuiDebug() << std::endl;
37  wstate = NC::WSdumb;
38 }
39 
40 
41 NCRadioButtonGroup::~NCRadioButtonGroup()
42 {
43  yuiDebug() << std::endl;
44 }
45 
46 
47 void NCRadioButtonGroup::setSize( int newwidth, int newheight )
48 {
49  wRelocate( wpos( 0 ), wsze( newheight, newwidth ) );
50  YRadioButtonGroup::setSize( newwidth, newheight );
51 }
52 
53 
54 void NCRadioButtonGroup::addRadioButton( YRadioButton *button )
55 {
56  YRadioButtonGroup::addRadioButton( button );
57 }
58 
59 
60 void NCRadioButtonGroup::removeRadioButton( YRadioButton *button )
61 {
62  YRadioButtonGroup::removeRadioButton( button );
63 }
64 
65 
66 void NCRadioButtonGroup::focusNextButton( )
67 {
68  int n = 0;
69 
70  if ( focusId < radioButtonsCount() )
71  focusId++;
72  else if ( focusId == radioButtonsCount() )
73  focusId = 0;
74 
75  for ( YRadioButtonListConstIterator it = radioButtonsBegin();
76  it != radioButtonsEnd();
77  ++it )
78  {
79  if ( ++n == focusId )
80  {
81  NCRadioButton * radioButton = dynamic_cast<NCRadioButton *>( *it );
82 
83  if ( radioButton )
84  radioButton->setKeyboardFocus();
85  }
86  }
87 }
88 
89 
90 void NCRadioButtonGroup::focusPrevButton()
91 {
92  int n = 0;
93 
94  if ( focusId > 0 )
95  focusId--;
96  else if ( focusId == 0 )
97  focusId = radioButtonsCount() - 1;
98 
99  for ( YRadioButtonListConstIterator it = radioButtonsBegin();
100  it != radioButtonsEnd();
101  ++it )
102  {
103  n++;
104 
105  if ( n == focusId )
106  {
107  NCRadioButton * radioButton = dynamic_cast<NCRadioButton *>( *it );
108 
109  if ( radioButton )
110  radioButton->setKeyboardFocus();
111  }
112  }
113 }
114 
115 
117 {
118  for ( YRadioButtonListConstIterator it = radioButtonsBegin();
119  it != radioButtonsEnd();
120  ++it )
121  {
122  NCRadioButton * radioButton = dynamic_cast<NCRadioButton *>( *it );
123 
124  if ( radioButton )
125  radioButton->setEnabled( do_bv );
126  }
127 
128  YRadioButtonGroup::setEnabled( do_bv );
129 }
Definition: position.h:109
Definition: position.h:154
virtual void setEnabled(bool do_bv)
virtual void setEnabled(bool do_bv)