cc-rich-text.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CC_RICH_TEXT_H
00022 #define CC_RICH_TEXT_H
00023
00024 #include <ccc/cc-shape.h>
00025 #include <pango/pango-layout.h>
00026
00027 G_BEGIN_DECLS
00028
00029 typedef struct _CcRichText CcRichText;
00030 typedef struct _CcRichTextClass CcRichTextClass;
00031
00032 #define CC_TYPE_RICH_TEXT (cc_rich_text_get_type())
00033 #define CC_RICH_TEXT(i) (G_TYPE_CHECK_INSTANCE_CAST((i), CC_TYPE_RICH_TEXT, CcRichText))
00034 #define CC_RICH_TEXT_CLASS(c) (G_TYPE_ECHCK_CLASS_CAST((c), CC_TYPE_RICH_TEXT, CcRichTextClass))
00035 #define CC_IS_RICH_TEXT(i) (G_TYPE_CHECK_INSTANCE_TYPE((i), CC_TYPE_RICH_TEXT))
00036 #define CC_IS_RICH_TEXT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE((c), CC_TYPE_RICH_TEXT))
00037 #define CC_RICH_TEXT_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS((i), CC_TYPE_RICH_TEXT, CcRichTextClass))
00038
00039 struct _CcRichText {
00040 CcShape base_instance;
00041
00042 PangoLayout *layout;
00043
00044 PangoAttrList *insert_attrs;
00045
00046 gdouble x, y;
00047
00048 gdouble width, height;
00049 gdouble _width, _height;
00050 GtkAnchorType anchor;
00051 guint rgba;
00052 gchar *color_name;
00053 gboolean editing, cursor_visible;
00054 guint blink_timeout, clicks;
00055
00056 gint index, start_sel, xl;
00057
00058 gint line;
00059 CcHashMap * im_contexts;
00060 };
00061
00062 struct CcRichTextBounds {
00063 gint start, cur;
00064 };
00065
00066
00067 struct _CcRichTextClass {
00068 CcShapeClass base_class;
00069
00070
00071 void (*changed) (CcRichText * self);
00072 void (*sel_changed) (CcRichText * self,
00073 struct CcRichTextBounds *bounds);
00074 };
00075
00076 GType cc_rich_text_get_type(void) G_GNUC_CONST;
00077
00078 void cc_rich_text_set_anchor(CcRichText *self, gdouble x, gdouble y);
00079 void cc_rich_text_set_anchor_type (CcRichText *self, GtkAnchorType anchor);
00080 PangoLayout* cc_rich_text_get_layout (CcRichText *text);
00081 void cc_rich_text_set_layout (CcRichText *text, PangoLayout *layout);
00082 void cc_rich_text_set_insert_attrs (CcRichText *text, PangoAttrList *attr_list);
00083 void cc_rich_text_apply_attrs_to_selection (CcRichText *text, PangoAttrList *attr_list);
00084 int cc_rich_text_get_cur_index (CcRichText *text);
00085 int cc_rich_text_get_selection_start (CcRichText *text);
00086 void cc_rich_text_set_selection_bounds (CcRichText *text, unsigned start, unsigned end);
00087 void pango_layout_replace_text (PangoLayout *layout, unsigned start, unsigned length, char const *new_str, PangoAttrList *l);
00088
00089 G_END_DECLS
00090
00091 #endif