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: NCTree.h 00020 00021 Author: Michael Andres <ma@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef NCTree_h 00026 #define NCTree_h 00027 00028 #include <iosfwd> 00029 00030 #include <yui/YTree.h> 00031 #include "NCPadWidget.h" 00032 #include "NCTreePad.h" 00033 #include "NCTablePad.h" 00034 00035 class NCTreeLine; 00036 00037 00038 class NCTree : public YTree, public NCPadWidget 00039 { 00040 private: 00041 friend std::ostream & operator<<( std::ostream & STREAM, const NCTree & OBJ ); 00042 00043 NCTree & operator=( const NCTree & ); 00044 NCTree( const NCTree & ); 00045 00046 int idx; 00047 bool multiSel; 00048 00049 void CreateTreeLines( NCTreeLine * p, NCTreePad * pad, YItem * item ); 00050 00051 protected: 00052 00053 virtual NCTreePad * myPad() const 00054 { return dynamic_cast<NCTreePad*>( NCPadWidget::myPad() ); } 00055 00056 const NCTreeLine * getTreeLine( unsigned idx ) const; 00057 NCTreeLine * modifyTreeLine( unsigned idx ); 00058 00059 virtual const char * location() const { return "NCTree"; } 00060 00061 virtual NCPad * CreatePad(); 00062 virtual void DrawPad(); 00063 00064 virtual void startMultipleChanges() { startMultidraw(); } 00065 virtual void doneMultipleChanges() { stopMultidraw(); } 00066 00067 public: 00068 00069 NCTree( YWidget * parent, const std::string & label, bool multiselection=false, bool recursiveselection=false ); 00070 virtual ~NCTree(); 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 virtual void rebuildTree(); 00079 00080 virtual YTreeItem * getCurrentItem() const; 00081 00082 virtual YTreeItem * currentItem(); 00083 00084 virtual void deselectAllItems(); 00085 00086 virtual void selectItem( YItem *item, bool selected ); 00087 virtual void selectItem( int index ); 00088 00089 virtual NCursesEvent wHandleInput( wint_t key ); 00090 00091 virtual void setEnabled( bool do_bv ); 00092 00093 virtual bool setKeyboardFocus() 00094 { 00095 if ( !grabFocus() ) 00096 return YWidget::setKeyboardFocus(); 00097 00098 return true; 00099 } 00100 00101 void deleteAllItems(); 00102 }; 00103 00104 00105 #endif // NCTree_h