/* * pawscombobox.h - Author: Andrew Craig * * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org) * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation (version 2 of the License) * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef PAWS_COMBO_BOX_HEADER #define PAWS_COMBO_BOX_HEADER #include "pawswidget.h" class pawsButton; class pawsTextBox; class pawsListBox; class pawsListBoxRow; /** A basic combo box widget. This widget consists of a textbox and a drop down list box. When an item from the list box is selected the textbox is updated. This is the format of how it is defined in a widget file: This class sets the listbox with the id of the combo widget so if you want to track messages from this you override the Selected( pawsListBox* widget ) funtion in your controlling widget and have a case for this widget's ID number. */ class pawsComboBox : public pawsWidget { public: pawsComboBox(); ~pawsComboBox(); bool Setup( iDocumentNode* node ); bool PostSetup(); bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget ); void OnListAction( pawsListBox* widget, int status ); void SetNumRows(int numRows) { rows = numRows; } void SetRowHeight(int height) { rowHeight = height; } pawsListBoxRow* NewOption(); pawsListBoxRow* NewOption(const csString & text); /** Returns index of selected option (-1 if none is selected */ int GetSelectedRowNum(); /** Returns string of selected option */ csString GetSelectedRowString(); /** Selects given option in combo */ pawsListBoxRow* Select(int optionNum); pawsListBoxRow* Select(const char * text); int GetRowCount(); bool Clear(); private: pawsTextBox* itemChoice; pawsListBox* listChoice; pawsButton* arrow; csString initalText; int oldHeight; int oldWidth; bool closed; bool fliptotop; int rows; int rowHeight; int listalpha; csString text; }; CREATE_PAWS_FACTORY ( pawsComboBox ); #endif