Planeshift

pawsnumberpromptwindow.h

Go to the documentation of this file.
00001 /*
00002  * pawsnumberpromptwindow.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_NUMBER_PROMPT_WINDOW_HEADER
00021 #define PAWS_NUMBER_PROMPT_WINDOW_HEADER
00022 
00023 #include <csutil/list.h>
00024 #include <iutil/document.h>
00025 #include "pawspromptwindow.h"
00026 
00027 class pawsButton;
00028 class pawsEditTextBox;
00029 class pawsScrollbar;
00030 
00035 class iOnNumberEnteredAction
00036 {
00037 public:
00038     virtual void OnNumberEntered(const char* name,int param,int number) = 0;
00039     // can be -1
00040     virtual ~iOnNumberEnteredAction() {};
00041 };
00042 
00046 class pawsNumberPromptWindow : public pawsPromptWindow
00047 {
00048 public:
00049     pawsNumberPromptWindow();
00050     pawsNumberPromptWindow(const pawsNumberPromptWindow &origin);
00051     //from pawsWidget:
00052     virtual bool PostSetup();
00053     bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
00054     virtual bool OnScroll(int scrollDirection, pawsScrollBar* widget);
00055     virtual bool OnChange(pawsWidget* widget);
00056     virtual void Close();
00057 
00058     void Initialize(const csString &label, int number, int minNumber, int maxNumber,
00059                     iOnNumberEnteredAction* action,const char* name, int param=0);
00060 
00061     static pawsNumberPromptWindow* Create(const csString &label,
00062                                           int number, int minNumber, int maxNumber,
00063                                           iOnNumberEnteredAction* action,const char* name, int param=0);
00064 
00065 
00066 protected:
00067     void SetBoundaries(int minNumber, int maxNumber);
00068 
00069     void LayoutWindow();
00070 
00072     bool TextIsValidForEditing(const csString &text);
00073 
00076     bool TextIsValidForOutput(const csString &text);
00077 
00079     void NumberWasEntered(int count);
00080 
00081     int maxNumber, minNumber;
00082     int maxDigits;
00083 
00085     csString lastValidText;
00086 
00087     pawsEditTextBox* editBox;
00088     pawsScrollBar* scrollBar;
00089 
00090     iOnNumberEnteredAction* action;
00091     csString name;
00092     int param;
00093 };
00094 
00095 CREATE_PAWS_FACTORY(pawsNumberPromptWindow);
00096 
00099 #endif
00100