libyui-mga-ncurses  1.1.0
NCMenu.h
1 /*
2  Copyright 2020 by Angelo Naselli <anaselli at linux dot it>
3 
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 
21  File: NCMenu.h
22 
23  Author: Michael Andres <ma@suse.de>
24 
25 /-*/
26 
27 #ifndef NCMenu_h
28 #define NCMenu_h
29 
30 #include <iosfwd>
31 
32 #include <yui/YTree.h>
33 #include <yui/YMenuItem.h>
34 #include "NCPadWidget.h"
35 #include <yui/ncurses/NCTreePad.h>
36 #include <yui/ncurses/NCTablePad.h>
37 
38 class NCMenuLine;
39 
40 
41 class NCMenu : public YTree, public NCPadWidget
42 {
43 private:
44  friend std::ostream & operator<<( std::ostream & str, const NCMenu & obj );
45 
46  NCMenu & operator=( const NCMenu & );
47  NCMenu( const NCMenu & );
48 
49  int idx;
50 
51  void CreateTreeLine(NCTreePad* pad, YItem* item);
52 
53 protected:
54 
55  virtual NCTreePad * myPad() const
56  {
57  return dynamic_cast<NCTreePad*>( NCPadWidget::myPad() );
58  }
59 
60 
61 
62  const NCMenuLine * getTreeLine( unsigned idx ) const;
63  NCMenuLine * modifyTreeLine( unsigned idx );
64 
65  virtual const char * location() const {
66  return "NCMenu";
67  }
68 
69  virtual NCPad * CreatePad();
70  virtual void DrawPad();
71 
72  virtual void startMultipleChanges() {
73  startMultidraw();
74  }
75  virtual void doneMultipleChanges() {
76  stopMultidraw();
77  }
78 
79  virtual void activate() {}
80 
81 public:
82 
83  NCMenu( YWidget * parent );
84  virtual ~NCMenu();
85 
86  virtual int preferredWidth();
87  virtual int preferredHeight();
88  virtual void setSize( int newWidth, int newHeight );
89 
90  bool HasHotkey(int key);
91  NCursesEvent wHandleHotkey( wint_t key );
92 
93  virtual void rebuildTree();
94 
95  virtual YMenuItem * getCurrentItem() const;
96 
97  virtual YMenuItem * currentItem();
98 
99  virtual void deselectAllItems();
100 
101  virtual void selectItem( YItem *item, bool selected );
102  virtual void selectItem( int index );
103 
104  virtual NCursesEvent wHandleInput( wint_t key );
105 
106  virtual void setEnabled( bool do_bv );
107 
108  virtual bool setKeyboardFocus()
109  {
110  if ( !grabFocus() )
111  return YWidget::setKeyboardFocus();
112 
113  return true;
114  }
115 
116  void deleteAllItems();
117 
118 
119 
120 };
121 
122 
123 #endif // NCMenu_h
NCMenu
Definition: NCMenu.h:42
NCMenuLine
Definition: NCMenu.cc:38