libyui-ncurses  2.57.2
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 class NCMultiSelectionBox : public YMultiSelectionBox, public NCPadWidget
36 {
37 
38  friend std::ostream & operator<<( std::ostream & str, const NCMultiSelectionBox & obj );
39 
40  NCMultiSelectionBox & operator=( const NCMultiSelectionBox & );
42 
43 protected:
44 
45  /**
46  * Overload myPad to narrow the type
47  */
48  virtual NCTablePad * myPad() const
49  { return dynamic_cast<NCTablePad*>( NCPadWidget::myPad() ); }
50 
51  NCTableTag * tagCell( int index );
52  const NCTableTag * tagCell( int index ) const;
53 
54  bool isItemSelected( YItem *item );
55 
56  void toggleCurrentItem();
57 
58 public:
59 
60  virtual void startMultipleChanges() { startMultidraw(); }
61 
62  virtual void doneMultipleChanges() { stopMultidraw(); }
63 
64  virtual const char * location() const { return "NCMultiSelectionBox"; }
65 
66  virtual void addItem( YItem * item );
67 
68  virtual void deleteAllItems();
69 
70  virtual void selectItem( YItem * item, bool selected );
71 
72  virtual void deselectAllItems();
73 
74 protected:
75 
76  virtual NCPad * CreatePad();
77  virtual void wRecoded();
78 
79 
80 public:
81 
82  NCMultiSelectionBox( YWidget * parent, const std::string & label );
83  virtual ~NCMultiSelectionBox();
84 
85  virtual int preferredWidth();
86  virtual int preferredHeight();
87 
88  virtual void setSize( int newWidth, int newHeight );
89 
90  virtual void setLabel( const std::string & nlabel );
91 
92  virtual YItem * currentItem();
93  virtual void setCurrentItem( YItem * item );
94 
95  virtual NCursesEvent wHandleInput( wint_t key );
96 
97  virtual void setEnabled( bool do_bv );
98 
99  virtual bool setKeyboardFocus()
100  {
101  if ( !grabFocus() )
102  return YWidget::setKeyboardFocus();
103 
104  return true;
105  }
106 
107  unsigned getNumLines() { return myPad()->Lines(); }
108 
109  const NCTableLine * getLine( int index ) { return myPad()->GetLine( index ); }
110 
111  void clearItems() { return myPad()->ClearTable(); }
112 };
113 
114 
115 #endif // NCMultiSelectionBox_h
NCTablePadBase::ClearTable
void ClearTable()
Clear all content.
Definition: NCTablePadBase.cc:51
NCTablePad
An NCPad for an NCTable.
Definition: NCTablePad.h:62
NCTablePadBase::Lines
unsigned Lines() const
Return the number of table lines (logical, not screen)
Definition: NCTablePadBase.h:122
NCMultiSelectionBox::CreatePad
virtual NCPad * CreatePad()
Create empty MsB pad.
Definition: NCMultiSelectionBox.cc:209
NCMultiSelectionBox::toggleCurrentItem
void toggleCurrentItem()
Toggle item from selected -> deselected and vice versa.
Definition: NCMultiSelectionBox.cc:191
NCTablePadBase::GetLine
const NCTableLine * GetLine(unsigned idx) const
Return the line at idx for read-only operations.
Definition: NCTablePadBase.cc:87
NCPad
A virtual window with a real viewport (which is NCursesWindow) and a scrolling mechanism.
Definition: NCPad.h:113
NCMultiSelectionBox
Definition: NCMultiSelectionBox.h:36
NCMultiSelectionBox::myPad
virtual NCTablePad * myPad() const
Overload myPad to narrow the type.
Definition: NCMultiSelectionBox.h:48
NCPadWidget::myPad
virtual NCPad * myPad() const
Return the current pad.
Definition: NCPadWidget.h:64
NCMultiSelectionBox::setEnabled
virtual void setEnabled(bool do_bv)
Pure virtual to make sure every widget implements it.
Definition: NCMultiSelectionBox.cc:60
NCTableLine
One line in a NCTable with multiple cells and an optional tree hierarchy.
Definition: NCTableItem.h:68
NCursesEvent
Definition: NCurses.h:73
NCPadWidget
Base class for widgets with scrollable contents.
Definition: NCPadWidget.h:40
NCMultiSelectionBox::tagCell
NCTableTag * tagCell(int index)
Return pointer to current line tag (holds state and yitem pointer)
Definition: NCMultiSelectionBox.cc:115
NCTableTag
A column (one cell) used as a selection marker: [ ]/[x] or ( )/(x).
Definition: NCTableItem.h:647