From aa41b3033b13395b920c93d087458de36aab6133 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 27 Nov 2001 10:56:14 +0000 Subject: [PATCH] cleanups by john and andre git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3089 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 10 +++- src/LColor.C | 2 +- src/LColor.h | 4 +- src/frontends/controllers/ChangeLog | 4 ++ src/frontends/controllers/ControlToc.C | 9 ++- src/frontends/xforms/ChangeLog | 4 ++ src/frontends/xforms/FormToc.C | 3 +- src/insets/ChangeLog | 11 +++- src/insets/insetfloatlist.C | 40 ++++++++----- src/insets/insetfloatlist.h | 13 ++--- src/text.C | 80 +++++++++++++++++++++----- src/vspace.C | 2 +- 12 files changed, 132 insertions(+), 50 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 11179e0840..8818f02388 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,10 +1,18 @@ +2001-11-26 John Levon + + * 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 * paragraph.C: whitespace changes * files form the 26th: change *::pos_type into lyx::pos_type - 2001-11-27 Dekel Tsur * buffer.C (parseSingleLyXformat2Token): Set the language to the diff --git a/src/LColor.C b/src/LColor.C index 775d4c87fa..3a24065cae 100644 --- a/src/LColor.C +++ b/src/LColor.C @@ -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" }, diff --git a/src/LColor.h b/src/LColor.h index 8c16950edf..ab1d52fcae 100644 --- a/src/LColor.h +++ b/src/LColor.h @@ -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 diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 44322f635a..64c5c4f47d 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2001-11-04 John Levon + + * ControlToc.C: changes for floatlist + 2001-11-04 John Levon * ControlVCLog.C: use _() diff --git a/src/frontends/controllers/ControlToc.C b/src/frontends/controllers/ControlToc.C index 9498787396..3d32d7cbc3 100644 --- a/src/frontends/controllers/ControlToc.C +++ b/src/frontends/controllers/ControlToc.C @@ -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 diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index efbb13730a..93d7145c00 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2001-11-04 John Levon + + * FormToc.C: fixes to make floatlists work + 2001-11-23 John Levon * Makefile.am: diff --git a/src/frontends/xforms/FormToc.C b/src/frontends/xforms/FormToc.C index b9d0a11745..657a29f890 100644 --- a/src/frontends/xforms/FormToc.C +++ b/src/frontends/xforms/FormToc.C @@ -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 diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 322fa445cf..ab506aa870 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,8 +1,15 @@ +2001-11-04 John Levon + + * insetfloatlist.h: + * insetfloatlist.C: derive from InsetCommand so gui can use it + easily + 2001-11-26 André Pönitz * 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 diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index b10e2b5a69..b51064490b 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -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(); diff --git a/src/insets/insetfloatlist.h b/src/insets/insetfloatlist.h index caf19cdecd..5717995128 100644 --- a/src/insets/insetfloatlist.h +++ b/src/insets/insetfloatlist.h @@ -16,20 +16,19 @@ #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 diff --git a/src/text.C b/src/text.C index fab24b2585..8223f710b1 100644 --- a/src/text.C +++ b/src/text.C @@ -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 { diff --git a/src/vspace.C b/src/vspace.C index 9d35ec29f2..1d74f77103 100644 --- a/src/vspace.C +++ b/src/vspace.C @@ -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; -- 2.39.2