libyui
|
#include <YShortcut.h>
Public Types | |
enum | { None = 0 } |
Public Member Functions | |
YShortcut (YWidget *shortcut_widget) | |
virtual | ~YShortcut () |
YWidget * | widget () const |
const char * | widgetClass () const |
bool | isButton () const |
bool | isWizardButton () const |
virtual bool | isMenuItem () const |
std::string | shortcutString () |
std::string | cleanShortcutString () |
char | preferred () |
char | shortcut () |
virtual void | setShortcut (char newShortcut) |
void | clearShortcut () |
bool | conflict () |
void | setConflict (bool newConflictState=true) |
int | distinctShortcutChars () |
bool | hasValidShortcutChar () |
virtual std::string | debugLabel () const |
Static Public Member Functions | |
static std::string | cleanShortcutString (std::string shortcutString) |
static char | shortcutMarker () |
static std::string::size_type | findShortcutPos (const std::string &str, std::string::size_type start_pos=0) |
static char | findShortcut (const std::string &str, std::string::size_type start_pos=0) |
static bool | isValid (char c) |
static char | normalized (char c) |
static std::string | getShortcutString (const YWidget *widget) |
Protected Member Functions | |
virtual std::string | getShortcutString () |
Protected Attributes | |
YWidget * | _widget |
(not owned) | |
std::string | _shortcutString |
bool | _shortcutStringCached |
is _shortcutString initialized | |
std::string | _cleanShortcutString |
bool | _cleanShortcutStringCached |
always false :facepalm: | |
int | _preferred |
int | _shortcut |
bool | _conflict |
bool | _isButton |
bool | _isWizardButton |
int | _distinctShortcutChars |
Helper class for shortcut management: This class holds data about the shortcut for one single widget.
Notice that there is also a derived class YItemShortcut for item-based widgets that may have multiple shortcuts like YDumbTab, YMenuBar, YItemSelector.
YShortcut::YShortcut | ( | YWidget * | shortcut_widget | ) |
Constructor
shortcut_widget | (not owned, not nullptr) |
|
virtual |
Destructor
string YShortcut::cleanShortcutString | ( | ) |
Returns the shortcut string ( from the widget's shortcut property ) without any "&" markers.
But an escaped "&&" is preserved.
|
static |
Static version of the above for general use: Returns the specified string without any "&" markers. But an escaped "&&" is preserved.
void YShortcut::clearShortcut | ( | ) |
Clear the shortcut: Override the shortcut character with nothing. This may happen if a conflict cannot be resolved.
|
inline |
Query the internal 'conflict' marker. This class doesn't care about that flag, it just stores it for the convenience of higher-level classes.
|
inlinevirtual |
Label of this shortcut suitable for debugging
Reimplemented in YItemShortcut.
int YShortcut::distinctShortcutChars | ( | ) |
Obtain the number of distinct valid shortcut characters in the shortcut string, i.e. how many different shortcuts that widget could get.
|
static |
Static function: Find the next shortcut marker in a string, beginning at starting position start_pos.
Returns the shortcut character or 0 if none found.
|
static |
Static function: Find the next occurrence of the shortcut marker ('&') in a string, beginning at starting position start_pos.
An escaped "&&" does not count.
Returns string::npos if not found or the position of the shortcut marker (not the shortcut character!) if found.
|
protectedvirtual |
Obtain the the shortcut property of this shortcut's widget - the string that contains "&" to designate a shortcut.
Reimplemented in YItemShortcut.
Obtain a widget's shortcut property - the string that contains "&" to designate a shortcut.
bool YShortcut::hasValidShortcutChar | ( | ) |
Return true if this shortcut contains any character that would be valid as a shortcut character.
|
inline |
Returns 'true' if the widget that is associated with this shortcut is a button (derived from YPushButton).
Returns 'true' if this is a shortcut for a (toplevel) menu item.
This default implementation always returns 'false'. Derived classes like YItemShortcut can choose to overwrite this.
Reimplemented in YItemShortcut.
Returns 'true' if 'c' is a valid shortcut character, i.e. [a-zA-Z0-9], 'false' otherwise.
|
inline |
Returns 'true' if the widget that is associated with this shortcut is a wizard button (one of the navigation buttons of a wizard).
Return the normalized version of shortcut character 'c', i.e. a lowercase letter or a digit [a-z0-9]. Returns 0 if 'c' is invalid.
char YShortcut::preferred | ( | ) |
The preferred shortcut character, i.e. the character that had been preceded by "&" before checking / resolving conflicts began. 0 if none.
Set or unset the internal 'conflict' marker.
Set (override) the shortcut character.
Reimplemented in YItemShortcut.
char YShortcut::shortcut | ( | ) |
The actual shortcut character. 0 if none.
This may be different from preferred() if it is overridden.
Static function: Returns the character used for marking keyboard shortcuts.
string YShortcut::shortcutString | ( | ) |
Returns the complete shortcut string (which may or may not contain "&"), i.e. the value of the widget's shortcut property. For PushButtons, this is the label on the button ( e.g., "&Details..." ), for other widgets usually the caption above it.
This value is chached, i.e. this isn't a too expensive operation.
Returns the textual representation of the widget class of the widget this shortcut data belongs to.
|
protected |
-1 means uninitialized
|
protected |
|
protected |
char or 0 (none found) or -1 (not initialized yet)
|
protected |
char or 0 (none found) or -1 (not initialized yet)
|
protected |