![[]](/images/special/trans.gif)
LibN2L-4 Library Code ReferenceClassesCompounds Files Members Method Index Full Reference cGuiSButtonSelectBox.hGo to the documentation of this file.00001 /************************************************************************ 00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library 00003 Copyright (C) 2002 Aaron Cameron 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library 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 GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 A copy of the GNU Lesser General Public License has been provided with 00020 this library in the file 'COPYING'. 00021 00022 Contact information for the author of this library has been provided 00023 with this library in the file 'AUTHOR'. 00024 ************************************************************************/ 00025 #ifndef _n2l4_cGuiSButtonSelectBox_H 00026 #define _n2l4_cGuiSButtonSelectBox_H 00027 00028 #include "n2l/n2l.h" 00029 00030 #include "gui/types.h" 00031 #include "gui/cGuiInteractive.h" 00032 #include "gui/cGuiFill.h" 00033 #include "gui/cGuiACInt.h" 00034 00035 /******************************************************************************/ 00036 namespace n2l 00037 { 00038 class cVfsNodeInterface; 00039 class cDynVar; 00040 class cGuiSButton; 00041 class cGuiSlider; 00042 class cGuiCanvas; 00043 00047 class cGuiSButtonSelectBox : public cGuiInteractive 00048 { 00049 public: 00050 static const tUint NoSelection; 00051 00052 cGuiSButtonSelectBox(); 00053 cGuiSButtonSelectBox( const cVfsNodeInterface &iNode ); 00054 cGuiSButtonSelectBox( const cDynVar &iDef ); 00055 virtual ~cGuiSButtonSelectBox(); 00056 00057 virtual void load( const cVfsNodeInterface &iNode ); 00058 virtual void load( const cDynVar &iDef ); 00059 00060 virtual void draw() const; 00061 00062 virtual void slider( const cGuiSlider &iSliderTemplate ); 00063 00064 virtual const cAutoPtr<cGuiSButton> addButton( 00065 const cDynVar &iValue, const tString &iLabel, 00066 const cGuiSButton &iButtonTemplate ); 00067 00068 virtual void multiple( const tBool iMultiple ); 00069 virtual const tBool multiple() const; 00070 00075 virtual void noUnselect( const tBool iUnselectable ); 00076 virtual const tBool noUnselect() const; 00077 00078 virtual const tUint numButtons() const; 00079 00080 virtual const cAutoPtr<cGuiElement> clone() const; 00081 00082 virtual void systemEvent( 00083 const cAutoPtr<const cEventInterface> &i_iEvent ); 00084 00085 virtual void systemEventOutside( 00086 const cAutoPtr<const cEventInterface> &i_iEvent ); 00087 00088 virtual void update( const tUint iTimePassed ); 00089 00090 virtual void clearSelections(); 00091 virtual void clearButtons(); 00092 00096 virtual void selected( const cDynVar &iValue ); 00097 00102 virtual void selectedByLabel( const cDynVar &iValue ); 00103 00104 virtual void selectedByIndex( const tUint &iIndex ); 00105 00106 virtual void selectNext(); 00107 virtual void selectPrev(); 00108 00109 virtual const cAutoPtr<cGuiSButton> &getButton( 00110 const cDynVar &iValue ); 00111 00112 virtual const cAutoPtr<cGuiSButton> &getButtonByLabel( 00113 const cDynVar &iLabel ); 00114 00115 virtual const cAutoPtr<cGuiSButton> &getButtonByIndex( 00116 const tUint &iIndex ); 00117 00118 00122 virtual const cDynVar &selected() const; 00123 00124 virtual const cDynVar &getValueByLabel( const cDynVar &iValue ); 00125 virtual const cDynVar &getValueByIndex( const tUint &iIndex ) const; 00126 00127 virtual const tBool isAnySelected() const { 00128 return mSelected!=NoSelection; 00129 } 00130 00131 virtual const tBool wantsFocus() const; 00132 00133 protected: 00134 virtual void cloneInto( 00135 const cAutoPtr<cGuiSButtonSelectBox> &i_ioElement ) const; 00136 00139 virtual void dimensionChanged(); 00140 00141 private: 00142 class cItemSelectedAction: public cGuiACInt 00143 { 00144 public: 00145 cItemSelectedAction( cGuiSButtonSelectBox *const i_ioElement, 00146 const cDynVar & iValue ); 00147 00148 virtual ~cItemSelectedAction(); 00149 virtual void execute( cGuiElement *const i_ioElement, 00150 const tGuiActionType iType, const tActionData &iData ); 00151 00152 virtual const cAutoPtr<cGuiACInt> clone() const; 00153 00154 protected: 00155 virtual void cloneInto( 00156 const cAutoPtr<cItemSelectedAction> &ioElement ) const; 00157 00158 private: 00159 cGuiSButtonSelectBox *mParent; 00160 cDynVar mValue; 00161 }; 00162 00163 typedef std::vector<cDynVar> tValueContainer; 00164 typedef std::vector<cAutoPtr<cGuiSButton> > tButtonContainer; 00165 00166 tValueContainer mValues; 00167 tButtonContainer mButtons; 00168 00169 cAutoPtr<cGuiCanvas> mButtonsCanvas; 00170 cAutoPtr<cGuiSlider> mSlider; 00171 00172 tFloat mAltOffset; 00173 00174 tBool mMultiple; 00175 tBool mNoUnselect; 00176 00177 tUint mSelected; 00178 tGuiPos mNextButtonPos; 00179 00180 // To allow references to be returned from 'selected' calls for 00181 // multiselects we'll keep this temporary as a member. It isn't 00182 // authoritative and won't necessarily be populated let alone 00183 // correct. 00184 mutable cDynVar mTmpValueList; 00185 00186 # ifdef N2L_PASSIVE_GUI_REG 00187 static tBool smRegistered; 00188 # endif 00189 00190 // Return the box to its constructed state 00191 virtual void reset(); 00192 00193 virtual void processKey( const tKey &iKey, const tKeyMods &iMods ); 00194 00195 static void keystrokeCallback( cGuiElement *const i_ioElement, 00196 const tGuiActionType iType, const tActionData &iData ); 00197 00198 void broadcastUnselected( const tUint &iIndex ); 00199 void broadcastSelected( const tUint &iIndex ); 00200 00201 }; // class cGuiCanvas 00202 00203 } // namespace n2l 00204 00205 #endif |