libyui-ncurses  2.44.1
 All Classes Functions Variables
NCTreePad.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: NCTreePad.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #ifndef NCTreePad_h
26 #define NCTreePad_h
27 
28 #include <iosfwd>
29 #include <vector>
30 
31 #include "NCTableItem.h"
32 #include "NCPad.h"
33 #include "NCstring.h"
34 
35 class NCTableLine;
36 class NCTableCol;
37 
38 
39 class NCTreePad : public NCPad
40 {
41 private:
42 
43  friend std::ostream & operator<<( std::ostream & STREAM, const NCTreePad & OBJ );
44 
45  NCTreePad & operator=( const NCTreePad & );
46  NCTreePad( const NCTreePad & );
47 
48 
49  NCursesPad Headpad;
50  bool dirtyHead;
51  bool dirtyFormat;
52 
53  NCTableStyle ItemStyle;
54  NCTableLine Headline;
55  std::vector<NCTableLine*> Items;
56  std::vector<NCTableLine*> visItems;
57  wpos citem;
58 
59  void assertLine( unsigned idx );
60 
61 protected:
62 
63  void DirtyFormat() { dirty = dirtyFormat = true; }
64 
65  virtual wsze UpdateFormat();
66 
67  virtual int dirtyPad() { return setpos( CurPos() ); }
68 
69  virtual int setpos( const wpos & newpos );
70  virtual int DoRedraw();
71  virtual void updateScrollHint();
72 
73 public:
74 
75  NCTreePad( int lines, int cols, const NCWidget & p );
76  virtual ~NCTreePad();
77 
78 public:
79 
80  NCursesWindow * Destwin() { return NCPad::Destwin(); }
81 
82  virtual void Destwin( NCursesWindow * dwin );
83 
84  virtual void wRecoded();
85 
86  virtual wpos CurPos() const;
87  virtual bool handleInput( wint_t key );
88 
89 public:
90 
91  bool SetHeadline( const std::vector<NCstring> & head );
92 
93  virtual void SendHead()
94  {
95  SetHead( Headpad, srect.Pos.C );
96  dirtyHead = false;
97  }
98 
99  unsigned Cols() const { return ItemStyle.Cols(); }
100 
101  unsigned Lines() const { return Items.size(); }
102 
103  unsigned visLines() const { return visItems.size(); }
104 
105  void SetLines( unsigned idx );
106  void SetLines( std::vector<NCTableLine*> & nItems );
107  void ClearTable() { SetLines( 0 ); }
108 
109  void Append( NCTableLine * item ) { AddLine( Lines(), item ); }
110 
111  void Append( std::vector<NCTableCol*> & nItems ) { AddLine( Lines(), new NCTableLine( nItems ) ); }
112 
113  void AddLine( unsigned idx, NCTableLine * item );
114  void DelLine( unsigned idx );
115 
116  const NCTableLine * GetCurrentLine() const ;
117  const NCTableLine * GetLine( unsigned idx ) const;
118 
119  NCTableLine * ModifyLine( unsigned idx );
120 
121  void ShowItem( const NCTableLine * item );
122 };
123 
124 
125 #endif // NCTreePad_h
C++ class for windows.
Definition: ncursesw.h:904
static int lines()
Definition: ncursesw.h:1042
Definition: NCPad.h:93
static int cols()
Definition: ncursesw.h:1047
Definition: position.h:109
Definition: position.h:154