Torque3D Documentation / _generateds / customField.cpp

customField.cpp

Engine/source/gui/editor/inspector/customField.cpp

More...

Public Functions

ConsoleDocClass(GuiInspectorCustomField , "@brief A <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> that allows <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> edit the custom properties (text) of one or more <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SimObjects.\n\n</a>" "Editor use <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">only.\n\n</a>" "@internal" )

Detailed Description

Public Functions

ConsoleDocClass(GuiInspectorCustomField , "@brief A <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> that allows <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> edit the custom properties (text) of one or more <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SimObjects.\n\n</a>" "Editor use <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">only.\n\n</a>" "@internal" )

IMPLEMENT_CONOBJECT(GuiInspectorCustomField )

  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#include "console/simBase.h"
 25#include "console/engineAPI.h"
 26#include "gui/editor/inspector/customField.h"
 27#include "gui/editor/guiInspector.h"
 28
 29//-----------------------------------------------------------------------------
 30// GuiInspectorCustomField - Child class of GuiInspectorField 
 31//-----------------------------------------------------------------------------
 32IMPLEMENT_CONOBJECT( GuiInspectorCustomField );
 33
 34ConsoleDocClass( GuiInspectorCustomField,
 35   "@brief A control that allows to edit the custom properties (text) of one or more SimObjects.\n\n"
 36   "Editor use only.\n\n"
 37   "@internal"
 38);
 39
 40GuiInspectorCustomField::GuiInspectorCustomField( GuiInspector *inspector,
 41                                                    GuiInspectorGroup* parent, 
 42                                                    SimFieldDictionary::Entry* field )
 43{
 44   mInspector = inspector;
 45   mParent = parent;
 46   setBounds(0,0,100,20);
 47   mDoc = StringTable->insert("no Docs Found!");
 48}
 49
 50GuiInspectorCustomField::GuiInspectorCustomField()
 51{
 52   mInspector = NULL;
 53   mParent = NULL;
 54   mDoc = StringTable->insert("no Docs Found!");
 55}
 56
 57void GuiInspectorCustomField::setData( const char* data, bool callbacks )
 58{
 59   mCustomValue = data;
 60
 61   // Force our edit to update
 62   updateValue();
 63}
 64
 65const char* GuiInspectorCustomField::getData( U32 inspectObjectIndex )
 66{
 67   return mCustomValue;
 68}
 69
 70void GuiInspectorCustomField::updateValue()
 71{
 72   setValue( mCustomValue );
 73}
 74
 75void GuiInspectorCustomField::setDoc( const char* doc )
 76{
 77   mDoc = StringTable->insert( doc, true );
 78}
 79
 80void GuiInspectorCustomField::setToolTip( StringTableEntry data )
 81{
 82   static StringTableEntry sTooltipProfile = StringTable->insert( "tooltipProfile" );
 83   static StringTableEntry sHoverTime = StringTable->insert( "hovertime" );
 84   static StringTableEntry sTooltip = StringTable->insert( "tooltip" );
 85   
 86   mEdit->setDataField( sTooltipProfile, NULL, "GuiToolTipProfile" );
 87   mEdit->setDataField( sHoverTime, NULL, "1000" );
 88   mEdit->setDataField( sTooltip, NULL, data );
 89}
 90
 91bool GuiInspectorCustomField::onAdd()
 92{
 93   if( !Parent::onAdd() )
 94      return false;
 95
 96   return true;
 97}
 98
 99void GuiInspectorCustomField::setInspectorField( AbstractClassRep::Field *field, 
100                                                  StringTableEntry caption, 
101                                                  const char*arrayIndex ) 
102{
103   // Override the base just to be sure it doesn't get called.
104   // We don't use an AbstractClassRep::Field...
105
106//    mField = field; 
107//    mCaption = StringTable->EmptyString();
108//    mRenameCtrl->setText( getFieldName() );
109}
110
111GuiControl* GuiInspectorCustomField::constructEditControl()
112{
113   GuiControl* retCtrl = new GuiTextCtrl();
114
115   static StringTableEntry sProfile = StringTable->insert( "profile" );
116   retCtrl->setDataField( sProfile, NULL, "GuiInspectorTextEditProfile" );
117
118   // Register the object
119   retCtrl->registerObject();
120
121   return retCtrl;
122}
123
124void GuiInspectorCustomField::setValue( const char* newValue )
125{
126   GuiTextCtrl *ctrl = dynamic_cast<GuiTextCtrl*>( mEdit );
127   if( ctrl != NULL )
128      ctrl->setText( newValue );
129}
130
131void GuiInspectorCustomField::_executeSelectedCallback()
132{
133   Con::executef( mInspector, "onFieldSelected", mCaption, ConsoleBaseType::getType(TypeCaseString)->getTypeName(), mDoc );
134}
135