CornerImage.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // This may look like C code, but it's really -*- C++ -*-
  2. /*
  3. * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
  4. *
  5. * See the LICENSE file for terms of use.
  6. */
  7. #ifndef CORNER_IMAGE_H_
  8. #define CORNER_IMAGE_H_
  9. #include <Wt/WColor>
  10. #include <Wt/WImage>
  11. using namespace Wt;
  12. class CornerResource;
  13. /**
  14. * @addtogroup styleexample
  15. */
  16. /*@{*/
  17. /*! \brief The CornerImage is a painted widget with a rounded corner.
  18. *
  19. * The CornerImage is a dynamically generated image which draws an arc
  20. * of 90°, to represent one of the four corners of a rounded widget.
  21. *
  22. * The CornerImage is part of the %Wt style example.
  23. *
  24. * \sa RoundedWidget
  25. */
  26. class CornerImage : public WImage
  27. {
  28. public:
  29. /*! \brief One of the four corners of a widget.
  30. */
  31. enum Corner { TopLeft = (int)Top | (int)Left, //!< Top left
  32. TopRight = (int)Top | (int)Right, //!< Top right
  33. BottomLeft = (int)Bottom | (int)Left, //!< Bottom left
  34. BottomRight = (int)Bottom | (int)Right //!< Bottom right
  35. };
  36. /*! \brief Construct a new CornerImage.
  37. *
  38. * Construct a corner image, to draw the specified corner, with
  39. * the given foreground and background color, and the specified radius.
  40. *
  41. * The colors must be constructed using red/green/blue values,
  42. * using WColor::WColor(int, int, int).
  43. */
  44. CornerImage(Corner corner, WColor fg, WColor bg,
  45. int radius, WContainerWidget *parent = 0);
  46. /*! \brief Change the corner radius (and image dimensions).
  47. */
  48. void setRadius(int radius);
  49. /*! \brief Get the corner radius.
  50. */
  51. int radius() const { return radius_; }
  52. /*! \brief Change the foreground color.
  53. */
  54. void setForeground(WColor color);
  55. /*! \brief Get the foreground color.
  56. */
  57. WColor foreground() const { return fg_; }
  58. /*! \brief Change the background color.
  59. */
  60. void setBackground(WColor color);
  61. /*! \brief Get the background color.
  62. */
  63. WColor background() const { return bg_; }
  64. Corner corner() const { return corner_; }
  65. private:
  66. //! One of the four corners, which this image represents.
  67. Corner corner_;
  68. //! Foreground color
  69. WColor fg_;
  70. //! Background color
  71. WColor bg_;
  72. //! Radius
  73. int radius_;
  74. CornerResource *resource_;
  75. };
  76. /*@}*/
  77. #endif // CORNER_IMAGE_H_