libyui
 
Loading...
Searching...
No Matches
YMenuItem.h
1/*
2 Copyright (C) 2000-2018 Novell, Inc
3 Copyright (c) [2019-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: YMenuItem.h
21
22 Author: Stefan Hundhammer <shundhammer@suse.de>
23
24/-*/
25
26#ifndef YMenuItem_h
27#define YMenuItem_h
28
29#include "YTreeItem.h"
30
31
32
43class YMenuItem: public YTreeItem
44{
45public:
49 YMenuItem( const std::string & label,
50 const std::string & iconName = "" )
52 , _enabled( true )
53 , _visible( true )
54 , _uiItem( 0 )
55 {}
56
67 const std::string & label,
68 const std::string & iconName = "" )
70 , _enabled( true )
71 , _visible( true )
72 , _uiItem( 0 )
73 {}
74
75
81 virtual ~YMenuItem() {}
82
88 YMenuItem * addItem( const std::string & label,
89 const std::string & iconName = "" );
90
96 YMenuItem * addMenu( const std::string & label,
97 const std::string & iconName = "" );
98
104
109 { return dynamic_cast<YMenuItem *> ( YTreeItem::parent() ); }
110
115 bool isMenu() const { return hasChildren(); }
116
120 bool isSeparator() const { return label().empty(); }
121
125 bool isEnabled() const { return _enabled; }
126
134 void setEnabled( bool enabled = true ) { _enabled = enabled; }
135
139 bool isVisible() const { return _visible; }
140
148 void setVisible( bool visible = true ) { _visible = visible; }
149
153 void * uiItem() const { return _uiItem; }
154
160 void setUiItem( void * uiItem ) { _uiItem = uiItem; }
161
162
163private:
164
165 // Disable unwanted base class methods
166
167 bool isOpen() const { return false; }
168 void setOpen( bool ) {}
169
170
171 // Data members
172
173 bool _enabled;
174 bool _visible;
175 void * _uiItem;
176};
177
178
179#endif // YMenuItem_h
std::string label() const
Definition YItem.h:97
std::string iconName() const
Definition YItem.h:107
Definition YMenuItem.h:44
YMenuItem * addSeparator()
Definition YMenuItem.cc:43
virtual ~YMenuItem()
Definition YMenuItem.h:81
bool isEnabled() const
Definition YMenuItem.h:125
YMenuItem(YMenuItem *parent, const std::string &label, const std::string &iconName="")
Definition YMenuItem.h:66
bool isMenu() const
Definition YMenuItem.h:115
YMenuItem * addMenu(const std::string &label, const std::string &iconName="")
Definition YMenuItem.cc:36
YMenuItem * parent() const
Definition YMenuItem.h:108
bool isVisible() const
Definition YMenuItem.h:139
YMenuItem * addItem(const std::string &label, const std::string &iconName="")
Definition YMenuItem.cc:29
void setVisible(bool visible=true)
Definition YMenuItem.h:148
bool isSeparator() const
Definition YMenuItem.h:120
void setEnabled(bool enabled=true)
Definition YMenuItem.h:134
YMenuItem(const std::string &label, const std::string &iconName="")
Definition YMenuItem.h:49
void setUiItem(void *uiItem)
Definition YMenuItem.h:160
void * uiItem() const
Definition YMenuItem.h:153
virtual YTreeItem * parent() const
Definition YTreeItem.h:134
virtual bool hasChildren() const
Definition YTreeItem.h:82
YTreeItem(const std::string &label, bool isOpen=false)