gccv/text.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * gccv/text.h 
00006  *
00007  * Copyright (C) 2008 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 GCCV_TEXT_H
00026 #define GCCV_TEXT_H
00027 
00028 #include "rectangle.h"
00029 #include "structs.h"
00030 #include <gtk/gtk.h>
00031 #include <pango/pango.h>
00032 #include <list>
00033 
00035 namespace gccv {
00036 
00037 #define GCCV_TEXT_PROP(type,member) \
00038 public: \
00039         void Set##member (type val) {   \
00040                 m_##member = val;       \
00041                 SetPosition (m_x, m_y); \
00042         }       \
00043         type Get##member (void) const {return m_##member;}      \
00044         type &GetRef##member (void) {return m_##member;}        \
00045 private:        \
00046         type m_##member;
00047 
00048 // These are private classes
00049 class TextPrivate;
00050 class TextRun;
00051 
00052 typedef enum {
00053         AnchorNorthWest, AnchorNorth, AnchorNorthEast,
00054         AnchorLineWest, AnchorLine, AnchorLineEast,
00055         AnchorWest, AnchorCenter, AnchorEast,
00056         AnchorSouthWest, AnchorSouth, AnchorSouthEast 
00057 } Anchor;
00058 
00059 class Text: public Rectangle
00060 {
00061 friend class TextPrivate;
00062 public:
00063         Text (Canvas *canvas, double x, double y);
00064         Text (Group *parent, double x, double y, ItemClient *client = NULL);
00065         virtual ~Text ();
00066 
00067         void SetPosition (double x, double y);
00068         void SetText (char const *text);
00069         void SetFontDescription (PangoFontDescription *desc);
00070         void SetEditing (bool editing);
00071 
00072         void GetBounds (Rect *ink, Rect *logical);
00073 
00074         // virtual methods
00075         void Draw (cairo_t *cr, bool is_vector) const;
00076         void Move (double x, double y);
00077 
00078         // static methods
00079         static PangoContext *GetContext ();
00080 
00081 private:
00082         double m_x, m_y;
00083         unsigned long m_BlinkSignal;
00084         bool m_CursorVisible;
00085         unsigned m_CurPos;
00086         std::list <TextRun *> m_Runs;
00087 
00088 GCU_RO_POINTER_PROP (PangoLayout, Layout)
00089 GCCV_TEXT_PROP (double, Padding)
00090 GCCV_TEXT_PROP (Anchor, Anchor)
00091 GCCV_TEXT_PROP (double, LineOffset)
00092 GCU_RO_PROP (double, Width)
00093 GCU_RO_PROP (double, Height)
00094 GCU_RO_PROP (double, Ascent)
00095 GCU_RO_PROP (double, Y)
00096 };
00097 
00098 }   //  namespace gccv
00099 
00100 #endif  //      GCCV_TEXT_H

Generated on Wed Dec 17 13:43:18 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6