26 #define YUILogComponent "ui"
29 #include "YUISymbols.h"
30 #include "YShortcut.h"
31 #include "YMenuWidget.h"
33 #define VERBOSE_SHORTCUTS 0
57 YUI_CHECK_NEW( priv );
80 item->
setIndex( ++(priv->nextSerialNo) );
94 item->
setIndex( ++(priv->nextSerialNo) );
106 priv->nextSerialNo = 0;
144 if ( item->
index() == wantedIndex )
167 #define USED_SIZE ((int) sizeof( char ) << 8)
169 bool used[ USED_SIZE ];
171 for (
int i = 0; i < USED_SIZE; i++ )
174 std::vector<YMenuItem*> conflicts;
194 conflicts.push_back(item);
196 #if VERBOSE_SHORTCUTS
197 yuiMilestone() <<
"No or invalid shortcut found: \""
198 << item->
label() <<
"\""
202 else if ( used[ (
unsigned) shortcut ] )
204 conflicts.push_back(item);
205 #if VERBOSE_SHORTCUTS
206 yuiWarning() <<
"Conflicting shortcut found: \""
207 << item->
label() <<
"\""
213 used[ (unsigned) shortcut ] =
true;
218 yuiWarning() <<
"Non-menu item used in call: \""
219 << (*it)->label() <<
"\""
232 for (; index < clean.size(); ++index)
237 if ( ch != 0 && ! used[ (
unsigned) ch ] )
240 used[ (unsigned) ch ] =
true;
249 #if VERBOSE_SHORTCUTS
250 yuiDebug() <<
"New label used: " << clean << endl;
254 i->setLabel( clean );
271 return findItem( path.begin(), path.end(),
278 std::vector<std::string>::iterator path_end,
290 if ( item->
label() == *path_begin )
292 if ( std::next( path_begin ) == path_end )
std::string label() const
Return this item's label.
static char shortcutMarker()
Static function: Returns the character used for marking keyboard shortcuts.
void setIndex(int index)
Set this item's index.
YItemCollection::iterator YItemIterator
Mutable iterator over YItemCollection.
std::vector< YItem * > YItemCollection
Collection of pointers to YItem.
int index() const
Return the index of this item (as set with setIndex() ).
virtual YItemIterator childrenBegin()
Return an iterator that points to the first child item of this item.
static char findShortcut(const std::string &str, std::string::size_type start_pos=0)
Static function: Find the next shortcut marker in a string, beginning at starting position start_pos.
virtual bool hasChildren() const
Return 'true' if this item has any child items.
virtual YItemIterator childrenBegin()
Return an iterator that points to the first child item of this item.
virtual YItemIterator childrenEnd()
Return an iterator that points after the last child item of this item.
virtual bool hasChildren() const
Return 'true' if this item has any child items.
static char normalized(char c)
Return the normalized version of shortcut character 'c', i.e.
virtual YItemIterator childrenEnd()
Return an iterator that points after the last child item of this item.
std::string cleanShortcutString()
Returns the shortcut string ( from the widget's shortcut property ) without any "&" markers.
YItemCollection::const_iterator YItemConstIterator
Const iterator over YItemCollection.
Simple item class for SelectionBox, ComboBox, MultiSelectionBox etc.