text-edit.cpp revision ece97dc3fa31475f418681626b278d5d92b74013
/**
* @file
* Text editing dialog.
*/
/* Authors:
* Lauris Kaplinski <lauris@ximian.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <goejendaagh@zonnet.nl>
* Abhishek Sharma
* John Smith
*
* Copyright (C) 1999-2012 Authors
* 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 "text-edit.h"
#include <libnrtype/font-instance.h>
#ifdef WITH_GTKSPELL
extern "C" {
# include <gtkspell/gtkspell.h>
}
#endif
#include <libnrtype/font-instance.h>
#include <libnrtype/font-style-to-pos.h>
#include "macros.h"
#include "inkscape.h"
#include "document.h"
#include "desktop.h"
#include "desktop-style.h"
#include "desktop-handles.h"
#include "document-undo.h"
#include "selection.h"
#include "style.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "text-editing.h"
#include "ui/icon-names.h"
#include "preferences.h"
#include "verbs.h"
#include "interface.h"
#include "svg/css-ostringstream.h"
#include "widgets/font-selector.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
font_label(_("_Font"), true),
layout_frame(_("Layout")),
text_label(_("_Text"), true),
setasdefault_button(_("Set as _default")),
deskTrack(),
/*
TRANSLATORS: Test string used in text and font dialog (when no
* text has been entered) to get a preview of the font. Choose
* some representative characters that users of your locale will be
* interested in.*/
blocked(false),
samplephrase(_("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()"))
{
/* Font selector */
/* Align buttons */
/* Direction buttons */
styleButton(&text_horizontal, _("Horizontal text"), INKSCAPE_ICON("format-text-direction-horizontal"), NULL);
styleButton(&text_vertical, _("Vertical text"), INKSCAPE_ICON("format-text-direction-vertical"), &text_horizontal);
/* Line Spacing */
GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("text_line_spacing") );
/*
This would introduce dependency on gtk version 2.24 which is currently not available in
This conditional and its #else block can be deleted in the future.
*/
#else
#endif
const gchar *spacings[] = {"50%", "80%", "90%", "100%", "110%", "120%", "130%", "140%", "150%", "200%", "300%", NULL};
for (int i = 0; spacings[i]; i++) {
/*
This would introduce dependency on gtk version 2.24 which is currently not available in
This conditional and its #else block can be deleted in the future.
*/
#else
#endif
}
/* 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).
onReadSelection looks like a suitable place.
*/
}
#endif
/* Buttons */
/* Signal handlers */
close_button.signal_clicked().connect(sigc::bind(_signal_response.make_slot(), GTK_RESPONSE_CLOSE));
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &TextEdit::setTargetDesktop) );
}
{
}
void TextEdit::styleButton(Gtk::RadioButton *button, gchar const *tooltip, gchar const *icon_name, Gtk::RadioButton *group_button )
{
if (!GTK_IS_IMAGE(icon)) {
}
if (group_button) {
}
}
{
SP_OBJECT_STYLE_MODIFIED_FLAG )) != 0 );
SP_TEXT_CONTENT_MODIFIED_FLAG )) != 0 );
}
{
if (blocked)
return;
{
return;
}
blocked = true;
if (text)
{
if (items == 1) {
} else {
}
apply_button.set_sensitive ( false );
setasdefault_button.set_sensitive ( true );
//if (docontent) { // When would we NOT want to show the content ?
if (str) {
if (items == 1) {
}
} else {
}
//} // end of if (docontent)
} else {
apply_button.set_sensitive ( false );
setasdefault_button.set_sensitive ( false );
}
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_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
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)
// (Ok to not get a font specification - must just rely on the family and style in that case)
|| result_numbers == QUERY_STYLE_NOTHING) {
}
// FIXME: process result_family/style == QUERY_STYLE_MULTIPLE_DIFFERENT by showing "Many" in the lists
// Get a font_instance using the font-specification attribute stored in SPStyle if available
if (font) {
}
} else {
}
} else {
}
} else {
}
double height;
}
blocked = false;
}
{
if (!font) {
return;
}
}
{
if (!SP_ACTIVE_DESKTOP)
return NULL;
{
}
return NULL;
}
unsigned TextEdit::getSelectedTextCount (void)
{
if (!SP_ACTIVE_DESKTOP)
return 0;
unsigned int items = 0;
{
++items;
}
return items;
}
void TextEdit::onSelectionChange()
{
}
{
// write text
if (gtk_text_buffer_get_modified (text_buffer)) {
}
}
{
// font
if ( font ) {
gchar c[256];
os << sp_font_selector_get_size (fsel) << "px"; // must specify px, see inkscape bug 1221626 and 1610103
}
// Layout
if ( align_left.get_active() ) {
} else if ( align_center.get_active() ) {
} else if ( align_right.get_active() ){
} else {
// Align Justify
}
if (text_horizontal.get_active()) {
} 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
/*
This would introduce dependency on gtk version 2.24 which is currently not available in
This conditional and its #else block can be deleted in the future.
*/
#else
const gchar *sstr = gtk_entry_get_text ((GtkEntry *) (gtk_bin_get_child (GTK_BIN (spacing_combo))));
#endif
return css;
}
void TextEdit::onSetDefault()
{
blocked = true;
blocked = false;
setasdefault_button.set_sensitive ( false );
}
{
blocked = true;
unsigned items = 0;
// apply style to the reprs of all text objects in the selection
// backwards compatibility:
reinterpret_cast<SPObject*>(item_list->data)->getRepr()->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
setasdefault_button.set_sensitive ( false );
} else if (items == 1) {
// exactly one text object; now set its text, too
}
}
// complete the transaction
_("Set text style"));
apply_button.set_sensitive ( false );
blocked = false;
}
{
return;
}
if (font) {
} else {
}
if (text) {
//self->onApply();
}
}
{
return;
if (font) {
} else {
}
if (text) {
//self->onApply();
}
}
{
if (blocked)
return;
if (text) {
apply_button.set_sensitive ( true );
//onApply();
}
setasdefault_button.set_sensitive ( true );
}
{
return;
if (text) {
//self->onApply();
}
}
{
}
{
if (this->desktop) {
}
selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &TextEdit::onSelectionChange)));
subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &TextEdit::onSelectionChange)));
selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &TextEdit::onSelectionModified)));
}
//widget_setup();
}
}
} //namespace Dialog
} //namespace UI
} //namespace Inkscape
/*
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:fileencoding=utf-8:textwidth=99 :