+2000-07-17 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/mathed/formula.h (ConvertFont): constify
+
+ * src/mathed/formula.C (Read): add warning if \end_inset is not
+ found on expected place.
+
+ * src/insets/lyxinset.h (ConvertFont): consify
+
+ * src/insets/insetquotes.C (ConvertFont): constify
+ * src/insets/insetquotes.h: ditto
+
+ * src/insets/insetinfo.h: add labelfont
+
+ * src/insets/insetinfo.C (InsetInfo): set the labelfont
+ (ascent): use labelfont
+ (descent): likewise
+ (width): likewise
+ (draw): likewise
+ (Write): make .lyx file a bit nicer
+
+ * src/insets/insetfloat.C (Write): simplify somewhat...
+ (Read): add warning if arg is not found
+
+ * src/insets/insetcollapsable.C: add using std::max
+ (Read): move string token and add warning in arg is not found
+ (draw): use std::max to get the right ty
+ (getMaxWidth): simplify by using std::max
+
+ * src/insets/insetsection.h: new file
+ * src/insets/insetsection.C: new file
+ * src/insets/insetcaption.h: new file
+ * src/insets/insetcaption.C: new file
+
+ * src/insets/inset.C (ConvertFont): constify signature
+
+ * src/insets/Makefile.am (libinsets_la_SOURCES): add
+ insetcaption.[Ch] and insetsection.[Ch]
+
+ * src/layout.h: remove LABEL_FIRST_COUNTER from enum, change all
+ uses to use LABEL_COUNTER_CHAPTER instead.
+ * src/text2.C (SetCounter): here
+
+ * src/counters.h: new file
+ * src/counters.C: new file
+ * src/Sectioning.h: new file
+ * src/Sectioning.C: new file
+
+ * src/Makefile.am (lyx_SOURCES): add Sectioning.[hC] and counters.[Ch]
+
2000-07-17 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lib/Makefile.am (listerrors): build-listerrors is in ${srcdir},
PaperLayout.C \
ParagraphExtra.C \
PrinterParams.h \
+ Sectioning.h \
+ Sectioning.C \
Spacing.C \
Spacing.h \
TableLayout.C \
combox.h \
commandtags.h \
config.h.in \
+ counters.C \
+ counters.h \
credits.C \
credits.h \
credits_form.C \
--- /dev/null
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "Sectioning.h"
+
+string const & Section::name() const
+{
+ return name_;
+}
+
+
+int Section::level() const
+{
+ return level_;
+}
+
+
+string const & Section::indent() const
+{
+ return indent_;
+}
+
+
+string const & Section::beforeskip() const
+{
+ return beforeskip_;
+}
+
+
+string const & Section::afterskip() const
+{
+ return afterskip_;
+}
+
+
+LyXFont const & Section::style() const
+{
+ return style_;
+}
+
+
+bool Section::display() const
+{
+ // If afterskip is negative it is a display section.
+ if (!afterskip_.empty() && afterskip_[0] == '-')
+ return false;
+ return true;
+}
--- /dev/null
+// -*- C++ -*-
+
+#ifndef SECTIONING_H
+#define SECTIONING_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <map>
+
+#include "LString.h"
+#include "lyxfont.h"
+
+///
+class Section {
+public:
+ ///
+ string const & name() const;
+ ///
+ int level() const;
+ ///
+ string const & indent() const;
+ ///
+ string const & beforeskip() const;
+ ///
+ string const & afterskip() const;
+ ///
+ LyXFont const & style() const;
+ ///
+ bool display() const;
+private:
+ ///
+ string name_;
+ ///
+ int level_;
+ ///
+ string indent_;
+ ///
+ string beforeskip_;
+ ///
+ string afterskip_;
+ ///
+ LyXFont style_;
+};
+
+
+///
+class SectioningList {
+public:
+private:
+ ///
+ typedef std::map<string, Section> List_;
+ ///
+ List_ list_;
+};
+
+#endif
--- /dev/null
+#include <config.h>
+
+#include "counters.h"
+#include "debug.h"
+
+#ifdef SIGC_CXX_NAMESPACES
+using SigC::Connection;
+using SigC::slot;
+#endif
+
+using std::endl;
+
+
+Counter::Counter()
+{
+ reset();
+}
+
+
+void Counter::set(int v)
+{
+ value_ = v;
+}
+
+
+void Counter::addto(int v)
+{
+ value_ += v;
+}
+
+
+int Counter::value() const
+{
+ return value_;
+}
+
+
+void Counter::step()
+{
+ ++value_;
+ onstep.emit();
+}
+
+
+void Counter::reset()
+{
+ value_ = 0;
+}
+
+
+Counters::~Counters()
+{
+ // We need this since we store the Counter's as pointers in
+ // the counterList.
+ for (CounterList::iterator it = counterList.begin();
+ it != counterList.end();
+ ++it)
+ delete (*it).second;
+}
+
+
+void Counters::newCounter(string const & newc)
+{
+ // First check if newc already exist
+ CounterList::const_iterator cit = counterList.find(newc);
+ // if alrady exist give warning and return
+ if (cit != counterList.end()) {
+ lyxerr << "The new counter already exist." << endl;
+ return;
+ }
+ counterList[newc] = new Counter;
+}
+
+
+void Counters::newCounter(string const & newc, string const & oldc)
+{
+ // First check if newc already exist
+ CounterList::const_iterator cit = counterList.find(newc);
+ // if already existant give warning and return
+ if (cit != counterList.end()) {
+ lyxerr << "The new counter already exist." << endl;
+ return;
+ }
+ // then check if oldc exist
+ CounterList::iterator it = counterList.find(oldc);
+ // if not give warning and return
+ if (it == counterList.end()) {
+ lyxerr << "The old counter does not exist." << endl;
+ return;
+ }
+
+ Counter * tmp = new Counter;
+ (*it).second->onstep.connect(slot(tmp,
+ &Counter::reset));
+ counterList[newc] = tmp;
+}
+
+
+void Counters::set(string const & ctr, int val)
+{
+ CounterList::iterator it = counterList.find(ctr);
+ if (it == counterList.end()) {
+ lyxerr << "Counter does not exist." << endl;
+ return;
+ }
+ (*it).second->set(val);
+}
+
+
+void Counters::addto(string const & ctr, int val)
+{
+ CounterList::iterator it = counterList.find(ctr);
+ if (it == counterList.end()) {
+ lyxerr << "Counter does not exist." << endl;
+ return;
+ }
+ (*it).second->addto(val);
+}
+
+
+int Counters::value(string const & ctr) const
+{
+ CounterList::const_iterator cit = counterList.find(ctr);
+ if (cit == counterList.end()) {
+ lyxerr << "Counter does not exist." << endl;
+ return 0;
+ }
+ return (*cit).second->value();
+}
+
+
+void Counters::step(string const & ctr)
+{
+ CounterList::iterator it = counterList.find(ctr);
+ if (it == counterList.end()) {
+ lyxerr << "Counter does not exist." << endl;
+ return;
+ }
+ (*it).second->step();
+}
--- /dev/null
+// -*- C++ -*-
+
+#ifndef COUNTERS_H
+#define COUTNERS_H
+
+#include <map>
+#include <sigc++/signal_system.h>
+#include "LString.h"
+
+#ifdef SIGC_CXX_NAMESPACES
+using SigC::Object;
+using SigC::Signal0;
+#endif
+
+
+///
+class Counter : public Object {
+public:
+ ///
+ Counter();
+ ///
+ void set(int v);
+ ///
+ void addto(int v);
+ ///
+ int value() const;
+ ///
+ void step();
+ ///
+ void reset();
+ ///
+ Signal0<void> onstep;
+private:
+ ///
+ int value_;
+};
+
+
+/** This is a class of (La)TeX type counters. The counters is in a text
+ Style and can be reset by signals emitted from a single counter.
+*/
+class Counters {
+public:
+ ///
+ ~Counters();
+ ///
+ void newCounter(string const & newc);
+ ///
+ void newCounter(string const & newc, string const & oldc);
+ ///
+ void set(string const & ctr, int val);
+ ///
+ void addto(string const & ctr, int val);
+ ///
+ int value(string const & ctr) const;
+ ///
+ void step(string const & ctr);
+ // string refstep(string const & cou);
+private:
+ ///
+ typedef std::map<string, Counter*> CounterList;
+ ///
+ CounterList counterList;
+};
+
+#endif
insetbib.h \
insetbutton.C \
insetbutton.h \
+ insetcaption.C \
+ insetcaption.h \
insetcite.C \
insetcite.h \
insetcollapsable.C \
insetquotes.h \
insetref.C \
insetref.h \
+ insetsection.h \
+ insetsection.C \
insetspecialchar.C \
insetspecialchar.h \
insettabular.C \
}
-LyXFont Inset::ConvertFont(LyXFont font)
+LyXFont Inset::ConvertFont(LyXFont const & font) const
{
- return font;
+ return LyXFont(font);
}
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ * ======================================================
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetcaption.h"
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ *======================================================
+ */
+
+
+#ifndef INSETCAPTION_H
+#define INSETCAPTION_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insettext.h"
+
+/** A caption inset
+*/
+class InsetCaption : public InsetText {
+public:
+protected:
+private:
+};
+
+#endif
using std::ostream;
using std::endl;
+using std::max;
InsetCollapsable::InsetCollapsable()
: UpdatableInset()
void InsetCollapsable::Read(Buffer const * buf, LyXLex & lex)
{
- string token;
-
if (lex.IsOK()) {
lex.next();
- token = lex.GetString();
+ string token = lex.GetString();
if (token == "collapsed") {
lex.next();
collapsed = lex.GetBool();
+ } else {
+ lyxerr << "InsetCollapsable::Read: Missing collapsed!"
+ << endl;
}
}
inset->Read(buf, lex);
if (!cleared && ((inset->need_update == InsetText::FULL) ||
(inset->need_update == InsetText::INIT) ||
(top_x!=int(x)) || (top_baseline!=baseline))) {
- int w = owner()? width(bv, f) : pain.paperWidth();
- int h = ascent(bv,f) + descent(bv, f);
- int tx = (needFullRow() && !owner())? 0:int(x);
- int ty = baseline - ascent(bv,f);
+ int w = owner() ? width(bv, f) : pain.paperWidth();
+ int h = ascent(bv, f) + descent(bv, f);
+ int tx = (needFullRow() && !owner()) ? 0 : int(x);
+ int ty = max(0, baseline - ascent(bv, f));
- if (ty < 0)
- ty = 0;
if ((ty + h) > pain.paperHeight())
h = pain.paperHeight();
if ((top_x + w) > pain.paperWidth())
w = pain.paperWidth();
- pain.fillRectangle(tx, ty-1, w, h+2);
+ pain.fillRectangle(tx, ty - 1, w, h + 2);
cleared = true;
}
int w = UpdatableInset::getMaxWidth(pain,inset);
if (w < 0) {
+ // What does a negative max width signify? (Lgb)
return w;
}
- w -= widthCollapsed;
// should be at least 30 pixels !!!
- if (w < 30)
- w = 30;
- return w; // - top_x - widthCollapsed;
+ return max(30, w - widthCollapsed);
}
void InsetFloat::Write(Buffer const * buf, ostream & os) const
{
os << getInsetName()
- << " " << floatType
- << "\nplacement ";
- if (floatPlacement.empty())
- os << floatList.getType(floatType).placement << "\n";
- else
- os << floatPlacement << "\n";
+ << " " << floatType << '\n';
+
+ if (floatPlacement.empty()) {
+ os << "placement "
+ << floatList.getType(floatType).placement << "\n";
+ } else {
+ os << "placement " << floatPlacement << "\n";
+ }
+
InsetCollapsable::Write(buf, os);
}
if (token == "placement") {
lex.next();
floatPlacement = lex.GetString();
+ } else {
+ lyxerr << "InsetFloat::Read: Missing placement!"
+ << endl;
}
}
InsetCollapsable::Read(buf, lex);
*
* LyX, The Document Processor
*
- * Copyright 1998 The LyX Team.
+ * Copyright 2000 The LyX Team.
*
* ======================================================
*/
InsetInfo::InsetInfo()
- : form(0)
-{}
+ : form(0), labelfont(LyXFont::ALL_SANE)
+{
+ labelfont.decSize().decSize()
+ .setColor(LColor::note).setLatex(LyXFont::OFF);
+}
InsetInfo::InsetInfo(string const & str)
- : contents(str), form(0)
-{}
+ : contents(str), form(0), labelfont(LyXFont::ALL_SANE)
+{
+ labelfont.decSize().decSize()
+ .setColor(LColor::note).setLatex(LyXFont::OFF);
+}
InsetInfo::~InsetInfo()
}
-int InsetInfo::ascent(BufferView *, LyXFont const & font) const
+int InsetInfo::ascent(BufferView *, LyXFont const &) const
{
- return lyxfont::maxAscent(font) + 1;
+ return lyxfont::maxAscent(labelfont) + 1;
}
-int InsetInfo::descent(BufferView *, LyXFont const & font) const
+int InsetInfo::descent(BufferView *, LyXFont const &) const
{
- return lyxfont::maxDescent(font) + 1;
+ return lyxfont::maxDescent(labelfont) + 1;
}
-int InsetInfo::width(BufferView *, LyXFont const & font) const
+int InsetInfo::width(BufferView *, LyXFont const &) const
{
- return 6 + lyxfont::width(_("Note"), font);
+ return 6 + lyxfont::width(_("Note"), labelfont);
}
-void InsetInfo::draw(BufferView * bv, LyXFont const & f,
+void InsetInfo::draw(BufferView * bv, LyXFont const &,
int baseline, float & x, bool) const
{
Painter & pain = bv->painter();
+#if 0
LyXFont font(f);
- /* Info-insets are never LaTeX, so just correct the font */
+ // Info-insets are never LaTeX, so just correct the font
font.setLatex(LyXFont::OFF).setColor(LColor::note);
-
+#endif
// Draw as "Note" in a yellow box
x += 1;
- pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
- width(bv, font) - 2,
- ascent(bv, font) + descent(bv, font) - 2,
+ pain.fillRectangle(int(x), baseline - ascent(bv, labelfont),
+ width(bv, labelfont) - 2,
+ ascent(bv, labelfont) + descent(bv, labelfont) - 2,
LColor::notebg);
- pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
- width(bv, font) - 2,
- ascent(bv, font) + descent(bv, font) - 2,
+ pain.rectangle(int(x), baseline - ascent(bv, labelfont),
+ width(bv, labelfont) - 2,
+ ascent(bv, labelfont) + descent(bv, labelfont) - 2,
LColor::noteframe);
- pain.text(int(x + 2), baseline, _("Note"), font);
- x += width(bv, font) - 1;
+ pain.text(int(x + 2), baseline, _("Note"), labelfont);
+ x += width(bv, labelfont) - 1;
}
void InsetInfo::Write(Buffer const *, ostream & os) const
{
- os << "Info " << contents;
+ os << "Info\n" << contents;
}
FL_FORM * form;
///
FL_OBJECT * strobj;
+ ///
+ LyXFont labelfont;
};
#endif
//LyXFont InsetQuotes::ConvertFont(LyXFont font)
// I really belive this should be
-LyXFont InsetQuotes::ConvertFont(LyXFont const & f)
+LyXFont InsetQuotes::ConvertFont(LyXFont const & f) const
{
LyXFont font(f);
// quotes-insets cannot be latex of any kind
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
- LyXFont ConvertFont(LyXFont const & font);
+ LyXFont ConvertFont(LyXFont const & font) const;
//LyXFont ConvertFont(LyXFont font);
///
void Write(Buffer const *, std::ostream &) const;
string DispString() const;
};
#endif
+
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ * ======================================================
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetsection.h"
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ *======================================================
+ */
+
+
+#ifndef INSETSECTION_H
+#define INSETSECTION_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+
+#include "insettext.h"
+
+/** A colapsable text inset
+*/
+class InsetSection : public InsetText {
+public:
+protected:
+private:
+ string type_;
+};
+
+#endif
virtual void update(BufferView *, LyXFont const &, bool = false)
{}
///
- virtual LyXFont ConvertFont(LyXFont font);
+ virtual LyXFont ConvertFont(LyXFont const & font) const;
/// what appears in the minibuffer when opening
virtual const char * EditMessage() const;
///
///
LABEL_COUNTER_ENUMIII,
///
- LABEL_COUNTER_ENUMIV,
- ///
- LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
+ LABEL_COUNTER_ENUMIV
};
enum LYX_END_LABEL_TYPES {
bool noindent;
private:
+ ///
block<int, 10> counter_;
public:
///
///
InsetText * inset_owner;
- ///
- // void owner(BufferView *);
-
///
LyXFont GetFont(Buffer const *, LyXParagraph * par,
LyXParagraph::size_type pos) const;
///
void SetCursorFromCoordinates(BufferView *, int x, long y) const;
- void SetCursorFromCoordinates(BufferView *, LyXCursor &, int x, long y) const;
+ void SetCursorFromCoordinates(BufferView *, LyXCursor &,
+ int x, long y) const;
///
void CursorUp(BufferView *) const;
///
///
int workWidth(BufferView *) const;
///
- // Buffer * buffer() const;
- ///
void ComputeBidiTables(Buffer const *, Row * row) const;
/// Maps positions in the visual string to positions in logical string.
label = mathed_label;
mathed_label = 0;
}
+
// reading of end_inset in the inset!!!
while (lex.IsOK()) {
lex.nextToken();
if (lex.GetString() == "\\end_inset")
break;
+ lyxerr << "InsetFormula::Read: Garbage before \\end_inset,"
+ " or missing \\end_inset!" << endl;
}
#ifdef DEBUG
///
Inset::Code LyxCode() const { return Inset::MATH_CODE; }
///
- LyXFont ConvertFont(LyXFont font) {
+ LyXFont ConvertFont(LyXFont const & f) const {
// We have already discussed what was here
+ LyXFont font(f);
font.setLatex(LyXFont::OFF);
return font;
}
id_ = paragraph_id++;
bibkey = 0; // ale970302
Clear();
+#if 0
+ // Insert the main counters
+ // Should later (asap) be moved to layout files
+ counters.newCounter("part");
+ counters.newCounter("section");
+ counters.newCounter("subsection", "section");
+ counters.newCounter("subsubsection", "subsection");
+ counters.newCounter("paragraph", "subsubsection");
+ counters.newCounter("subparagraph", "paragraph");
+#endif
}
bibkey = 0; // ale970302
Clear();
+#if 0
+ // Insert the main counters
+ // Should later (asap) be moved to layout files
+ counters.newCounter("part");
+ counters.newCounter("section");
+ counters.newCounter("subsection", "section");
+ counters.newCounter("subsubsection", "subsection");
+ counters.newCounter("paragraph", "subsubsection");
+ counters.newCounter("subparagraph", "paragraph");
+#endif
}
}
/* is it a layout that has an automatic label ? */
- if (layout.labeltype >= LABEL_FIRST_COUNTER) {
+ if (layout.labeltype >= LABEL_COUNTER_CHAPTER) {
- int i = layout.labeltype - LABEL_FIRST_COUNTER;
+ int i = layout.labeltype - LABEL_COUNTER_CHAPTER;
if (i >= 0 && i<= buf->params.secnumdepth) {
par->incCounter(i); // increment the counter
ostrstream s;
#endif
if (!par->appendix) {
- switch (2 * LABEL_FIRST_COUNTER -
+ switch (2 * LABEL_COUNTER_CHAPTER -
textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
s << par->getCounter(i);
break;
default:
+ // Can this ever be reached? And in the
+ // case it is, how can this be correct?
+ // (Lgb)
s << par->getCounter(i) << '.';
break;
}
} else { // appendix
- switch (2 * LABEL_FIRST_COUNTER - textclass.maxcounter() + i) {
+ switch (2 * LABEL_COUNTER_CHAPTER - textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
if (par->isRightToLeftPar(buf->params))
s << hebrewCounter(par->getCounter(i));
// Can this ever be reached? And in the
// case it is, how can this be correct?
// (Lgb)
- s << static_cast<unsigned char>(par->getCounter(i)) << '.';
+ s << par->getCounter(i) << '.';
break;
}
}
} else if (layout.labeltype == LABEL_BIBLIO) {// ale970302
- int i = LABEL_COUNTER_ENUMI - LABEL_FIRST_COUNTER + par->enumdepth;
+ int i = LABEL_COUNTER_ENUMI - LABEL_COUNTER_CHAPTER + par->enumdepth;
par->incCounter(i);
int number = par->getCounter(i);
if (!par->bibkey)