The Gnome Chemistry Utils 0.13.3
|
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 00036 namespace gccv { 00037 class Text; 00038 } 00039 00041 namespace gcp { 00042 00043 class TextEditor; 00044 00050 class TextObject: public gcu::Object, public gccv::TextClient 00051 { 00052 public: 00058 TextObject (gcu::TypeId Type); 00066 TextObject (double x, double y, gcu::TypeId Type); 00070 virtual ~TextObject (); 00071 00078 void GetSize (double& x, double& y) {x = m_length; y = m_height;} 00083 xmlNodePtr SaveSelected (); 00089 void LoadSelected (xmlNodePtr node); 00096 virtual bool OnChanged (bool save) = 0; 00103 bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const; 00109 bool Load (xmlNodePtr node); 00117 void Move (double x, double y, double z = 0); 00124 bool IsLocked () {return m_bLoading;} 00131 void GetSelectionBounds (unsigned &start, unsigned &end) {start = m_StartSel; end = m_EndSel;} 00135 std::string GetBuffer () {return m_buf;} 00142 virtual std::string GetProperty (unsigned property) const; 00143 00144 // virtual methods for the gccv:TextClient interface 00147 void SelectionChanged (unsigned start, unsigned end); 00150 void TextChanged (unsigned pos); 00151 00152 protected: 00156 double m_x; 00160 double m_y; 00164 double m_length; 00168 double m_height; 00172 int m_ascent; 00176 int m_InsertOffset; 00180 std::string m_buf; 00184 bool m_bLoading; 00188 unsigned m_StartSel; 00192 unsigned m_EndSel; 00197 bool m_RealSave; 00198 00199 //GCU_PROT_PROP (GtkAnchorType, Anchor) 00206 GCU_PROT_PROP (gccv::TextTagList, TagList) 00207 GCU_PROP (TextEditor*, Editor) 00208 GCU_PROT_PROP (gccv::Text*, TextItem) 00209 }; 00210 00211 } // namespace gcp 00212 00213 #endif //GCHEMPAINT_TEXT_OBJECT_H