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 <display/display-forward.h>
23 #include <libnr/nr-point.h>
24 #include "libnrtype/Layout-TNG.h"
26 #define SP_TYPE_TEXT_CONTEXT (sp_text_context_get_type ())
27 #define SP_TEXT_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_TEXT_CONTEXT, SPTextContext))
28 #define SP_TEXT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_TEXT_CONTEXT, SPTextContextClass))
29 #define SP_IS_TEXT_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_TEXT_CONTEXT))
30 #define SP_IS_TEXT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_TEXT_CONTEXT))
32 class SPTextContext;
33 class SPTextContextClass;
34 class SPCanvasArena;
36 struct SPTextContext : public SPEventContext {
38 sigc::connection sel_changed_connection;
39 sigc::connection sel_modified_connection;
40 sigc::connection style_set_connection;
41 sigc::connection style_query_connection;
43 GtkIMContext *imc;
45 SPItem *text; // the text we're editing, or NULL if none selected
47 /* Text item position in root coordinates */
48 NR::Point pdoc;
49 /* Insertion point position */
50 Inkscape::Text::Layout::iterator text_sel_start;
51 Inkscape::Text::Layout::iterator text_sel_end;
53 gchar uni[9];
54 bool unimode;
55 guint unipos;
57 SPCanvasItem *cursor;
58 SPCanvasItem *indicator;
59 SPCanvasItem *frame; // hiliting the first frame of flowtext; FIXME: make this a list to accommodate arbitrarily many chained shapes
60 std::vector<SPCanvasItem*> text_selection_quads;
61 gint timeout;
62 guint show : 1;
63 guint phase : 1;
64 guint nascent_object : 1; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL
66 guint over_text : 1; // true if cursor is over a text object
68 guint dragging : 2; // dragging selection over text
70 guint creating : 1; // dragging rubberband to create flowtext
71 SPCanvasItem *grabbed; // we grab while we are creating, to get events even if the mouse goes out of the window
72 NR::Point p0; // initial point if the flowtext rect
74 /* Preedit String */
75 gchar* preedit_string;
76 };
78 struct SPTextContextClass {
79 SPEventContextClass parent_class;
80 };
82 /* Standard Gtk function */
83 GtkType sp_text_context_get_type (void);
85 bool sp_text_paste_inline(SPEventContext *ec);
86 Glib::ustring sp_text_get_selected_text(SPEventContext const *ec);
87 bool sp_text_delete_selection(SPEventContext *ec);
89 #endif