guiTextCtrl.h

Engine/source/gui/controls/guiTextCtrl.h

More...

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 _GUITEXTCTRL_H_
25#define _GUITEXTCTRL_H_
26
27#ifndef _GFONT_H_
28#include "gfx/gFont.h"
29#endif
30#ifndef _GUITYPES_H_
31#include "gui/core/guiTypes.h"
32#endif
33#ifndef _GUICONTAINER_H_
34#include "gui/containers/guiContainer.h"
35#endif
36
37class GuiTextCtrl : public GuiContainer
38{
39private:
40   typedef GuiContainer Parent;
41
42public:
43   enum Constants { MAX_STRING_LENGTH = 1024 };
44
45
46protected:
47   StringTableEntry mInitialText;
48   StringTableEntry mInitialTextID;
49   UTF8 mText[MAX_STRING_LENGTH + 1];
50   S32 mMaxStrLen;   // max string len, must be less then or equal to 255
51
52public:
53
54   //creation methods
55   DECLARE_CONOBJECT(GuiTextCtrl);
56   DECLARE_CATEGORY( "Gui Text" );
57   DECLARE_DESCRIPTION( "A control that displays a single line of text." );
58   
59   GuiTextCtrl();
60   static void initPersistFields();
61
62   //Parental methods
63   bool onAdd();
64   virtual bool onWake();
65
66   //text methods
67   virtual void setText(const char *txt = NULL);
68   virtual void setTextID(S32 id);
69   virtual void setTextID(const char *id);
70   const char *getText() { return (const char*)mText; }
71
72   // Text Property Accessors
73   static bool setText(void *object, const char *index, const char *data) 
74      { static_cast<GuiTextCtrl*>(object)->setText(data); return true; }
75   static const char* getTextProperty(void* obj, const char* data) 
76      { return static_cast<GuiTextCtrl*>(obj)->getText(); }
77
78
79   void inspectPostApply();
80   //rendering methods
81   void onPreRender();
82   void onRender(Point2I offset, const RectI &updateRect);
83   void displayText( S32 xOffset, S32 yOffset );
84
85   // resizing
86   void autoResize();
87
88   //Console methods
89   const char *getScriptValue();
90   void setScriptValue(const char *value);
91};
92
93#endif //_GUI_TEXT_CONTROL_H_
94