]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCharStyle.cpp
Streamlining CollapseStatus stuff
[lyx.git] / src / insets / InsetCharStyle.cpp
index 2b1450d7183eee7f788ba695f03f3b47cacaa009..955d335e34c4dcf3166c04e4e9718a87c9bba04f 100644 (file)
@@ -23,9 +23,9 @@
 #include "Cursor.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
-#include "LColor.h"
+#include "Color.h"
 #include "Lexer.h"
-#include "LyXText.h"
+#include "Text.h"
 #include "MetricsInfo.h"
 #include "Paragraph.h"
 #include "paragraph_funcs.h"
@@ -51,8 +51,6 @@ using std::ostringstream;
 
 void InsetCharStyle::init()
 {
-       setInsetName(from_utf8("CharStyle"));
-       setInlined();
        setDrawFrame(false);
 }
 
@@ -83,9 +81,9 @@ InsetCharStyle::InsetCharStyle(InsetCharStyle const & in)
 }
 
 
-auto_ptr<InsetBase> InsetCharStyle::doClone() const
+auto_ptr<Inset> InsetCharStyle::doClone() const
 {
-       return auto_ptr<InsetBase>(new InsetCharStyle(*this));
+       return auto_ptr<Inset>(new InsetCharStyle(*this));
 }
 
 
@@ -100,9 +98,9 @@ void InsetCharStyle::setUndefined()
        params_.latextype.clear();
        params_.latexname.clear();
        params_.latexparam.clear();
-       params_.font = LyXFont(LyXFont::ALL_INHERIT);
-       params_.labelfont = LyXFont(LyXFont::ALL_INHERIT);
-       params_.labelfont.setColor(LColor::error);
+       params_.font = Font(Font::ALL_INHERIT);
+       params_.labelfont = Font(Font::ALL_INHERIT);
+       params_.labelfont.setColor(Color::error);
        params_.show_label = true;
 }
 
@@ -135,23 +133,22 @@ void InsetCharStyle::read(Buffer const & buf, Lexer & lex)
 {
        params_.read(lex);
        InsetCollapsable::read(buf, lex);
-       setInlined();
 }
 
 
 bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       LyXFont tmpfont = mi.base.font;
+       Font tmpfont = mi.base.font;
        getDrawFont(mi.base.font);
-       mi.base.font.reduce(LyXFont(LyXFont::ALL_SANE));
+       mi.base.font.reduce(Font(Font::ALL_SANE));
        mi.base.font.realize(tmpfont);
        mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
        InsetText::metrics(mi, dim);
        mi.base.font = tmpfont;
        if (params_.show_label) {
                // consider width of the inset label
-               LyXFont font(params_.labelfont);
-               font.realize(LyXFont(LyXFont::ALL_SANE));
+               Font font(params_.labelfont);
+               font.realize(Font(Font::ALL_SANE));
                font.decSize();
                font.decSize();
                int w = 0;
@@ -180,7 +177,7 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
 {
        setPosCache(pi, x, y);
 
-       LyXFont tmpfont = pi.base.font;
+       Font tmpfont = pi.base.font;
        getDrawFont(pi.base.font);
        // I don't understand why the above .reduce and .realize aren't
        //needed, or even wanted, here. It just works. -- MV 10.04.2005
@@ -199,8 +196,8 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
 
        // the name of the charstyle. Can be toggled.
        if (params_.show_label) {
-               LyXFont font(params_.labelfont);
-               font.realize(LyXFont(LyXFont::ALL_SANE));
+               Font font(params_.labelfont);
+               font.realize(Font(Font::ALL_SANE));
                font.decSize();
                font.decSize();
                int w = 0;
@@ -212,7 +209,7 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
                        s = _("Undef: ") + s;
                theFontMetrics(font).rectText(s, w, a, d);
                pi.pain.rectText(x + (dim_.wid - w) / 2, y + desc + a,
-                       s, font, LColor::none, LColor::none);
+                       s, font, Color::none, Color::none);
        }
 
        // a visual clue when the cursor is inside the inset
@@ -229,7 +226,7 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-void InsetCharStyle::getDrawFont(LyXFont & font) const
+void InsetCharStyle::getDrawFont(Font & font) const
 {
        font = params_.font;
 }
@@ -237,14 +234,13 @@ void InsetCharStyle::getDrawFont(LyXFont & font) const
 
 void InsetCharStyle::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
-       setInlined();
        switch (cmd.action) {
-       
-       case LFUN_MOUSE_PRESS:
+
+       case LFUN_MOUSE_RELEASE:
                        if (cmd.button() == mouse_button::button3)
                                params_.show_label = !params_.show_label;
                        else
-                               InsetText::doDispatch(cur, cmd);
+                               InsetCollapsable::doDispatch(cur, cmd);
                        break;
 
        case LFUN_INSET_TOGGLE:
@@ -284,7 +280,7 @@ bool InsetCharStyle::getStatus(Cursor & cur, FuncRequest const & cmd,
 
 
 int InsetCharStyle::latex(Buffer const & buf, odocstream & os,
-                          OutputParams const & runparams) const
+                         OutputParams const & runparams) const
 {
        if (!undefined()) {
                // FIXME UNICODE
@@ -301,23 +297,23 @@ int InsetCharStyle::latex(Buffer const & buf, odocstream & os,
 
 
 int InsetCharStyle::plaintext(Buffer const & buf, odocstream & os,
-                              OutputParams const & runparams) const
+                             OutputParams const & runparams) const
 {
        return InsetText::plaintext(buf, os, runparams);
 }
 
 
 int InsetCharStyle::docbook(Buffer const & buf, odocstream & os,
-                            OutputParams const & runparams) const
+                           OutputParams const & runparams) const
 {
        ParagraphList::const_iterator beg = paragraphs().begin();
        ParagraphList::const_iterator par = paragraphs().begin();
        ParagraphList::const_iterator end = paragraphs().end();
 
        if (!undefined())
-                // FIXME UNICODE
-                sgml::openTag(os, params_.latexname,
-                              par->getID(buf, runparams) + params_.latexparam);
+               // FIXME UNICODE
+               sgml::openTag(os, params_.latexname,
+                             par->getID(buf, runparams) + params_.latexparam);
 
        for (; par != end; ++par) {
                par->simpleDocBookOnePar(buf, os, runparams,