1 // -*- C++ -*- 2 3 /* 4 * Gnome Chemistry Utils 5 * gccv/fill-item.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_LINE_ITEM_H 26 #define GCCV_LINE_ITEM_H 27 28 /*!\file*/ 29 30 #include "item.h" 31 #include <gcu/macros.h> 32 33 namespace gccv { 34 35 /*! 36 @brief Base class for line items, whether straight or curved. 37 38 This base class implements the common properties of all lines. 39 */ 40 class LineItem: public Item { 41 public: 42 /*! 43 @param canvas a Canvas. 44 45 Creates a new LineItem and sets it as a child of the root Group of \a canvas. 46 */ 47 LineItem (Canvas *canvas); 48 /*! 49 @param parent the Group to which the new LineItem will be added. 50 @param client the ItemClient for the new LineItem if any. 51 52 Creates a new LineItem inside \a parent and sets \a client as its associated 53 ItemClient. 54 */ 55 LineItem (Group *parent, ItemClient *client = NULL); 56 /*! 57 The destructor. 58 */ 59 virtual ~LineItem (); 60 61 /*! 62 @return the line color whether it is an automatic color or not. 63 */ 64 GOColor GetEffectiveLineColor () const; 65 /*! 66 @param cr the cairo_t to which the line must be rendered. 67 68 Sets the line style to \a cairo. cairo_restore must be called when done. 69 @return true if the line is not transparent. 70 */ 71 bool ApplyLine (cairo_t *cr) const; 72 /*! 73 @param dashes the dashes lengths. 74 @param num_dashes the dashes number inside the pattern. 75 @param offset the dashes offset at line start. 76 77 Sets the line dashes, see cairo_set_dash for more details on the parameters 78 values. 79 */ 80 void SetDashes (double const *dashes, int num_dashes, double offset); 81 82 private: 83 double *m_Dashes; 84 int m_DashesNb; 85 double m_DashOffset; 86 87 /*!\fn SetLineWidth(double width) 88 @param width the new line width. 89 90 Sets the LineItem line width. 91 */ 92 /*!\fn GetLineWidth() 93 @return the line width 94 */ 95 GCCV_ITEM_POS_PROP (double, LineWidth) 96 /*!\fn SetLineColor(GOColor color) 97 @param color the new line color. 98 99 Sets the LineItem color. 100 */ 101 /*!\fn GetLineColor() 102 @return the line color. 103 */ 104 GCCV_ITEM_PROP (GOColor, LineColor) 105 /*!\fn SetAutoColor(bool auto) 106 @param auto whether to use a color from the theme. 107 108 if \a auto is true, the color used to draw the line whiil be retrieved from 109 the Gtk+ theme instead of using the LineColor member. 110 */ 111 /*!\fn GetAutoColor() 112 @return the line color mode, true if automatic, false otherwise. 113 */ 114 GCCV_ITEM_PROP (bool, AutoColor) 115 }; 116 117 } 118 119 #endif // GCCV_LINE_ITEM_H 120