# 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-2007 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 <pango/pango-layout.h>
    00031 #include <string>
    00032 #include <canvas/gcp-canvas-pango.h>
    00033
    00035 namespace gcp {
    00036
    00042 class TextObject: public gcu::Object
    00043 {
    00044 public:
    00050         TextObject (gcu::TypeId Type);
    00058         TextObject (double x, double y, gcu::TypeId Type);
    00062         virtual ~TextObject ();
    00063
    00070         void GetSize (double& x, double& y) {x = m_length; y = m_height;}
    00075         xmlNodePtr SaveSelected ();
    00081         void LoadSelected (xmlNodePtr node);
    00088         virtual bool OnChanged (bool save) = 0;
    00095         void OnSelChanged (struct GnomeCanvasPangoSelBounds *bounds);
    00102         bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
    00108         bool Load (xmlNodePtr node);
    00116         void Move (double x, double y, double z = 0);
    00123         bool IsLocked () {return m_bLoading;}
    00130         void GetSelectionBounds (unsigned &start, unsigned &end) {start = m_StartSel; end = m_EndSel;}
    00134         std::string GetBuffer () {return m_buf;}
    00141         virtual std::string GetProperty (unsigned property) const;
    00142
    00143 protected:
    00147         double m_x;
    00151         double m_y;
    00155         double m_length;
    00159         double m_height;
    00163         int m_ascent;
    00167         int m_InsertOffset;
    00171         std::string m_buf;
    00175         bool m_bLoading;
    00179         unsigned m_StartSel;
    00183         unsigned m_EndSel;
    00188         bool m_RealSave;
    00189
    00196 GCU_PROT_PROP (PangoLayout*, Layout);
    00203 GCU_PROT_PROP (PangoAttrList*, AttrList);
    00212 GCU_PROT_PROP (GtkAnchorType, Anchor);
    00213 };
    00214
    00215 }       // namespace gcp
    00216
    00217 #endif  //GCHEMPAINT_TEXT_OBJECT_H