cc-rich-text.h

00001 /* ccc/cc-rich-text-.h
00002  *
00003  * Copyright (c) 2005-2006 Jean Bréfort <jean.brefort@normalesup.org>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the
00017  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
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         /* Attributes to apply to inserted text */
00044         PangoAttrList *insert_attrs;
00045         /* Position at anchor */
00046         gdouble x, y;
00047         /* Dimensions */
00048         gdouble width, height; /* user set size */
00049         gdouble _width, _height; /* size of the pango layout */
00050         GtkAnchorType anchor;
00051         guint rgba;
00052         gchar *color_name;
00053         gboolean editing, cursor_visible;
00054         guint blink_timeout, clicks;
00055         /* current position and selection bounds */
00056         gint index, start_sel, xl;
00057         /* Current line */
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         /* vtable */
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 /* CC_RICH_TEXT_H */

Generated on Sat Apr 24 09:29:17 2010 for The Gnome Chemistry Utils by  doxygen 1.5.9