The Gnome Chemistry Utils  0.13.7
gccv/brackets.h
00001 // -*- C++ -*-
00002 
00003 /*
00004  * GChemPaint library
00005  * brackets.h
00006  *
00007  * Copyright (C) 2011-2012 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 3 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_BRACKETS_H
00026 #define GCCV_BRACKETS_H
00027 
00028 #include "line-item.h"
00029 #include <list>
00030 #include <string>
00031 
00032 namespace gccv {
00033 
00034 typedef struct _BracketsMetrics BracketsMetrics;
00035 
00039 typedef enum
00040 {
00044         BracketsTypeNormal,
00048         BracketsTypeSquare,
00052         BracketsTypeCurly
00053 } BracketsTypes;
00054 
00058 typedef enum
00059 {
00063         BracketsOpening = 1,
00067         BracketsClosing,
00071         BracketsBoth
00072 } BracketsUses;
00073 
00074 class Brackets: public LineItem
00075 {
00076 public:
00090         Brackets (Canvas *canvas, BracketsTypes type, BracketsUses use, char const *fontdesc, double x0, double y0, double x1, double y1);
00105         Brackets (Group *parent, BracketsTypes type, BracketsUses use, char const *fontdesc, double x0, double y0, double x1, double y1, ItemClient *client = NULL);
00109         ~Brackets ();
00110 
00119         void SetPosition (double x0, double y0, double x1, double y1);
00128         void GetPosition (double &x0, double &y0, double &x1, double &y1);
00129 
00130         // virtual methods
00138         double Distance (double x, double y, Item **item) const;
00145         void Draw (cairo_t *cr, bool is_vector) const;
00152         void Move (double x, double y);
00153 
00154 protected:
00158         void UpdateBounds ();
00159 
00160 private:
00161 
00162 private:
00163         BracketsMetrics const *m_Metrics;
00164 //      std::string m_FontDesc;
00165         double m_x0, m_y0, m_x1, m_y1;
00166 
00167         typedef struct
00168         {
00169                 char const *ch;
00170                 double x, y, w, h, offset;
00171                 bool needs_clip;
00172         } BracketElem;
00173         std::list < BracketElem > m_Elems;
00174 
00183 GCCV_ITEM_POS_PROP (double, Size)
00184 
00185 
00193 GCCV_ITEM_POS_PROP (std::string, FontDesc)
00194 
00203 GCCV_ITEM_POS_PROP (BracketsTypes, Type)
00204 
00213 GCCV_ITEM_POS_PROP (BracketsUses, Used)
00214 };
00215 
00216 }
00217 
00218 #endif  //      GCCV_BRACKETS_H