libyui-mga-ncurses  1.0.1
YMGA_NCCBTable.h
1 /*
2  This library is free software; you can redistribute it and/or modify
3  it under the terms of the GNU Lesser General Public License as
4  published by the Free Software Foundation; either version 2.1 of the
5  License, or (at your option) version 3.0 of the License. This library
6  is distributed in the hope that it will be useful, but WITHOUT ANY
7  WARRANTY; without even the implied warranty of MERCHANTABILITY or
8  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
9  License for more details. You should have received a copy of the GNU
10  Lesser General Public License along with this library; if not, write
11  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
12  Floor, Boston, MA 02110-1301 USA
13 */
14 
15 
16 /*-/
17 
18  File: YMGANCWidgetFactory.h
19 
20  Author: Angelo Naselli <anaselli@linux.it>
21 
22 /-*/
23 
24 #ifndef YMGA_NCCBTable_h
25 #define YMGA_NCCBTable_h
26 
27 #include <iosfwd>
28 
29 #include <yui/mga/YMGA_CBTable.h>
30 #include <yui/ncurses/NCPadWidget.h>
31 #include <yui/ncurses/NCTablePad.h>
32 
33 
34 class YMGA_NCCBTable : public YMGA_CBTable, public NCPadWidget
35 {
36 public:
37 
38  YMGA_NCCBTable( YWidget * parent, YTableHeader *tableHeader, YCBTableMode mode = YCBTableMode::YCBTableCheckBoxOnFirstColumn);
39 
40  virtual ~YMGA_NCCBTable();
41 
42  bool bigList() const { return biglist; }
43 
44  void setHeader( std::vector <std::string> head );
45  void getHeader( std::vector <std::string> & head );
46 
47  virtual void setAlignment( int col, YAlignmentType al );
48 
49  void setBigList( const bool big ) { biglist = big; }
50 
51  void SetSepChar( const chtype colSepchar ) { myPad()->SetSepChar( colSepchar ); }
52 
53  void SetSepWidth( const unsigned sepwidth ) { myPad()->SetSepWidth( sepwidth ); }
54 
55  void SetHotCol( const int hcol ) { myPad()->SetHotCol( hcol ); }
56 
57  virtual void addItem( YItem *yitem );
58  virtual void addItems( const YItemCollection & itemCollection );
59  virtual void deleteAllItems( );
60 
61  virtual int getCurrentItem();
62  YItem * getCurrentItemPointer();
63 
64  virtual void setCurrentItem( int index );
65  virtual void selectItem( YItem *yitem, bool selected );
66  void selectCurrentItem();
67  virtual void deselectAllItems();
68 
69  virtual int preferredWidth();
70  virtual int preferredHeight();
71 
72  virtual void setSize( int newWidth, int newHeight );
73 
74  virtual void setLabel( const std::string & nlabel );
75 
76  virtual void setEnabled( bool do_bv );
77 
78  bool setItemByKey( int key );
79 
80  virtual NCursesEvent wHandleInput( wint_t key );
81 
82  virtual bool setKeyboardFocus()
83  {
84  if ( !grabFocus() )
85  return YWidget::setKeyboardFocus();
86 
87  return true;
88  }
89 
90  void stripHotkeys() { myPad()->stripHotkeys(); }
91 
92  void setSortStrategy( NCTableSortStrategyBase * newStrategy ) { myPad()->setSortStrategy( newStrategy ); }
93 
94  void checkItem( YItem* yitem, bool checked = true );
95 
96 protected:
97 
98  /**
99  * Overload myPad to narrow the type
100  */
101  virtual NCTablePad * myPad() const
102  { return dynamic_cast<NCTablePad*>( NCPadWidget::myPad() ); }
103 
104  bool biglist;
105 
106 protected:
107 
108  virtual const char * location() const { return "YMGA_NCCBTable"; }
109 
110  virtual NCPad * CreatePad();
111 
112  virtual void cellChanged( int index, int colnum, const std::string & newtext );
113  virtual void cellChanged( const YTableCell *cell );
114 
115  virtual void startMultipleChanges() { startMultidraw(); }
116  virtual void doneMultipleChanges() { stopMultidraw(); }
117 
118  //internal overloaded version of addItem - both addItem(yitem)
119  //and addItems(itemCollection) use it, but in different mode
120  virtual void addItem( YItem *yitem, bool allAtOnce );
121  void toggleCurrentItem();
122 
123 private:
124 
125  std::vector<NCstring> _header;
126 
127  friend std::ostream & operator<<( std::ostream & STREAM, const YMGA_NCCBTable & OBJ );
128 
129  YMGA_NCCBTable & operator=( const YMGA_NCCBTable & );
130  YMGA_NCCBTable( const YMGA_NCCBTable & );
131 
132 };
133 
134 
135 #endif // YMGA_NCCBTable_h
virtual NCTablePad * myPad() const
Overload myPad to narrow the type.
void toggleCurrentItem()
Toggle item from selected -> deselected and vice versa.