+
+ if (attr.HasLeftIndent())
+ {
+ // Indentation attribute
+
+ // Clear old indentation tags
+ GtkTextIter para_start, para_end = *end;
+ gtk_text_buffer_get_iter_at_line( text_buffer,
+ ¶_start,
+ gtk_text_iter_get_line(start) );
+ gtk_text_iter_forward_line(¶_end);
+
+ wxGtkTextRemoveTagsWithPrefix(text_buffer, "WXINDENT", ¶_start, ¶_end);
+
+ // Convert indent from 1/10th of a mm into pixels
+ float factor =
+ (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
+ gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
+
+ const int indent = (int)(factor * attr.GetLeftIndent());
+ const int subIndent = (int)(factor * attr.GetLeftSubIndent());
+
+ gint gindent;
+ gint gsubindent;
+
+ if (subIndent >= 0)
+ {
+ gindent = indent;
+ gsubindent = -subIndent;
+ }
+ else
+ {
+ gindent = -subIndent;
+ gsubindent = indent;
+ }
+
+ g_snprintf(buf, sizeof(buf), "WXINDENT %d %d", gindent, gsubindent);
+ tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ),
+ buf );
+ if (!tag)
+ tag = gtk_text_buffer_create_tag( text_buffer, buf,
+ "left-margin", gindent, "indent", gsubindent, NULL );
+ gtk_text_buffer_apply_tag (text_buffer, tag, ¶_start, ¶_end);
+ }
+
+ if (attr.HasTabs())
+ {
+ // Set tab stops
+
+ // Clear old tabs
+ GtkTextIter para_start, para_end = *end;
+ gtk_text_buffer_get_iter_at_line( text_buffer,
+ ¶_start,
+ gtk_text_iter_get_line(start) );
+ gtk_text_iter_forward_line(¶_end);
+
+ wxGtkTextRemoveTagsWithPrefix(text_buffer, "WXTABS", ¶_start, ¶_end);
+
+ const wxArrayInt& tabs = attr.GetTabs();
+
+ wxString tagname = wxT("WXTABS");
+ g_snprintf(buf, sizeof(buf), "WXTABS");
+ for (size_t i = 0; i < tabs.GetCount(); i++)
+ tagname += wxString::Format(wxT(" %d"), tabs[i]);
+
+ const wxWX2MBbuf buftag = tagname.utf8_str();
+
+ tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ),
+ buftag );
+ if (!tag)
+ {
+ // Factor to convert from 1/10th of a mm into pixels
+ float factor =
+ (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
+ gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
+
+ PangoTabArray* tabArray = pango_tab_array_new(tabs.GetCount(), TRUE);
+ for (size_t i = 0; i < tabs.GetCount(); i++)
+ pango_tab_array_set_tab(tabArray, i, PANGO_TAB_LEFT, (gint)(tabs[i] * factor));
+ tag = gtk_text_buffer_create_tag( text_buffer, buftag,
+ "tabs", tabArray, NULL );
+ pango_tab_array_free(tabArray);
+ }
+ gtk_text_buffer_apply_tag (text_buffer, tag, ¶_start, ¶_end);
+ }