]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
* src/LaTeXFeatures.cpp: simplify greektext definition. Patch by G. Milde (bug #6458)
[lyx.git] / src / BufferParams.cpp
index 98d4fd0a7cfeea47f5a295bedf8ed86767491387..6ca616ae38bec104a259532f6ccd68554fbb1b6d 100644 (file)
@@ -367,13 +367,15 @@ BufferParams::BufferParams()
        listings_params = string();
        pagestyle = "default";
        suppress_date = false;
-       // white is equal to no background color
+       // no color is the default (white)
        backgroundcolor = lyx::rgbFromHexName("#ffffff");
+       isbackgroundcolor = false;
        // no color is the default (black)
        fontcolor = lyx::rgbFromHexName("#000000");
        isfontcolor = false;
        // light gray is the default font color for greyed-out notes
        notefontcolor = lyx::rgbFromHexName("#cccccc");
+       boxbgcolor = lyx::rgbFromHexName("#ff0000");
        compressed = lyxrc.save_compressed;
        for (int iter = 0; iter < 4; ++iter) {
                user_defined_bullet(iter) = ITEMIZE_DEFAULTS[iter];
@@ -726,6 +728,7 @@ string BufferParams::readToken(Lexer & lex, string const & token,
        } else if (token == "\\backgroundcolor") {
                lex.eatLine();
                backgroundcolor = lyx::rgbFromHexName(lex.getString());
+               isbackgroundcolor = true;
        } else if (token == "\\fontcolor") {
                lex.eatLine();
                fontcolor = lyx::rgbFromHexName(lex.getString());
@@ -735,8 +738,13 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                string color = lex.getString();
                notefontcolor = lyx::rgbFromHexName(color);
                // set the font color within LyX
-               // FIXME: the color is correctly set but later overwritten by the default
                lcolor.setColor(Color_greyedouttext, color);
+       } else if (token == "\\boxbgcolor") {
+               lex.eatLine();
+               string color = lex.getString();
+               boxbgcolor = lyx::rgbFromHexName(color);
+               // set the font color within LyX
+               lcolor.setColor(Color_shadedbg, color);
        } else if (token == "\\paperwidth") {
                lex >> paperwidth;
        } else if (token == "\\paperheight") {
@@ -927,12 +935,14 @@ void BufferParams::writeFile(ostream & os) const
           << "\n\\paperorientation " << string_orientation[orientation]
           << "\n\\suppress_date " << convert<string>(suppress_date)
           << '\n';
-       if (backgroundcolor != lyx::rgbFromHexName("#ffffff"))
+       if (isbackgroundcolor == true)
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
        if (isfontcolor == true)
                os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n';
        if (notefontcolor != lyx::rgbFromHexName("#cccccc"))
                os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n';
+       if (boxbgcolor != lyx::rgbFromHexName("#ff0000"))
+               os << "\\boxbgcolor " << lyx::X11hexname(boxbgcolor) << '\n';
 
        BranchList::const_iterator it = branchlist().begin();
        BranchList::const_iterator end = branchlist().end();
@@ -1455,8 +1465,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                texrow.newline();
        }
 
-       // only output when the background color is not white
-       if (backgroundcolor != lyx::rgbFromHexName("#ffffff")) {
+       // only output when the background color is not default
+       if (isbackgroundcolor == true) {
                // only require color here, the background color will be defined
                // in LaTeXFeatures.cpp to avoid interferences with the LaTeX
                // package pdfpages 
@@ -1762,10 +1772,11 @@ bool BufferParams::setBaseClass(string const & classname)
        LayoutFileList & bcl = LayoutFileList::get();
        if (!bcl.haveClass(classname)) {
                docstring s = 
-                       bformat(_("The document class %1$s could not be found. "
-                               "A default textclass with default layouts will be used. "
-                               "LyX might not be able to produce output unless a correct "
-                               "textclass is selected from the document settings dialog."),
+                       bformat(_("The layout file:\n"
+                               "%1$s\n"
+                               "could not be found. A default textclass with default\n"
+                               "layouts will be used. LyX will not be able to produce\n"
+                               "correct output."),
                        from_utf8(classname));
                frontend::Alert::error(_("Document class not found"), s);
                bcl.addEmptyClass(classname);
@@ -1774,10 +1785,14 @@ bool BufferParams::setBaseClass(string const & classname)
        bool const success = bcl[classname].load();
        if (!success) {
                docstring s = 
-                       bformat(_("The document class %1$s could not be loaded."),
+                       bformat(_("Due to some error in it, the layout file:\n"
+                               "%1$s\n"
+                               "could not be loaded. A default textclass with default\n"
+                               "layouts will be used. LyX will not be able to produce\n"
+                               "correct output."),
                        from_utf8(classname));
                frontend::Alert::error(_("Could not load class"), s);
-               return false;
+               bcl.addEmptyClass(classname);
        }
 
        pimpl_->baseClass_ = classname;
@@ -1816,6 +1831,7 @@ void BufferParams::makeDocumentClass()
        }
 }
 
+
 bool BufferParams::moduleCanBeAdded(string const & modName) const
 {
        return layoutModules_.moduleCanBeAdded(modName, baseClass());