Planeshift
pawsnumberpromptwindow.h
Go to the documentation of this file.
1 /*
2  * pawsnumberpromptwindow.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_NUMBER_PROMPT_WINDOW_HEADER
21 #define PAWS_NUMBER_PROMPT_WINDOW_HEADER
22 
23 #include <csutil/list.h>
24 #include <iutil/document.h>
25 #include "pawspromptwindow.h"
26 
27 class pawsButton;
28 class pawsEditTextBox;
29 class pawsScrollbar;
30 
36 {
37 public:
38  virtual void OnNumberEntered(const char* name,int param,int number) = 0;
39  // can be -1
41 };
42 
47 {
48 public:
51  //from pawsWidget:
52  virtual bool PostSetup();
53  bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
54  virtual bool OnScroll(int scrollDirection, pawsScrollBar* widget);
55  virtual bool OnChange(pawsWidget* widget);
56  virtual void Close();
57 
58  void Initialize(const csString &label, int number, int minNumber, int maxNumber,
59  iOnNumberEnteredAction* action,const char* name, int param=0);
60 
61  static pawsNumberPromptWindow* Create(const csString &label,
62  int number, int minNumber, int maxNumber,
63  iOnNumberEnteredAction* action,const char* name, int param=0);
64 
65 
66 protected:
67  void SetBoundaries(int minNumber, int maxNumber);
68 
69  void LayoutWindow();
70 
72  bool TextIsValidForEditing(const csString &text);
73 
76  bool TextIsValidForOutput(const csString &text);
77 
79  void NumberWasEntered(int count);
80 
81  int maxNumber, minNumber;
82  int maxDigits;
83 
85  csString lastValidText;
86 
89 
91  csString name;
92  int param;
93 };
94 
96 
99 #endif
100 
virtual void OnNumberEntered(const char *name, int param, int number)=0
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
An edit box widget/.
Definition: pawstextbox.h:409
iOnNumberEnteredAction * action
CREATE_PAWS_FACTORY(pawsNumberPromptWindow)
A simple scroll bar widget.
Definition: pawscrollbar.h:64
void void Initialize(iObjectRegistry *object_reg)
csString lastValidText
This is last valid input from user - we use it to fall back from invalid input.
pawsPromptWindow is the common base for windows that let the user enter one piece of information...
pawsNumberPromptWindow is window that lets the user enter a number
A simple button widget.
Definition: pawsbutton.h:43