Planeshift
pawscombo.h
Go to the documentation of this file.
1 /*
2  * pawscombobox.h - Author: Andrew Craig
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_BOX_HEADER
21 #define PAWS_COMBO_BOX_HEADER
22 
23 #include "pawswidget.h"
24 #include "pawslistbox.h"
25 
26 class pawsButton;
27 class pawsTextBox;
28 class pawsListBox;
29 class pawsListBoxRow;
30 
53 class pawsComboBox : public pawsWidget
54 {
55 public:
56  pawsComboBox();
57  ~pawsComboBox();
58  pawsComboBox(const pawsComboBox &origin);
59 
60  bool Setup(iDocumentNode* node);
61  bool PostSetup();
62  bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
63  void OnListAction(pawsListBox* widget, int status);
64 
65  void SetNumRows(int numRows)
66  {
67  rows = numRows;
68  }
69  void SetRowHeight(int height)
70  {
71  rowHeight = height;
72  }
73  void SetUpButtonImage(const char* name)
74  {
75  upButton = name;
76  }
77  void SetUpDownButtonImage(const char* name)
78  {
79  downButton = name;
80  }
81  void SetUpButtonPressedImage(const char* name)
82  {
83  upButtonPressed = name;
84  }
86  {
87  downButtonPressed = name;
88  }
89 
91  void SetSorted(bool sorting);
93  pawsListBoxRow* NewOption(const csString &text);
94 
97  {
98  return listChoice;
99  }
100 
102  int GetSelectedRowNum();
103 
105  csString GetSelectedRowString();
106 
108  pawsListBoxRow* Select(int optionNum);
109  pawsListBoxRow* Select(const char* text);
110 
111  int GetRowCount();
112  bool Clear();
113 
114 private:
115  pawsTextBox* itemChoice;
116  pawsListBox* listChoice;
117  pawsButton* arrow;
118  csString initalText;
119 
120  int oldHeight;
121  int oldWidth;
122  bool closed;
123  bool fliptotop;
124  bool useScrollBar;
125 
126  int rows;
127  int rowHeight;
128  int listalpha;
129  bool sorted;
130 
131  csString text, upButton, upButtonPressed, downButton, downButtonPressed;
132 };
133 
135 
138 #endif
pawsListBox * GetChoiceList()
@@ Hack: please someone tell me how to do this better?
Definition: pawscombo.h:96
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
pawsListBoxRow * Select(int optionNum)
Selects given option in combo.
bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget *widget)
Called whenever a button is pressed.
pawsListBoxRow * NewOption()
csString name
The name of this widget.
Definition: pawswidget.h:217
bool Setup(iDocumentNode *node)
Setup this widget.
int GetRowCount()
void SetSorted(bool sorting)
sets if the list has to be sorted. NOTE: call before adding entries.
A simple list box widget.
Definition: pawslistbox.h:202
void SetUpDownButtonPressedImage(const char *name)
Definition: pawscombo.h:85
int GetSelectedRowNum()
Returns index of selected option (-1 if none is selected.
A simple button widget.
Definition: pawsbutton.h:43
A basic combo box widget.
Definition: pawscombo.h:53
void SetUpButtonPressedImage(const char *name)
Definition: pawscombo.h:81
void SetRowHeight(int height)
Definition: pawscombo.h:69
A List Box Row.
Definition: pawslistbox.h:85
CREATE_PAWS_FACTORY(pawsComboBox)
csString GetSelectedRowString()
Returns string of selected option.
bool PostSetup()
This is called after the widget and all of it's children have been created.
void SetUpDownButtonImage(const char *name)
Definition: pawscombo.h:77
void OnListAction(pawsListBox *widget, int status)
Called whenever an item in a child list box is selected.
A basic text box widget.
Definition: pawstextbox.h:42
void SetNumRows(int numRows)
Definition: pawscombo.h:65
void SetUpButtonImage(const char *name)
Definition: pawscombo.h:73