libyui-ncurses  2.44.1
 All Classes Functions Variables
NCMultiSelectionBox.h
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: NCMultiSelectionBox.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #ifndef NCMultiSelectionBox_h
26 #define NCMultiSelectionBox_h
27 
28 #include <iosfwd>
29 
30 #include <yui/YMultiSelectionBox.h>
31 #include "NCPadWidget.h"
32 #include "NCTablePad.h"
33 
34 
35 
36 
37 
38 
39 class NCMultiSelectionBox : public YMultiSelectionBox, public NCPadWidget
40 {
41 
42  friend std::ostream & operator<<( std::ostream & STREAM, const NCMultiSelectionBox & OBJ );
43 
44  NCMultiSelectionBox & operator=( const NCMultiSelectionBox & );
46 
47 protected:
48 
49  /**
50  * Overload myPad to narrow the type
51  */
52  virtual NCTablePad * myPad() const
53  { return dynamic_cast<NCTablePad*>( NCPadWidget::myPad() ); }
54 
55  NCTableTag * tagCell( int index );
56  const NCTableTag * tagCell( int index ) const;
57 
58  bool isItemSelected( YItem *item );
59 
60  void toggleCurrentItem();
61 
62 public:
63 
64  virtual void startMultipleChanges() { startMultidraw(); }
65 
66  virtual void doneMultipleChanges() { stopMultidraw(); }
67 
68  virtual const char * location() const { return "NCMultiSelectionBox"; }
69 
70  virtual void addItem( YItem * item );
71 
72  virtual void deleteAllItems();
73 
74  virtual void selectItem( YItem * item, bool selected );
75 
76  virtual void deselectAllItems();
77 
78 protected:
79 
80  virtual NCPad * CreatePad();
81  virtual void wRecoded();
82 
83 
84 public:
85 
86  NCMultiSelectionBox( YWidget * parent, const std::string & label );
87  virtual ~NCMultiSelectionBox();
88 
89  virtual int preferredWidth();
90  virtual int preferredHeight();
91 
92  virtual void setSize( int newWidth, int newHeight );
93 
94  virtual void setLabel( const std::string & nlabel );
95 
96  virtual YItem * currentItem();
97  virtual void setCurrentItem( YItem * item );
98 
99  virtual NCursesEvent wHandleInput( wint_t key );
100 
101  virtual void setEnabled( bool do_bv );
102 
103  virtual bool setKeyboardFocus()
104  {
105  if ( !grabFocus() )
106  return YWidget::setKeyboardFocus();
107 
108  return true;
109  }
110 
111  unsigned int getNumLines( ) { return myPad()->Lines(); }
112 
113  const NCTableLine * getLine( const int & index ) { return myPad()->GetLine( index ); }
114 
115  void clearItems() { return myPad()->ClearTable(); }
116 };
117 
118 
119 #endif // NCMultiSelectionBox_h
Definition: NCPad.h:93
virtual void setEnabled(bool do_bv)
virtual NCPad * myPad() const
Definition: NCPadWidget.h:62
virtual NCTablePad * myPad() const
NCTableTag * tagCell(int index)
virtual NCPad * CreatePad()