AaronCameron.net
No ads. No Profit. No Master, But Truth.
Not a Member? - Login or Create an Account
Sunday the 20th of May 2012 @ 04:41pm
Front Page Journal Projects Your Profile About
[]

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

cGuiButton.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_cGuiButton_H
00026 #define _n2l4_cGuiButton_H
00027 
00028 #include "n2l/n2l.h"
00029 
00030 #include "gui/types.h"
00031 #include "gui/cGuiInteractive.h"
00032 
00033 #include "gui/cGuiFill.h"
00034 #include "gui/cGuiTextStyle.h"
00035 
00036 namespace n2l
00037 {
00038     class cVfsNodeInterface;
00039     class cDynVar;
00040     class cAudioChunk;
00041 
00046     class cGuiButton : public cGuiInteractive
00047     {
00048     public:
00049         typedef enum {
00050             Button_Normal,
00051             Button_Over,
00052             Button_Down,
00053 
00054             Button_NormalDisabled,
00055             Button_OverDisabled,
00056             Button_DownDisabled,
00057             
00058             Button_NumStates
00059         } tButtonState;
00060 
00061         typedef enum {
00062             Prop_Background,
00063             
00064             Prop_NumProps
00065         } tProp;
00066 
00067         typedef enum {
00068             Type_Push,
00069             Type_Toggle,
00070 
00071             Type_NumTypes
00072         } tType;
00073 
00074 
00075         cGuiButton();
00076         cGuiButton( const cVfsNodeInterface & iNode );
00077         cGuiButton( const cDynVar & iDefinition );
00078 
00079         virtual ~cGuiButton();
00080 
00081         virtual void load( const cVfsNodeInterface & iNode );
00082         virtual void load( const cDynVar & iDefinition );
00083 
00084         virtual void draw() const;
00085 
00086         virtual void fill( const tButtonState iState,
00087             const tProp iProp, const cGuiFill & iFill );
00088 
00089         virtual const cGuiFill & fill( const tButtonState iState,
00090             const tProp iProp ) const;
00091 
00092         virtual void audio( const tButtonState iState,
00093             const cAutoPtr<const cAudioChunk> & i_ioSound );
00094 
00095         virtual void label( const tString & iLabel );
00096         virtual const tString & label() const;
00097         virtual void labelStyle( const tButtonState iState,
00098             const cGuiTextStyle & iStyle );
00099 
00100         virtual void type( const tType iType );
00101         virtual const tType type() const;
00102 
00103         virtual void toggledOn( const tBool iToggled );
00104         virtual const tBool toggledOn() const;
00105 
00106         virtual void enabled( const tBool iEnabled );
00107         virtual const tBool enabled() const;
00108 
00109         virtual void setAccel( const tKey &iKey, const tKeyMods &iMods );
00110         virtual void clearAccel();
00111 
00112         virtual const cAutoPtr<cGuiElement> clone() const;
00113 
00114         friend class cGuiButtonSelectBox;
00115 
00116     protected:
00117         tString mLabel;
00118 
00119         cGuiTextStyle mLabelStyle[Button_NumStates];
00120         cGuiFill mFills[Button_NumStates][Prop_NumProps];
00121         cAutoPtr<const cAudioChunk> mSounds[Button_NumStates];
00122 
00123         tType mType;
00124         tBool mToggledOn;
00125         tBool mEnabled;
00126 
00129         tBool mUseAccel;
00130         tKey mKey;
00131         tKeyMods mKeyMod;
00132 
00133         virtual void cloneInto(
00134             const cAutoPtr<cGuiButton> &i_ioElement ) const;
00135 
00136         virtual void addExtraClickedData( tActionData &oData );
00137         virtual void addExtraOverData( tActionData &oData );
00138         virtual void addExtraOutData( tActionData &oData );
00139 
00140     private:
00141 
00142 #       ifdef N2L_PASSIVE_GUI_REG
00143             static tBool smRegistered;
00144 #       endif
00145 
00146         void boundCheckProp( const tProp iProp ) const;
00147         void boundCheckState( const tButtonState iState ) const;
00148         void boundCheckType( const tType iType ) const;
00149 
00153         void reset();
00154 
00155         // Callbacks
00156         static void overAndOutCallback( cGuiElement *const i_ioElement,
00157             const tGuiActionType iType, const tActionData &iData );
00158 
00159         static void clickedCallback( cGuiElement *const i_ioElement,
00160             const tGuiActionType iType, const tActionData &iData );
00161 
00162         static void keystrokeCallback( cGuiElement *const i_ioElement,
00163             const tGuiActionType iType, const tActionData &iData );
00164 
00165     }; // class
00166 
00167 } // namespace n2l
00168 
00169 #endif
©2012 Aaron Cameron