Planeshift
pawsconfigkeys.h
Go to the documentation of this file.
1 /*
2  * pawsconfigkeys.h - Author: Ondrej Hurt
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PAWS_CONFIG_KEYS_HEADER
21 #define PAWS_CONFIG_KEYS_HEADER
22 
23 // CS INCLUDES
24 #include <csutil/array.h>
25 #include <iutil/event.h>
26 
27 // CLIENT INCLUDES
28 #include "pscharcontrol.h"
29 
30 // PAWS INCLUDES
31 #include "paws/pawswidget.h"
32 #include "paws/pawsbutton.h"
33 #include "paws/pawstextbox.h"
34 #include "pawsconfigwindow.h"
35 
38 
39 
40 #define NO_BIND ""
41 
42 
44 // pawsFingeringReceiver
46 
50 {
51 public:
53  virtual bool OnFingering(csString string, psControl::Device device, uint button, uint32 mods) = 0;
54  virtual ~pawsFingeringReceiver() {};
55 };
56 
58 // pawsConfigKeys
60 
65 {
66 public:
68 
70  virtual bool Initialize();
71  virtual bool LoadConfig();
72  virtual bool SaveConfig() { dirty = false; return true; }
73  virtual void SetDefault();
74 
75  void UpdateNicks(pawsTreeNode * subtreeRoot = NULL);
76 
78  virtual bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget );
79  virtual void Draw();
80 
82  virtual bool OnFingering(csString string, psControl::Device device, uint button, uint32 mods);
83 
84 protected:
88  bool CreateTree();
92  void CreateTreeWidgets(pawsTreeNode * subtreeRoot);
93 
95  void SetKeyLabels(pawsTreeNode * subtreeRoot);
96 
98  void SetTriggerTextOfCommand(const csString & command, const csString & trigger);
99 
103  bool FindFingeringWindow();
104 
105  pawsTree * tree; // the tree that makes whole window GUI
106  pawsFingeringWindow * fingWnd; // pointer to FingeringWindow (object is NOT OWNER)
107 
108  csString editedCmd; // command that is being changed
109 };
110 
111 
112 
113 
115 
116 
117 
119 // pawsFingeringWindow
121 
126 {
127 public:
128 
130 
131  void ShowDialog(pawsFingeringReceiver * receiver, const char * editedCmd);
132 
133  // from pawsWidget:
134  virtual bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget );
135  virtual bool OnKeyDown( utf32_char keyCode, utf32_char keyChar, int modifiers );
136  virtual bool OnMouseDown( int button, int modifiers, int x, int y );
137  virtual bool PostSetup();
138  virtual void Hide();
139 
140  /* Prepares dialog GUI so that it can begin keypress detection.
141  * @param cmdName The name of edited command.
142  */
143  void SetupGUIForDetection(const csString & cmdName);
144 
146  void SetCollisionInfo(const char* action);
147 
149  void SetNotify( pawsFingeringReceiver* widget );
150 
151  virtual bool GetFocusOverridesControls() const { return true; }
152 
153 private:
154 
155  void RefreshCombo();
156 
157  pawsFingeringReceiver* notify;
158 
159  pawsTextBox* labelTextBox;
160  pawsTextBox* buttonTextBox;
161 
162  uint button;
163  uint32 mods;
164  psControl::Device device;
165 
166  csString combo;
167 };
168 
169 
171 
172 #endif
173 
virtual bool GetFocusOverridesControls() const
Test if the widget should intercept all key presses.
pawsTree * tree
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
virtual bool OnFingering(csString string, psControl::Device device, uint button, uint32 mods)=0
Returns whether the combo was accepted and the fingering window should hide.
pawsFingeringWindow * fingWnd
csString editedCmd
virtual ~pawsFingeringReceiver()
This window is used to configure keyboard bindings.
CREATE_PAWS_FACTORY(pawsConfigKeys)
void void Initialize(iObjectRegistry *object_reg)
Class pawsFingeringWindow is a small dialog box that ask the user to press a key combination that wil...
This interface receive OnFingering notification from the FingeringWindow.
virtual bool SaveConfig()
remembers settings in-game and saves them permanently to a file also
A basic text box widget.
Definition: pawstextbox.h:42