Torque3D Documentation / _generateds / guiTextListCtrl.h

guiTextListCtrl.h

Engine/source/gui/controls/guiTextListCtrl.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 _GUITEXTLISTCTRL_H_
 25#define _GUITEXTLISTCTRL_H_
 26
 27#ifndef _GUIARRAYCTRL_H_
 28#include "gui/core/guiArrayCtrl.h"
 29#endif
 30
 31class GuiTextListCtrl : public GuiArrayCtrl
 32{
 33  private:
 34   typedef GuiArrayCtrl Parent;
 35
 36  public:
 37   struct Entry
 38   {
 39      char *text;
 40      U32 id;
 41      bool active;
 42   };
 43
 44   Vector<Entry> mList;
 45
 46  protected:
 47   enum ScrollConst
 48   {
 49      UP = 0,
 50      DOWN = 1
 51   };
 52   enum : <a href="/coding/file/types_8h/#types_8h_1ac3df7cf3c8cb172a588adec881447d68">U32</a>
 53   {
 54      InvalidId = 0xFFFFFFFF
 55   };
 56   Vector<S32> mColumnOffsets;
 57
 58   bool  mFitParentWidth;
 59   bool  mClipColumnText;
 60
 61   U32 getRowWidth(Entry *row);
 62   bool cellSelected(Point2I cell);
 63   void onCellSelected(Point2I cell);
 64
 65  public:
 66   GuiTextListCtrl();
 67
 68   DECLARE_CONOBJECT(GuiTextListCtrl);
 69   DECLARE_CATEGORY( "Gui Lists" );
 70   DECLARE_DESCRIPTION( "A control that displays text in tabular form." );
 71   
 72   DECLARE_CALLBACK( void, onSelect, (S32 cellid, const char* text));
 73   DECLARE_CALLBACK( void, onDeleteKey, ( S32 id ));
 74
 75   static void initPersistFields();
 76
 77   virtual void setCellSize( const Point2I &size ){ mCellSize = size; }
 78   virtual void getCellSize(       Point2I &size ){ size = mCellSize; }
 79
 80   const char *getScriptValue();
 81   void setScriptValue(const char *value);
 82
 83   U32 getNumEntries();
 84
 85   void clear();
 86   virtual void addEntry(U32 id, const char *text);
 87   virtual void insertEntry(U32 id, const char *text, S32 index);
 88   void setEntry(U32 id, const char *text);
 89   void setEntryActive(U32 id, bool active);
 90   S32 findEntryById(U32 id);
 91   S32 findEntryByText(const char *text);
 92   bool isEntryActive(U32 id);
 93
 94   U32 getEntryId(U32 index);
 95
 96   bool onWake();
 97   void removeEntry(U32 id);
 98   virtual void removeEntryByIndex(S32 id);
 99   virtual void sort(U32 column, bool increasing = true);
100   virtual void sortNumerical(U32 column, bool increasing = true);
101
102   U32 getSelectedId();
103   U32 getSelectedRow();
104   const char *getSelectedText();
105
106   bool onKeyDown(const GuiEvent &event);
107
108   virtual void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver);
109
110   void setSize(Point2I newSize);
111   void onRemove();
112   void addColumnOffset(S32 offset) { mColumnOffsets.push_back(offset); }
113   void clearColumnOffsets() { mColumnOffsets.clear(); }
114};
115
116#endif //_GUI_TEXTLIST_CTRL_H
117