Planeshift
pawscombopromptwindow.h
Go to the documentation of this file.
1 /*
2  * pawscombopromptwindow.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_COMBO_PROMPT_WINDOW_HEADER
21 #define PAWS_COMBO_PROMPT_WINDOW_HEADER
22 
23 #include <csutil/list.h>
24 #include <iutil/document.h>
25 #include "pawspromptwindow.h"
26 #include "pawscombo.h"
27 
28 class pawsButton;
29 class ComboWrapper;
30 
36 {
37 public:
38  virtual void OnItemChosen(const char* name,int param,int itemNum, const csString &itemText) = 0;
39  // can be -1
40  virtual ~iOnItemChosenAction() {};
41 };
42 
43 
44 class ComboWrapper : public pawsWidget
45 {
46 public:
47  ComboWrapper(int width, int height)
48  {
49  SetRelativeFrameSize(width, height);
50  }
52  ComboWrapper(const ComboWrapper &origin)
53  :pawsWidget(origin)
54  {
55  }
56  bool PostSetup()
57  {
58  combo = new pawsComboBox();
59  AddChild(combo);
60  combo->SetRelativeFrame(0, 0, 200, 40);
61  combo->UseBorder("line");
62  combo->SetNumRows(6);
63  combo->SetRowHeight(20);
64  combo->PostSetup();
65  combo->SetSorted(false);
66  return true;
67  }
68 
70 };
76 {
77 public:
80  //from pawsWidget:
81  virtual bool PostSetup();
82  virtual void Close();
83  bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
84 
85  void NewOption(const csString &text);
86  void Select(int optionNum);
87 
88  void SetAction(iOnItemChosenAction* action,const char* name, int param)
89  {
90  this->action = action;
91  this->name = name;
92  this->param = param;
93  }
94 
95  static pawsComboPromptWindow* Create(const csString &label, iOnItemChosenAction* action,const char* name, int param=0);
96 
97 protected:
99  csString name;
100  int param;
101 
103 };
104 
106 
109 #endif
110 
pawsComboPromptWindow is window that lets the user choose item from combo box
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
CREATE_PAWS_FACTORY(ComboWrapper)
ComboWrapper(const ComboWrapper &origin)
iOnItemChosenAction * action
bool PostSetup()
This is called after the widget and all of it&#39;s children have been created.
void SetAction(iOnItemChosenAction *action, const char *name, int param)
pawsPromptWindow is the common base for windows that let the user enter one piece of information...
A simple button widget.
Definition: pawsbutton.h:43
A basic combo box widget.
Definition: pawscombo.h:53
ComboWrapper(int width, int height)
virtual void OnItemChosen(const char *name, int param, int itemNum, const csString &itemText)=0
pawsComboBox * combo