1 // This may look like C code, but it's really -*- C++ -*- 2 /* 3 * Copyright (C) 2008 Emweb bv, Herent, Belgium. 4 * 5 * See the LICENSE file for terms of use. 6 */ 7 #ifndef WBORDER_H_ 8 #define WBORDER_H_ 9 10 #include <Wt/WLength.h> 11 #include <Wt/WColor.h> 12 13 namespace Wt { 14 15 /*! \brief Enumeration for border width 16 */ 17 enum class BorderWidth { 18 Thin, //!< Browser-dependent 'thin' border. 19 Medium, //!< Browser-dependent 'medium' border, default. 20 Thick, //!< Browser-dependent 'thick' border. 21 Explicit //!< Explicit width. See also explicitWidth() 22 }; 23 24 /*! \brief Enumeration for border style 25 */ 26 enum class BorderStyle { 27 None, //!< No border (width ignored), default. 28 Hidden, //!< Invisible border (of specified width). 29 Dotted, //!< Dotted border 30 Dashed, //!< Dashed border 31 Solid, //!< Solid border 32 Double, //!< Double lined border 33 Groove, //!< Relief border grooved into the canvas 34 Ridge, //!< Relief border coming out of the canvas 35 Inset, //!< Relief border lowering contents into the canvas 36 Outset //!< Relief border letting contents come out of the canvas 37 }; 38 39 /*! \class WBorder Wt/WBorder.h Wt/WBorder.h 40 * \brief A value class that defines the CSS border style of a widget. 41 * 42 * \ingroup style 43 */ 44 class WT_API WBorder 45 { 46 public: 47 /*! \brief Typedef for enum Wt::BorderWidth */ 48 typedef BorderWidth Width; 49 /*! \brief Typedef for enum Wt::BorderStyle */ 50 typedef BorderStyle Style; 51 52 /*! \brief Creates a border indicating <i>no border</i>. 53 */ 54 WBorder(); 55 56 /*! \brief Creates a border with given style, thickness and color. 57 */ 58 WBorder(BorderStyle style, BorderWidth = BorderWidth::Medium, 59 WColor color = WColor()); 60 61 /*! \brief Creates a border with an absolute width. 62 */ 63 WBorder(BorderStyle style, const WLength& width, WColor color = WColor()); 64 65 /*! \brief Comparison operator 66 */ 67 bool operator==(const WBorder& other) const; 68 69 /*! \brief Comparison operator 70 */ 71 bool operator!=(const WBorder& other) const; 72 73 /*! \brief Sets the border width. 74 * 75 * If width == Explicit, then the width specified in 76 * \p explicitWidth is used. 77 */ 78 void setWidth(BorderWidth width, 79 const WLength& explicitWidth = WLength::Auto); 80 81 /*! \brief Sets the border color. 82 */ 83 void setColor(WColor color); 84 85 /*! \brief Sets the border style. 86 */ 87 void setStyle(BorderStyle style); 88 89 /*! \brief Returns the border width. 90 * 91 * \sa setWidth() 92 */ width()93 BorderWidth width() const { return width_; } 94 95 /*! \brief Returns the border width when set explicitly. 96 * 97 * \sa setWidth() 98 */ explicitWidth()99 WLength explicitWidth() const { return explicitWidth_; } 100 101 /*! \brief Returns the border color. 102 * 103 * \sa setColor() 104 */ color()105 WColor color() const { return color_; } 106 107 /*! \brief Returns the border style. 108 * 109 * \sa setStyle() 110 */ style()111 BorderStyle style() const { return style_; } 112 113 /*! \brief Returns the CSS text for this border style. 114 */ 115 std::string cssText() const; 116 117 #ifdef WT_TARGET_JAVA 118 /*! \brief Clone method. 119 * 120 * Clones this border. 121 */ 122 WBorder clone() const; 123 #endif 124 125 private: 126 BorderWidth width_; 127 WLength explicitWidth_; 128 WColor color_; 129 BorderStyle style_; 130 }; 131 132 } 133 134 #endif // WLENGTH 135