Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

NCTablePad.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013    File:       NCTablePad.h
00014 
00015    Author:     Michael Andres <ma@suse.de>
00016    Maintainer: Michael Andres <ma@suse.de>
00017 
00018 /-*/
00019 #ifndef NCTablePad_h
00020 #define NCTablePad_h
00021 
00022 #include <iosfwd>
00023 
00024 #include <vector>
00025 using namespace std;
00026 
00027 #include "NCTableItem.h"
00028 #include "NCPad.h"
00029 #include "NCstring.h"
00030 
00031 class NCTableLine;
00032 class NCTableCol;
00033 
00035 //
00036 //      CLASS NAME : NCTablePad
00037 //
00038 //      DESCRIPTION :
00039 //
00040 class NCTablePad : public NCPad {
00041 
00042   friend std::ostream & operator<<( std::ostream & STREAM, const NCTablePad & OBJ );
00043 
00044   NCTablePad & operator=( const NCTablePad & );
00045   NCTablePad            ( const NCTablePad & );
00046 
00047   private:
00048 
00049     NCursesPad  Headpad;
00050     bool        dirtyHead;
00051     bool        dirtyFormat;
00052 
00053     NCTableStyle         ItemStyle;
00054     NCTableLine          Headline;
00055     vector<NCTableLine*> Items;
00056     wpos                 citem;
00057 
00058     void assertLine( unsigned idx );
00059 
00060   protected:
00061 
00062     void         DirtyFormat() { dirty = dirtyFormat = true; }
00063     virtual wsze UpdateFormat();
00064 
00065     virtual int  dirtyPad() { return setpos( CurPos() ); }
00066     virtual int  setpos( const wpos & newpos );
00067     virtual int  DoRedraw();
00068     virtual void updateScrollHint();
00069 
00070   public:
00071 
00072     NCTablePad( int lines, int cols, const NCWidget & p );
00073     virtual ~NCTablePad();
00074 
00075   public:
00076 
00077     virtual void wRecoded();
00078 
00079     virtual wpos CurPos() const;
00080     virtual bool handleInput( wint_t key );
00081 
00082     bool setItemByKey( int key );
00083 
00084     wsze tableSize() { return dirtyFormat ? UpdateFormat()
00085                                           : wsze( Lines(), ItemStyle.TableWidth() ); }
00086 
00087   public:
00088 
00089     bool SetHeadline( const vector<NCstring> & head );
00090 
00091     virtual void SendHead() {
00092       SetHead( Headpad, srect.Pos.C );
00093       dirtyHead = false;
00094     }
00095 
00096     void SetSepChar( const chtype colSepchar ) {
00097       ItemStyle.SetSepChar( colSepchar );
00098     }
00099     void SetSepWidht( const unsigned sepwidth ) {
00100       ItemStyle.SetSepWidht( sepwidth );
00101     }
00102     void SetHotCol( const int hcol ) {
00103       ItemStyle.SetHotCol( hcol );
00104     }
00105 
00106     unsigned Cols()  const { return ItemStyle.Cols(); }
00107     unsigned Lines() const { return Items.size(); }
00108     unsigned HotCol()const { return ItemStyle.HotCol(); }
00109 
00110     void     SetLines( unsigned idx );
00111     void     SetLines( vector<NCTableLine*> & nItems );
00112     void     ClearTable()  { SetLines( 0 ); }
00113 
00114     void Append( NCTableLine * item )           { AddLine( Lines(), item ); }
00115     void Append( vector<NCTableCol*> & nItems ) { AddLine( Lines(), new NCTableLine( nItems ) ); }
00116     void AddLine( unsigned idx, NCTableLine * item );
00117     void DelLine( unsigned idx );
00118 
00119     const NCTableLine * GetLine( unsigned idx ) const;
00120     NCTableLine *       ModifyLine( unsigned idx );
00121 };
00122 
00124 
00125 #endif // NCTablePad_h

Generated on Wed Sep 5 17:18:55 2007 for yast2-ncurses by doxygen 1.3.6