libyui-ncurses  2.55.0
NCMenuButton.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: NCMenuButton.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #ifndef NCMenuButton_h
26 #define NCMenuButton_h
27 
28 #include <iosfwd>
29 
30 #include <yui/YMenuButton.h>
31 #include "NCApplication.h"
32 #include "NCWidget.h"
33 
34 
35 class NCMenuButton : public YMenuButton, public NCWidget
36 {
37 private:
38 
39  friend std::ostream & operator<<( std::ostream & str, const NCMenuButton & obj );
40 
41  NCMenuButton & operator=( const NCMenuButton & );
42  NCMenuButton( const NCMenuButton & );
43 
44  NClabel label;
45  bool haveUtf8() { return YUI::app()->hasFullUtf8Support(); }
46 
47 protected:
48 
49  virtual const char * location() const { return "NCMenuButton"; }
50 
51  virtual void wRedraw();
52 
53  NCursesEvent postMenu();
54 
55 public:
56 
57  NCMenuButton( YWidget * parent,
58  std::string label );
59  virtual ~NCMenuButton();
60 
61  virtual int preferredWidth();
62  virtual int preferredHeight();
63 
64  virtual void setSize( int newWidth, int newHeight );
65 
66  virtual void rebuildMenuTree();
67 
68  virtual NCursesEvent wHandleInput( wint_t key );
69 
70  virtual void setLabel( const std::string & nlabel );
71 
72  virtual void setEnabled( bool do_bv );
73 
74  YMenuItem * findItem( int selection ) { return findMenuItem( selection ); }
75 
76  virtual bool setKeyboardFocus()
77  {
78  if ( !grabFocus() )
79  return YWidget::setKeyboardFocus();
80 
81  return true;
82  }
83 
84  /**
85  * Activate the item selected in the tree. Can be used in tests to simulate user input.
86  *
87  * Derived classes are required to implement this.
88  **/
89  virtual void activateItem( YMenuItem * item );
90 
91 };
92 
93 
94 #endif // NCMenuButton_h
virtual void setEnabled(bool do_bv)
Pure virtual to make sure every widget implements it.
Definition: NCMenuButton.cc:62
virtual void activateItem(YMenuItem *item)
Activate the item selected in the tree.
Definition: NCtext.h:82