libyui-ncurses  2.44.1
 All Classes Functions Variables
NCTable.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: NCTable.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #ifndef NCTable_h
26 #define NCTable_h
27 
28 #include <iosfwd>
29 
30 #include <yui/YTable.h>
31 #include "NCPadWidget.h"
32 #include "NCTablePad.h"
33 
34 
35 class NCTable : public YTable, public NCPadWidget
36 {
37 public:
38 
39  NCTable( YWidget * parent, YTableHeader *tableHeader, bool multiSelection = false );
40 
41  virtual ~NCTable();
42 
43  bool bigList() const { return biglist; }
44 
45  void setHeader( std::vector <std::string> head );
46  void getHeader( std::vector <std::string> & head );
47 
48  //std::vector<NCstring> getHeader( ) const { return _header };
49 
50  virtual void setAlignment( int col, YAlignmentType al );
51 
52  void setBigList( const bool big ) { biglist = big; }
53 
54  void SetSepChar( const chtype colSepchar ) { myPad()->SetSepChar( colSepchar ); }
55 
56  void SetSepWidth( const unsigned sepwidth ) { myPad()->SetSepWidth( sepwidth ); }
57 
58  void SetHotCol( const int hcol ) { myPad()->SetHotCol( hcol ); }
59 
60  virtual void addItem( YItem *yitem );
61  virtual void addItems( const YItemCollection & itemCollection );
62  virtual void deleteAllItems( );
63 
64  virtual int getCurrentItem();
65  YItem * getCurrentItemPointer();
66 
67  virtual void setCurrentItem( int index );
68  virtual void selectItem( YItem *yitem, bool selected );
69  void selectCurrentItem();
70  virtual void deselectAllItems();
71 
72  virtual int preferredWidth();
73  virtual int preferredHeight();
74 
75  virtual void setSize( int newWidth, int newHeight );
76 
77  virtual void setLabel( const std::string & nlabel );
78 
79  virtual void setEnabled( bool do_bv );
80 
81  bool setItemByKey( int key );
82 
83  virtual NCursesEvent wHandleInput( wint_t key );
84 
85  virtual bool setKeyboardFocus()
86  {
87  if ( !grabFocus() )
88  return YWidget::setKeyboardFocus();
89 
90  return true;
91  }
92 
93  void stripHotkeys() { myPad()->stripHotkeys(); }
94 
95  void setSortStrategy( NCTableSortStrategyBase * newStrategy ) { myPad()->setSortStrategy( newStrategy ); }
96 
97 protected:
98 
99  /**
100  * Overload myPad to narrow the type
101  */
102  virtual NCTablePad * myPad() const
103  { return dynamic_cast<NCTablePad*>( NCPadWidget::myPad() ); }
104 
105  bool biglist;
106  bool multiselect;
107 
108 
109 protected:
110 
111  virtual const char * location() const { return "NCTable"; }
112 
113  virtual NCPad * CreatePad();
114 
115  virtual void cellChanged( int index, int colnum, const std::string & newtext );
116  virtual void cellChanged( const YTableCell *cell );
117 
118  virtual void startMultipleChanges() { startMultidraw(); }
119  virtual void doneMultipleChanges() { stopMultidraw(); }
120 
121  //internal overloaded version of addItem - both addItem(yitem)
122  //and addItems(itemCollection) use it, but in different mode
123  virtual void addItem( YItem *yitem, bool allAtOnce );
124  void toggleCurrentItem();
125 
126 private:
127 
128  std::vector<NCstring> _header;
129 
130  friend std::ostream & operator<<( std::ostream & STREAM, const NCTable & OBJ );
131 
132  NCTable & operator=( const NCTable & );
133  NCTable( const NCTable & );
134 
135 };
136 
137 
138 #endif // NCTable_h
Definition: NCPad.h:93
virtual NCTablePad * myPad() const
Definition: NCTable.h:102
virtual NCPad * myPad() const
Definition: NCPadWidget.h:62
virtual void setEnabled(bool do_bv)
Definition: NCTable.cc:468
void toggleCurrentItem()
Definition: NCTable.cc:588