Planeshift

pawsconfigkeys.h

Go to the documentation of this file.
00001 /*
00002  * pawsconfigkeys.h - Author: Ondrej Hurt
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 PAWS_CONFIG_KEYS_HEADER
00021 #define PAWS_CONFIG_KEYS_HEADER
00022 
00023 // CS INCLUDES
00024 #include <csutil/array.h>
00025 #include <iutil/event.h>
00026 
00027 // CLIENT INCLUDES
00028 #include "pscharcontrol.h"
00029 
00030 // PAWS INCLUDES
00031 #include "paws/pawswidget.h"
00032 #include "paws/pawsbutton.h"
00033 #include "paws/pawstextbox.h"
00034 #include "pawsconfigwindow.h"
00035 
00036 class pawsFingeringWindow;
00037 class pawsFingeringReceiver;
00038 
00039 
00040 #define NO_BIND ""
00041 
00042 
00044 //                        pawsFingeringReceiver
00046 
00049 class pawsFingeringReceiver 
00050 {
00051 public:
00053     virtual bool OnFingering(csString string, psControl::Device device, uint button, uint32 mods) = 0;
00054     virtual ~pawsFingeringReceiver() {};
00055 };
00056 
00058 //                        pawsConfigKeys
00060 
00064 class pawsConfigKeys : public pawsConfigSectionWindow, public pawsFingeringReceiver
00065 {
00066 public:
00067     pawsConfigKeys();
00068     
00070     virtual bool Initialize();
00071     virtual bool LoadConfig();
00072     virtual bool SaveConfig() { dirty = false; return true; }       
00073     virtual void SetDefault();
00074     
00075     void UpdateNicks(pawsTreeNode * subtreeRoot = NULL);
00076 
00078     virtual bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget );
00079     virtual void Draw();
00080 
00082     virtual bool OnFingering(csString string, psControl::Device device, uint button, uint32 mods);
00083 
00084 protected:
00088     bool CreateTree();
00092     void CreateTreeWidgets(pawsTreeNode * subtreeRoot);
00093     
00095     void SetKeyLabels(pawsTreeNode * subtreeRoot);
00096     
00098     void SetTriggerTextOfCommand(const csString & command, const csString & trigger);
00099     
00103     bool FindFingeringWindow();
00104 
00105     pawsTree * tree;                    // the tree that makes whole window GUI
00106     pawsFingeringWindow * fingWnd;      // pointer to FingeringWindow (object is NOT OWNER)
00107 
00108     csString editedCmd;        // command that is being changed
00109 };
00110 
00111 
00112 
00113 
00114 CREATE_PAWS_FACTORY(pawsConfigKeys);
00115 
00116 
00117 
00119 //                        pawsFingeringWindow
00121 
00125 class pawsFingeringWindow : public pawsWidget
00126 {
00127 public:
00128 
00129     pawsFingeringWindow();
00130     
00131     void ShowDialog(pawsFingeringReceiver * receiver, const char * editedCmd);
00132 
00133     // from pawsWidget:
00134     virtual bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget );
00135     virtual bool OnKeyDown( utf32_char keyCode, utf32_char keyChar, int modifiers );
00136     virtual bool OnMouseDown( int button, int modifiers, int x, int y );
00137     virtual bool PostSetup();
00138     virtual void Hide();
00139 
00140     /* Prepares dialog GUI so that it can begin keypress detection.
00141      * @param cmdName The name of edited command.
00142      */
00143     void SetupGUIForDetection(const csString & cmdName);
00144 
00146     void SetCollisionInfo(const char* action);
00147 
00149     void SetNotify( pawsFingeringReceiver* widget );
00150         
00151     virtual bool GetFocusOverridesControls() const { return true; }
00152 
00153 private:
00154 
00155     void RefreshCombo();
00156 
00157     pawsFingeringReceiver* notify;  
00158     
00159     pawsTextBox* labelTextBox;
00160     pawsTextBox* buttonTextBox;
00161 
00162     uint button;  
00163     uint32 mods;  
00164     psControl::Device device;  
00165     
00166     csString combo;  
00167 };
00168 
00169 
00170 CREATE_PAWS_FACTORY(pawsFingeringWindow);
00171 
00172 #endif
00173