text-context.h revision 851352c059212fb89b24a36de4bcb9c7d0a13212
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#ifndef __SP_TEXT_CONTEXT_H__
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#define __SP_TEXT_CONTEXT_H__
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose/*
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose * SPTextContext
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose *
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose * Authors:
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose * Lauris Kaplinski <lauris@kaplinski.com>
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose * bulia byak <buliabyak@users.sf.net>
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose *
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose * Copyright (C) 1999-2005 authors
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose * Copyright (C) 2001 Ximian, Inc.
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose *
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose * Released under GNU GPL, read the file 'COPYING' for more information
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose */
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose/* #include <gdk/gdkic.h> */
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#include <stddef.h>
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#include <sigc++/sigc++.h>
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#include <gtk/gtk.h>
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#include "event-context.h"
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#include <2geom/point.h>
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#include "libnrtype/Layout-TNG.h"
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#define SP_TYPE_TEXT_CONTEXT (sp_text_context_get_type ())
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#define SP_TEXT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_TEXT_CONTEXT, SPTextContext))
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#define SP_TEXT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_TEXT_CONTEXT, SPTextContextClass))
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#define SP_IS_TEXT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_TEXT_CONTEXT))
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#define SP_IS_TEXT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_TEXT_CONTEXT))
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bosestruct SPCtrlLine;
ff6e24f4474cca6226cd44c47ba2ec6ba6cf9a16Sumit Boseclass SPTextContext;
ff6e24f4474cca6226cd44c47ba2ec6ba6cf9a16Sumit Boseclass SPTextContextClass;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bosestruct SPTextContext : public SPEventContext {
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose sigc::connection sel_changed_connection;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose sigc::connection sel_modified_connection;
ff6e24f4474cca6226cd44c47ba2ec6ba6cf9a16Sumit Bose sigc::connection style_set_connection;
ff6e24f4474cca6226cd44c47ba2ec6ba6cf9a16Sumit Bose sigc::connection style_query_connection;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose GtkIMContext *imc;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose SPItem *text; // the text we're editing, or NULL if none selected
9d17f436795a36b1b1126f444923aa847fd0f93aPavel Reichl
9d17f436795a36b1b1126f444923aa847fd0f93aPavel Reichl /* Text item position in root coordinates */
9d17f436795a36b1b1126f444923aa847fd0f93aPavel Reichl Geom::Point pdoc;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose /* Insertion point position */
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose Inkscape::Text::Layout::iterator text_sel_start;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose Inkscape::Text::Layout::iterator text_sel_end;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose gchar uni[9];
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose bool unimode;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose guint unipos;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose SPCtrlLine *cursor;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose SPCanvasItem *indicator;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose SPCanvasItem *frame; // hiliting the first frame of flowtext; FIXME: make this a list to accommodate arbitrarily many chained shapes
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose std::vector<SPCanvasItem*> text_selection_quads;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose gint timeout;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose guint show : 1;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose guint phase : 1;
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek guint nascent_object : 1; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose guint over_text : 1; // true if cursor is over a text object
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose guint dragging : 2; // dragging selection over text
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose guint creating : 1; // dragging rubberband to create flowtext
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose SPCanvasItem *grabbed; // we grab while we are creating, to get events even if the mouse goes out of the window
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose Geom::Point p0; // initial point if the flowtext rect
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose /* Preedit String */
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose gchar* preedit_string;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose};
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bosestruct SPTextContextClass {
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose SPEventContextClass parent_class;
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose};
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose/* Standard Gtk function */
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit BoseGType sp_text_context_get_type (void);
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bosebool sp_text_paste_inline(SPEventContext *ec);
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit BoseGlib::ustring sp_text_get_selected_text(SPEventContext const *ec);
4e5e846de22407f825fe3b4040d79606818a2419Jakub HrozekSPCSSAttr *sp_text_get_style_at_cursor(SPEventContext const *ec);
8babbeee01e67893af4828ddfc922ecac0be4197Pavel Reichlbool sp_text_delete_selection(SPEventContext *ec);
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bosevoid sp_text_context_place_cursor (SPTextContext *tc, SPObject *text, Inkscape::Text::Layout::iterator where);
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bosevoid sp_text_context_place_cursor_at (SPTextContext *tc, SPObject *text, Geom::Point const p);
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit BoseInkscape::Text::Layout::iterator *sp_text_context_get_cursor_position(SPTextContext *tc, SPObject *text);
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose#endif
d064fef06dcbcb5f6c1be03e286b1a3433d6dfd7Sumit Bose