]> git.lyx.org Git - features.git/commitdiff
cleanups by john and andre
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 27 Nov 2001 10:56:14 +0000 (10:56 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 27 Nov 2001 10:56:14 +0000 (10:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3089 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/ChangeLog
src/LColor.C
src/LColor.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlToc.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormToc.C
src/insets/ChangeLog
src/insets/insetfloatlist.C
src/insets/insetfloatlist.h
src/text.C
src/vspace.C

index 11179e0840a86b24b5d03489ee46929cebb2b72d..8818f0238823f84f07947ee5cc354572ee7ac9b4 100644 (file)
@@ -1,10 +1,18 @@
+2001-11-26  John Levon  <moz@compsoc.man.ac.uk>
+
+       * text.C: 
+       * LColor.h:
+       * LColor.C: change vfillline->added_space
+       * text.C: add markers and text for added space
+       * vspace.C: fix comment
 
 2001-11-28  André Pönitz <poenitz@gmx.net>
 
        * paragraph.C: whitespace changes
        * files form the 26th: change *::pos_type into lyx::pos_type
        
-
 2001-11-27  Dekel Tsur  <dekelts@tau.ac.il>
 
        * buffer.C (parseSingleLyXformat2Token): Set the language to the
index 775d4c87faff52501211facdc70486992b8a7b65..3a24065cae0298cc3d4139d007fcb8d7b8a70a96 100644 (file)
@@ -85,7 +85,7 @@ LColor::LColor()
        { error, N_("LaTeX error"), "error", "Red", "error" },
        { eolmarker, N_("end-of-line marker"), "eolmarker", "Brown", "eolmarker" },
        { appendixline, N_("appendix line"), "appendixline", "Brown", "appendixline" },
-       { vfillline, N_("vfill line"), "vfillline", "Brown", "vfillline" },
+       { added_space, N_("added space markers"), "added_space", "Brown", "added_space" },
        { topline, N_("top/bottom line"), "topline", "Brown", "topline" },
        { tabularline, N_("tabular line"), "tabularline", "black",
             "tabularline" },
index 8c16950edf5eba4e1cd3be939a339a28402b4592..ab1d52fcae74d246ed850a6f1ceba447cc55379f 100644 (file)
@@ -131,10 +131,10 @@ public:
                error,
                /// EOL marker color
                eolmarker,
+               /// Added space colour
+               added_space,
                /// Appendix line color
                appendixline,
-               /// VFill line color
-               vfillline,
                /// Top and bottom line color
                topline,
                /// Table line color
index 44322f635ad13084316a5e2933e05e6c2c0805b7..64c5c4f47d522992f60466a3da279365f8ed4175 100644 (file)
@@ -1,3 +1,7 @@
+2001-11-04  John Levon  <moz@compsoc.man.ac.uk>
+
+       * ControlToc.C: changes for floatlist
 2001-11-04  John Levon  <moz@compsoc.man.ac.uk>
 
        * ControlVCLog.C: use _()
index 9498787396c0e7eb285e89d70b953ad3fe2bfec6..3d32d7cbc359aa9cd6b2c0ef8ad0b1c6720c96fe 100644 (file)
@@ -89,14 +89,13 @@ namespace toc
 
 string const getType(string const & cmdName)
 {
-       string type;
+       string type = cmdName;
 
-       // It would be nice to have a map to extract this info.
-       // Does one already exist, Lars?
-       if (cmdName == "tableofcontents" )
+       // special case
+       if (cmdName == "tableofcontents")
                type = "TOC";
 
-       return cmdName;
+       return type;
 }
  
 } // namespace toc 
index efbb13730a34bbf66994d4926a8c07fbaaec59ed..93d7145c0070618582ffca66c77bb605ba2b2798 100644 (file)
@@ -1,3 +1,7 @@
+2001-11-04  John Levon  <moz@compsoc.man.ac.uk>
+
+       * FormToc.C: fixes to make floatlists work
 2001-11-23  John Levon  <moz@compsoc.man.ac.uk>
 
        * Makefile.am:
index b9d0a11745b5d6a8ca74a5ec6e3ec8010e0d282b..657a29f8902cc3ea61ef60b789e6b9d30c7796d9 100644 (file)
@@ -73,8 +73,7 @@ void FormToc::updateType()
 {
        // Update the choice list from scratch
        fl_clear_choice(dialog_->choice_toc_type);
-       string const choice =
-               " " + getStringFromVector(controller().getTypes(), " | ") + " ";
+       string const choice = getStringFromVector(controller().getTypes(), "|");
        fl_addto_choice(dialog_->choice_toc_type, choice.c_str());
 
        // And select the correct one
index 322fa445cfaabcdcf3ea33e1978faf224a7e2238..ab506aa87016a569f5f753bc7771bcf1b7a095bf 100644 (file)
@@ -1,8 +1,15 @@
+2001-11-04  John Levon  <moz@compsoc.man.ac.uk>
+
+       * insetfloatlist.h:
+       * insetfloatlist.C: derive from InsetCommand so gui can use it
+         easily
 2001-11-26  André Pönitz <poenitz@gmx.net>
        
        * insettext.[Ch]:
-       *       insetert.C:
-       *       insetnote.C: reduce header dependencies, introduce type for positions
+       * insetert.C:
+       * insetnote.C: reduce header dependencies, introduce type for
+       positions 
 
 2001-11-23  John Levon  <moz@compsoc.man.ac.uk>
 
index b10e2b5a69cbd362954d4d25919cd4110c8ed604..b51064490b5b1f910fc329fa6d60943d11dcadee 100644 (file)
@@ -6,15 +6,31 @@
 
 #include "insetfloatlist.h"
 #include "FloatList.h"
+#include "frontends/Dialogs.h"
+#include "LyXView.h"
+#include "BufferView.h"
 #include "buffer.h"
 #include "gettext.h"
 #include "debug.h"
 
 using std::endl;
 
+InsetFloatList::InsetFloatList()
+       : InsetCommand(InsetCommandParams())
+{
+}
+
+InsetFloatList::InsetFloatList(string const & type)
+       : InsetCommand(InsetCommandParams())
+{
+       setCmdName(type);
+}
+
+
 string const InsetFloatList::getScreenLabel(Buffer const *) const 
 {
-       string const guiName = floatList[float_type]->second.name();
+       string const guiName = floatList[getCmdName()]->second.name();
        if (!guiName.empty()) {
                string const res = guiName + _(" List");
                return res;
@@ -31,7 +47,7 @@ Inset::Code InsetFloatList::lyxCode() const
 
 void InsetFloatList::write(Buffer const *, std::ostream & os) const
 {
-       os << "FloatList " << float_type << "\n";
+       os << "FloatList " << getCmdName() << "\n";
 }
 
 
@@ -40,8 +56,8 @@ void InsetFloatList::read(Buffer const *, LyXLex & lex)
        string token;
 
        if (lex.eatLine()) {
-               float_type = lex.getString();
-               lyxerr << "FloatList::float_type: " << float_type << endl;
+               setCmdName(lex.getString());
+               lyxerr << "FloatList::float_type: " << getCmdName() << endl;
        } else
                lex.printError("InsetFloatList: Parse error: `$$Token'");
        while (lex.isOK()) {
@@ -57,12 +73,9 @@ void InsetFloatList::read(Buffer const *, LyXLex & lex)
 }
 
 
-void InsetFloatList::edit(BufferView *, int, int, unsigned int)
+void InsetFloatList::edit(BufferView * bv, int, int, unsigned int)
 {
-       // FIX: Implement me please.
-#if 0
-       bv->owner()->getDialogs()->showFloatList(this);
-#endif
+       bv->owner()->getDialogs()->showTOC(this);
 }
 
 
@@ -74,9 +87,8 @@ void InsetFloatList::edit(BufferView * bv, bool)
 
 int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
 {
-       FloatList::const_iterator cit = floatList[float_type];
+       FloatList::const_iterator cit = floatList[getCmdName()];
 
-       
        if (cit != floatList.end()) {
                if (cit->second.builtin()) {
                        // Only two different types allowed here:
@@ -89,11 +101,11 @@ int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
                                os << "%% unknown builtin float\n";
                        }
                } else {
-                       os << "\\listof{" << float_type << "}{"
+                       os << "\\listof{" << getCmdName() << "}{"
                           << _("List of ") << cit->second.name() << "}\n";
                }
        } else {
-               os << "%%\\listof{" << float_type << "}{"
+               os << "%%\\listof{" << getCmdName() << "}{"
                   << _("List of ") << cit->second.name() << "}\n";
        }
        return 1;
@@ -106,7 +118,7 @@ int InsetFloatList::ascii(Buffer const * buffer, std::ostream & os, int) const
 
        Buffer::Lists const toc_list = buffer->getLists();
        Buffer::Lists::const_iterator cit =
-               toc_list.find(float_type);
+               toc_list.find(getCmdName());
        if (cit != toc_list.end()) {
                Buffer::SingleList::const_iterator ccit = cit->second.begin();
                Buffer::SingleList::const_iterator end = cit->second.end();
index caf19cdecd5c39050c4017e463c3c29208d78135..57179951281ea144593f552c89c15824be315061 100644 (file)
 #pragma interface
 #endif
 
-#include "insetbutton.h"
+#include "insetcommand.h"
 
 /** Used to insert table of contents
  */
-class InsetFloatList : public InsetButton {
+class InsetFloatList : public InsetCommand {
 public:
        ///
-       InsetFloatList() {}
+       InsetFloatList();
        ///
-       InsetFloatList(string const & type) 
-               : float_type(type) {}
+       InsetFloatList(string const & type);
        ///
        Inset * clone(Buffer const &, bool = false) const {
-               return new InsetFloatList(*this);
+               return new InsetFloatList(getCmdName());
        }
        ///
        string const getScreenLabel(Buffer const *) const;
@@ -55,8 +54,6 @@ public:
        int docbook(Buffer const *, std::ostream &) const { return 0; }
        ///
        int ascii(Buffer const *, std::ostream &, int linelen) const;
-private:
-       string float_type;
 };
 
 #endif
index fab24b25854400a08ee182d422f50c5cf3dfd991..8223f710b12e8be61305f520e72cccfd7ecbe04e 100644 (file)
@@ -3154,7 +3154,8 @@ void LyXText::paintFirstRow(DrawRowParams & p)
        // draw a top pagebreak
        if (parparams.pagebreakTop()) {
                int const y = p.yo + y_top + 2*defaultHeight();
-               p.pain->line(0, y, p.width, y, LColor::pagebreak, Painter::line_onoffdash);
+               p.pain->line(p.xo, y, p.xo + p.width, y, 
+                       LColor::pagebreak, Painter::line_onoffdash);
  
                int w = 0;
                int a = 0;
@@ -3175,18 +3176,43 @@ void LyXText::paintFirstRow(DrawRowParams & p)
                int const y1 = p.yo + y_top + 3 * defaultHeight();
                int const y2 = p.yo + 2 + y_top;
  
-               p.pain->line(0, y1, LYX_PAPER_MARGIN, y1, LColor::vfillline);
+               p.pain->line(0, y1, LYX_PAPER_MARGIN, y1, LColor::added_space);
                
-               p.pain->line(0, y2, LYX_PAPER_MARGIN, y2, LColor::vfillline);
+               p.pain->line(0, y2, LYX_PAPER_MARGIN, y2, LColor::added_space);
 
                int const x = LYX_PAPER_MARGIN / 2;
  
-               p.pain->line(x, y2, x, y1, LColor::vfillline);
+               p.pain->line(x, y2, x, y1, LColor::added_space);
                
                y_top += 3 * defaultHeight();
+       } else if (parparams.spaceTop().kind() == VSpace::LENGTH) {
+               string str(string(_("Space above")) + " ("
+                       + parparams.spaceTop().asLyXCommand()
+                       + ")");
+               int const space = int(parparams.spaceTop().inPixels(p.bv));
+               int const y = p.yo + y_top + space / 2;
+               p.pain->line(p.xo, y, p.xo + p.width, y, 
+                       LColor::added_space, Painter::line_onoffdash);
+               int w = 0;
+               int a = 0;
+               int d = 0;
+               LyXFont pb_font;
+               pb_font.setColor(LColor::added_space).decSize();
+               lyxfont::rectText(str, pb_font, w, a, d);
+
+               // don't draw if it won't fit 
+               if (a + d + 4 < space) { 
+                       p.pain->rectText(p.xo + (p.width - w)/2, y + d,
+                                     str, pb_font,
+                                     backgroundColor(),
+                                     backgroundColor());
+               }
        }
        
-       // think about user added space
        y_top += int(parparams.spaceTop().inPixels(p.bv));
        
        Buffer const * buffer = p.bv->buffer();
@@ -3350,7 +3376,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
                pb_font.setColor(LColor::pagebreak).decSize();
                int const y = p.yo + y_bottom - 2 * defaultHeight();
  
-               p.pain->line(0, y, ww, y, LColor::pagebreak, Painter::line_onoffdash);
+               p.pain->line(p.xo, y, p.xo + p.width, y, LColor::pagebreak, Painter::line_onoffdash);
  
                int w = 0;
                int a = 0;
@@ -3370,11 +3396,37 @@ void LyXText::paintLastRow(DrawRowParams & p)
                int const y = p.yo + y_bottom - 3 * defaultHeight();
                int const y2 = p.yo + y_bottom - 2;
                
-               p.pain->line(0, y, x2, y, LColor::vfillline);
-               p.pain->line(0, y2, x2, y2, LColor::vfillline);
-               p.pain->line(x, y, x, y2, LColor::vfillline);
+               p.pain->line(0, y, x2, y, LColor::added_space);
+               p.pain->line(0, y2, x2, y2, LColor::added_space);
+               p.pain->line(x, y, x, y2, LColor::added_space);
  
                y_bottom -= 3 * defaultHeight();
+       } else if (parparams.spaceBottom().kind() == VSpace::LENGTH) {
+               string str(string(_("Space below")) + " ("
+                       + parparams.spaceBottom().asLyXCommand()
+                       + ")");
+               int const space = int(parparams.spaceBottom().inPixels(p.bv));
+               int const y = p.yo + y_bottom - space / 2;
+               p.pain->line(p.xo, y, p.xo + p.width, y,
+                       LColor::added_space, Painter::line_onoffdash);
+               int w = 0;
+               int a = 0;
+               int d = 0;
+               LyXFont pb_font;
+               pb_font.setColor(LColor::added_space).decSize();
+               lyxfont::rectText(str, pb_font, w, a, d);
+
+               // don't draw if it won't fit 
+               if (a + d + 4 < space) { 
+                       p.pain->rectText(p.xo + (p.width - w) / 2, y + d,
+                                     str, pb_font,
+                                     backgroundColor(),
+                                     backgroundColor());
+               } 
        }
        
        // think about user added space
@@ -3480,7 +3532,7 @@ void LyXText::paintRowText(DrawRowParams & p)
                        int const y1 = y0 - defaultHeight() / 2;
 
                        p.pain->line(int(p.x), y1, int(p.x), y0,
-                                    LColor::vfillline);
+                                    LColor::added_space);
                        
                        if (hfillExpansion(buffer, p.row, pos)) {
                                int const y2 = (y0 + y1) / 2;
@@ -3488,19 +3540,19 @@ void LyXText::paintRowText(DrawRowParams & p)
                                if (pos >= main_body) {
                                        p.pain->line(int(p.x), y2,
                                                  int(p.x + p.hfill), y2,
-                                                 LColor::vfillline,
+                                                 LColor::added_space,
                                                  Painter::line_onoffdash);
                                        p.x += p.hfill;
                                } else {
                                        p.pain->line(int(p.x), y2,
                                                  int(p.x + p.label_hfill), y2,
-                                                 LColor::vfillline,
+                                                 LColor::added_space,
                                                  Painter::line_onoffdash);
                                        p.x += p.label_hfill;
                                }
                                p.pain->line(int(p.x), y1,
                                             int(p.x), y0,
-                                            LColor::vfillline);
+                                            LColor::added_space);
                        }
                        p.x += 2;
                        ++vpos;
@@ -3570,7 +3622,7 @@ void LyXText::getVisibleRow(BufferView * bv, int y_offset, int x_offset,
        // paint text
        paintRowText(p); 
 }
-
 
 int LyXText::defaultHeight() const
 {
index 9d35ec29f2155adbaa441817e7525db92d1a57d1..1d74f771035c5d1e4f56c969ea143ad4af08c561 100644 (file)
@@ -594,7 +594,7 @@ int VSpace::inPixels(int default_height, int default_skip, int default_width) co
                // is the same as on paper.
 
                // we don't care about sign of value, we
-               // can't display negative anyway
+               // display negative space with text too
                result = 0.0;
                value = len.value();
                int val_sign = value < 0.0 ? -1 : 1;