2
0

guiPopUpCtrl.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUIPOPUPCTRL_H_
  23. #define _GUIPOPUPCTRL_H_
  24. #ifndef _GUITEXTCTRL_H_
  25. #include "gui/guiTextCtrl.h"
  26. #endif
  27. #ifndef _GUITEXTLISTCTRL_H_
  28. #include "gui/guiTextListCtrl.h"
  29. #endif
  30. #ifndef _GUIBUTTONCTRL_H_
  31. #include "gui/buttons/guiButtonCtrl.h"
  32. #endif
  33. #ifndef _GUISCROLLCTRL_H_
  34. #include "gui/containers/guiScrollCtrl.h"
  35. #endif
  36. class GuiPopUpMenuCtrl;
  37. class GuiPopupTextListCtrl;
  38. class GuiPopUpBackgroundCtrl : public GuiControl
  39. {
  40. protected:
  41. GuiPopUpMenuCtrl *mPopUpCtrl;
  42. GuiPopupTextListCtrl *mTextList;
  43. public:
  44. GuiPopUpBackgroundCtrl(GuiPopUpMenuCtrl *ctrl, GuiPopupTextListCtrl* textList);
  45. void onTouchDown(const GuiEvent &event);
  46. };
  47. class GuiPopupTextListCtrl : public GuiTextListCtrl
  48. {
  49. private:
  50. typedef GuiTextListCtrl Parent;
  51. protected:
  52. GuiPopUpMenuCtrl *mPopUpCtrl;
  53. public:
  54. GuiPopupTextListCtrl(); // for inheritance
  55. GuiPopupTextListCtrl(GuiPopUpMenuCtrl *ctrl);
  56. // GuiArrayCtrl overload:
  57. void onCellSelected(Point2I cell);
  58. // GuiControl overloads:
  59. bool onKeyDown(const GuiEvent &event);
  60. void onTouchDown(const GuiEvent &event);
  61. void onTouchUp(const GuiEvent &event);
  62. void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver);
  63. };
  64. class GuiPopUpMenuCtrl : public GuiControl
  65. {
  66. typedef GuiControl Parent;
  67. public:
  68. struct Entry
  69. {
  70. char buf[256];
  71. S32 id;
  72. U16 ascii;
  73. U16 scheme;
  74. bool usesColorBox; // DAW: Added
  75. ColorI colorbox; // DAW: Added
  76. };
  77. struct Scheme
  78. {
  79. U32 id;
  80. ColorI fontColor;
  81. ColorI fontColorHL;
  82. ColorI fontColorSEL;
  83. };
  84. bool mBackgroundCancel; // DAW: Added
  85. protected:
  86. GuiPopupTextListCtrl *mTl;
  87. GuiScrollCtrl *mSc;
  88. GuiPopUpBackgroundCtrl *mBackground;
  89. Vector<Entry> mEntries;
  90. Vector<Scheme> mSchemes;
  91. S32 mSelIndex;
  92. S32 mMaxPopupHeight;
  93. F32 mIncValue;
  94. F32 mScrollCount;
  95. S32 mLastYvalue;
  96. GuiEvent mEventSave;
  97. S32 mRevNum;
  98. bool mInAction;
  99. bool mReplaceText;
  100. bool mMouseOver; // DAW: Added
  101. bool mRenderScrollInNA; // DAW: Added
  102. bool mReverseTextList; // DAW: Added - Should we reverse the text list if we display up?
  103. StringTableEntry mBitmapName; // DAW: Added
  104. Point2I mBitmapBounds; // DAW: Added
  105. TextureHandle mTextureNormal; // DAW: Added
  106. TextureHandle mTextureDepressed; // DAW: Added
  107. virtual void addChildren();
  108. virtual void repositionPopup();
  109. public:
  110. GuiPopUpMenuCtrl(void);
  111. ~GuiPopUpMenuCtrl();
  112. GuiScrollCtrl::Region mScrollDir;
  113. bool onWake(); // DAW: Added
  114. bool onAdd();
  115. void onSleep();
  116. void setBitmap(const char *name); // DAW: Added
  117. void sort();
  118. void sortID(); // DAW: Added
  119. void addEntry(const char *buf, S32 id, U32 scheme = 0);
  120. void addScheme(U32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL);
  121. void onRender(Point2I offset, const RectI &updateRect);
  122. void onAction();
  123. virtual void closePopUp();
  124. void clear();
  125. void onTouchDown(const GuiEvent &event);
  126. void onTouchUp(const GuiEvent &event);
  127. void onTouchEnter(const GuiEvent &event); // DAW: Added
  128. void onTouchLeave(const GuiEvent &); // DAW: Added
  129. void setupAutoScroll(const GuiEvent &event);
  130. void autoScroll();
  131. bool onKeyDown(const GuiEvent &event);
  132. void reverseTextList();
  133. bool getFontColor(ColorI &fontColor, S32 id, bool selected, bool mouseOver);
  134. bool getColoredBox(ColorI &boxColor, S32 id); // DAW: Added
  135. S32 getSelected();
  136. void setSelected(S32 id, bool bNotifyScript = true);
  137. void setFirstSelected(); // DAW: Added
  138. void setNoneSelected(); // DAW: Added
  139. const char *getScriptValue();
  140. const char *getTextById(S32 id);
  141. S32 findText( const char* text );
  142. S32 getNumEntries() { return( mEntries.size() ); }
  143. void replaceText(S32);
  144. DECLARE_CONOBJECT(GuiPopUpMenuCtrl);
  145. static void initPersistFields(void);
  146. };
  147. #endif //_GUI_POPUPMENU_CTRL_H