text-object.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint libray
00005  * text-object.h 
00006  *
00007  * Copyright (C) 2002-2009 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 GCHEMPAINT_TEXT_OBJECT_H
00026 #define GCHEMPAINT_TEXT_OBJECT_H
00027 
00028 #include <gcu/object.h>
00029 #include <gcu/macros.h>
00030 #include <gccv/structs.h>
00031 #include <gccv/text-client.h>
00032 #include <gccv/text-tag.h>
00033 #include <pango/pango-layout.h>
00034 #include <string>
00035 
00037 namespace gcp {
00038 
00039 class TextEditor;
00040 
00046 class TextObject: public gcu::Object, public gccv::TextClient
00047 {
00048 public:
00054         TextObject (gcu::TypeId Type);
00062         TextObject (double x, double y, gcu::TypeId Type);
00066         virtual ~TextObject ();
00067 
00074         void GetSize (double& x, double& y) {x = m_length; y = m_height;}
00079         xmlNodePtr SaveSelected ();
00085         void LoadSelected (xmlNodePtr node);
00092         virtual bool OnChanged (bool save) = 0;
00099         bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
00105         bool Load (xmlNodePtr node);
00113         void Move (double x, double y, double z = 0);
00120         bool IsLocked () {return m_bLoading;}
00127         void GetSelectionBounds (unsigned &start, unsigned &end) {start = m_StartSel; end = m_EndSel;}
00131         std::string GetBuffer () {return m_buf;}
00138         virtual std::string GetProperty (unsigned property) const;
00139 
00140         // virtual methods for the gccv:TextClient interface
00143         void SelectionChanged (unsigned start, unsigned end);
00146         void TextChanged (unsigned pos);
00147 
00148 protected:
00152         double m_x;
00156         double m_y;
00160         double m_length;
00164         double m_height;
00168         int m_ascent;
00172         int m_InsertOffset;
00176         std::string m_buf;
00180         bool m_bLoading;
00184         unsigned m_StartSel;
00188         unsigned m_EndSel;
00193         bool m_RealSave;
00194 
00203 //GCU_PROT_PROP (GtkAnchorType, Anchor)
00210 GCU_PROT_PROP (gccv::TextTagList, TagList)
00211 GCU_PROP (TextEditor*, Editor)
00212 };
00213 
00214 }       // namespace gcp
00215 
00216 #endif  //GCHEMPAINT_TEXT_OBJECT_H

Generated on Thu Jun 25 13:24:20 2009 for The Gnome Chemistry Utils by  doxygen 1.5.9