Planeshift
|
00001 /* 00002 * pawscombopromptwindow.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_COMBO_PROMPT_WINDOW_HEADER 00021 #define PAWS_COMBO_PROMPT_WINDOW_HEADER 00022 00023 #include <csutil/list.h> 00024 #include <iutil/document.h> 00025 #include "pawspromptwindow.h" 00026 #include "pawscombo.h" 00027 00028 class pawsButton; 00029 class ComboWrapper; 00030 00035 class iOnItemChosenAction 00036 { 00037 public: 00038 virtual void OnItemChosen(const char* name,int param,int itemNum, const csString &itemText) = 0; 00039 // can be -1 00040 virtual ~iOnItemChosenAction() {}; 00041 }; 00042 00043 00044 class ComboWrapper : public pawsWidget 00045 { 00046 public: 00047 ComboWrapper(int width, int height) 00048 { 00049 SetRelativeFrameSize(width, height); 00050 } 00051 ComboWrapper() {}; 00052 ComboWrapper(const ComboWrapper &origin) 00053 :pawsWidget(origin) 00054 { 00055 } 00056 bool PostSetup() 00057 { 00058 combo = new pawsComboBox(); 00059 AddChild(combo); 00060 combo->SetRelativeFrame(0, 0, 200, 40); 00061 combo->UseBorder("line"); 00062 combo->SetNumRows(6); 00063 combo->SetRowHeight(20); 00064 combo->PostSetup(); 00065 combo->SetSorted(false); 00066 return true; 00067 } 00068 00069 pawsComboBox* combo; 00070 }; 00071 CREATE_PAWS_FACTORY(ComboWrapper); 00075 class pawsComboPromptWindow : public pawsPromptWindow 00076 { 00077 public: 00078 pawsComboPromptWindow(); 00079 pawsComboPromptWindow(const pawsComboPromptWindow &origin); 00080 //from pawsWidget: 00081 virtual bool PostSetup(); 00082 virtual void Close(); 00083 bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget); 00084 00085 void NewOption(const csString &text); 00086 void Select(int optionNum); 00087 00088 void SetAction(iOnItemChosenAction* action,const char* name, int param) 00089 { 00090 this->action = action; 00091 this->name = name; 00092 this->param = param; 00093 } 00094 00095 static pawsComboPromptWindow* Create(const csString &label, iOnItemChosenAction* action,const char* name, int param=0); 00096 00097 protected: 00098 iOnItemChosenAction* action; 00099 csString name; 00100 int param; 00101 00102 ComboWrapper* wrapper; 00103 }; 00104 00105 CREATE_PAWS_FACTORY(pawsComboPromptWindow); 00106 00109 #endif 00110