guiIconButtonCtrl.h
Engine/source/gui/buttons/guiIconButtonCtrl.h
Classes:
class
The GuiIconButtonCtrl draws an icon and text caption within a normal button control with several layout options.
Public Typedefs
GuiIconButtonIconLocation
GuiIconButtonTextLocation
Public Functions
Detailed Description
Public Typedefs
typedef GuiIconButtonCtrl::IconLocation GuiIconButtonIconLocation
typedef GuiIconButtonCtrl::TextLocation GuiIconButtonTextLocation
Public Functions
DefineEnumType(GuiIconButtonIconLocation )
DefineEnumType(GuiIconButtonTextLocation )
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 _GUIICONBUTTON_H_ 25#define _GUIICONBUTTON_H_ 26 27#ifndef _GUIBUTTONCTRL_H_ 28#include "gui/buttons/guiButtonCtrl.h" 29#endif 30#ifndef GFX_Texture_Manager_H_ 31#include "gfx/gfxTextureManager.h" 32#endif 33 34 35/// The GuiIconButtonCtrl draws an icon and text caption within a normal 36/// button control with several layout options. 37/// 38class GuiIconButtonCtrl : public GuiButtonCtrl 39{ 40private: 41 typedef GuiButtonCtrl Parent; 42 43protected: 44 45 StringTableEntry mBitmapName; 46 GFXTexHandle mTextureNormal; 47 S32 mIconLocation; 48 S32 mTextLocation; 49 S32 mTextMargin; 50 Point2I mButtonMargin; 51 52 /// Make the bitmap fill the button extent. 53 bool mFitBitmapToButton; 54 55 /// Keep a square aspect ration on the icon. 56 bool mMakeIconSquare; 57 58 /// Calculate extent based on icon size, text width, and layout options. 59 bool mAutoSize; 60 61 // Optional bitmap to be displayed when the proper bitmap cannot be found 62 StringTableEntry mErrorBitmapName; 63 GFXTexHandle mErrorTextureHandle; 64 65 void renderButton( Point2I &offset, const RectI& updateRect); 66 67 enum 68 { 69 stateNormal, 70 stateMouseOver, 71 statePressed, 72 stateDisabled, 73 }; 74 75 void renderBitmapArray(RectI &bounds, S32 state); 76 77public: 78 enum TextLocation 79 { 80 TextLocNone, 81 TextLocBottom, 82 TextLocRight, 83 TextLocTop, 84 TextLocLeft, 85 TextLocCenter, 86 }; 87 88 enum IconLocation 89 { 90 IconLocNone, 91 IconLocLeft, 92 IconLocRight, 93 IconLocCenter 94 }; 95 96 97 DECLARE_CONOBJECT(GuiIconButtonCtrl); 98 DECLARE_DESCRIPTION( "A button control that displays an icon on the button in addition\n" 99 "to the optional text label." ); 100 101 GuiIconButtonCtrl(); 102 103 static void initPersistFields(); 104 105 //Parent methods 106 bool onWake(); 107 void onSleep(); 108 void inspectPostApply(); 109 void onStaticModified(const char* slotName, const char* newValue = NULL); 110 bool resize(const Point2I &newPosition, const Point2I &newExtent); 111 112 void setBitmap(const char *name); 113 114 // Used to set the optional error bitmap 115 void setErrorBitmap(const char *name); 116 117 void onRender(Point2I offset, const RectI &updateRect); 118}; 119 120typedef GuiIconButtonCtrl::TextLocation GuiIconButtonTextLocation; 121typedef GuiIconButtonCtrl::IconLocation GuiIconButtonIconLocation; 122 123DefineEnumType( GuiIconButtonTextLocation ); 124DefineEnumType( GuiIconButtonIconLocation ); 125 126#endif //_GUIICONBUTTON_H_ 127