AaronCameron.net
Because you all make me very, very tired.
Not a Member? - Login or Create an Account
Wednesday the 23rd of May 2012 @ 09:28am
Front Page Journal Projects Your Profile About
[]

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

cGuiButtonSelectBox.h

Go 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_cGuiButtonSelectBox_H
00026 #define _n2l4_cGuiButtonSelectBox_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 cGuiButton;
00041     class cGuiSlider;
00042     class cGuiCanvas;
00043 
00047     class cGuiButtonSelectBox : public cGuiInteractive
00048     {
00049     public:
00050         static const tUint NoSelection;
00051 
00052         cGuiButtonSelectBox();
00053         cGuiButtonSelectBox( const cVfsNodeInterface &iNode );
00054         cGuiButtonSelectBox( const cDynVar &iDef );
00055         virtual ~cGuiButtonSelectBox();
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 void addButton( const cDynVar &iValue,
00065             const tString &iLabel,
00066             const cGuiButton &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 clearSelections();
00089         virtual void clearButtons();
00090         
00094         virtual void selected( const cDynVar &iValue );
00095 
00100         virtual void selectedByLabel( const cDynVar &iValue );
00101 
00102         virtual void selectedByIndex( const tUint &iIndex );
00103 
00104         virtual void selectNext();
00105         virtual void selectPrev();
00106 
00107         virtual const cAutoPtr<cGuiButton> &getButton(
00108             const cDynVar &iValue );
00109 
00110         virtual const cAutoPtr<cGuiButton> &getButtonByLabel(
00111             const cDynVar &iLabel );
00112 
00113         virtual const cAutoPtr<cGuiButton> &getButtonByIndex(
00114             const tUint &iIndex );
00115 
00119         virtual const cDynVar &selected() const;
00120 
00121         virtual const cDynVar &getValueByLabel( const cDynVar &iValue );
00122 
00123         virtual const tBool isAnySelected() const {
00124             return mSelected!=NoSelection;
00125         }
00126 
00127         virtual const tBool wantsFocus() const;
00128 
00129     protected:
00130         virtual void cloneInto(
00131             const cAutoPtr<cGuiButtonSelectBox> &i_ioElement ) const;
00132 
00135         virtual void dimensionChanged();
00136 
00137     private:
00138         class cItemSelectedAction: public cGuiACInt
00139         {
00140         public:
00141             cItemSelectedAction( cGuiButtonSelectBox *const i_ioElement,
00142                 const cDynVar & iValue );
00143 
00144             virtual ~cItemSelectedAction();
00145             virtual void execute( cGuiElement *const i_ioElement,
00146                 const tGuiActionType iType, const tActionData &iData );
00147 
00148             virtual const cAutoPtr<cGuiACInt> clone() const;
00149 
00150         protected:
00151             virtual void cloneInto(
00152                 const cAutoPtr<cItemSelectedAction> &ioElement ) const;
00153 
00154         private:
00155             cGuiButtonSelectBox *mParent;
00156             cDynVar mValue;
00157         };  
00158 
00159         typedef std::vector<cDynVar> tValueContainer;
00160         typedef std::vector<cAutoPtr<cGuiButton> > tButtonContainer;
00161 
00162         tValueContainer mValues;
00163         tButtonContainer mButtons;
00164         
00165         cAutoPtr<cGuiCanvas> mButtonsCanvas;
00166         cAutoPtr<cGuiSlider> mSlider;
00167 
00168         tFloat mAltOffset;
00169 
00170         tBool mMultiple;
00171         tBool mNoUnselect;
00172         
00173         tUint mSelected;
00174         tGuiPos mNextButtonPos;
00175 
00176         // To allow references to be returned from 'selected' calls for
00177         // multiselects we'll keep this temporary as a member.  It isn't
00178         // authoritative and won't necessarily be populated let alone
00179         // correct.
00180         mutable cDynVar mTmpValueList;
00181 
00182 #       ifdef N2L_PASSIVE_GUI_REG
00183             static tBool smRegistered;
00184 #       endif
00185 
00186         // Return the box to its constructed state
00187         virtual void reset();
00188 
00189         virtual void processKey( const tKey &iKey, const tKeyMods &iMods );
00190 
00191         static void keystrokeCallback( cGuiElement *const i_ioElement,
00192             const tGuiActionType iType, const tActionData &iData );
00193 
00194         void broadcastUnselected( const tUint &iIndex );
00195         void broadcastSelected( const tUint &iIndex );
00196 
00197      }; // class cGuiCanvas
00198 
00199 } // namespace n2l
00200 
00201 #endif
©2012 Aaron Cameron