Planeshift

eeditshortcutstoolbox.h

Go to the documentation of this file.
00001 /*
00002  * Author: Andrew Robberts
00003  *
00004  * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 
00020 #ifndef EEDIT_SHORTCUTS_TOOLBOX_WINDOW_HEADER
00021 #define EEDIT_SHORTCUTS_TOOLBOX_WINDOW_HEADER
00022 
00023 #include <csutil/array.h>
00024 #include "eedittoolbox.h"
00025 #include "paws/pawswidget.h"
00026 
00027 class pawsListBox;
00028 
00033 struct EEditShortcutKey
00034 {
00035     EEditShortcutKey(const char * _command, int _key, int _modifiers)
00036         : command(_command), key(_key), modifiers(_modifiers)
00037     {
00038     }
00039 
00040     csString command;
00041     int key;
00042     int modifiers;
00043 };
00044 
00047 class EEditShortcutsToolbox : public EEditToolbox, public pawsWidget, public scfImplementation0<EEditShortcutsToolbox>
00048 {
00049 public:
00050     EEditShortcutsToolbox();
00051     virtual ~EEditShortcutsToolbox();
00052 
00056     void AddShortcut(const char * name);
00057 
00062     void ExecuteShortcutCommand(int key, int modifiers=0) const;
00063 
00064     // inheritted from EEditToolbox
00065     virtual void Update(unsigned int elapsed);
00066     virtual size_t GetType() const;
00067     virtual const char * GetName() const;
00068     
00069     // inheritted from pawsWidget
00070     virtual bool PostSetup(); 
00071     virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
00072     virtual void Show();
00073     virtual void OnListAction(pawsListBox * selected, int status);
00074 
00075 private:
00076 
00079     void SaveShortcuts();
00080 
00083     void RedrawShortcuts();
00084 
00085     pawsListBox *   shortcutsList;
00086     pawsButton *    applyButton;
00087     pawsButton *    cancelButton;
00088     pawsButton *    okButton;
00089 
00090     csArray<EEditShortcutKey>   shortcuts;
00091 };
00092 
00093 CREATE_PAWS_FACTORY(EEditShortcutsToolbox);
00094 
00097 #endif