text-edit.cpp revision c569e825f7ace90f49190d896197a19729a8955e
/**
* @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
* Tavmjong Bah
*
* Copyright (C) 1999-2013 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-lister.h>
#include "macros.h"
#include "inkscape.h"
#include "document.h"
#include "desktop.h"
#include "desktop-style.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 "ui/interface.h"
#include "svg/css-ostringstream.h"
#include "widgets/font-selector.h"
#include "sp-textpath.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
font_label(_("_Font"), true),
layout_frame(),
text_label(_("_Text"), true),
vari_label(_("_Variants"), 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 */
styleButton(&align_justify, _("Justify (only flowed text)"), INKSCAPE_ICON("format-justify-fill"), &align_left);
#if WITH_GTKMM_3_0
#endif
/* 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);
#if WITH_GTKMM_3_0
#endif
/* Line Spacing */
GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("text_line_spacing") );
const gchar *spacings[] = {"50%", "80%", "90%", "100%", "110%", "120%", "130%", "140%", "150%", "200%", "300%", NULL};
for (int i = 0; spacings[i]; i++) {
}
// Text start Offset
{
const gchar *spacings[] = {"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%", NULL};
for (int i = 0; spacings[i]; i++) {
}
gtk_entry_set_text(reinterpret_cast<GtkEntry *>(gtk_bin_get_child(reinterpret_cast<GtkBin *>(startOffset))), "0%");
#if WITH_GTKMM_3_0
#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) {
if (SP_IS_TEXT_TEXTPATH(text)) {
gtk_entry_set_text(reinterpret_cast<GtkEntry *>(gtk_bin_get_child(reinterpret_cast<GtkBin *>(startOffset))), tp->getAttribute("startOffset"));
}
}
} 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
// This is normally done for us by text-toolbar but only when we are in text editing context
} else {
}
} else {
}
} else {
}
double height;
// Update font variant widget
//int result_variants =
}
blocked = false;
}
{
return;
}
double pt_size = Inkscape::Util::Quantity::convert(sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit), "px", "pt");
// Pango font size is in 1024ths of a point
// C++11: Glib::ustring size = std::to_string( int(pt_size * PANGO_SCALE) );
}
{
if (!SP_ACTIVE_DESKTOP)
return NULL;
{
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i))
return *i;
}
return NULL;
}
unsigned TextEdit::getSelectedTextCount (void)
{
if (!SP_ACTIVE_DESKTOP)
return 0;
unsigned int items = 0;
{
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i))
++items;
}
return items;
}
void TextEdit::onSelectionChange()
{
}
{
// write text
if (gtk_text_buffer_get_modified (text_buffer)) {
}
}
{
// TODO, possibly move this to FontLister::set_css to be shared.
os << sp_style_css_size_units_to_px(sp_font_selector_get_size (fsel), unit) << sp_style_get_css_unit_string(SP_CSS_UNIT_PX);
} else {
}
}
// 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 SVG 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
// Font variants
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
if (SP_IS_TEXT (*i)) {
// backwards compatibility:
(*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
++items;
}
else if (SP_IS_FLOWTEXT (*i))
// 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
}
}
// Update FontLister
}
// complete the transaction
_("Set text style"));
apply_button.set_sensitive ( false );
blocked = false;
}
{
return;
}
} else {
}
if (text) {
//self->onApply();
}
}
{
return;
if (fontspec) {
} else {
}
if (text) {
//self->onApply();
}
}
{
{
const gchar *sstr = gtk_combo_box_text_get_active_text(reinterpret_cast<GtkComboBoxText *>(self->startOffset));
DocumentUndo::maybeDone(SP_ACTIVE_DESKTOP->getDocument(), "startOffset", SP_VERB_CONTEXT_TEXT, _("Set text style"));
}
}
{
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 :