libyui
 
Loading...
Searching...
No Matches
YMenuWidget.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: YMenuWidget.h
20
21 Author: Stefan Hundhammer <shundhammer@suse.de>
22
23/-*/
24
25#ifndef YMenuWidget_h
26#define YMenuWidget_h
27
28#include "YSelectionWidget.h"
29#include "YMenuItem.h"
30
32
33
39{
40protected:
48 YMenuWidget( YWidget * parent, const std::string & label = "" );
49
50public:
51
55 virtual ~YMenuWidget();
56
61 virtual const char * widgetClass() const { return "YMenuWidget"; }
62
71 virtual void rebuildMenuTree() = 0;
72
83 virtual void addItems( const YItemCollection & itemCollection );
84
98 virtual void addItem( YItem * item_disown );
99
105 virtual void deleteAllItems();
106
116
125 virtual void setItemEnabled( YMenuItem * item, bool enabled );
126
135 virtual void setItemVisible( YMenuItem * item, bool visible );
136
146 YMenuItem * findItem( std::vector<std::string> & path ) const;
147
156 virtual void activateItem( YMenuItem * item ) = 0;
157
162 YMenuItem * findMenuItem( int index );
163
164
165 // No propertySet(), setProperty(), getProperty() on this level:
166 //
167 // This is left to derived widgets (very much like for YSelectionWidget)
168 // so they can be tailored to what they really can provide.
169 //
170 // There is infrastructure for properties like "EnabledItems" here and in
171 // the UI bindings, though, to easily support those properties.
172
173protected:
174
180
187 YMenuItem * findMenuItem( int index,
190
199 YMenuItem * findItem( std::vector<std::string>::iterator path_begin,
200 std::vector<std::string>::iterator path_end,
202 YItemConstIterator end ) const;
203
208 YMenuItem * itemAt( int index )
209 { return findMenuItem( index ); }
210
216
217
218private:
219
221};
222
223
224#endif // YMenuWidget_h
YItemCollection::const_iterator YItemConstIterator
Const iterator over YItemCollection.
Definition YItem.h:45
YItemCollection::iterator YItemIterator
Mutable iterator over YItemCollection.
Definition YItem.h:42
std::vector< YItem * > YItemCollection
Collection of pointers to YItem.
Definition YItem.h:39
Definition ImplPtr.h:43
Definition YItem.h:56
Definition YMenuItem.h:44
virtual const char * widgetClass() const
Definition YMenuWidget.h:61
virtual void setItemEnabled(YMenuItem *item, bool enabled)
Definition YMenuWidget.cc:111
virtual ~YMenuWidget()
Definition YMenuWidget.cc:61
YMenuWidget(YWidget *parent, const std::string &label="")
Definition YMenuWidget.cc:51
YMenuItem * findItem(std::vector< std::string > &path) const
Definition YMenuWidget.cc:269
virtual void deleteAllItems()
Definition YMenuWidget.cc:103
virtual void setItemVisible(YMenuItem *item, bool visible)
Definition YMenuWidget.cc:119
YMenuItem * findMenuItem(int index)
Definition YMenuWidget.cc:127
void resolveShortcutConflicts()
Definition YMenuWidget.cc:262
virtual void addItem(YItem *item_disown)
Definition YMenuWidget.cc:77
virtual void activateItem(YMenuItem *item)=0
void assignUniqueIndex(YItemIterator begin, YItemIterator end)
Definition YMenuWidget.cc:88
virtual void addItems(const YItemCollection &itemCollection)
Definition YMenuWidget.cc:68
YMenuItem * itemAt(int index)
Definition YMenuWidget.h:208
virtual void rebuildMenuTree()=0
YSelectionWidget(YWidget *parent, const std::string &label, bool enforceSingleSelection, bool recursiveSelection=false)
Definition YSelectionWidget.cc:59
std::string label() const
Definition YSelectionWidget.cc:99
YWidgetListIterator end()
Definition YWidget.h:245
YWidgetListIterator begin()
Definition YWidget.h:238
YWidget(YWidget *parent)
Definition YWidget.cc:106
YWidget * parent() const
Definition YWidget.cc:277
Definition YMenuWidget.cc:40