File: CornerImage.h

package info (click to toggle)
witty 3.1.2-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 45,512 kB
  • ctags: 35,832
  • sloc: cpp: 69,469; ansic: 66,945; xml: 4,383; sh: 594; perl: 108; makefile: 106
file content (107 lines) | stat: -rw-r--r-- 2,373 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */

#ifndef CORNER_IMAGE_H_
#define CORNER_IMAGE_H_

#include <Wt/WImage>

namespace Wt {
  class WMemoryResource;
}

using namespace Wt;

/**
 * @addtogroup styleexample
 */
/*@{*/

/*! \brief The CornerImage is an image to draw a rounded corner.
 *
 * The CornerImage is a dynamically generated WImage, which draws
 * an arc of 90, to represent one of the four corners of a widget.
 *
 * The CornerImage is part of the %Wt style example.
 *
 * \sa RoundedWidget
 */
class CornerImage : public WImage
{
public:
  /*! \brief One of the four corners of a widget.
   */
  enum Corner { TopLeft = (int)Top | (int)Left,         //!< Top left
		TopRight = (int)Top | (int)Right,       //!< Top right
		BottomLeft = (int)Bottom | (int)Left,   //!< Bottom left
		BottomRight = (int)Bottom | (int)Right  //!< Bottom right
  };

  /*! \brief Construct a new CornerImage.
   *
   * Construct a corner image, to draw the specified corner, with
   * the given foreground and background color, and the specified radius.
   *
   * The colors must be constructed using red/green/blue values,
   * using WColor::WColor(int, int, int).
   */
  CornerImage(Corner corner, WColor fg, WColor bg,
	      int radius, WContainerWidget *parent = 0);

  /*! \brief CornerImage destructor.
   */
  ~CornerImage();

  /*! \brief Change the corner radius (and image dimensions).
   */
  void setRadius(int radius);

  /*! \brief Get the corner radius.
   */
  int radius() const { return radius_; }

  /*! \brief Change the foreground color.
   */
  void setForeground(WColor color);

  /*! \brief Get the foreground color.
   */
  WColor foreground() const { return fg_; }

  /*! \brief Change the background color.
   */
  void setBackground(WColor color);

  /*! \brief Get the background color.
   */
  WColor background() const { return bg_; }

private:
  //! One of the four corners, which this image represents.
  Corner corner_;

  //! Foreground color
  WColor fg_;

  //! Background color
  WColor bg_;

  //! Radius
  int radius_;

  /*! \brief The resource which contains the generated image.
   */
  WMemoryResource *resource_;

  /*! \brief Regenerate the image.
   */
  void compute();
};

/*@}*/

#endif // CORNER_IMAGE_H_