The Gnome Chemistry Utils  0.14.0
text-object.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint libray
5  * text-object.h
6  *
7  * Copyright (C) 2002-2009 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 GCHEMPAINT_TEXT_OBJECT_H
26 #define GCHEMPAINT_TEXT_OBJECT_H
27 
28 #include <gcu/object.h>
29 #include <gcu/macros.h>
30 #include <gccv/structs.h>
31 #include <gccv/text-client.h>
32 #include <gccv/text-tag.h>
33 #include <pango/pango-layout.h>
34 #include <string>
35 
36 namespace gccv {
37  class Text;
38 }
39 
41 namespace gcp {
42 
43 class TextEditor;
44 
51 {
52 public:
58  TextObject (gcu::TypeId Type);
66  TextObject (double x, double y, gcu::TypeId Type);
70  virtual ~TextObject ();
71 
78  void GetSize (double& x, double& y) {x = m_length; y = m_height;}
83  xmlNodePtr SaveSelected ();
89  void LoadSelected (xmlNodePtr node);
96  virtual bool OnChanged (bool save) = 0;
103  bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
109  bool Load (xmlNodePtr node);
117  void Move (double x, double y, double z = 0);
124  bool IsLocked () {return m_bLoading;}
131  void GetSelectionBounds (unsigned &start, unsigned &end) {start = m_StartSel; end = m_EndSel;}
135  std::string GetBuffer () {return m_buf;}
142  virtual std::string GetProperty (unsigned property) const;
143 
144  // virtual methods for the gccv:TextClient interface
147  void SelectionChanged (unsigned start, unsigned end);
150  void TextChanged (unsigned pos);
151 
152 protected:
156  double m_x;
160  double m_y;
164  double m_length;
168  double m_height;
172  int m_ascent;
180  std::string m_buf;
188  unsigned m_StartSel;
192  unsigned m_EndSel;
198 
199 //GCU_PROT_PROP (GtkAnchorType, Anchor)
207 
208 
220 
227 GCU_PROT_PROP (gccv::Text*, TextItem)
228 };
229 
230 } // namespace gcp
231 
232 #endif //GCHEMPAINT_TEXT_OBJECT_H