guiTextEditSliderBitmapCtrl.h
Engine/source/gui/controls/guiTextEditSliderBitmapCtrl.h
Classes:
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _GUITEXTEDITSLIDERBITMAPCTRL_H_ 25#define _GUITEXTEDITSLIDERBITMAPCTRL_H_ 26 27#ifndef _GUITYPES_H_ 28#include "gui/core/guiTypes.h" 29#endif 30#ifndef _GUITEXTEDITCTRL_H_ 31#include "gui/controls/guiTextEditCtrl.h" 32#endif 33 34class GuiTextEditSliderBitmapCtrl : public GuiTextEditCtrl 35{ 36 typedef GuiTextEditCtrl Parent; 37 38public: 39 40 enum CtrlArea 41 { 42 None, 43 Slider, 44 ArrowUp, 45 ArrowDown 46 }; 47 48 GuiTextEditSliderBitmapCtrl(); 49 ~GuiTextEditSliderBitmapCtrl(); 50 51 DECLARE_CONOBJECT(GuiTextEditSliderBitmapCtrl); 52 DECLARE_CATEGORY( "Gui Values" ); 53 DECLARE_DESCRIPTION( "A text control that display a numeric value and bitmapped up/down sliders." ); 54 55 static void initPersistFields(); 56 57 virtual void getText(char *dest); // dest must be of size 58 // StructDes::MAX_STRING_LEN + 1 59 60 virtual void setText(const char *txt); 61 62 void setValue(); 63 void checkRange(); 64 void checkIncValue(); 65 void timeInc(U32 elapseTime); 66 67 virtual bool onKeyDown(const GuiEvent &event); 68 virtual void onMouseDown(const GuiEvent &event); 69 virtual void onMouseDragged(const GuiEvent &event); 70 virtual void onMouseUp(const GuiEvent &event); 71 virtual bool onMouseWheelUp(const GuiEvent &event); 72 virtual bool onMouseWheelDown(const GuiEvent &event); 73 74 bool onWake(); 75 virtual void onPreRender(); 76 virtual void onRender(Point2I offset, const RectI &updateRect); 77 78 void setBitmap(const char *name); 79 80protected: 81 82 Point2F mRange; 83 F32 mIncAmount; 84 F32 mValue; 85 F32 mIncCounter; 86 F32 mMulInc; 87 StringTableEntry mFormat; 88 U32 mMouseDownTime; 89 bool mFocusOnMouseWheel; 90 S32 mNumberOfBitmaps; 91 StringTableEntry mBitmapName; 92 93 CtrlArea mTextAreaHit; 94}; 95 96#endif //_GUITEXTEDITSLIDERBITMAPCTRL_H_ 97