libyui-ncurses
Loading...
Searching...
No Matches
NCTree.h
1/*
2 Copyright (C) 2000-2012 Novell, Inc
3 Copyright (C) 2020 SUSE LLC
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) version 3.0 of the License. This library
8 is distributed in the hope that it will be useful, but WITHOUT ANY
9 WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11 License for more details. You should have received a copy of the GNU
12 Lesser General Public License along with this library; if not, write
13 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
14 Floor, Boston, MA 02110-1301 USA
15*/
16
17
18/*-/
19
20 File: NCTree.h
21
22 Authors: Michael Andres <ma@suse.de>
23 Stefan Hundhammer <shundhammer@suse.de>
24
25/-*/
26
27#ifndef NCTree_h
28#define NCTree_h
29
30#include <iosfwd>
31
32#include <yui/YTree.h>
33#include "NCPadWidget.h"
34#include "NCTreePad.h"
35#include "NCTablePad.h"
36
37class NCTreeLine;
38
46class NCTree : public YTree, public NCPadWidget
47{
48 friend std::ostream & operator<<( std::ostream & str, const NCTree & obj );
49
50public:
51
52 NCTree( YWidget * parent,
53 const std::string & label,
54 bool multiselection = false,
55 bool recursiveselection = false );
56
57 virtual ~NCTree();
58
64 virtual void rebuildTree();
65
69 virtual YTreeItem * getCurrentItem() const;
70
76 virtual YTreeItem * currentItem();
77
78 virtual void deselectAllItems();
79
85 virtual void selectItem( YItem *item, bool selected );
86
90 virtual void selectItem( int index );
91
97 virtual void deleteAllItems();
98
105 virtual int preferredWidth();
106
113 virtual int preferredHeight();
114
121 virtual void setSize( int newWidth, int newHeight );
122
128 virtual void setLabel( const std::string & nlabel );
129
135 virtual void setEnabled( bool do_bv );
136
142 virtual bool setKeyboardFocus()
143 {
144 if ( !grabFocus() )
145 return YWidget::setKeyboardFocus();
146
147 return true;
148 }
149
156 virtual void activate();
157
163 virtual NCursesEvent wHandleInput( wint_t key );
164
165
166protected:
167
173 virtual const char * location() const { return "NCTree"; }
174
178 virtual NCPad * CreatePad();
179
186 virtual NCTreePad * myPad() const
187 { return dynamic_cast<NCTreePad*>( NCPadWidget::myPad() ); }
188
192 virtual void DrawPad();
193
194
199 const NCTreeLine * getTreeLine( unsigned idx ) const;
200
206 NCTreeLine * modifyTreeLine( unsigned idx );
207
214 virtual void startMultipleChanges() { startMultidraw(); }
215
222 virtual void doneMultipleChanges() { stopMultidraw(); }
223
228 void CreateTreeLines( NCTreeLine * parentLine,
229 NCTreePad * pad,
230 YItem * item );
231
232private:
233
234 // Disable unwanted assignment operator and copy constructor
235
236 NCTree & operator=( const NCTree & );
237 NCTree( const NCTree & );
238
239
240 //
241 // Data members
242 //
243
244 bool _multiSelect;
245 int _nextItemIndex; // Only used in CreateTreeLines()
246};
247
248
262{
263public:
264
265 NCTreeLine( NCTreeLine * parentLine,
266 YTreeItem * origItem,
267 bool multiSelection );
268
269 virtual ~NCTreeLine();
270
271public:
272
276 YTreeItem * YItem() const { return dynamic_cast<YTreeItem *>( _yitem ); }
277
289 virtual bool ChangeToVisible();
290
291 virtual unsigned Hotspot( unsigned & at ) const;
292
297 virtual bool handleInput( wint_t key );
298
299
300 //
301 // Some covariants of the tree operations returning this derived class
302 //
303
304 virtual NCTreeLine * parent() const { return dynamic_cast<NCTreeLine *>( _parent ); }
305 virtual NCTreeLine * firstChild() const { return dynamic_cast<NCTreeLine *>( _firstChild ); }
306 virtual NCTreeLine * nextSibling() const { return dynamic_cast<NCTreeLine *>( _nextSibling ); }
307
308
309private:
310
311 //
312 // Data members
313 //
314
315 bool _multiSelect;
316};
317
318
319#endif // NCTree_h
Definition NCPadWidget.h:40
virtual NCPad * myPad() const
Definition NCPadWidget.h:64
Definition NCPad.h:113
Definition NCTableItem.h:68
YItem * _yitem
not owned
Definition NCTableItem.h:387
YTableItem * origItem() const
Definition NCTableItem.h:127
Definition NCTree.h:262
virtual bool handleInput(wint_t key)
Definition NCTree.cc:484
YTreeItem * YItem() const
Definition NCTree.h:276
virtual bool ChangeToVisible()
Definition NCTree.cc:443
Definition NCTreePad.h:50
Definition NCTree.h:47
virtual const char * location() const
Definition NCTree.h:173
virtual NCPad * CreatePad()
Definition NCTree.cc:230
virtual void startMultipleChanges()
Definition NCTree.h:214
virtual YTreeItem * currentItem()
Definition NCTree.cc:291
virtual void rebuildTree()
Definition NCTree.cc:223
virtual void activate()
Definition NCTree.cc:395
virtual void deleteAllItems()
Definition NCTree.cc:405
virtual void DrawPad()
Definition NCTree.cc:297
const NCTreeLine * getTreeLine(unsigned idx) const
Definition NCTree.cc:66
virtual void setSize(int newWidth, int newHeight)
Definition NCTree.cc:106
virtual int preferredWidth()
Definition NCTree.cc:85
virtual int preferredHeight()
Definition NCTree.cc:92
virtual void selectItem(YItem *item, bool selected)
Definition NCTree.cc:146
virtual NCursesEvent wHandleInput(wint_t key)
Definition NCTree.cc:321
void CreateTreeLines(NCTreeLine *parentLine, NCTreePad *pad, YItem *item)
Definition NCTree.cc:240
virtual void setEnabled(bool do_bv)
Definition NCTree.cc:99
virtual bool setKeyboardFocus()
Definition NCTree.h:142
NCTreeLine * modifyTreeLine(unsigned idx)
Definition NCTree.cc:76
virtual NCTreePad * myPad() const
Definition NCTree.h:186
virtual YTreeItem * getCurrentItem() const
Definition NCTree.cc:112
virtual void doneMultipleChanges()
Definition NCTree.h:222
virtual void setLabel(const std::string &nlabel)
Definition NCTree.cc:216
Definition NCurses.h:73