text-edit.cpp revision cd4b3d6b35dc66928db5fd4880f9441d0e70bff9
#define __SP_TEXT_EDIT_C__
/**
* \brief Text editing dialog
*
* Author:
* Lauris Kaplinski <lauris@ximian.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <libnrtype/font-instance.h>
#ifdef WITH_GTKSPELL
extern "C" {
# include <gtkspell/gtkspell.h>
}
#endif
#include "macros.h"
#include "../widgets/font-selector.h"
#include "../inkscape.h"
#include "../document.h"
#include "../desktop-style.h"
#include "../desktop-handles.h"
#include "../selection.h"
#include "../style.h"
#include "../sp-text.h"
#include "../sp-flowtext.h"
#include "../text-editing.h"
#include "../inkscape-stock.h"
#include <libnrtype/font-style-to-pos.h>
#include "dialog-events.h"
#include "../prefs-utils.h"
#include "../verbs.h"
#include "../interface.h"
#include "svg/css-ostringstream.h"
#define VB_MARGIN 4
static void sp_text_edit_dialog_selection_modified (Inkscape::Application *inkscape, Inkscape::Selection *sel, guint flags, GtkWidget *dlg);
static void sp_text_edit_dialog_selection_changed (Inkscape::Application *inkscape, Inkscape::Selection *sel, GtkWidget *dlg);
static void sp_text_edit_dialog_subselection_changed ( Inkscape::Application *inkscape, SPDesktop *desktop, GtkWidget *dlg);
static void sp_text_edit_dialog_font_changed (SPFontSelector *fontsel, font_instance *font, GtkWidget *dlg);
static SPItem *sp_ted_get_selected_text_item (void);
static unsigned sp_ted_get_selected_text_count (void);
static const gchar *spacings[] = {"50%", "80%", "90%", "100%", "110%", "120%", "130%", "140%", "150%", "200%", "300%", NULL};
// impossible original values to make sure they are read from prefs
static void
{
}
static gboolean
{
if (x<0) x=0;
if (y<0) y=0;
return FALSE; // which means, go ahead and destroy it
}
/**
These callbacks set the eatkeys flag when the text editor is entered and cancel it when it's left.
This flag is used to prevent passing keys from the dialog to canvas, so that the text editor
can handle keys like Esc and Ctrl+Z itself.
*/
{
return FALSE;
}
{
return FALSE;
}
void
sp_text_edit_dialog (void)
{
if (!dlg) {
if (x == -1000 || y == -1000) {
}
if (w ==0 || h == 0) {
}
if (x<0) x=0;
if (y<0) y=0;
if (x != 0 || y != 0) {
} else {
}
if (w && h)
g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd );
gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (sp_text_edit_dialog_delete), dlg );
g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_text_edit_dialog_delete), dlg );
// box containing the notebook and the bottom buttons
// notebook
// Font tab
{
/* HBox containing font selection and layout */
// font and style selector
g_signal_connect ( G_OBJECT (fontsel), "font_set", G_CALLBACK (sp_text_edit_dialog_font_changed), dlg );
"row-activated",
dlg);
// Layout
{
{
// align left
{
// TODO - replace with Inkscape-specific call
}
// align center
{
// TODO - replace with Inkscape-specific call
/* TRANSLATORS: `Center' here is a verb. */
}
// align right
{
// TODO - replace with Inkscape-specific call
}
}
{
// horizontal
{
}
// vertical
{
}
}
{
l = gtk_label_new (_("Line spacing:"));
}
{
GtkWidget *c = gtk_combo_new ();
{ /* Setup strings */
for (int i = 0; spacings[i]; i++) {
}
g_list_free (sl);
}
"changed",
dlg );
}
}
/* Font preview */
}
// Text tab
{
#ifdef WITH_GTKSPELL
/* todo: Use computed xml:lang attribute of relevant element, if present, to specify the
language (either as 2nd arg of gtkspell_new_attach, or with explicit
gtkspell_set_language call in; see advanced.c example in gtkspell docs).
sp_text_edit_dialog_read_selection looks like a suitable place. */
}
#endif
}
/* Buttons */
{
dlg );
}
{
}
{
}
g_signal_connect (INKSCAPE, "change_subselection", G_CALLBACK (sp_text_edit_dialog_subselection_changed), dlg);
}
} // end of sp_text_edit_dialog()
static void
{
style =
((flags & ( SP_OBJECT_CHILD_MODIFIED_FLAG |
SP_OBJECT_STYLE_MODIFIED_FLAG )) != 0 );
content =
((flags & ( SP_OBJECT_CHILD_MODIFIED_FLAG |
SP_TEXT_CONTENT_MODIFIED_FLAG )) != 0 );
}
static void
{
}
static void sp_text_edit_dialog_subselection_changed ( Inkscape::Application *inkscape, SPDesktop *desktop, GtkWidget *dlg )
{
}
static void
{
/* write text */
if (gtk_text_buffer_get_modified (tb)) {
}
}
{
/* font */
if ( font ) {
gchar c[256];
}
/* Layout */
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b))) {
} else {
"text_anchor_middle");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b))) {
} else {
}
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b))) {
} else {
}
// Note that CSS 1.1 does not support line-height; we set it for consistency, but also set
// sodipodi:linespacing for backwards compatibility; in 1.2 we use line-height for flowtext
return css;
}
static void
{
}
static void
{
unsigned items = 0;
// apply style to the reprs of all text objects in the selection
// backwards compatibility:
SP_OBJECT_REPR(item_list->data)->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
++items;
}
// no need to set sodipodi:linespacing, because Inkscape never supported it on flowtext
++items;
}
if (items == 0) {
// no text objects; apply style to prefs for new objects
} else if (items == 1) {
/* exactly one text object; now set its text, too */
}
}
// complete the transaction
}
static void
{
}
static void
{
return;
if (text)
{
if (items == 1) {
} else {
}
if (docontent) {
if (str) {
int pos;
pos = 0;
if (items == 1) {
}
} else {
}
} // end of if (docontent)
} else {
}
if (dostyle) {
// create temporary style
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) {
if (repr) {
} else {
}
}
// FIXME: process result_family/style == QUERY_STYLE_MULTIPLE_DIFFERENT by showing "Many" in the lists
font_instance *font = (font_factory::Default())->Face ( query->text->font_family.value, font_style_to_pos(*query) );
if (font) {
// the font is oversized, so we need to pass the true size separately
}
GtkWidget *b;
} else {
}
} else {
}
double height;
}
}
static void
{
return;
} else {
}
if (text) {
}
} // end of sp_text_edit_dialog_text_changed()
static void
{
return;
if (text)
{
}
} // end of sp_text_edit_dialog_font_changed()
static void
{
return;
if (text) {
}
}
static void
{
return;
if (text) {
}
}
static SPItem *
{
if (!SP_ACTIVE_DESKTOP)
return NULL;
{
}
return NULL;
}
static unsigned
{
if (!SP_ACTIVE_DESKTOP)
return 0;
unsigned int items = 0;
{
++items;
}
return items;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :