libyui  3.4.2
YMenuItem.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: YMenuItem.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YMenuItem_h
26 #define YMenuItem_h
27 
28 #include "YTreeItem.h"
29 
30 
31 
32 /**
33  * Item class for menu items.
34  **/
35 class YMenuItem: public YTreeItem
36 {
37 public:
38  /**
39  * Constructors for toplevel items.
40  **/
41  YMenuItem( const std::string & label )
42  : YTreeItem( label )
43  {}
44 
45  YMenuItem( const std::string & label,
46  const std::string & iconName )
47  : YTreeItem( label, iconName )
48  {}
49 
50  /**
51  * Constructors for items that have a parent item.
52  *
53  * They will automatically register this item with the parent item. The
54  * parent assumes ownership of this item and will delete it in its (the
55  * parent's) destructor.
56  **/
58  const std::string & label )
59  : YTreeItem( parent, label )
60  {}
61 
63  const std::string & label,
64  const std::string & iconName )
65  : YTreeItem( parent, label, iconName )
66  {}
67 
68  /**
69  * Destructor.
70  *
71  * This will delete all children.
72  **/
73  virtual ~YMenuItem() {}
74 
75 
76  /**
77  * Returns this item's parent item or 0 if it is a toplevel item.
78  **/
79  YMenuItem * parent() const
80  { return dynamic_cast<YMenuItem *> ( YTreeItem::parent() ); }
81 
82 
83 private:
84 
85  // Disable unwanted base class methods
86 
87  bool isOpen() const { return false; }
88  void setOpen( bool ) {}
89 };
90 
91 
92 #endif // YMenuItem_h
std::string label() const
Return this item&#39;s label.
Definition: YItem.h:82
std::string iconName() const
Return this item&#39;s icon name.
Definition: YItem.h:92
virtual YTreeItem * parent() const
Returns this item&#39;s parent item or 0 if it is a toplevel item.
Definition: YTreeItem.h:129
YMenuItem(YMenuItem *parent, const std::string &label)
Constructors for items that have a parent item.
Definition: YMenuItem.h:57
YTreeItem(const std::string &label, bool isOpen=false)
Constructors for toplevel items.
Definition: YTreeItem.cc:28
Item class for menu items.
Definition: YMenuItem.h:35
virtual ~YMenuItem()
Destructor.
Definition: YMenuItem.h:73
YMenuItem * parent() const
Returns this item&#39;s parent item or 0 if it is a toplevel item.
Definition: YMenuItem.h:79
YMenuItem(const std::string &label)
Constructors for toplevel items.
Definition: YMenuItem.h:41
Item class for tree items.
Definition: YTreeItem.h:37