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: NCMultiSelectionBox.h 00020 00021 Author: Michael Andres <ma@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef NCMultiSelectionBox_h 00026 #define NCMultiSelectionBox_h 00027 00028 #include <iosfwd> 00029 00030 #include <yui/YMultiSelectionBox.h> 00031 #include "NCPadWidget.h" 00032 #include "NCTablePad.h" 00033 00034 00035 00036 00037 00038 00039 class NCMultiSelectionBox : public YMultiSelectionBox, public NCPadWidget 00040 { 00041 00042 friend std::ostream & operator<<( std::ostream & STREAM, const NCMultiSelectionBox & OBJ ); 00043 00044 NCMultiSelectionBox & operator=( const NCMultiSelectionBox & ); 00045 NCMultiSelectionBox( const NCMultiSelectionBox & ); 00046 00047 protected: 00048 00049 /** 00050 * Overload myPad to narrow the type 00051 */ 00052 virtual NCTablePad * myPad() const 00053 { return dynamic_cast<NCTablePad*>( NCPadWidget::myPad() ); } 00054 00055 NCTableTag * tagCell( int index ); 00056 const NCTableTag * tagCell( int index ) const; 00057 00058 bool isItemSelected( YItem *item ); 00059 00060 void toggleCurrentItem(); 00061 00062 public: 00063 00064 virtual void startMultipleChanges() { startMultidraw(); } 00065 00066 virtual void doneMultipleChanges() { stopMultidraw(); } 00067 00068 virtual const char * location() const { return "NCMultiSelectionBox"; } 00069 00070 virtual void addItem( YItem * item ); 00071 00072 virtual void deleteAllItems(); 00073 00074 virtual void selectItem( YItem * item, bool selected ); 00075 00076 virtual void deselectAllItems(); 00077 00078 protected: 00079 00080 virtual NCPad * CreatePad(); 00081 virtual void wRecoded(); 00082 00083 00084 public: 00085 00086 NCMultiSelectionBox( YWidget * parent, const std::string & label ); 00087 virtual ~NCMultiSelectionBox(); 00088 00089 virtual int preferredWidth(); 00090 virtual int preferredHeight(); 00091 00092 virtual void setSize( int newWidth, int newHeight ); 00093 00094 virtual void setLabel( const std::string & nlabel ); 00095 00096 virtual YItem * currentItem(); 00097 virtual void setCurrentItem( YItem * item ); 00098 00099 virtual NCursesEvent wHandleInput( wint_t key ); 00100 00101 virtual void setEnabled( bool do_bv ); 00102 00103 virtual bool setKeyboardFocus() 00104 { 00105 if ( !grabFocus() ) 00106 return YWidget::setKeyboardFocus(); 00107 00108 return true; 00109 } 00110 00111 unsigned int getNumLines( ) { return myPad()->Lines(); } 00112 00113 const NCTableLine * getLine( const int & index ) { return myPad()->GetLine( index ); } 00114 00115 void clearItems() { return myPad()->ClearTable(); } 00116 }; 00117 00118 00119 #endif // NCMultiSelectionBox_h