]> git.lyx.org Git - lyx.git/commitdiff
This should be the last of the commits refactoring the InsetLayout code.
authorRichard Heck <rgheck@comcast.net>
Fri, 22 Feb 2008 16:15:21 +0000 (16:15 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 22 Feb 2008 16:15:21 +0000 (16:15 +0000)
This one just moves the Decoration enum into InsetLayout, changing the names
to avoid possible conflicts now that it is in the lyx namespace.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23135 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetBranch.cpp
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetERT.cpp
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h
src/insets/InsetListings.cpp

index f0efce791a34b5f362904900dbb5836d1843bbbd..a3eb164d90cebef3d34c27be690e5ab67bdce3ac 100644 (file)
@@ -92,7 +92,7 @@ void InsetBranch::setButtonLabel()
                        s = _("Undef: ") + s;
                }
        }
-       if (decoration() == Classic)
+       if (decoration() == Deco_Classic)
                setLabel(isOpen() ? s : getNewLabel(s) );
        else
                setLabel(params_.branch + ": " + getNewLabel(s));
index b979c9a251886fc0c08c3842daba650776f60f97..6135a63545e69494301a66ba7928e58729a98007 100644 (file)
@@ -52,7 +52,7 @@ InsetCollapsable::CollapseStatus InsetCollapsable::status() const
 InsetCollapsable::Geometry InsetCollapsable::geometry() const
 {
        switch (decoration()) {
-       case Classic:
+       case Deco_Classic:
                if (status() == Open) {
                        if (openinlined_)
                                return LeftButton;
@@ -61,11 +61,14 @@ InsetCollapsable::Geometry InsetCollapsable::geometry() const
                } else
                        return ButtonOnly;
 
-       case Minimalistic:
+       case Deco_Minimalistic:
                return status() == Open ? NoButton : ButtonOnly ;
 
-       case Conglomerate:
+       case Deco_Conglomerate:
                return status() == Open ? SubLabel : Corners ;
+
+       case Deco_Default:
+               break; // this shouldn't happen
        }
 
        // dummy return value to shut down a warning,
@@ -533,7 +536,7 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3) {
                        // There is no button to right click:
-                       if (decoration() == Minimalistic ||
+                       if (decoration() == Deco_Minimalistic ||
                            geometry() == Corners ||
                            geometry() == SubLabel ||
                            geometry() == NoButton
@@ -798,18 +801,23 @@ docstring InsetCollapsable::floatName(string const & type, BufferParams const &
 }
 
 
-InsetCollapsable::Decoration InsetCollapsable::decoration() const
+InsetDecoration InsetCollapsable::decoration() const
 {
-       if (!layout_ || layout_->decoration() == "classic")
-               return Classic;
-       if (layout_->decoration() == "minimalistic")
-               return Minimalistic;
-       if (layout_->decoration() == "conglomerate")
-               return Conglomerate;
+       if (!layout_)
+               return Deco_Classic;
+       InsetDecoration const dec = layout_->decoration();
+       switch (dec) {
+       case Deco_Classic:
+       case Deco_Minimalistic:
+       case Deco_Conglomerate:
+               return dec;
+       case Deco_Default:
+               break;
+       }
        if (lyxCode() == FLEX_CODE)
                // FIXME: Is this really necessary?
-               return Conglomerate;
-       return Classic;
+               return Deco_Conglomerate;
+       return Deco_Classic;
 }
 
 
index 22ca612f3ba32d021aa3a00099b88796a3173374..57a089858d1eda392d57ba68629c431ca7f940a0 100644 (file)
@@ -117,14 +117,8 @@ public:
         *   x) toggled by autoOpen_
         */
 
-       ///
-       enum Decoration {
-               Classic,
-               Minimalistic,
-               Conglomerate
-       };
        /// Default looks
-       virtual Decoration decoration() const;
+       virtual InsetDecoration decoration() const;
        ///
        enum Geometry {
                TopButton,
index 76402d0d9d2715c9af5b26afab8156f152484f68..b509ae5874a451a85d11e8a4182482f47dde45a8 100644 (file)
@@ -189,7 +189,7 @@ bool InsetERT::getStatus(Cursor & cur, FuncRequest const & cmd,
 
 void InsetERT::setButtonLabel()
 {
-       if (decoration() == Classic)
+       if (decoration() == Deco_Classic)
                setLabel(isOpen() ? _("ERT") : getNewLabel(_("ERT")));
        else
                setLabel(getNewLabel(_("ERT")));
index a9d3e06fe4a8ec3633d39c2bec2e2674fba140a5..1de4b1cbe29b2a9ad24671c954754a3530fd3ab0 100644 (file)
@@ -59,6 +59,20 @@ enum InsetLayoutTags {
 };
 
 
+namespace {
+       InsetDecoration translateDecoration(std::string const & str) 
+       {
+               if (str == "classic")
+                       return Deco_Classic;
+               if (str == "minimalistic")
+                       return Deco_Minimalistic;
+               if (str == "conglomerate")
+                       return Deco_Conglomerate;
+               return Deco_Default;
+       }
+}
+
+
 bool InsetLayout::read(Lexer & lexrc)
 {
        name_ = support::subst(lexrc.getDocString(), '_', ' ');
@@ -114,7 +128,7 @@ bool InsetLayout::read(Lexer & lexrc)
                        break;
                case IL_DECORATION:
                        lexrc.next();
-                       decoration_ = lexrc.getString();
+                       decoration_ = translateDecoration(lexrc.getString());
                        break;
                case IL_LATEXNAME:
                        lexrc.next();
index 21d11a6f3a5c1ba71d2accd3b8e646d9932168a7..27eae62e563cf5dd25b2b0096fb05477be4c4202 100644 (file)
 namespace lyx {
 
 class Lexer;
-       
+
+///
+enum InsetDecoration {
+       Deco_Classic,
+       Deco_Minimalistic,
+       Deco_Conglomerate,
+       Deco_Default
+};
+
 ///
 class InsetLayout {
 public:
@@ -39,8 +47,7 @@ public:
        ///
        docstring labelstring() const { return labelstring_; };
        ///
-       //FIXME This could be an enum
-       std::string decoration() const { return decoration_; };
+       InsetDecoration decoration() const { return decoration_; };
        ///
        std::string latextype() const { return latextype_; };
        ///
@@ -77,7 +84,7 @@ private:
        ///
        docstring labelstring_;
        ///
-       std::string decoration_;
+       InsetDecoration decoration_;
        ///
        std::string latextype_;
        ///
index c225446038acd43c006520cfbb5884eb0e50c271..d3deadb6242df1fc3a51a4cf5b6cef0c2fe46098 100644 (file)
@@ -251,7 +251,7 @@ bool InsetListings::getStatus(Cursor & cur, FuncRequest const & cmd,
 void InsetListings::setButtonLabel()
 {
        // FIXME UNICODE
-       if (decoration() == Classic)
+       if (decoration() == Deco_Classic)
                setLabel(isOpen() ?  _("Listing") : getNewLabel(_("Listing")));
        else
                setLabel(getNewLabel(_("Listing")));