Planeshift
pawskeyselectbox.h
Go to the documentation of this file.
1 /*
2  * Author: Andrew Robberts
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_KEY_SELECT_BOX_HEADER
21 #define PAWS_KEY_SELECT_BOX_HEADER
22 
23 #include "pawswidget.h"
24 
33 {
34 public:
36  {
37  factory = "pawsKeySelectBox";
38  }
39  virtual ~pawsKeySelectBox();
40  pawsKeySelectBox(const pawsKeySelectBox &origin);
41  bool Setup(iDocumentNode* node);
42 
43  void Draw();
44 
45  bool OnKeyDown(utf32_char keyCode, utf32_char keyChar, int modifiers);
46 
51  void SetKey(int _key, int _modifiers=0);
52 
53  int GetKey() const
54  {
55  return key;
56  }
57  int GetModifiers() const
58  {
59  return modifiers;
60  }
61 
65  const char* GetText() const;
66 
70  void SetText(const char* keyText);
71 
72  virtual int GetBorderStyle();
73 
74  virtual bool GetFocusOverridesControls() const
75  {
76  return true;
77  }
78 
79 protected:
80 
83  void CalcTextPos();
84 
86  csString text;
87 
88  int key;
89  int modifiers;
90 
91  int textX, textY; // Position of text inside the widget
92 };
94 
97 #endif
int GetKey() const
int GetModifiers() const
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
bool Setup(iDocumentNode *node)
Setup this widget.
const char * GetText() const
Gets a text representation of the key combination.
void SetKey(int _key, int _modifiers=0)
Sets the key for this key select box.
csString factory
factory name
Definition: pawswidget.h:124
A widget that can be used to get a key combination (alt+a, ctrl+s) and display it in text format...
virtual int GetBorderStyle()
This returns the BORDER_BUMP style.
void CalcTextPos()
Calculates the position of the text after centering.
void Draw()
Draws the widget and all of it's children.
csString text
String representing the key combination.
virtual bool GetFocusOverridesControls() const
Test if the widget should intercept all key presses.
void SetText(const char *keyText)
Sets the key combination of this text box by parsing a representing key string.
CREATE_PAWS_FACTORY(pawsKeySelectBox)
bool OnKeyDown(utf32_char keyCode, utf32_char keyChar, int modifiers)
Process keydown messages.
virtual ~pawsKeySelectBox()