guiTextListCtrl.h
Engine/source/gui/controls/guiTextListCtrl.h
Classes:
class
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 S32 mRowHeightPadding; 61 62 U32 getRowWidth(Entry *row); 63 bool cellSelected(Point2I cell); 64 void onCellSelected(Point2I cell); 65 66 public: 67 GuiTextListCtrl(); 68 69 DECLARE_CONOBJECT(GuiTextListCtrl); 70 DECLARE_CATEGORY( "Gui Lists" ); 71 DECLARE_DESCRIPTION( "A control that displays text in tabular form." ); 72 73 DECLARE_CALLBACK( void, onSelect, (S32 cellid, const char* text)); 74 DECLARE_CALLBACK( void, onDeleteKey, ( S32 id )); 75 76 static void initPersistFields(); 77 78 virtual void setCellSize( const Point2I &size ){ mCellSize = size; } 79 virtual void getCellSize( Point2I &size ){ size = mCellSize; } 80 81 const char *getScriptValue(); 82 void setScriptValue(const char *value); 83 84 U32 getNumEntries(); 85 86 void clear(); 87 virtual void addEntry(U32 id, const char *text); 88 virtual void insertEntry(U32 id, const char *text, S32 index); 89 void setEntry(U32 id, const char *text); 90 void setEntryActive(U32 id, bool active); 91 S32 findEntryById(U32 id); 92 S32 findEntryByText(const char *text); 93 bool isEntryActive(U32 id); 94 95 U32 getEntryId(U32 index); 96 97 bool onWake(); 98 void removeEntry(U32 id); 99 virtual void removeEntryByIndex(S32 id); 100 virtual void sort(U32 column, bool increasing = true); 101 virtual void sortNumerical(U32 column, bool increasing = true); 102 103 U32 getSelectedId(); 104 U32 getSelectedRow(); 105 const char *getSelectedText(); 106 107 bool onKeyDown(const GuiEvent &event); 108 bool onGamepadAxisUp(const GuiEvent& event); 109 bool onGamepadAxisDown(const GuiEvent& event); 110 111 virtual void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver); 112 113 void setSize(Point2I newSize); 114 void onRemove(); 115 void addColumnOffset(S32 offset) { mColumnOffsets.push_back(offset); } 116 void clearColumnOffsets() { mColumnOffsets.clear(); } 117}; 118 119#endif //_GUI_TEXTLIST_CTRL_H 120