+Qt::CheckState getMarkupState(lyx::FontState fs)
+{
+ switch (fs) {
+ case FONT_OFF:
+ return Qt::Unchecked;
+ case FONT_ON:
+ return Qt::Checked;
+ case FONT_TOGGLE:
+ case FONT_INHERIT:
+ case FONT_IGNORE:
+ default:
+ return Qt::PartiallyChecked;
+ }
+}
+
+lyx::FontState setMarkupState(Qt::CheckState cs)
+{
+ switch (cs) {
+ case Qt::Unchecked:
+ return FONT_OFF;
+ case Qt::Checked:
+ return FONT_ON;
+ case Qt::PartiallyChecked:
+ default:
+ return FONT_IGNORE;
+ }
+}
+
+} // end namespace anon
+
+
+void GuiCharacter::updateContents()
+{
+ if (bufferview()->cursor().selection()) {
+ Font font = bufferview()->cursor().real_current_font;
+ FontInfo fi = font.fontInfo();
+ BufferParams const & bp = buffer().masterParams();
+
+ // Check if each font attribute is constant for the selection range.
+ DocIterator const from = bufferview()->cursor().selectionBegin();
+ DocIterator const to = bufferview()->cursor().selectionEnd();
+ for (DocIterator dit = from ; dit != to && !dit.atEnd(); ) {
+ if (!dit.inTexted()) {
+ dit.forwardPos();
+ continue;
+ }
+ Paragraph const & par = dit.paragraph();
+ pos_type const pos = dit.pos();
+ Font tmp = par.getFont(bp, pos, font);
+ if (font.language() != tmp.language())
+ font.setLanguage(ignore_language);
+ if (fi.family() != tmp.fontInfo().family())
+ font.fontInfo().setFamily(IGNORE_FAMILY);
+ if (fi.series() != tmp.fontInfo().series())
+ font.fontInfo().setSeries(IGNORE_SERIES);
+ if (fi.shape() != tmp.fontInfo().shape())
+ font.fontInfo().setShape(IGNORE_SHAPE);
+ if (fi.size() != tmp.fontInfo().size())
+ font.fontInfo().setSize(FONT_SIZE_IGNORE);
+ if (fi.emph() != tmp.fontInfo().emph())
+ font.fontInfo().setEmph(FONT_IGNORE);
+ if (fi.noun() != tmp.fontInfo().noun())
+ font.fontInfo().setNoun(FONT_IGNORE);
+ if (fi.color() != tmp.fontInfo().color())
+ font.fontInfo().setColor(Color_ignore);
+ if (fi.underbar() != tmp.fontInfo().underbar()
+ || fi.uuline() != tmp.fontInfo().uuline()
+ || fi.uwave() != tmp.fontInfo().uwave())
+ setBar(font.fontInfo(), IGNORE);
+ if (fi.strikeout() != tmp.fontInfo().strikeout()
+ || fi.xout() != tmp.fontInfo().xout())
+ setStrike(font.fontInfo(), IGNORE);
+ dit.forwardPos();
+ }
+ font_ = font;
+ } else
+ font_ = bufferview()->cursor().real_current_font;
+
+ paramsToDialog(font_);
+}
+
+
+void GuiCharacter::setBar(FontInfo & fi, FontState val)