gccv/text.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
00075 void Draw (cairo_t *cr, bool is_vector) const;
00076 void Move (double x, double y);
00077
00078
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 }
00099
00100 #endif // GCCV_TEXT_H