libyui-ncurses
NCMenuBar.h
1 /*
2  Copyright (C) 2020 SUSE LLC
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: NCMenuBar.h
20 
21  Author: Jose Iván López <jlopez@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef NCMenuBar_h
27 #define NCMenuBar_h
28 
29 #include <yui/YMenuBar.h>
30 #include "NCWidget.h"
31 #include "CyclicContainer.h"
32 
33 class NCMenuBar: public YMenuBar, public NCWidget
34 {
35 public:
39  NCMenuBar( YWidget * parent );
40 
44  virtual ~NCMenuBar();
45 
51  virtual void rebuildMenuTree();
52 
58  virtual void setItemEnabled( YMenuItem * item, bool enabled );
59 
65  virtual void setItemVisible( YMenuItem * item, bool visible );
66 
75  virtual void activateItem( YMenuItem * item );
76 
81  virtual NCursesEvent wHandleInput( wint_t key );
82 
87  virtual int preferredWidth();
88 
93  virtual int preferredHeight();
94 
99  virtual void setSize( int newWidth, int newHeight );
100 
105  virtual void setEnabled( bool enabled );
106 
111  virtual bool setKeyboardFocus();
112 
117  virtual NCursesEvent wHandleHotkey( wint_t key );
118 
123  virtual bool HasHotkey( int key ) ;
124 
130  virtual void shortcutChanged();
131 
132 protected:
133 
137  void clear();
138 
139  virtual const char * location() const { return "NCMenuBar"; }
140 
144  virtual void wRedraw();
145 
151 
152 private:
153 
154  struct Menu;
155 
156  friend std::ostream & operator<<( std::ostream & str,
157  const NCMenuBar & obj );
158 
159  // Disable assignment operator and copy constructor
160 
161  NCMenuBar & operator=( const NCMenuBar & );
162  NCMenuBar( const NCMenuBar & );
163 
168  NCursesEvent handlePostMenu( const NCursesEvent & event );
169 
173  Menu * selectedMenu();
174 
178  void selectNextMenu();
179 
183  void selectPreviousMenu();
184 
189  CyclicContainer<Menu>::Iterator findMenuWithHotkey( wint_t key );
190 
196  const NCstyle::StWidget & menuStyle( const Menu * menu );
197 
203  CyclicContainer<Menu> _menus;
204 
205 }; // NCMenuBar
206 
207 #endif // NCMenuBar_h
Definition: NCurses.h:72
NCMenuBar(YWidget *parent)
Definition: NCMenuBar.cc:74
virtual void setItemEnabled(YMenuItem *item, bool enabled)
Definition: NCMenuBar.cc:187
Definition: NCMenuBar.cc:43
NCursesEvent postMenu()
Definition: NCMenuBar.cc:165
virtual bool HasHotkey(int key)
Definition: NCMenuBar.cc:295
virtual void setItemVisible(YMenuItem *item, bool visible)
Definition: NCMenuBar.cc:196
void clear()
Definition: NCMenuBar.cc:88
virtual bool setKeyboardFocus()
Definition: NCMenuBar.cc:285
virtual int preferredWidth()
Definition: NCMenuBar.cc:256
virtual void activateItem(YMenuItem *item)
Definition: NCMenuBar.cc:205
virtual void rebuildMenuTree()
Definition: NCMenuBar.cc:100
virtual void setSize(int newWidth, int newHeight)
Definition: NCMenuBar.cc:270
virtual void shortcutChanged()
Definition: NCMenuBar.cc:320
virtual int preferredHeight()
Definition: NCMenuBar.cc:263
Definition: NCMenuBar.h:33
virtual NCursesEvent wHandleHotkey(wint_t key)
Definition: NCMenuBar.cc:305
virtual NCursesEvent wHandleInput(wint_t key)
Definition: NCMenuBar.cc:220
virtual void setEnabled(bool enabled)
Definition: NCMenuBar.cc:277
Definition: CyclicContainer.h:39
Definition: NCWidget.h:45
Definition: NCstyle.h:357
virtual ~NCMenuBar()
Definition: NCMenuBar.cc:81
virtual void wRedraw()
Definition: NCMenuBar.cc:137