playing around with insets

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2315 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-07-24 10:13:19 +00:00
parent 94c00c08a8
commit cb8bb668e7
19 changed files with 159 additions and 63 deletions

4
NEWS
View File

@ -18,8 +18,8 @@ Switch to the so-called 'new' insets:
- TeX mode has been superseded by the 666 (aka ERT) inset, which is
foldable
- new graphics inset superseding the older figure inset [will that be
OK in 1.2.0?]
- new graphics inset with support for hassle-free inclusion of various
image formats (GIF, JPEG, PNG and EPS by default).
- new minipage inset

View File

@ -27,7 +27,7 @@
Bienvenue dans l'univers de LyX !
\begin_inset Info
Informations de révision :
Traduction : Mise à jour, Date: 2001/02/16
Traduction : Mise à jour, Date: 2001/06/10
Original : Révision: 1.5, Date: 2000/12/28
\end_inset
@ -37,8 +37,8 @@ Original : R
Le Top N des choses à connaître pour utiliser LyX
\layout Enumerate
LyX est fourni avec une excellente documentation -- servez-vous-en s'il
vous plaît ! Vous pouvez commencer par
LyX est fourni avec une excellente documentation -- servez-vous-en donc
! Vous pouvez commencer par
\family sans
\bar under
A
@ -58,10 +58,9 @@ A
\bar default
ide\SpecialChar \menuseparator
Manuel\SpecialChar ~
d'Apprentissage.
d'Apprentissage
\family default
Seul le titre des autres documents est traduit en français pour le moment.
.
\layout Enumerate
LyX est ce qu'on appelle un
@ -76,7 +75,7 @@ LyX est ce qu'on appelle un
Par sa conception, il se distingue des traitements de texte ordinaires
-- en ce sens qu'il facilite l'écriture des documents.
Mais la distinction est minime, ne vous inquiétez pas.
La documentation est là pour faire toute la lumière la-dessus
La documentation est là pour faire toute la lumière là-dessus
\begin_float footnote
\layout Standard
@ -85,8 +84,7 @@ Avons-nous d
.
\layout Enumerate
Les résultats de mise en page de LyX sont très esthétiques ! Sélectionnez
Les résultats de mise en page de LyX sont très esthétiques ! Faites
\family sans
\bar under
V
@ -122,15 +120,15 @@ d'Apprentissage
\layout Enumerate
LyX possède de nombreuses fonctionnalités pour ceux qui lisent ou écrivent
d'autres langages que l'anglais.
De plus, le clavier, la barre d'outils et beaucoup d'autres caractéristiques
dans d'autres langues que l'anglais.
En outre, le clavier, la barre d'outils et beaucoup d'autres caractéristiques
sont pleinement configurables (pour la plupart en éditant votre fichier
\family typewriter
lyxrc
\family default
).
Voir le fichier
Voir
\family sans
\bar under
A

View File

@ -1,3 +1,16 @@
2001-07-24 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* lyxtext.h: remove unused (and unimplemented) methods
2001-07-23 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* text.C (getVisibleRow): honor background color
* PainterBase.h:
* Painter.h: remove default color argument for fillRectangle
* text.C (backgroundColor): new method
2001-07-24 Lars Gullik Bjønnes <larsbj@birdstep.com>
* text.C (getVisibleRow): adjust

View File

@ -74,7 +74,7 @@ public:
/// Fill a rectangle
PainterBase & fillRectangle(int x, int y, int w, int h,
LColor::color = LColor::background);
LColor::color);
/// For the graphics inset.
PainterBase & image(int x, int y, int w, int h, LyXImage const * image);

View File

@ -137,7 +137,7 @@ public:
/// Fill a rectangle
virtual PainterBase & fillRectangle(
int x, int y, int w, int h,
LColor::color = LColor::background) = 0;
LColor::color) = 0;
/// A filled rectangle with the shape of a 3D button
virtual PainterBase & button(int x, int y, int w, int h);

View File

@ -1,3 +1,34 @@
2001-07-24 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insetminipage.C (InsetMinipage): set background color to red :)
2001-07-23 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insettext.C (insetUnlock): only set update to CLEAR_FRAME if
draw frame mode is LOCKED.
* insetcollapsable.C (edit):
(insetButtonRelease): set update status to full when
opening inset.
* insettext.C (clearInset):
* insettabular.C (draw):
* insetlatexaccent.C (draw): honor background color.
* inset.h: new member background_color_, initialized to
LColor::inherit.
* inset.C (backgroundColor): new method.
(setBackgroundColor): new method.
* insetert.C (init): new method, called by the ctors.
(InsetERT): when inserting contents, make sure the font is
ALL_INHERIT.
* insetnote.C (InsetNote): when inserting content, remove trailing
newline
(init): set background color to LColor::note
2001-07-24 Lars Gullik Bjønnes <larsbj@birdstep.com>
* insetcollapsable.C: adjust

View File

@ -90,6 +90,24 @@ LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
}
void Inset::setBackgroundColor(LColor::color color)
{
background_color_ = color;
}
LColor::color Inset::backgroundColor() const
{
if (background_color_ == LColor::inherit) {
if (owner())
return owner()->backgroundColor();
else
return LColor::background;
} else
return background_color_;
}
int Inset::id() const
{
return id_;

View File

@ -19,6 +19,7 @@
#include "LString.h"
#include <X11/Xlib.h>
#include "commandtags.h"
#include "LColor.h"
class LyXFont;
class BufferView;
@ -128,7 +129,7 @@ public:
};
///
Inset() : top_x(0), top_baseline(0), scx(0), id_(inset_id++), owner_(0) {}
Inset() : top_x(0), top_baseline(0), scx(0), id_(inset_id++), owner_(0), background_color_(LColor::inherit) {}
/// Virtual base destructor
virtual ~Inset() {}
///
@ -225,6 +226,10 @@ public:
///
Inset * owner() const { return owner_; }
///
void setBackgroundColor(LColor::color);
///
LColor::color backgroundColor() const;
///
int x() const { return top_x; }
///
int y() const { return top_baseline; }
@ -288,6 +293,8 @@ private:
Inset * owner_;
///
string name;
///
LColor::color background_color_;
};

View File

@ -289,6 +289,7 @@ void InsetCollapsable::edit(BufferView * bv, bool front)
collapsed_ = false;
if (!bv->lockInset(this))
return;
inset.setUpdateStatus(bv, InsetText::FULL);
bv->updateInset(this, false);
inset.edit(bv, front);
} else {
@ -347,6 +348,7 @@ void InsetCollapsable::insetButtonRelease(BufferView * bv,
draw_label = label;
collapsed_ = false;
inset.insetButtonRelease(bv, 0, 0, button);
inset.setUpdateStatus(bv, InsetText::FULL);
bv->updateInset(this, false);
} else {
if (change_label_with_text) {
@ -620,8 +622,9 @@ void InsetCollapsable::setLabel(string const & l, bool flag)
string InsetCollapsable::get_new_label() const
{
string la;
Paragraph::size_type const max_length = 10;
int n = std::min(10, inset.paragraph()->size());
int n = std::min(max_length, inset.paragraph()->size());
int i,j;
for(i=0,j=0; i < n && j < inset.paragraph()->size(); ++j) {
if (inset.paragraph()->isInset(j))

View File

@ -23,37 +23,33 @@
using std::ostream;
InsetERT::InsetERT() : InsetCollapsable()
void InsetERT::init()
{
setLabel(_("666"), true);
//LyXFont font(LyXFont::ALL_SANE);
//font.setLatex (LyXFont::ON);
labelfont = LyXFont(LyXFont::ALL_SANE);
labelfont.decSize();
labelfont.decSize();
#ifndef NO_LATEX
labelfont.setLatex(LyXFont::ON);
#else
labelfont.setColor(LColor::latex);
#endif
setAutoCollapse(false);
setInsetName("ERT");
}
InsetERT::InsetERT() : InsetCollapsable()
{
init();
}
InsetERT::InsetERT(string const & contents, bool collapsed)
: InsetCollapsable(collapsed)
{
setLabel(_("666"));
LyXFont font(LyXFont::ALL_SANE);
#ifndef NO_LATEX
font.setLatex(LyXFont::ON);
#else
font.setColor(LColor::latex);
#endif
labelfont = LyXFont(LyXFont::ALL_SANE);
labelfont.decSize();
labelfont.decSize();
labelfont.setColor(LColor::latex);
setAutoCollapse(false);
setInsetName("ERT");
init();
LyXFont const font(LyXFont::ALL_INHERIT);
string::const_iterator cit = contents.begin();
string::const_iterator end = contents.end();
Paragraph::size_type pos = 0;

View File

@ -58,6 +58,9 @@ public:
virtual int linuxdoc(Buffer const *, std::ostream &) const;
///
virtual int docBook(Buffer const *, std::ostream &) const;
private:
///
void init();
};
#endif

View File

@ -409,7 +409,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
pain.fillRectangle(int(x + tmpx), tmpvar, wid,
lyxfont::ascent('i', font) -
lyxfont::ascent('x', font) - 1,
LColor::background);
backgroundColor());
// the five lines below is a simple hack to
// make the display of accent 'i' and 'j'
// better. It makes the accent be written
@ -602,7 +602,8 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
baseline - ascent(bv, font) + 1,
width(bv, font) - 2,
ascent(bv, font)
+ descent(bv, font) - 2);
+ descent(bv, font) - 2,
backgroundColor());
pain.rectangle(int(x + 1), baseline - ascent(bv, font) + 1,
width(bv, font) - 2,
ascent(bv, font) + descent(bv, font) - 2);

View File

@ -69,6 +69,8 @@ InsetMinipage::InsetMinipage()
font.setColor(LColor::collapsable);
setLabelFont(font);
setAutoCollapse(false);
// just for experimentation :)
setBackgroundColor(LColor::red);
setInsetName("Minipage");
width_ = "100%"; // set default to 100% of column_width
}

View File

@ -22,6 +22,7 @@
#include "lyxtext.h"
#include "insets/insettext.h"
#include "support/LOstream.h"
#include "support/lstrings.h"
#include "debug.h"
using std::ostream;
@ -32,18 +33,22 @@ void InsetNote::init()
font.decSize();
font.setColor(LColor::note);
setLabelFont(font);
setAutoCollapse(false);
setBackgroundColor(LColor::note);
setLabel(_("note"));
setInsetName("Note");
}
InsetNote::InsetNote()
: InsetCollapsable()
{
init();
}
InsetNote::InsetNote(Buffer const * buf, string const & contents,
bool collapsed)
: InsetCollapsable(collapsed)
@ -52,9 +57,11 @@ InsetNote::InsetNote(Buffer const * buf, string const & contents,
Paragraph * par = inset.paragraph();
Paragraph::size_type pos = 0;
buf->insertStringAsLines(par, pos, labelfont, contents);
buf->insertStringAsLines(par, pos, LyXFont(LyXFont::ALL_INHERIT),
strip(contents, '\n'));
}
Inset * InsetNote::clone(Buffer const &, bool same_id) const
{
InsetNote * result = new InsetNote;

View File

@ -259,7 +259,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
h = pain.paperHeight();
if ((top_x + w) > pain.paperWidth())
w = pain.paperWidth();
pain.fillRectangle(tx, ty, w, h);
pain.fillRectangle(tx, ty, w, h, backgroundColor());
need_update = FULL;
cleared = true;
}
@ -366,7 +366,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
baseline - tabular->GetAscentOfRow(i) + 1,
int(cx - nx - 1),
tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1);
tabular->GetDescentOfRow(i) - 1,
backgroundColor());
// clear behind the inset
pain.fillRectangle(
int(cx + the_locking_inset->width(bv,font) + 1),
@ -376,7 +377,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
the_locking_inset->width(bv,font) -
tabular->GetAdditionalWidth(cell) - 1,
tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1);
tabular->GetDescentOfRow(i) - 1,
backgroundColor());
}
}
x -= ADD_TO_TABULAR_WIDTH;

View File

@ -472,7 +472,7 @@ void InsetText::clearFrame(Painter & pain, bool cleared) const
if (!cleared) {
pain.rectangle(top_x + 1, top_baseline - insetAscent + 1,
insetWidth - 1, insetAscent + insetDescent - 1,
LColor::background);
backgroundColor());
}
frame_is_visible = false;
}
@ -667,7 +667,11 @@ void InsetText::insetUnlock(BufferView * bv)
hideInsetCursor(bv);
no_selection = false;
locked = false;
int code = CURSOR|CLEAR_FRAME;
int code;
if (drawFrame_ == LOCKED)
code = CURSOR|CLEAR_FRAME;
else
code = CURSOR;
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
@ -1941,7 +1945,8 @@ void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const
h = pain.paperHeight();
if ((top_x + drawTextXOffset + w) > pain.paperWidth())
w = pain.paperWidth();
pain.fillRectangle(top_x+drawTextXOffset, ty, w, h);
pain.fillRectangle(top_x+drawTextXOffset, ty, w, h,
backgroundColor());
cleared = true;
need_update = FULL;
}

View File

@ -289,8 +289,11 @@ private:
UpdatableInset::RESULT moveDown(BufferView *);
///
void setCharFont(Buffer const *, int pos, LyXFont const & font);
#if 0
///What's that ??? Not used, not implemented!
///
string const getText(int);
#endif
///
bool checkAndActivateInset(BufferView * bv, bool behind);
///

View File

@ -22,6 +22,7 @@
#include "layout.h"
#include "lyxrow.h"
#include "vspace.h"
#include "LColor.h"
class Buffer;
class BufferParams;
@ -392,14 +393,6 @@ public:
void copyEnvironmentType();
///
void pasteEnvironmentType(BufferView *);
///
void insertFootnote();
///
void insertMarginpar();
///
void insertFigure();
///
void insertTabular();
/** the DTP switches for paragraphs. LyX will store the top settings
always in the first physical paragraph, the bottom settings in the
@ -606,6 +599,8 @@ private:
*/
bool hfillExpansion(Buffer const *, Row const * row_ptr,
Paragraph::size_type pos) const;
///
LColor::color backgroundColor();
///

View File

@ -1159,6 +1159,14 @@ bool LyXText::hfillExpansion(Buffer const * buf, Row const * row_ptr,
}
LColor::color LyXText::backgroundColor()
{
if (inset_owner)
return inset_owner->backgroundColor();
else
return LColor::background;
}
void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
{
/* get the maximum ascent and the maximum descent */
@ -2938,25 +2946,29 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
int const w = inset_owner ?
inset_owner->width(bview, font) - 2 : ww;
int const x = x_offset;
pain.fillRectangle(x, y, w, h);
pain.fillRectangle(x, y, w, h, backgroundColor());
} else if (inset != 0) {
int h = row_ptr->baseline() - inset->ascent(bview, font);
if (h > 0) {
int const w = (inset_owner ?
inset_owner->width(bview, font) : ww);
pain.fillRectangle(x_offset, y_offset, w, h);
pain.fillRectangle(x_offset, y_offset, w, h,
backgroundColor());
}
h += inset->ascent(bview, font) + inset->descent(bview, font);
if ((row_ptr->height() - h) > 0) {
int const w = (inset_owner ?
inset_owner->width(bview, font) : ww);
pain.fillRectangle(x_offset, y_offset + h,
w, row_ptr->height() - h);
w, row_ptr->height() - h,
backgroundColor());
}
if (!inset_owner && !inset->display() && !inset->needFullRow())
{
int const w = inset->width(bview, font) + int(x);
pain.fillRectangle(w, y_offset, ww - w, row_ptr->height());
pain.fillRectangle(w, y_offset,
ww - w, row_ptr->height(),
backgroundColor());
}
}
@ -3158,8 +3170,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
0,
_("Page Break (top)"),
pb_font,
LColor::background,
LColor::background, false, w, a, d);
backgroundColor(),
backgroundColor(), false, w, a, d);
#else
;
lyxfont::rectText(_("Page Break (top)"), pb_font,
@ -3169,8 +3181,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
y_offset + y_top + 2 * defaultHeight() + d,
_("Page Break (top)"),
pb_font,
LColor::background,
LColor::background);
backgroundColor(),
backgroundColor());
y_top += 3 * defaultHeight();
}
@ -3354,8 +3366,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
.rectText(0, 0,
_("Page Break (bottom)"),
pb_font,
LColor::background,
LColor::background, false, w, a, d);
backgroundColor(),
backgroundColor(), false, w, a, d);
#else
;
lyxfont::rectText(_("Page Break (bottom)"), pb_font,
@ -3364,8 +3376,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
pain.rectText((ww - w) / 2, y_place + d,
_("Page Break (bottom)"),
pb_font,
LColor::background,
LColor::background);
backgroundColor(),
backgroundColor());
y_bottom -= 3 * defaultHeight();
}