guiPopUpCtrlEx.h
Engine/source/gui/controls/guiPopUpCtrlEx.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 _GUIPOPUPCTRLEX_H_ 25#define _GUIPOPUPCTRLEX_H_ 26 27#ifndef _GUITEXTCTRL_H_ 28#include "gui/controls/guiTextCtrl.h" 29#endif 30#ifndef _GUITEXTLISTCTRL_H_ 31#include "gui/controls/guiTextListCtrl.h" 32#endif 33#ifndef _GUIBUTTONCTRL_H_ 34#include "gui/buttons/guiButtonCtrl.h" 35#endif 36#ifndef _GUISCROLLCTRL_H_ 37#include "gui/containers/guiScrollCtrl.h" 38#endif 39class GuiPopUpMenuCtrlEx; 40class GuiPopupTextListCtrlEx; 41 42class GuiPopUpBackgroundCtrlEx : public GuiControl 43{ 44protected: 45 GuiPopUpMenuCtrlEx *mPopUpCtrl; 46 GuiPopupTextListCtrlEx *mTextList; 47public: 48 GuiPopUpBackgroundCtrlEx(GuiPopUpMenuCtrlEx *ctrl, GuiPopupTextListCtrlEx* textList); 49 void onMouseDown(const GuiEvent &event); 50}; 51 52class GuiPopupTextListCtrlEx : public GuiTextListCtrl 53{ 54 private: 55 typedef GuiTextListCtrl Parent; 56 57 bool hasCategories(); 58 59 protected: 60 GuiPopUpMenuCtrlEx *mPopUpCtrl; 61 62 public: 63 GuiPopupTextListCtrlEx(); // for inheritance 64 GuiPopupTextListCtrlEx(GuiPopUpMenuCtrlEx *ctrl); 65 66 // GuiArrayCtrl overload: 67 void onCellSelected(Point2I cell); 68 69 // GuiControl overloads: 70 bool onKeyDown(const GuiEvent &event); 71 void onMouseUp(const GuiEvent &event); 72 void onMouseMove(const GuiEvent &event); 73 void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver); 74}; 75 76class GuiPopUpMenuCtrlEx : public GuiTextCtrl 77{ 78 typedef GuiTextCtrl Parent; 79 80 public: 81 struct Entry 82 { 83 char buf[256]; 84 S32 id; 85 U16 ascii; 86 U16 scheme; 87 bool usesColorBox; // Added 88 ColorI colorbox; // Added 89 }; 90 91 struct Scheme 92 { 93 U32 id; 94 ColorI fontColor; 95 ColorI fontColorHL; 96 ColorI fontColorSEL; 97 }; 98 99 bool mBackgroundCancel; // Added 100 101 protected: 102 GuiPopupTextListCtrlEx *mTl; 103 GuiScrollCtrl *mSc; 104 GuiPopUpBackgroundCtrlEx *mBackground; 105 Vector<Entry> mEntries; 106 Vector<Scheme> mSchemes; 107 S32 mSelIndex; 108 S32 mMaxPopupHeight; 109 F32 mIncValue; 110 F32 mScrollCount; 111 S32 mLastYvalue; 112 GuiEvent mEventSave; 113 S32 mRevNum; 114 bool mInAction; 115 bool mReplaceText; 116 bool mMouseOver; // Added 117 bool mRenderScrollInNA; // Added 118 bool mReverseTextList; // Added - Should we reverse the text list if we display up? 119 bool mHotTrackItems; 120 StringTableEntry mBitmapName; // Added 121 Point2I mBitmapBounds; // Added 122 GFXTexHandle mTextureNormal; // Added 123 GFXTexHandle mTextureDepressed; // Added 124 S32 mIdMax; 125 126 virtual void addChildren(); 127 virtual void repositionPopup(); 128 129 public: 130 GuiPopUpMenuCtrlEx(void); 131 ~GuiPopUpMenuCtrlEx(); 132 GuiScrollCtrl::Region mScrollDir; 133 bool onWake(); // Added 134 bool onAdd(); 135 void onSleep(); 136 void setBitmap(const char *name); // Added 137 void sort(); 138 void sortID(); // Added 139 void addEntry(const char *buf, S32 id = -1, U32 scheme = 0); 140 void addScheme(U32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL); 141 void onRender(Point2I offset, const RectI &updateRect); 142 void onAction(); 143 virtual void closePopUp(); 144 void clear(); 145 void clearEntry( S32 entry ); // Added 146 void onMouseDown(const GuiEvent &event); 147 void onMouseUp(const GuiEvent &event); 148 void onMouseEnter(const GuiEvent &event); // Added 149 void onMouseLeave(const GuiEvent &); // Added 150 void setupAutoScroll(const GuiEvent &event); 151 void autoScroll(); 152 bool onKeyDown(const GuiEvent &event); 153 void reverseTextList(); 154 bool getFontColor(ColorI &fontColor, S32 id, bool selected, bool mouseOver); 155 bool getColoredBox(ColorI &boxColor, S32 id); // Added 156 157 S32 getSelected(); 158 void setSelected(S32 id, bool bNotifyScript = true); 159 void setFirstSelected(bool bNotifyScript = true); // Added 160 void setNoneSelected(); // Added 161 const char *getScriptValue(); 162 const char *getTextById(S32 id); 163 S32 findText( const char* text ); 164 S32 getNumEntries() { return( mEntries.size() ); } 165 void replaceText(S32); 166 167 DECLARE_CONOBJECT(GuiPopUpMenuCtrlEx); 168 DECLARE_CATEGORY( "Gui Lists" ); 169 DECLARE_DESCRIPTION( "A control that allows to select a value from a drop-down list." ); 170 171 static void initPersistFields(void); 172}; 173 174#endif //_GUIIMPROVEDPOPUPCTRL_H_ 175