25 #define YUILogComponent "ncurses"
26 #include <yui/YUILog.h>
27 #include "NCMultiSelectionBox.h"
30 NCMultiSelectionBox::NCMultiSelectionBox( YWidget * parent,
31 const std::string & nlabel )
32 : YMultiSelectionBox( parent, nlabel )
35 yuiDebug() << std::endl;
41 NCMultiSelectionBox::~NCMultiSelectionBox()
43 yuiDebug() << std::endl;
47 int NCMultiSelectionBox::preferredWidth()
49 wsze sze = wGetDefsze();
50 return sze.W > ( int )( labelWidth() + 2 ) ? sze.W : ( labelWidth() + 2 );
54 int NCMultiSelectionBox::preferredHeight()
56 return wGetDefsze().H;
63 YMultiSelectionBox::setEnabled( do_bv );
67 void NCMultiSelectionBox::setSize(
int newwidth,
int newheight )
69 wRelocate(
wpos( 0 ),
wsze( newheight, newwidth ) );
73 YItem * NCMultiSelectionBox::currentItem()
75 if ( !
myPad()->Lines() )
78 int index =
myPad()->CurPos().L;
80 return itemAt( index );
85 void NCMultiSelectionBox::setCurrentItem( YItem * item )
88 myPad()->ScrlLine( item->index() );
91 void NCMultiSelectionBox::addItem( YItem * item )
93 std::vector<NCTableCol*> Items( 2U, 0 );
97 YMultiSelectionBox::addItem( item );
98 Items[0] =
new NCTableTag( item, item->selected() );
104 myPad()->Append( Items );
121 return static_cast<NCTableTag *
>( cl->GetCol( 0 ) );
132 return static_cast<const NCTableTag *
>( cl->GetCol( 0 ) );
137 void NCMultiSelectionBox::deleteAllItems()
139 YMultiSelectionBox::deleteAllItems();
140 myPad()->ClearTable();
145 bool NCMultiSelectionBox::isItemSelected( YItem *item )
148 return item->selected();
154 void NCMultiSelectionBox::selectItem( YItem *yitem,
bool selected )
158 YMultiSelectionBox::selectItem( yitem, selected );
162 YUI_CHECK_PTR( tag );
164 tag->SetSelected( selected );
171 void NCMultiSelectionBox::deselectAllItems()
173 YMultiSelectionBox::deselectAllItems();
175 for (
unsigned int i = 0; i < getNumLines(); i++ )
180 t->SetSelected(
false );
193 YItem *it = currentItem();
195 selectItem( it, !( it->selected() ) );
199 void NCMultiSelectionBox::setLabel(
const std::string & nlabel )
201 YMultiSelectionBox::setLabel( nlabel );
202 NCPadWidget::setLabel(
NCstring( nlabel ) );
211 wsze psze( defPadSze() );
213 npad->
bkgd( listStyle().item.plain );
214 npad->SetSepChar(
' ' );
219 void NCMultiSelectionBox::wRecoded()
221 NCPadWidget::wRecoded();
225 NCursesEvent NCMultiSelectionBox::wHandleInput( wint_t key )
228 bool valueChanged =
false;
229 YItem *oldCurrentItem = currentItem();
231 if ( ! handleInput( key ) )
233 YItem *citem = currentItem();
246 if ( !isItemSelected( citem ) )
248 selectItem( citem,
true );
258 if ( isItemSelected( citem ) )
260 selectItem( citem,
false );
273 ret = NCursesEvent::ValueChanged;
274 else if ( oldCurrentItem != currentItem() )
275 ret = NCursesEvent::SelectionChanged;
int bkgd(const chtype ch)
virtual void setEnabled(bool do_bv)
virtual NCTablePad * myPad() const
NCTableTag * tagCell(int index)
virtual NCPad * CreatePad()