item.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * gccv/item.h 
00006  *
00007  * Copyright (C) 2008-2010 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 #ifndef GCCV_ITEM_H
00026 #define GCCV_ITEM_H
00027 
00028 #include <gcu/macros.h>
00029 #include <cairo.h>
00030 
00048 #define GCCV_ITEM_PROP(type,member) \
00049 public: \
00050         void Set##member (type val) {   \
00051                 m_##member = val;       \
00052                 Invalidate ();  \
00053         }       \
00054         type Get##member (void) const {return m_##member;}      \
00055 private:        \
00056         type m_##member;
00057 
00074 #define GCCV_ITEM_POS_PROP(type,member) \
00075 public: \
00076         void Set##member (type val) {   \
00077                 Invalidate ();  \
00078                 m_##member = val;       \
00079                 BoundsChanged ();       \
00080                 Invalidate ();  \
00081         }       \
00082         type Get##member (void) const {return m_##member;}      \
00083 private:        \
00084         type m_##member;
00085 
00086 namespace gccv {
00087 
00088 class Canvas;
00089 class Group;
00090 class ItemClient;
00091 
00100 class Item
00101 {
00102 public:
00108         Item (Canvas *canvas);
00115         Item (Group *parent, ItemClient *client = NULL);
00119         virtual ~Item ();
00120 
00129         void GetBounds (double &x0, double &y0, double &x1, double &y1) const;
00134         void Invalidate () const;
00140         void SetVisible (bool visible);
00141 
00142         // virtual methods
00155         virtual double Distance (double x, double y, Item **item) const;
00164         virtual void Draw (cairo_t *cr, bool is_vector) const;
00180         virtual bool Draw (cairo_t *cr, double x0, double y0, double x1, double y1, bool is_vector) const;
00187         virtual void Move (double x, double y);
00188 
00189 protected:
00193         void BoundsChanged ();
00199         virtual void UpdateBounds ();
00204         Canvas const *GetCanvas () const {return m_Canvas;}
00205 
00206 protected:
00210         double m_x0;
00214         double m_y0;
00218         double m_x1;
00222         double m_y1;
00223 
00224 private:
00225         Canvas *m_Canvas;
00226         bool m_CachedBounds;
00227         bool m_NeedsRedraw;
00228 
00237 GCU_POINTER_PROP (ItemClient, Client)
00241 GCU_RO_POINTER_PROP (Group, Parent)
00245 GCU_RO_PROP (bool, Visible)
00254 GCCV_ITEM_PROP (cairo_operator_t, Operator);
00255 };
00256 
00257 }
00258 
00259 #endif  //       GCCV_ITEM_H

Generated on Fri Sep 24 15:58:41 2010 for The Gnome Chemistry Utils by  doxygen 1.5.9