1 // -*- C++ -*- 2 3 /* 4 * Gnome Chemistry Utils 5 * gccv/wedge.h 6 * 7 * Copyright (C) 2008-2012 Jean Bréfort <jean.brefort@normalesup.org> 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License as 11 * published by the Free Software Foundation; either version 3 of the 12 * License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 22 * USA 23 */ 24 25 #ifndef GCCV_WEDGE_H 26 #define GCCV_WEDGE_H 27 28 /*!\file*/ 29 30 #include "fill-item.h" 31 32 namespace gccv { 33 34 /*! 35 @brief Equilateral triangle. 36 37 Filled equilateral triangle. 38 */ 39 class Wedge: public Item 40 { 41 public: 42 /*! 43 @param canvas a Canvas. 44 @param x0 the triangle top horizontal position. 45 @param y0 the triangle top vertical position. 46 @param x1 the horizontal position of the canter of the triangle base. 47 @param y1 the vertical position of the canter of the triangle base. 48 @param width the triangle base width. 49 50 Creates a new Wedge and sets it as a child of the root Group of \a canvas. 51 */ 52 Wedge (Canvas *canvas, double x0, double y0, double x1, double y1, double width); 53 /*! 54 @param parent the Group to which the new Wedge will be added. 55 @param x0 the triangle top horizontal position. 56 @param y0 the triangle top vertical position. 57 @param x1 the horizontal position of the canter of the triangle base. 58 @param y1 the vertical position of the canter of the triangle base. 59 @param width the triangle base width. 60 @param client the ItemClient for the new Wedge if any. 61 62 Creates a new Wedge inside \a parent and sets \a client as its associated 63 ItemClient. 64 */ 65 Wedge (Group *parent, double x0, double y0, double x1, double y1, double width, ItemClient *client = NULL); 66 /*! 67 The destructor. 68 */ 69 virtual ~Wedge (); 70 71 /*! 72 @param x0 the triangle top horizontal position. 73 @param y0 the triangle top vertical position. 74 @param x1 the horizontal position of the canter of the triangle base. 75 @param y1 the vertical position of the canter of the triangle base. 76 77 Setes the new position for the Wedge instance. 78 */ 79 void SetPosition (double x0, double y0, double x1, double y1); 80 81 // virtual methods 82 /*! 83 @param x horizontal position 84 @param y vertical position 85 @param item where to store the Item. 86 87 Implementation of Item::Distance() for the Wedge class. Sets \a item to \a this. 88 */ 89 double Distance (double x, double y, Item **item) const; 90 /*! 91 @param cr a cairo_t. 92 @param is_vector whether the cairo_t is a vectorial context. 93 94 Draws the Wedge to \a cr. 95 */ 96 void Draw (cairo_t *cr, bool is_vector) const; 97 /*! 98 @param x the horizontal deplacement 99 @param y the vertical deplacement 100 101 Moves the Wedge. 102 */ 103 void Move (double x, double y); 104 105 protected: 106 /*! 107 Evaluates the Wedge bounds. 108 */ 109 void UpdateBounds (); 110 111 protected: 112 /*! 113 The horizontal start position. 114 */ 115 double m_xstart; 116 /*! 117 The vertical start position. 118 */ 119 double m_ystart; 120 /*! 121 The horizontal central end position. 122 */ 123 double m_xend; 124 /*! 125 The vertical central end position. 126 */ 127 double m_yend; 128 /*! 129 The horizontal position of the first corner at end position. This value is 130 automatically set and should not be changed by code external to this class. 131 */ 132 double m_xe1; 133 /*! 134 The vertical position of the first corner at end position. This value is 135 automatically set and should not be changed by code external to this class. 136 */ 137 double m_ye1; 138 /*! 139 The horizontal position of the second corner at end position. This value is 140 automatically set and should not be changed by code external to this class. 141 */ 142 double m_xe2; 143 /*! 144 The vertical position of the second corner at end position. This value is 145 automatically set and should not be changed by code external to this class. 146 */ 147 double m_ye2; 148 149 /*!\fn SetWidth(double width) 150 */ 151 /*!\fn GetWidth() 152 */ 153 GCCV_ITEM_POS_PROP (double, Width) 154 /*!\fn SetFillColor(GOColor color) 155 */ 156 /*!\fn GetFillColor() 157 */ 158 GCCV_ITEM_PROP (GOColor, FillColor) 159 /*!\fn SetAutoColor(bool auto) 160 @param auto whether to use a color from the theme. 161 162 if \a auto is true, the color used to draw the item will be retrieved from 163 the Gtk+ theme instead of using the LineColor member. 164 */ 165 /*!\fn GetAutoColor() 166 @return the line color mode, true if automatic, false otherwise. 167 */ 168 GCCV_ITEM_PROP (bool, AutoColor) 169 }; 170 171 } 172 173 #endif // GCCV_WEDGE_H 174