The Gnome Chemistry Utils  0.14.0
gccv/brackets.h
1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint library
5  * brackets.h
6  *
7  * Copyright (C) 2011-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_BRACKETS_H
26 #define GCCV_BRACKETS_H
27 
28 #include "line-item.h"
29 #include <list>
30 #include <string>
31 
32 namespace gccv {
33 
34 typedef struct _BracketsMetrics BracketsMetrics;
35 
39 typedef enum
40 {
54 
58 typedef enum
59 {
72 } BracketsUses;
73 
74 class Brackets: public LineItem
75 {
76 public:
90  Brackets (Canvas *canvas, BracketsTypes type, BracketsUses use, char const *fontdesc, double x0, double y0, double x1, double y1);
105  Brackets (Group *parent, BracketsTypes type, BracketsUses use, char const *fontdesc, double x0, double y0, double x1, double y1, ItemClient *client = NULL);
109  ~Brackets ();
110 
119  void SetPosition (double x0, double y0, double x1, double y1);
128  void GetPosition (double &x0, double &y0, double &x1, double &y1);
129 
130  // virtual methods
138  double Distance (double x, double y, Item **item) const;
145  void Draw (cairo_t *cr, bool is_vector) const;
152  void Move (double x, double y);
153 
154 protected:
158  void UpdateBounds ();
159 
160 private:
161 
162 private:
163  BracketsMetrics const *m_Metrics;
164 // std::string m_FontDesc;
165  double m_x0, m_y0, m_x1, m_y1;
166 
167  typedef struct
168  {
169  char const *ch;
170  double x, y, w, h, offset;
171  bool needs_clip;
172  } BracketElem;
173  std::list < BracketElem > m_Elems;
174 
183 GCCV_ITEM_POS_PROP (double, Size)
184 
185 
193 GCCV_ITEM_POS_PROP (std::string, FontDesc)
194 
204 
214 };
215 
216 }
217 
218 #endif // GCCV_BRACKETS_H