00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: YShortcut.h 00014 00015 Author: Stefan Hundhammer <sh@suse.de> 00016 00017 /-*/ 00018 00019 00020 #ifndef YShortcut_h 00021 #define YShortcut_h 00022 00023 #include "YWidget.h" 00024 #include <string> 00025 00026 00031 class YShortcut 00032 { 00033 public: 00037 YShortcut( YWidget *shortcut_widget ); 00038 00042 virtual ~YShortcut(); 00043 00047 enum { None = 0 }; 00048 00052 YWidget * widget() { return _widget; } 00053 00058 const char *widgetClass() { return widget()->widgetClass(); } 00059 00064 bool isButton() const { return _isButton; } 00065 00070 bool isWizardButton() const { return _isWizardButton; } 00071 00080 string shortcutString(); 00081 00086 string cleanShortcutString(); 00087 00092 static string cleanShortcutString( string shortcutString ); 00093 00098 char preferred(); 00099 00105 char shortcut(); 00106 00110 void setShortcut( char new_shortcut ); 00111 00116 void clearShortcut(); 00117 00122 bool conflict() { return _conflict; } 00123 00127 void setConflict( bool newConflictState = true ) { _conflict = newConflictState; } 00128 00133 int distinctShortcutChars(); 00134 00138 static char shortcutMarker() { return '&'; } 00139 00147 static string::size_type findShortcutPos( const string & str, string::size_type start_pos = 0 ); 00148 00155 static char findShortcut( const string & str, string::size_type start_pos = 0 ); 00156 00161 static bool isValid( char c ); 00162 00167 static char normalized( char c ); 00168 00173 static string getShortcutString( YWidget * widget ); 00174 00175 00176 protected: 00177 00182 string getShortcutString(); 00183 00184 00185 // Data members 00186 00187 YWidget * _widget; 00188 string _shortcut_string; 00189 bool _shortcut_string_chached; 00190 00191 string _clean_shortcut_string; 00192 bool _clean_shortcut_string_chached; 00193 00194 int _preferred; // int to enable initializing with invalid char ( -1 ) 00195 int _shortcut; // int to enable initializing with invalid char ( -1 ) 00196 00197 bool _conflict; 00198 bool _isButton; 00199 bool _isWizardButton; 00200 int _distinctShortcutChars; 00201 }; 00202 00203 typedef vector<YShortcut *> YShortcutList; 00204 typedef YShortcutList::iterator YShortcutListIterator; 00205 00206 00207 #endif // YShortcut_h
1.5.3