1 #ifndef __SP_TEXT_CONTEXT_H__
2 #define __SP_TEXT_CONTEXT_H__
4 /*
5 * SPTextContext
6 *
7 * Authors:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 * bulia byak <buliabyak@users.sf.net>
10 *
11 * Copyright (C) 1999-2005 authors
12 * Copyright (C) 2001 Ximian, Inc.
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 /* #include <gdk/gdkic.h> */
18 #include <sigc++/sigc++.h>
19 #include <gtk/gtkimcontext.h>
21 #include "event-context.h"
22 #include <2geom/point.h>
23 #include "libnrtype/Layout-TNG.h"
25 #define SP_TYPE_TEXT_CONTEXT (sp_text_context_get_type ())
26 #define SP_TEXT_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_TEXT_CONTEXT, SPTextContext))
27 #define SP_TEXT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_TEXT_CONTEXT, SPTextContextClass))
28 #define SP_IS_TEXT_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_TEXT_CONTEXT))
29 #define SP_IS_TEXT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_TEXT_CONTEXT))
31 class SPTextContext;
32 class SPTextContextClass;
33 class SPCanvasArena;
35 struct SPTextContext : public SPEventContext {
37 sigc::connection sel_changed_connection;
38 sigc::connection sel_modified_connection;
39 sigc::connection style_set_connection;
40 sigc::connection style_query_connection;
42 GtkIMContext *imc;
44 SPItem *text; // the text we're editing, or NULL if none selected
46 /* Text item position in root coordinates */
47 Geom::Point pdoc;
48 /* Insertion point position */
49 Inkscape::Text::Layout::iterator text_sel_start;
50 Inkscape::Text::Layout::iterator text_sel_end;
52 gchar uni[9];
53 bool unimode;
54 guint unipos;
56 SPCanvasItem *cursor;
57 SPCanvasItem *indicator;
58 SPCanvasItem *frame; // hiliting the first frame of flowtext; FIXME: make this a list to accommodate arbitrarily many chained shapes
59 std::vector<SPCanvasItem*> text_selection_quads;
60 gint timeout;
61 guint show : 1;
62 guint phase : 1;
63 guint nascent_object : 1; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL
65 guint over_text : 1; // true if cursor is over a text object
67 guint dragging : 2; // dragging selection over text
69 guint creating : 1; // dragging rubberband to create flowtext
70 SPCanvasItem *grabbed; // we grab while we are creating, to get events even if the mouse goes out of the window
71 Geom::Point p0; // initial point if the flowtext rect
73 /* Preedit String */
74 gchar* preedit_string;
75 };
77 struct SPTextContextClass {
78 SPEventContextClass parent_class;
79 };
81 /* Standard Gtk function */
82 GtkType sp_text_context_get_type (void);
84 bool sp_text_paste_inline(SPEventContext *ec);
85 Glib::ustring sp_text_get_selected_text(SPEventContext const *ec);
86 SPCSSAttr *sp_text_get_style_at_cursor(SPEventContext const *ec);
87 bool sp_text_delete_selection(SPEventContext *ec);
88 void sp_text_context_place_cursor (SPTextContext *tc, SPObject *text, Inkscape::Text::Layout::iterator where);
89 void sp_text_context_place_cursor_at (SPTextContext *tc, SPObject *text, Geom::Point const p);
90 Inkscape::Text::Layout::iterator *sp_text_context_get_cursor_position(SPTextContext *tc, SPObject *text);
92 #endif