WidgetLabel.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright © 2011-2020 Frictional Games
  3. *
  4. * This file is part of Amnesia: A Machine For Pigs.
  5. *
  6. * Amnesia: A Machine For Pigs is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. * Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #ifndef HPL_WIDGET_LABEL_H
  19. #define HPL_WIDGET_LABEL_H
  20. #include "gui/Widget.h"
  21. namespace hpl {
  22. class cGuiSkinFont;
  23. class cWidgetLabel : public iWidget
  24. {
  25. public:
  26. cWidgetLabel(cGuiSet *apSet, cGuiSkin *apSkin);
  27. virtual ~cWidgetLabel();
  28. void SetTextAlign(eFontAlign aType){mTextAlign = aType;}
  29. eFontAlign GetTextAlign(){ return mTextAlign;}
  30. bool GetWordWrap(){ return mbWordWrap;}
  31. void SetWordWrap(bool abX){ mbWordWrap = abX;}
  32. void SetMaxTextLength(int alLength);
  33. int GetMaxTextLength(){return mlMaxCharacters;}
  34. void SetAutogenerateSize(bool abX);
  35. bool GetAutogenerateSize(){ return mbAutogenerateSize;}
  36. void SetDefaultFontSize(const cVector2f& avSize);
  37. void SetDrawBackGround(bool abX) { mbDrawBackGround = abX; }
  38. bool GetDrawBackGround() { return mbDrawBackGround; }
  39. void SetBackGroundColor(const cColor &aColor){ mBackGroundColor = aColor;}
  40. const cColor& GetBackGroundColor(){ return mBackGroundColor;}
  41. void SetScrollWaitTime(float afX) { mfWaitToScrollTime = afX; }
  42. float GetScrollWaitTime() { return mfWaitToScrollTime; }
  43. void SetScrollOffset(float afX) { mfWordWrapOffset = afX; }
  44. void SetScrollSpeedMul(float afX) { mfScrollSpeedMul = afX; }
  45. float GetScrollSpeedMul() { return mfScrollSpeedMul; }
  46. protected:
  47. /////////////////////////
  48. // Own Funcs
  49. void DrawText(float afTimeStep, cGuiClipRegion *apClipRegion);
  50. /////////////////////////
  51. // Implemented functions
  52. void OnLoadGraphics();
  53. void OnUpdate(float afTimeStep);
  54. void OnChangeText();
  55. void OnDraw(float afTimeStep, cGuiClipRegion *apClipRegion);
  56. void OnDrawAfterClip(float afTimeStep, cGuiClipRegion *apClipRegion);
  57. bool OnMouseMove(const cGuiMessageData& aData);
  58. bool OnMouseDown(const cGuiMessageData& aData);
  59. bool OnMouseUp(const cGuiMessageData& aData);
  60. bool OnMouseEnter(const cGuiMessageData& aData);
  61. bool OnMouseLeave(const cGuiMessageData& aData);
  62. /////////////////////////
  63. // Data
  64. eFontAlign mTextAlign;
  65. bool mbWordWrap;
  66. float mfWordWrapRowsHeight;
  67. float mfWordWrapOffset;
  68. float mfScrollSpeedMul;
  69. float mfScrollTimer;
  70. float mfWaitToScrollTime;
  71. bool mbScrollingDown;
  72. float mfBackgroundZ;
  73. cGuiGfxElement *mpGfxBackground;
  74. bool mbDrawBackGround;
  75. cColor mBackGroundColor;
  76. int mlMaxCharacters;
  77. bool mbAutogenerateSize;
  78. };
  79. };
  80. #endif // HPL_WIDGET_LABEL_H