libyui-ncurses  2.44.1
/usr/src/RPM/BUILD/libyui-ncurses-2.44.1/src/NCTreePad.h
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:       NCTreePad.h
00020 
00021    Author:     Michael Andres <ma@suse.de>
00022 
00023 /-*/
00024 
00025 #ifndef NCTreePad_h
00026 #define NCTreePad_h
00027 
00028 #include <iosfwd>
00029 #include <vector>
00030 
00031 #include "NCTableItem.h"
00032 #include "NCPad.h"
00033 #include "NCstring.h"
00034 
00035 class NCTableLine;
00036 class NCTableCol;
00037 
00038 
00039 class NCTreePad : public NCPad
00040 {
00041 private:
00042 
00043     friend std::ostream & operator<<( std::ostream & STREAM, const NCTreePad & OBJ );
00044 
00045     NCTreePad & operator=( const NCTreePad & );
00046     NCTreePad( const NCTreePad & );
00047 
00048 
00049     NCursesPad  Headpad;
00050     bool        dirtyHead;
00051     bool        dirtyFormat;
00052 
00053     NCTableStyle         ItemStyle;
00054     NCTableLine          Headline;
00055     std::vector<NCTableLine*> Items;
00056     std::vector<NCTableLine*> visItems;
00057     wpos                 citem;
00058 
00059     void assertLine( unsigned idx );
00060 
00061 protected:
00062 
00063     void         DirtyFormat() { dirty = dirtyFormat = true; }
00064 
00065     virtual wsze UpdateFormat();
00066 
00067     virtual int  dirtyPad() { return setpos( CurPos() ); }
00068 
00069     virtual int  setpos( const wpos & newpos );
00070     virtual int  DoRedraw();
00071     virtual void updateScrollHint();
00072 
00073 public:
00074 
00075     NCTreePad( int lines, int cols, const NCWidget & p );
00076     virtual ~NCTreePad();
00077 
00078 public:
00079 
00080     NCursesWindow * Destwin() { return NCPad::Destwin(); }
00081 
00082     virtual void Destwin( NCursesWindow * dwin );
00083 
00084     virtual void wRecoded();
00085 
00086     virtual wpos CurPos() const;
00087     virtual bool handleInput( wint_t key );
00088 
00089 public:
00090 
00091     bool SetHeadline( const std::vector<NCstring> & head );
00092 
00093     virtual void SendHead()
00094     {
00095         SetHead( Headpad, srect.Pos.C );
00096         dirtyHead = false;
00097     }
00098 
00099     unsigned Cols()     const { return ItemStyle.Cols(); }
00100 
00101     unsigned Lines()    const { return Items.size(); }
00102 
00103     unsigned visLines() const { return visItems.size(); }
00104 
00105     void     SetLines( unsigned idx );
00106     void     SetLines( std::vector<NCTableLine*> & nItems );
00107     void     ClearTable()  { SetLines( 0 ); }
00108 
00109     void Append( NCTableLine * item )           { AddLine( Lines(), item ); }
00110 
00111     void Append( std::vector<NCTableCol*> & nItems ) { AddLine( Lines(), new NCTableLine( nItems ) ); }
00112 
00113     void AddLine( unsigned idx, NCTableLine * item );
00114     void DelLine( unsigned idx );
00115 
00116     const NCTableLine * GetCurrentLine() const ;
00117     const NCTableLine * GetLine( unsigned idx ) const;
00118 
00119     NCTableLine *       ModifyLine( unsigned idx );
00120 
00121     void ShowItem( const NCTableLine * item );
00122 };
00123 
00124 
00125 #endif // NCTreePad_h
 All Classes Functions Variables