00001 /******************************************************************************** 00002 * * 00003 * A c c e l e r a t o r T a b l e C l a s s * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXAccelTable.h,v 1.27 2006/01/22 17:57:58 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXACCELTABLE_H 00025 #define FXACCELTABLE_H 00026 00027 #ifndef FXOBJECT_H 00028 #include "FXObject.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00039 class FXAPI FXAccelTable : public FXObject { 00040 FXDECLARE(FXAccelTable) 00041 protected: 00042 struct FXAccelKey { 00043 FXObject *target; // Target object of message 00044 FXSelector messagedn; // Message being sent 00045 FXSelector messageup; // Message being sent 00046 FXHotKey code; // Keysym and modifier mask to match 00047 }; 00048 private: 00049 FXAccelKey *key; // Accelerator table 00050 FXuint max; // Largest table index 00051 FXuint num; // Number of entries 00052 private: 00053 void resize(FXuint m); 00054 private: 00055 FXAccelTable(const FXAccelTable&); 00056 FXAccelTable &operator=(const FXAccelTable&); 00057 public: 00058 long onKeyPress(FXObject*,FXSelector,void*); 00059 long onKeyRelease(FXObject*,FXSelector,void*); 00060 public: 00061 00063 FXAccelTable(); 00064 00066 void addAccel(FXHotKey hotkey,FXObject* target=NULL,FXSelector seldn=0,FXSelector selup=0); 00067 00069 void removeAccel(FXHotKey hotkey); 00070 00072 bool hasAccel(FXHotKey hotkey) const; 00073 00075 FXObject* targetOfAccel(FXHotKey hotkey) const; 00076 00082 friend FXAPI FXHotKey parseAccel(const FXString& string); 00083 00088 friend FXAPI FXString unparseAccel(FXHotKey key); 00089 00095 friend FXAPI FXHotKey parseHotKey(const FXString& string); 00096 00103 friend FXAPI FXint findHotKey(const FXString& string); 00104 00110 friend FXAPI FXString stripHotKey(const FXString& string); 00111 00113 virtual void save(FXStream& store) const; 00114 00116 virtual void load(FXStream& store); 00117 00119 virtual ~FXAccelTable(); 00120 }; 00121 00122 00123 extern FXAPI FXHotKey parseAccel(const FXString& string); 00124 extern FXAPI FXString unparseAccel(FXHotKey key); 00125 extern FXAPI FXHotKey parseHotKey(const FXString& string); 00126 extern FXAPI FXint findHotKey(const FXString& string); 00127 extern FXAPI FXString stripHotKey(const FXString& string); 00128 00129 } 00130 00131 #endif