PolyScreenLabel.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. Copyright (C) 2011 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #pragma once
  20. #include "PolyString.h"
  21. #include "PolyGlobals.h"
  22. #include "PolyCoreServices.h"
  23. #include "PolyScreenShape.h"
  24. #include "PolyScreenImage.h"
  25. #include "PolyFont.h"
  26. #include "PolyLabel.h"
  27. #include "PolyTexture.h"
  28. #include "PolyPolygon.h"
  29. #include "PolyMesh.h"
  30. #include <string>
  31. using std::string;
  32. using std::wstring;
  33. namespace Polycode {
  34. /**
  35. * 2D screen label display. Displays 2d text in a specified font.
  36. */
  37. class _PolyExport ScreenLabel : public ScreenShape {
  38. public:
  39. /**
  40. * Constructor.
  41. * @param fontName Name of a registered font to use. @see FontManager for info on how to register fonts.
  42. * @param text Text to display.
  43. * @param size Size in pixels.
  44. * @param Anti-aliasing mode.
  45. */
  46. ScreenLabel(const String& text, int size, const String& fontName = "sans", int amode = 0);
  47. ~ScreenLabel();
  48. /**
  49. * Adds a drop shadow to the label.
  50. * @param color Color of the drop shadow.
  51. * @param size Size of the drop shadow in pixels.
  52. * @param offsetX Horizontal offset of the drop shadow.
  53. * @param offsetY Vertical offset of the drop shadow.
  54. */
  55. void addDropShadow(Color color, Number size, Number offsetX, Number offsetY);
  56. /**
  57. * Sets a new text to the screen label.
  58. * @param newText Text to set.
  59. */
  60. void setText(const String& newText);
  61. /**
  62. * Returns the label's text as a string.
  63. * @return The label's text.
  64. */
  65. const String& getText() const;
  66. Label *getLabel() const;
  67. protected:
  68. Label *label;
  69. ScreenImage *dropShadowImage;
  70. };
  71. }