31#include <boost/range/adaptor/reversed.hpp>
32#include <glibmm/i18n.h>
33#include <gtkmm/adjustment.h>
34#include <gtkmm/button.h>
35#include <gtkmm/checkbutton.h>
36#include <gtkmm/frame.h>
37#include <gtkmm/grid.h>
38#include <gtkmm/listbox.h>
39#include <gtkmm/menubutton.h>
40#include <gtkmm/separator.h>
41#include <gtkmm/togglebutton.h>
82bool is_relative(
Unit const *unit)
84 return unit->
abbr ==
"" || unit->
abbr ==
"em" || unit->
abbr ==
"ex" || unit->
abbr ==
"%";
96 object->changeCSS(
css,
"style");
99 for (
auto i :
object->childList(
false)) {
100 recursively_set_properties(i, unset_descendents ? css_unset :
css);
105Glib::RefPtr<Gtk::ListStore> create_sizes_store_uncached(
int unit)
108 constexpr int sizes[] = {
109 4, 6, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 28,
110 32, 36, 40, 48, 56, 64, 72, 144
114 constexpr float ratios[] = {1, 1, 1, 10, 4, 40, 100, 16, 8, 0.16};
116 struct Columns : Gtk::TreeModelColumnRecord
118 Gtk::TreeModelColumn<Glib::ustring> str;
119 Columns() { add(str); }
121 static Columns
const columns;
123 auto store = Gtk::ListStore::create(columns);
125 for (
int i : sizes) {
135Glib::RefPtr<Gtk::ListStore> create_sizes_store(
int unit)
137 static std::unordered_map<int, Glib::RefPtr<Gtk::ListStore>>
cache;
142 result = create_sizes_store_uncached(unit);
149void sp_text_toolbox_select_cb(Gtk::Entry
const &entry)
151 auto const family = entry.get_buffer()->get_text();
155 std::vector<SPItem *> selectList;
160 for (
auto item : boost::adaptors::reverse(allList)) {
166 Glib::ustring family_style;
167 if (style->font_family.set) {
170 }
else if (style->font_specification.set) {
171 family_style = style->font_specification.value();
175 if (family_style.compare(family) == 0) {
177 selectList.push_back(
item);
185 selection->setList(selectList);
213 _tracker->prependUnit(unit_table.getUnit(
""));
214 _tracker->addUnit(unit_table.getUnit(
"%"));
215 _tracker->addUnit(unit_table.getUnit(
"em"));
216 _tracker->addUnit(unit_table.getUnit(
"ex"));
217 _tracker->setActiveUnit(unit_table.getUnit(
""));
220 _tracker->changeLabel(
"lines", 0,
true);
221 _tracker_fs->setActiveUnit(unit_table.getUnit(
"mm"));
233 {1, _(
"Single spaced")},
234 {1.25, _(
"Default")},
236 2, _(
"Double spaced")}
273 "TextFontFamilyAction",
275 _(
"Select Font Family (Alt-X to access)"),
276 fontlister->get_font_list(),
296 "TextFontStyleAction",
299 fontlister->get_style_list(),
313 int unit = prefs->getInt(
"/options/font/unitType",
SP_CSS_UNIT_PT);
315 auto tooltip = Glib::ustring::format(_(
"Font size"),
" (", unit_str,
")");
318 "TextFontSizeAction",
321 create_sizes_store(unit),
352 _subscript_btn.set_active(prefs->getBool(
"/tools/text/sub",
false));
357 get_widget<Gtk::Popover>(
builder,
"font_collections_popover")
369 get_widget<Gtk::Button>(
builder,
"fc_dialog_btn").signal_clicked().connect([
this]() {
415 auto const path =
"/tools/text/" +
name;
417 auto const adj = btn.get_adjustment();
419 adj->signal_value_changed().connect(sigc::mem_fun(*
this, value_changed_mem_fun));
428 for_each_child(box, [
this, mode_changed_mem_fun, &btn_index, &buttons](Gtk::Widget &
item) {
429 auto &btn =
dynamic_cast<Gtk::ToggleButton &
>(
item);
430 buttons.push_back(&btn);
431 btn.signal_clicked().connect(sigc::bind(sigc::mem_fun(*
this, mode_changed_mem_fun), btn_index++));
437 auto const path =
"/tools/text/" +
name;
439 buttons[active_button_index < buttons.size() ? active_button_index : 0]->set_active(
true);
453 if (is<SPText>(
item) || is<SPFlowtext>(
item)) {
458 double const ex = local.
descrim();
459 if (ex != 0.0 && ex != 1.0) {
462 recursively_set_properties(
item, css_set);
475 std::cout << std::endl;
476 std::cout <<
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" << std::endl;
477 std::cout <<
"sp_text_fontfamily_value_changed: " << std::endl;
483 std::cout <<
"sp_text_fontfamily_value_changed: frozen... return" << std::endl;
484 std::cout <<
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n" << std::endl;
498 std::cout <<
" Old family: " << fontlister->get_font_family() << std::endl;
499 std::cout <<
" New family: " << new_family << std::endl;
500 std::cout <<
" Old active: " << fontlister->get_font_family_row() << std::endl;
503 if (new_family.compare(fontlister->get_font_family()) != 0) {
508 fontlister->insert_font_family(new_family);
519 fontlister->fill_css(
css);
534 std::cout <<
"sp_text_toolbox_fontfamily_changes: exit" << std::endl;
535 std::cout <<
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" << std::endl;
536 std::cout << std::endl;
549 char const *text = active_text.c_str();
551 double size = g_strtod(text, &endptr);
552 if (endptr == text) {
553 g_warning(
"Conversion of size text to double failed, input: %s\n", text);
559 int max_size = prefs->getInt(
"/dialogs/textandfont/maxFontSize", 10000);
561 size = std::min<double>(
size, max_size);
566 int unit = prefs->getInt(
"/options/font/unitType",
SP_CSS_UNIT_PT);
567 if (prefs->getBool(
"/options/font/textOutputPx",
true)) {
578 auto const unit_lh =
_tracker->getActiveUnit();
579 if (!is_relative(unit_lh) &&
_outer) {
607 if (new_style.compare(fontlister->get_font_style()) != 0) {
609 fontlister->set_font_style(new_style);
613 fontlister->fill_css(
css);
640 std::cout <<
"TextToolbar::script_changed: " <<
mode << std::endl;
647 bool setSuper =
false;
668 setSuper = !superscriptSet &&
mode == 0;
669 setSub = !subscriptSet &&
mode == 1;
674 if (setSuper || setSub) {
685 }
else if( setSub ) {
714 for (
auto i : selection->
items()) {
715 auto text = cast<SPText>(i);
733 double width = bbox->dimensions()[axis];
737 double left_slack = 0;
738 double right_slack = 0;
747 move =
width/2 + (right_slack - left_slack)/2;
750 move =
width + right_slack;
756 move = -
width/2 - left_slack;
759 move = (right_slack - left_slack)/2;
762 move =
width/2 + right_slack;
768 move = -
width - left_slack;
771 move = -
width/2 + (right_slack - left_slack)/2;
784 cast<SPText>(
item)->attributes.setFirstXY(XY);
942 auto const unit =
_tracker->getActiveUnit();
950 if (is_relative(unit)) {
954 osfs << Quantity::convert(
_line_height_item.get_adjustment()->get_value(), unit,
"px") <<
"px";
960 auto itemlist = selection->
items();
965 auto parent = itemlist.front();
971 double minheight = 0;
976 for (
auto i :
parent->childList(
false)) {
977 auto child = cast<SPItem>(i);
981 recursively_set_properties(
child, cssfit);
985 parent->changeCSS(cssfit,
"style");
992 itemlist = selection->items();
993 bool modified =
false;
994 for (
auto item : itemlist) {
995 if (is<SPText>(
item) || is<SPFlowtext>(
item)) {
1009 for (
auto item : itemlist) {
1010 if (is<SPText>(
item) || is<SPFlowtext>(
item)) {
1058 auto const unit =
_tracker->getActiveUnit();
1063 temp_stream << 1 << unit->abbr;
1064 temp_length.
read(temp_stream.
str().c_str());
1066 if (old_unit == temp_length.
unit) {
1075 double line_height = line_height_adj->get_value();
1078 auto itemlist = selection->
items();
1081 double font_size = 0;
1082 double doc_scale = 1;
1085 for (
auto item : itemlist) {
1086 if (is<SPText>(
item) || is<SPFlowtext>(
item)) {
1100 }
else if ((unit->abbr ==
"" || unit->abbr ==
"em") && old_unit ==
SP_CSS_UNIT_EX) {
1105 line_height /= 100.0;
1109 line_height /= 50.0;
1112 }
else if (is_relative(unit)) {
1117 if (font_size > 0) {
1118 line_height /= font_size;
1120 if (unit->abbr ==
"%") {
1122 }
else if (unit->abbr ==
"ex") {
1129 line_height /= 100.0;
1133 line_height *= font_size;
1134 line_height = Quantity::convert(line_height,
"px", unit);
1143 if ( is_relative(unit) ) {
1144 osfs << line_height << unit->abbr;
1146 osfs << Quantity::convert(line_height, unit,
"px") <<
"px";
1151 line_height_adj->set_value(line_height);
1153 if (unit->abbr ==
"%") {
1154 line_height_adj->set_step_increment(1.0);
1155 line_height_adj->set_page_increment(10.0);
1157 line_height_adj->set_step_increment(0.1);
1158 line_height_adj->set_page_increment(1.0);
1161 SPItem *
parent = itemlist.empty() ? nullptr : itemlist.front();
1162 SPStyle *parent_style =
nullptr;
1164 parent_style =
parent->style;
1166 bool inside =
false;
1169 for (
auto item : itemlist) {
1170 if (is<SPText>(
item) || is<SPFlowtext>(
item)) {
1175 double const ex = local.
descrim();
1176 if (ex != 0.0 && ex != 1.0) {
1179 recursively_set_properties(
item, css_set);
1192 double minheight = 0;
1198 if (is<SPItem>(
child)) {
1199 recursively_set_properties(
child, cssfit);
1204 parent->changeCSS(cssfit,
"style");
1210 itemlist = selection->
items();
1212 bool modified =
false;
1213 for (
auto item : itemlist) {
1214 if (is<SPText>(
item) || is<SPFlowtext>(
item)) {
1227 for (
auto item : itemlist) {
1228 if (is<SPText>(
item) || is<SPFlowtext>(
item)) {
1253 temp_size_stream << 1 << unit->abbr;
1254 temp_size.
read(temp_size_stream.
str().c_str());
1316 double new_dx =
_dx_item.get_adjustment()->get_value();
1317 bool modified =
false;
1320 unsigned char_index = -1;
1322 double old_dx = attributes->getDx(char_index);
1323 double delta_dx = new_dx - old_dx;
1344 double new_dy =
_dy_item.get_adjustment()->get_value();
1345 bool modified =
false;
1348 unsigned char_index = -1;
1350 double old_dy = attributes->getDy(char_index);
1351 double delta_dy = new_dy - old_dy;
1372 double new_degrees =
_rotation_item.get_adjustment()->get_value();
1374 bool modified =
false;
1376 unsigned char_index = -1;
1378 double old_degrees = attributes->getRotate(char_index);
1379 double delta_deg = new_degrees - old_degrees;
1394 static int count = 0;
1398 std::cout << std::endl;
1399 std::cout <<
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
1400 std::cout <<
"sp_text_toolbox_selection_changed: start " << count << std::endl;
1406 std::cout <<
" Frozen, returning" << std::endl;
1407 std::cout <<
"sp_text_toolbox_selection_changed: exit " << count << std::endl;
1408 std::cout <<
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
1409 std::cout << std::endl;
1419 auto itemlist = selection->
items();
1422 for (
auto i : itemlist) {
1423 std::cout <<
" " << i->getId() << std::endl;
1426 auto const selected_text = get_selected_text(*text_tool);
1427 std::cout <<
" Selected text: |" << selected_text <<
"|" << std::endl;
1433 bool isFlow =
false;
1434 std::vector<SPItem *> to_work;
1435 for (
auto i : itemlist) {
1436 auto text = cast<SPText>(i);
1437 auto flowtext = cast<SPFlowtext>(i);
1438 if (text || flowtext) {
1439 to_work.push_back(i);
1442 (text && text->style && text->style->shape_inside.set)) {
1446 bool outside =
false;
1447 if (selection && to_work.empty()) {
1452 fontlister->selection_update();
1465 SPStyle query_fallback(document);
1476 int result_numbers = 0;
1477 int result_numbers_fallback = 0;
1504 if (prefs->getBool(
"/tools/text/usecurrent")) {
1511 std::cout <<
" read style from prefs:" << std::endl;
1512 std::cout <<
" Family set? " << query.
font_family.set
1521 std::cout <<
" text_style_from_prefs: toolbar already set" << std:: endl;
1522 std::cout <<
"sp_text_toolbox_selection_changed: exit " << count << std::endl;
1523 std::cout <<
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
1524 std::cout << std::endl;
1540 int unit = prefs->getInt(
"/options/font/unitType",
SP_CSS_UNIT_PT);
1556 Glib::ustring tooltip = Glib::ustring::format(_(
"Font size"),
" (", unit_str,
")");
1564 int rounded_size = std::round(
size);
1565 if (std::abs((
size - rounded_size)/
size) < 0.0001) {
1582 bool superscriptSet =
1608 int activeButton = 0;
1621 gint line_height_unit = 0;
1635 line_height_unit = query_fallback.
line_height.unit;
1648 if (!is_relative(
SPCSSUnit(line_height_unit))) {
1649 int curunit = prefs->getInt(
"/tools/text/lineheight/display_unit", 1);
1652 prefs->setInt(
"/tools/text/lineheight/display_unit", 1);
1656 line_height_unit = curunit;
1659 line_height_adj->set_value(
height);
1663 line_height_adj->set_step_increment(1.0);
1664 line_height_adj->set_page_increment(10.0);
1666 line_height_adj->set_step_increment(0.1);
1667 line_height_adj->set_page_increment(1.0);
1691 double letterSpacing;
1693 letterSpacing = 0.0;
1701 int activeButton2 = 0;
1709 int activeButton3 = 0;
1718 btn->set_sensitive(activeButton2 != 0);
1722 int activeButton4 = 0;
1729 std::cout <<
" GUI: fontfamily.value: " << query.
font_family.value() << std::endl;
1730 std::cout <<
" GUI: font_size.computed: " << query.
font_size.computed << std::endl;
1731 std::cout <<
" GUI: font_weight.computed: " << query.
font_weight.computed << std::endl;
1732 std::cout <<
" GUI: font_style.computed: " << query.
font_style.computed << std::endl;
1733 std::cout <<
" GUI: text_anchor.computed: " << query.
text_anchor.computed << std::endl;
1734 std::cout <<
" GUI: text_align.computed: " << query.
text_align.computed << std::endl;
1735 std::cout <<
" GUI: line_height.computed: " << query.
line_height.computed
1736 <<
" line_height.value: " << query.
line_height.value
1737 <<
" line_height.unit: " << query.
line_height.unit << std::endl;
1738 std::cout <<
" GUI: word_spacing.computed: " << query.
word_spacing.computed
1740 <<
" word_spacing.unit: " << query.
word_spacing.unit << std::endl;
1741 std::cout <<
" GUI: letter_spacing.computed: " << query.
letter_spacing.computed
1743 <<
" letter_spacing.unit: " << query.
letter_spacing.unit << std::endl;
1744 std::cout <<
" GUI: writing_mode.computed: " << query.
writing_mode.computed << std::endl;
1749 unsigned char_index = -1;
1752 double dx = attributes->getDx(char_index);
1753 _dx_item.get_adjustment()->set_value(dx);
1756 double dy = attributes->getDy(char_index);
1757 _dy_item.get_adjustment()->set_value(dy);
1760 double rotation = attributes->getRotate(char_index);
1762 if (rotation > 180.0) {
1768 std::cout <<
" GUI: Dx: " << dx << std::endl;
1769 std::cout <<
" GUI: Dy: " << dy << std::endl;
1770 std::cout <<
" GUI: Rotation: " << rotation << std::endl;
1781 std::cout <<
"sp_text_toolbox_selection_changed: exit " << count << std::endl;
1782 std::cout <<
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
1783 std::cout << std::endl;
1801 std::swap(tc->text_sel_end,
wrap_end);
1832 auto spobject = tc->textItem();
1833 auto spitem = tc->textItem();
1834 auto text = cast<SPText>(tc->textItem());
1835 auto flowtext = cast<SPFlowtext>(tc->textItem());
1844 bool changed =
false;
1845 std::vector<SPObject *> childs = spitem->childList(
false);
1846 for (
auto child : childs) {
1847 auto spstring = cast<SPString>(
child);
1849 Glib::ustring content = spstring->string;
1850 if (content !=
"\n") {
1855 rtspan->
addChild(rstring,
nullptr);
1856 text->getRepr()->addChild(rtspan,
child->getRepr());
1859 text->getRepr()->removeChild(spstring->getRepr());
1867 text->rebuildLayout();
1871 std::vector<SPObject *> containers;
1879 text->hide_shape_inside();
1880 }
else if (flowtext) {
1881 flowtext->fix_overflow_flowregion(
false);
1886 layout->validateIterator(&
wrap_end);
1887 layout->getSourceOfCharacter(
wrap_start, &rawptr_start);
1888 layout->getSourceOfCharacter(
wrap_end, &rawptr_end);
1890 text->show_shape_inside();
1891 }
else if (flowtext) {
1892 flowtext->fix_overflow_flowregion(
true);
1894 if (!rawptr_start || !rawptr_end) {
1903 while (
start->parent != spobject) {
1906 while (
end->parent != spobject) {
1911 containers.push_back(
start);
1915 containers.push_back(
start);
1919 for (
auto container : containers) {
1920 XML::Node *prevchild = container->getRepr();
1921 std::vector<SPObject*> childs = container->childList(
false);
1922 for (
auto child : childs) {
1923 auto spstring = cast<SPString>(
child);
1924 auto flowtspan = cast<SPFlowtspan>(
child);
1925 auto tspan = cast<SPTSpan>(
child);
1930 std::vector<SPObject*> fts_childs = flowtspan->childList(
false);
1931 bool hascontent =
false;
1935 for (
auto fts_child : fts_childs) {
1939 flowtspan->getRepr()->
removeChild(fts_child->getRepr());
1940 flowpara->
addChild(fts_child_node,
nullptr);
1947 flowpara->
setAttribute(
"style", flowtspan->getRepr()->attribute(
"style"));
1948 spobject->getRepr()->addChild(flowpara, prevchild);
1950 prevchild = flowpara;
1952 container->getRepr()->
removeChild(flowtspan->getRepr());
1954 if (
child->childList(
false).size()) {
1955 child->getRepr()->setAttribute(
"sodipodi:role",
"line");
1961 container->getRepr()->removeChild(
child->getRepr());
1963 }
else if (spstring) {
1970 tspan_node->
setAttribute(
"style", container->getRepr()->attribute(
"style"));
1971 tspan_node->
addChild(string_node,
nullptr);
1973 text->getRepr()->addChild(tspan_node, prevchild);
1976 prevchild = tspan_node;
1977 }
else if (flowtext) {
1979 flowpara_node->
setAttribute(
"style", container->getRepr()->attribute(
"style"));
1980 flowpara_node->
addChild(string_node,
nullptr);
1981 flowtext->getRepr()->addChild(flowpara_node, prevchild);
1984 prevchild = flowpara_node;
1986 container->getRepr()->
removeChild(spstring->getRepr());
1989 tc->textItem()->getRepr()->removeChild(container->getRepr());
1995 g_assert(repr !=
nullptr);
2005 grandparent->
addChild(newrepr, prevchild);
2011 std::cerr <<
"TextToolbar::unindent_node error: node has no (grand)parent, nothing done.\n";
2022 for(
auto const &col: font_collections->get_collections(
true)) {
2023 auto const btn = Gtk::make_managed<Gtk::CheckButton>(col);
2024 btn->set_margin_bottom(2);
2025 btn->set_active(font_collections->is_collection_selected(col));
2026 btn->signal_toggled().connect([font_collections, col](){
2028 font_collections->update_selected_collections(col);
2031 auto const row = Gtk::make_managed<Gtk::ListBoxRow>();
2032 row->set_focusable(
false);
2033 row->set_child(*btn);
2038 auto const sep = Gtk::make_managed<Gtk::Separator>();
2039 sep->set_margin_bottom(2);
2040 auto const sep_row = Gtk::make_managed<Gtk::ListBoxRow>();
2041 sep_row->set_focusable(
false);
2042 sep_row->set_child(*sep);
2046 for (
auto const& col: font_collections->get_collections()) {
2047 auto const btn = Gtk::make_managed<Gtk::CheckButton>(col);
2048 btn->set_margin_bottom(2);
2049 btn->set_active(font_collections->is_collection_selected(col));
2050 btn->signal_toggled().connect([font_collections, col](){
2052 font_collections->update_selected_collections(col);
2055 auto const row = Gtk::make_managed<Gtk::ListBoxRow>();
2056 row->set_focusable(
false);
2057 row->set_child(*btn);
2066 container->new_floating_dialog(
"FontCollections");
2074 font_collections->clear_selected_collections();
2077 font_lister->init_font_families();
2078 font_lister->init_default_styles();
2081 font_lister->add_document_fonts_at_top(document);
2087 std::cout << std::endl;
2088 std::cout <<
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
2089 std::cout <<
"subselection_changed: start " << std::endl;
2106 std::cout <<
" GUI: Start of selection: " << layout->
iteratorToCharIndex(start_selection) << std::endl;
2107 std::cout <<
" GUI: End of selection: " << layout->
iteratorToCharIndex(end_selection) << std::endl;
2108 std::cout <<
" GUI: Loop Subelements: " << std::endl;
2109 std::cout <<
" ::::::::::::::::::::::::::::::::::::::::::::: " << std::endl;
2112 if (start_selection == end_selection) {
2145 }
else if ((start_selection ==
start && end_selection ==
end) ||
2146 (start_selection ==
end && end_selection ==
start)) {
2168 std::cout <<
"subselection_changed: exit " << std::endl;
2169 std::cout <<
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
2170 std::cout << std::endl;
3x3 matrix representing an affine transformation.
Coord descrim() const
Calculate the descriminant.
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
A thin wrapper around std::ostringstream, but writing floating point numbers in the format required b...
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
static void maybeDone(SPDocument *document, const gchar *keyconst, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
static FontCollections * get()
std::pair< bool, std::string > get_font_count_label() const
static Inkscape::FontLister * get_instance()
SPItemRange items()
Returns a range of selected SPItems.
void clear()
Unselects all selected objects.
SPItem * singleItem()
Returns a single selected item.
double getDouble(Glib::ustring const &pref_path, double def=0.0, Glib::ustring const &unit="")
Retrieve a floating point value.
static Preferences * get()
Access the singleton Preferences object.
int getInt(Glib::ustring const &pref_path, int def=0)
Retrieve an integer.
void setInt(Glib::ustring const &pref_path, int value)
Set an integer value.
void mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style)
Merge a CSS style with the current preference value.
The set of selected SPObjects for a given document and layer model.
sigc::connection connectChangedFirst(sigc::slot< void(Selection *)> slot)
Similar to connectChanged, but will be run first.
Holds a position within the glyph output of Layout.
Generates the layout for either wrapped or non-wrapped text and stores the result.
iterator charIndexToIterator(int char_index) const
Returns an iterator pointing at the given character index.
int iteratorToCharIndex(iterator const &it) const
Returns the character index from the start of the flow represented by the given iterator.
iterator end() const
Returns an iterator pointing just past the end of the last glyph, which is also just past the end of ...
unsigned paragraphIndex(iterator const &it) const
Returns the zero-based number of the paragraph containing the character pointed to by it.
iterator begin() const
Returns an iterator pointing at the first glyph of the flowed output.
sigc::connection _selection_changed_conn
std::unique_ptr< UI::Widget::UnitTracker > _tracker
void direction_changed(int mode)
void wordspacing_value_changed()
void fontfamily_value_changed()
std::vector< Gtk::ToggleButton * > _writing_buttons
void rotation_value_changed()
void setup_derived_spin_button(UI::Widget::SpinButton &btn, Glib::ustring const &name, double default_value, ValueChangedMemFun value_changed_mem_fun)
XML::Node * unindent_node(XML::Node *repr, XML::Node *before)
void on_fcm_button_pressed()
void script_changed(int mode)
void(TextToolbar::*)() ValueChangedMemFun
bool _text_style_from_prefs
void display_font_collections()
UI::Widget::ComboBoxEntryToolItem * _font_style_item
void on_reset_button_pressed()
void writing_mode_changed(int mode)
UI::Widget::ComboBoxEntryToolItem * _font_size_item
void fontsize_unit_changed(int not_used)
void lineheight_unit_changed(int not_used)
Gtk::Button & _reset_button
Text::Layout::iterator wrap_start
void configure_mode_buttons(std::vector< Gtk::ToggleButton * > &buttons, Gtk::Box &box, Glib::ustring const &name, ModeChangedMemFun mode_changed_mem_fun)
double selection_fontsize
void orientation_changed(int mode)
UI::Widget::SpinButton & _dx_item
void setDesktop(SPDesktop *desktop) override
void subselection_wrap_toggle(bool start)
void _selectionChanged(Selection *selection)
Gtk::ToggleButton & _superscript_btn
void text_outer_set_style(SPCSSAttr *css)
SPItem * _sub_active_item
std::vector< Gtk::ToggleButton * > _direction_buttons
std::unique_ptr< UI::Widget::UnitTracker > _tracker_fs
std::vector< Gtk::ToggleButton * > _alignment_buttons
Gtk::ToggleButton & _subscript_btn
Gtk::ListBox & _font_collections_list
sigc::scoped_connection font_count_changed_connection
Text::Layout::iterator wrap_end
void fontstyle_value_changed()
void align_mode_changed(int mode)
sigc::scoped_connection fc_update
UI::Widget::SpinButton & _rotation_item
bool mergeDefaultStyle(SPCSSAttr *css)
Merge the style into either the tool or the desktop style depending on which one the user has decided...
void fontsize_value_changed()
void _cursorMoved(Tools::TextTool *texttool)
UI::Widget::SpinButton & _letter_spacing_item
sigc::connection _selection_modified_conn
UI::Widget::ComboToolItem * _line_height_units_item
sigc::connection _cursor_moved_conn
sigc::connection _fonts_updated_conn
void _selectionModified(Selection *selection, guint flags)
UI::Widget::SpinButton & _line_height_item
UI::Widget::SpinButton & _dy_item
void letterspacing_value_changed()
UI::Widget::SpinButton & _word_spacing_item
void(TextToolbar::*)(int) ModeChangedMemFun
sigc::scoped_connection fc_changed_selection
UI::Widget::ComboBoxEntryToolItem * _font_family_item
std::vector< Gtk::ToggleButton * > _orientation_buttons
UI::Widget::ComboToolItem * _font_size_units_item
void lineheight_value_changed()
Text::Layout::iterator text_sel_end
SPItem * textItem() const
Text::Layout::iterator text_sel_start
Formerly a Gtk::ToolItem that wraps a Gtk::ComboBox object.
void set_warning(Glib::ustring warning_cb)
bool set_active_text(Glib::ustring text, int row=-1)
void set_model(Glib::RefPtr< Gtk::TreeModel > model)
sigc::connection connectChanged(sigc::slot< void()> &&slot)
Glib::ustring const & get_active_text() const
void set_active(int active)
void setDefocusWidget(Gtk::Widget *widget)
void set_info_cb(InfoCallback info_cb)
void set_tooltip(Glib::ustring const &tooltip)
void set_warning_cb(InfoCallback warning)
void set_info(Glib::ustring info)
void focus_on_click(bool focus_on_click)
Interface for refcounted XML nodes.
virtual Node * parent()=0
Get the parent of this node.
virtual void addChild(Node *child, Node *after)=0
Insert another node as a child of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual Node * duplicate(Document *doc) const =0
Create a duplicate of this node.
virtual void removeChild(Node *child)=0
Remove a child of this node.
To do: update description of desktop.
SPDocument * getDocument() const
Inkscape::UI::Dialog::DialogContainer * getContainer()
Inkscape::Selection * getSelection() const
sigc::connection connect_text_cursor_moved(sigc::slot< void(Inkscape::UI::Tools::TextTool *)> const &slot)
Inkscape::UI::Tools::ToolBase * getTool() const
Typed SVG document implementation.
SPRoot * getRoot()
Returns our SPRoot.
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
int ensureUpToDate(unsigned int object_modified_tag=0)
Repeatedly works on getting the document updated, since sometimes it takes more than one pass to get ...
Length type internal to SPStyle.
void read(gchar const *str) override
Base class for visual SVG elements.
Geom::Affine i2dt_affine() const
Returns the transformation from item to desktop coords.
Geom::OptRect geometricBounds(Geom::Affine const &transform=Geom::identity()) const
Get item's geometric bounding box in this item's coordinate system.
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
std::vector< SPObject * > childList(bool add_ref, Action action=ActionGeneral)
Retrieves the children as a std vector object, optionally ref'ing the children in the process,...
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
void mergeCSS(SPCSSAttr *css)
T< SPAttr::FONT_WEIGHT, SPIEnum< SPCSSFontWeight > > font_weight
Weight of the font.
T< SPAttr::LINE_HEIGHT, SPILengthOrNormal > line_height
Line height (css2 10.8.1)
T< SPAttr::LETTER_SPACING, SPILengthOrNormal > letter_spacing
letter spacing (css2 16.4)
T< SPAttr::FONT_FAMILY, SPIString > font_family
Font family.
T< SPAttr::INKSCAPE_FONT_SPEC, SPIString > font_specification
Full font name, as FontFactory::ConstructFontSpecification would give, for internal use.
T< SPAttr::DIRECTION, SPIEnum< SPCSSDirection > > direction
text direction (svg1.1)
T< SPAttr::FONT_STYLE, SPIEnum< SPCSSFontStyle > > font_style
Font style.
T< SPAttr::WORD_SPACING, SPILengthOrNormal > word_spacing
word spacing (also css2 16.4)
T< SPAttr::TEXT_ALIGN, SPIEnum< SPCSSTextAlign > > text_align
text alignment (css2 16.2) (not to be confused with text-anchor)
T< SPAttr::TEXT_ANCHOR, SPIEnum< SPTextAnchor > > text_anchor
Anchor of the text (svg1.1 10.9.1)
T< SPAttr::WRITING_MODE, SPIEnum< SPCSSWritingMode > > writing_mode
Writing mode (svg1.1 10.7.2, CSS Writing Modes 3)
void readFromPrefs(Glib::ustring const &path)
Read style properties from preferences.
T< SPAttr::TEXT_ORIENTATION, SPIEnum< SPCSSTextOrientation > > text_orientation
Text orientation (CSS Writing Modes 3)
T< SPAttr::FONT_SIZE, SPIFontSize > font_size
Size of the font.
T< SPAttr::BASELINE_SHIFT, SPIBaselineShift > baseline_shift
Baseline shift (svg1.1 10.9.2)
TODO: insert short description here.
std::shared_ptr< Css const > css
void sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current, bool switch_style)
Apply style on selection on desktop.
int objects_query_fontnumbers(const std::vector< SPItem * > &objects, SPStyle *style_res)
Write to style_res the average font size and spacing of objects.
SPCSSAttr * sp_desktop_get_style(SPDesktop *desktop, bool with_text)
Return the desktop's current style.
int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
Query the subselection (if any) or selection on the given desktop for the given property,...
@ QUERY_STYLE_PROPERTY_FONTNUMBERS
@ QUERY_STYLE_PROPERTY_BASELINES
@ QUERY_STYLE_PROPERTY_FONTSTYLE
@ QUERY_STYLE_PROPERTY_FONTFAMILY
@ QUERY_STYLE_PROPERTY_WRITINGMODES
@ QUERY_STYLE_MULTIPLE_SAME
Editable view implementation.
A widget that manages DialogNotebook's and other widgets inside a horizontal DialogMultipaned.
static char const *const parent
TODO: insert short description here.
bool font_lister_separator_func(Glib::RefPtr< Gtk::TreeModel > const &, Gtk::TreeModel::const_iterator const &iter)
void font_lister_cell_data_func2(Gtk::CellRenderer &cell, Gtk::TreeModel::const_iterator const &iter, bool with_markup)
Dim2
2D axis enumeration (X or Y).
Macro for icon names used in Inkscape.
static R & release(R &r)
Decrements the reference count of a anchored object.
void remove_all_children(Widget &widget)
For each child in get_children(widget), call widget.remove(*child). May not cause delete child!
W & get_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id)
Gtk::Widget * for_each_child(Gtk::Widget &widget, Func &&func, bool const plus_self=false, bool const recurse=false, int const level=0)
Call Func with a reference to each child of parent, until it returns _break.
W & get_derived_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id, Args &&... args)
Glib::RefPtr< Gtk::Builder > create_builder(const char *filename)
Miscellaneous supporting code.
Glib::ustring format_classic(T const &... args)
bool is_query_style_updateable(const int style)
SPCSSAttr * sp_repr_css_attr_new()
Creates an empty SPCSSAttr (a class for manipulating CSS style properties).
void sp_repr_css_merge(SPCSSAttr *dst, SPCSSAttr *src)
Merges two SPCSSAttr's.
void sp_repr_css_attr_unref(SPCSSAttr *css)
Unreferences an SPCSSAttr (will be garbage collected if no references remain).
char const * sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const *defval)
Returns a character string of the value of a given style property or a default value if the attribute...
SPCSSAttr * sp_repr_css_attr_unset_all(SPCSSAttr *css)
Return a new SPCSSAttr with all the properties found in the input SPCSSAttr unset.
void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
Set a style property to a new value (e.g.
std::vector< SPItem * > get_all_items(SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector< SPItem * > const &exclude)
TODO: insert short description here.
TODO: insert short description here.
SPRoot: SVG <svg> implementation.
TODO: insert short description here.
TODO: insert short description here.
Interface for XML documents.
virtual Node * createTextNode(char const *content)=0
virtual Node * createElement(char const *name)=0
@ SP_CSS_BASELINE_SHIFT_SUPER
@ SP_CSS_BASELINE_SHIFT_SUB
@ SP_CSS_TEXT_ALIGN_RIGHT
@ SP_CSS_TEXT_ALIGN_CENTER
@ SP_CSS_TEXT_ALIGN_START
@ SP_CSS_TEXT_ALIGN_JUSTIFY
@ SP_CSS_WRITING_MODE_TB_RL
@ SP_CSS_WRITING_MODE_LR_TB
@ SP_CSS_WRITING_MODE_TB_LR
@ SP_CSS_WRITING_MODE_RL_TB
@ SP_CSS_TEXT_ORIENTATION_SIDEWAYS
@ SP_CSS_TEXT_ORIENTATION_UPRIGHT
@ SP_CSS_TEXT_ORIENTATION_MIXED
static const unsigned SP_STYLE_FLAG_IFSET(1<< 0)
@ SP_BASELINE_SHIFT_LITERAL
Common utility functions for manipulating style.
void css_font_family_unquote(Glib::ustring &val)
Remove paired single and double quotes from font names in font-family lists, changing string in place...
SPCSSAttr * sp_css_attr_scale(SPCSSAttr *css, double ex)
Scale any properties that may hold <length> by ex.
double sp_style_css_size_px_to_units(double size, int unit, double font_size)
double sp_style_css_size_units_to_px(double size, int unit, double font_size)
SPCSSAttr * sp_css_attr_from_style(SPStyle const *const style, guint const flags)
gchar const * sp_style_get_css_unit_string(int unit)
void sp_te_adjust_rotation(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *, gdouble degrees)
void sp_te_adjust_dx(SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *, double delta)
TextTagAttributes * text_tag_attributes_at_position(SPItem *item, Inkscape::Text::Layout::iterator const &position, unsigned *char_index)
Returns the attributes block and the character index within that block which represents the iterator ...
void sp_te_adjust_dy(SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *, double delta)
Inkscape::Text::Layout const * te_get_layout(SPItem const *item)
auto SP_TEXT_CONTEXT(Inkscape::UI::Tools::ToolBase *tool)
constexpr bool DEBUG_TEXT
Glib::RefPtr< Gtk::Builder > builder