libyui-ncurses
2.44.1
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: NCTable.h 00020 00021 Author: Michael Andres <ma@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef NCTable_h 00026 #define NCTable_h 00027 00028 #include <iosfwd> 00029 00030 #include <yui/YTable.h> 00031 #include "NCPadWidget.h" 00032 #include "NCTablePad.h" 00033 00034 00035 class NCTable : public YTable, public NCPadWidget 00036 { 00037 public: 00038 00039 NCTable( YWidget * parent, YTableHeader *tableHeader, bool multiSelection = false ); 00040 00041 virtual ~NCTable(); 00042 00043 bool bigList() const { return biglist; } 00044 00045 void setHeader( std::vector <std::string> head ); 00046 void getHeader( std::vector <std::string> & head ); 00047 00048 //std::vector<NCstring> getHeader( ) const { return _header }; 00049 00050 virtual void setAlignment( int col, YAlignmentType al ); 00051 00052 void setBigList( const bool big ) { biglist = big; } 00053 00054 void SetSepChar( const chtype colSepchar ) { myPad()->SetSepChar( colSepchar ); } 00055 00056 void SetSepWidth( const unsigned sepwidth ) { myPad()->SetSepWidth( sepwidth ); } 00057 00058 void SetHotCol( const int hcol ) { myPad()->SetHotCol( hcol ); } 00059 00060 virtual void addItem( YItem *yitem ); 00061 virtual void addItems( const YItemCollection & itemCollection ); 00062 virtual void deleteAllItems( ); 00063 00064 virtual int getCurrentItem(); 00065 YItem * getCurrentItemPointer(); 00066 00067 virtual void setCurrentItem( int index ); 00068 virtual void selectItem( YItem *yitem, bool selected ); 00069 void selectCurrentItem(); 00070 virtual void deselectAllItems(); 00071 00072 virtual int preferredWidth(); 00073 virtual int preferredHeight(); 00074 00075 virtual void setSize( int newWidth, int newHeight ); 00076 00077 virtual void setLabel( const std::string & nlabel ); 00078 00079 virtual void setEnabled( bool do_bv ); 00080 00081 bool setItemByKey( int key ); 00082 00083 virtual NCursesEvent wHandleInput( wint_t key ); 00084 00085 virtual bool setKeyboardFocus() 00086 { 00087 if ( !grabFocus() ) 00088 return YWidget::setKeyboardFocus(); 00089 00090 return true; 00091 } 00092 00093 void stripHotkeys() { myPad()->stripHotkeys(); } 00094 00095 void setSortStrategy( NCTableSortStrategyBase * newStrategy ) { myPad()->setSortStrategy( newStrategy ); } 00096 00097 protected: 00098 00099 /** 00100 * Overload myPad to narrow the type 00101 */ 00102 virtual NCTablePad * myPad() const 00103 { return dynamic_cast<NCTablePad*>( NCPadWidget::myPad() ); } 00104 00105 bool biglist; 00106 bool multiselect; 00107 00108 00109 protected: 00110 00111 virtual const char * location() const { return "NCTable"; } 00112 00113 virtual NCPad * CreatePad(); 00114 00115 virtual void cellChanged( int index, int colnum, const std::string & newtext ); 00116 virtual void cellChanged( const YTableCell *cell ); 00117 00118 virtual void startMultipleChanges() { startMultidraw(); } 00119 virtual void doneMultipleChanges() { stopMultidraw(); } 00120 00121 //internal overloaded version of addItem - both addItem(yitem) 00122 //and addItems(itemCollection) use it, but in different mode 00123 virtual void addItem( YItem *yitem, bool allAtOnce ); 00124 void toggleCurrentItem(); 00125 00126 private: 00127 00128 std::vector<NCstring> _header; 00129 00130 friend std::ostream & operator<<( std::ostream & STREAM, const NCTable & OBJ ); 00131 00132 NCTable & operator=( const NCTable & ); 00133 NCTable( const NCTable & ); 00134 00135 }; 00136 00137 00138 #endif // NCTable_h