mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-04 16:42:57 +00:00
Various updates for insets mostly regarding fixes for text-insets.
Added a new BaseClass InsetCollapsable and changed InsetERT to this new BaseClass, also added a footnote-inset. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@591 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7554e0687c
commit
b3e20a15e7
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
|||||||
|
2000-03-08 Juergen Vigna <jug@sad.it>
|
||||||
|
|
||||||
|
* src/insets/lyxinset.h: added owner call which tells us if
|
||||||
|
this inset is inside another inset. Changed also the return-type
|
||||||
|
of Editable to an enum so it tells clearer what the return-value is.
|
||||||
|
|
||||||
|
* src/insets/insettext.C (computeTextRows): fixed computing of
|
||||||
|
textinsets which split automatically on more rows.
|
||||||
|
|
||||||
|
* src/insets/insetert.[Ch]: changed this to be of BaseType
|
||||||
|
InsetCollapsable.
|
||||||
|
|
||||||
|
* src/insets/insetfoot.[Ch]: added footnote inset
|
||||||
|
|
||||||
|
* src/insets/insetcollapsable.[Ch]: added this BaseClass for
|
||||||
|
collapsable insets (like footnote, ert, ...)
|
||||||
|
|
||||||
2000-03-08 Lars Gullik Bjønnes <larsbj@lyx.org>
|
2000-03-08 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||||
|
|
||||||
* src/lyxdraw.h: remvoe file
|
* src/lyxdraw.h: remvoe file
|
||||||
|
@ -30,6 +30,8 @@ src/insets/insetbib.C
|
|||||||
src/insets/inseterror.C
|
src/insets/inseterror.C
|
||||||
src/insets/inseterror.h
|
src/insets/inseterror.h
|
||||||
src/insets/insetert.C
|
src/insets/insetert.C
|
||||||
|
src/insets/insetert.h
|
||||||
|
src/insets/insetfoot.C
|
||||||
src/insets/insetinclude.C
|
src/insets/insetinclude.C
|
||||||
src/insets/insetindex.C
|
src/insets/insetindex.C
|
||||||
src/insets/insetinfo.C
|
src/insets/insetinfo.C
|
||||||
|
@ -731,7 +731,7 @@ void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
|
|||||||
updateScrollbar();
|
updateScrollbar();
|
||||||
|
|
||||||
// Single left click in math inset?
|
// Single left click in math inset?
|
||||||
if (inset_hit != 0 && inset_hit->Editable() == 2) {
|
if (inset_hit != 0 && inset_hit->Editable()==Inset::HIGHLY_EDITABLE) {
|
||||||
// Highly editable inset, like math
|
// Highly editable inset, like math
|
||||||
selection_possible = false;
|
selection_possible = false;
|
||||||
owner_->updateLayoutChoice();
|
owner_->updateLayoutChoice();
|
||||||
|
@ -207,6 +207,8 @@ void LyXAction::init()
|
|||||||
N_("Toggle font underline"), Noop },
|
N_("Toggle font underline"), Noop },
|
||||||
{ LFUN_FOOTMELT, "footnote-insert", N_("Insert Footnote"),
|
{ LFUN_FOOTMELT, "footnote-insert", N_("Insert Footnote"),
|
||||||
Noop },
|
Noop },
|
||||||
|
{ LFUN_INSET_FOOTNOTE, "footnote-inset-insert",
|
||||||
|
N_("Insert Footnote"), Noop },
|
||||||
{ LFUN_RIGHTSEL, "forward-select", N_("Select next char"),
|
{ LFUN_RIGHTSEL, "forward-select", N_("Select next char"),
|
||||||
ReadOnly },
|
ReadOnly },
|
||||||
{ LFUN_HFILL, "hfill-insert",
|
{ LFUN_HFILL, "hfill-insert",
|
||||||
|
@ -76,6 +76,7 @@ using std::setw;
|
|||||||
#include "insets/insettext.h"
|
#include "insets/insettext.h"
|
||||||
#include "insets/insetert.h"
|
#include "insets/insetert.h"
|
||||||
#include "insets/insetgraphics.h"
|
#include "insets/insetgraphics.h"
|
||||||
|
#include "insets/insetfoot.h"
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/path.h"
|
#include "support/path.h"
|
||||||
#include "LaTeX.h"
|
#include "LaTeX.h"
|
||||||
@ -789,6 +790,13 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
|||||||
par->InsertInset(pos, inset);
|
par->InsertInset(pos, inset);
|
||||||
par->SetFont(pos, font);
|
par->SetFont(pos, font);
|
||||||
++pos;
|
++pos;
|
||||||
|
} else if (tmptok == "Foot") {
|
||||||
|
inset = new InsetFoot(this);
|
||||||
|
inset->Read(lex);
|
||||||
|
par->InsertChar(pos, LyXParagraph::META_INSET);
|
||||||
|
par->InsertInset(pos, inset);
|
||||||
|
par->SetFont(pos, font);
|
||||||
|
++pos;
|
||||||
} else if (tmptok == "GRAPHICS") {
|
} else if (tmptok == "GRAPHICS") {
|
||||||
inset = new InsetGraphics;
|
inset = new InsetGraphics;
|
||||||
//inset->Read(lex);
|
//inset->Read(lex);
|
||||||
|
@ -243,6 +243,7 @@ enum kb_action {
|
|||||||
LFUN_INSET_TEXT, // Jug 20000214
|
LFUN_INSET_TEXT, // Jug 20000214
|
||||||
LFUN_INSET_ERT, // Jug 20000218
|
LFUN_INSET_ERT, // Jug 20000218
|
||||||
LFUN_INSERT_GRAPHICS, // Lgb 20000226
|
LFUN_INSERT_GRAPHICS, // Lgb 20000226
|
||||||
|
LFUN_INSET_FOOTNOTE, // Jug 20000307
|
||||||
LFUN_LASTACTION /* this marks the end of the table */
|
LFUN_LASTACTION /* this marks the end of the table */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,12 +14,16 @@ libinsets_la_SOURCES = \
|
|||||||
inset.C \
|
inset.C \
|
||||||
insetbib.C \
|
insetbib.C \
|
||||||
insetbib.h \
|
insetbib.h \
|
||||||
|
insetcollapsable.C \
|
||||||
|
insetcollapsable.h \
|
||||||
insetcommand.C \
|
insetcommand.C \
|
||||||
insetcommand.h \
|
insetcommand.h \
|
||||||
inseterror.C \
|
inseterror.C \
|
||||||
inseterror.h \
|
inseterror.h \
|
||||||
insetert.C \
|
insetert.C \
|
||||||
insetert.h \
|
insetert.h \
|
||||||
|
insetfoot.C \
|
||||||
|
insetfoot.h \
|
||||||
insetgraphics.C \
|
insetgraphics.C \
|
||||||
insetgraphics.h \
|
insetgraphics.h \
|
||||||
insetinclude.C \
|
insetinclude.C \
|
||||||
|
@ -1256,9 +1256,9 @@ void InsetFig::Validate(LaTeXFeatures & features) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char InsetFig::Editable() const
|
Inset::EDITABLE InsetFig::Editable() const
|
||||||
{
|
{
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int, int, unsigned int);
|
void Edit(BufferView *, int, int, unsigned int);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const;
|
EDITABLE Editable() const;
|
||||||
///
|
///
|
||||||
bool Deletable() const;
|
bool Deletable() const;
|
||||||
///
|
///
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
#include "Painter.h"
|
||||||
|
|
||||||
/* Insets default methods */
|
/* Insets default methods */
|
||||||
|
|
||||||
@ -33,9 +34,9 @@ bool Inset::DirectWrite() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char Inset::Editable() const
|
Inset::EDITABLE Inset::Editable() const
|
||||||
{
|
{
|
||||||
return 0;
|
return NOT_EDITABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,9 +98,9 @@ void UpdatableInset::InsetUnlock(BufferView *)
|
|||||||
|
|
||||||
|
|
||||||
// An updatable inset is highly editable by definition
|
// An updatable inset is highly editable by definition
|
||||||
unsigned char UpdatableInset::Editable() const
|
Inset::EDITABLE UpdatableInset::Editable() const
|
||||||
{
|
{
|
||||||
return 2; // and what does "2" siginify? (Lgb)
|
return HIGHLY_EDITABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -154,3 +155,11 @@ UpdatableInset::LocalDispatch(BufferView *, int, string const &)
|
|||||||
#endif
|
#endif
|
||||||
return UNDISPATCHED;
|
return UNDISPATCHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int UpdatableInset::getMaxWidth(Painter & pain) const
|
||||||
|
{
|
||||||
|
if (owner_)
|
||||||
|
return owner_->getMaxWidth(pain);
|
||||||
|
return pain.paperWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int x, int y, unsigned int button);
|
void Edit(BufferView *, int x, int y, unsigned int button);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
struct Holder {
|
struct Holder {
|
||||||
@ -78,8 +78,8 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int x, int y, unsigned int button);
|
void Edit(BufferView *, int x, int y, unsigned int button);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
/// A user can't neither insert nor delete this inset
|
/// A user can't neither insert nor delete this inset
|
||||||
bool Deletable() const {
|
bool Deletable() const {
|
||||||
@ -135,8 +135,8 @@ public:
|
|||||||
///
|
///
|
||||||
string getKeys(char delim);
|
string getKeys(char delim);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
bool addDatabase(string const &);
|
bool addDatabase(string const &);
|
||||||
|
196
src/insets/insetcollapsable.C
Normal file
196
src/insets/insetcollapsable.C
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 The LyX Team.
|
||||||
|
*
|
||||||
|
*======================================================*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "insetcollapsable.h"
|
||||||
|
#include "gettext.h"
|
||||||
|
#include "lyxfont.h"
|
||||||
|
#include "BufferView.h"
|
||||||
|
#include "Painter.h"
|
||||||
|
|
||||||
|
|
||||||
|
InsetCollapsable::InsetCollapsable(Buffer * bf): InsetText(bf)
|
||||||
|
{
|
||||||
|
collapsed = true;
|
||||||
|
label = "Label";
|
||||||
|
autocolapse = true;
|
||||||
|
autoBreakRows = true;
|
||||||
|
framecolor = LColor::footnoteframe;
|
||||||
|
widthOffset = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Inset * InsetCollapsable::Clone()
|
||||||
|
{
|
||||||
|
Inset * result = new InsetCollapsable(buffer);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int InsetCollapsable::ascent_collapsed(Painter & pain, LyXFont const &) const
|
||||||
|
{
|
||||||
|
int width = 0, ascent = 0, descent = 0;
|
||||||
|
pain.buttonText(0, 0, label.c_str(), labelfont, false,
|
||||||
|
width, ascent, descent);
|
||||||
|
return ascent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int InsetCollapsable::descent_collapsed(Painter & pain, LyXFont const &) const
|
||||||
|
{
|
||||||
|
int width = 0, ascent = 0, descent = 0;
|
||||||
|
pain.buttonText(0, 0, label.c_str(), labelfont, false,
|
||||||
|
width, ascent, descent);
|
||||||
|
return descent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int InsetCollapsable::width_collapsed(Painter & pain, LyXFont const &) const
|
||||||
|
{
|
||||||
|
int width, ascent, descent;
|
||||||
|
pain.buttonText(TEXT_TO_INSET_OFFSET, 0, label.c_str(), labelfont, false,
|
||||||
|
width, ascent, descent);
|
||||||
|
return width + (2*TEXT_TO_INSET_OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int InsetCollapsable::ascent(Painter & pain, LyXFont const & font) const
|
||||||
|
{
|
||||||
|
if (collapsed)
|
||||||
|
return ascent_collapsed(pain, font);
|
||||||
|
else
|
||||||
|
return InsetText::ascent(pain, font) + TEXT_TO_TOP_OFFSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int InsetCollapsable::descent(Painter & pain, LyXFont const & font) const
|
||||||
|
{
|
||||||
|
if (collapsed)
|
||||||
|
return descent_collapsed(pain, font);
|
||||||
|
else
|
||||||
|
return InsetText::descent(pain, font) + TEXT_TO_BOTTOM_OFFSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int InsetCollapsable::width(Painter & pain, LyXFont const & font) const
|
||||||
|
{
|
||||||
|
if (collapsed)
|
||||||
|
return width_collapsed(pain, font);
|
||||||
|
|
||||||
|
return getMaxWidth(pain);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const &,
|
||||||
|
int baseline, float & x) const
|
||||||
|
{
|
||||||
|
int width = 0;
|
||||||
|
pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET, baseline,
|
||||||
|
label.c_str(), labelfont, true, width);
|
||||||
|
x += width + (2 * TEXT_TO_INSET_OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetCollapsable::draw(Painter & pain, LyXFont const & f,
|
||||||
|
int baseline, float & x) const
|
||||||
|
{
|
||||||
|
if (collapsed) {
|
||||||
|
draw_collapsed(pain, f, baseline, x);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
top_x = int(x);
|
||||||
|
top_baseline = baseline;
|
||||||
|
draw_collapsed(pain, f, baseline, x);
|
||||||
|
button_x = int(x - top_x);
|
||||||
|
|
||||||
|
maxWidth = getMaxWidth(pain) - button_x;
|
||||||
|
x += 2;
|
||||||
|
int
|
||||||
|
w = maxWidth - widthOffset,
|
||||||
|
h = ascent(pain,f) + descent(pain,f);
|
||||||
|
|
||||||
|
pain.rectangle(int(x), baseline - ascent(pain, f), w, h, framecolor);
|
||||||
|
|
||||||
|
x += 4;
|
||||||
|
top_x = int(x - top_x);
|
||||||
|
InsetText::draw(pain, f, baseline, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetCollapsable::Edit(BufferView *bv, int x, int y, unsigned int button)
|
||||||
|
{
|
||||||
|
if (collapsed) {
|
||||||
|
collapsed = false;
|
||||||
|
UpdateLocal(bv, true);
|
||||||
|
InsetText::Edit(bv, 0, 0, button);
|
||||||
|
} else if (button && (x < button_x) &&
|
||||||
|
(y < (labelfont.maxDescent()+labelfont.maxAscent()))) {
|
||||||
|
collapsed = true;
|
||||||
|
UpdateLocal(bv, false);
|
||||||
|
bv->unlockInset(this);
|
||||||
|
} else {
|
||||||
|
InsetText::Edit(bv, x-top_x, y, button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Inset::EDITABLE InsetCollapsable::Editable() const
|
||||||
|
{
|
||||||
|
if (collapsed)
|
||||||
|
return IS_EDITABLE;
|
||||||
|
return HIGHLY_EDITABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InsetCollapsable::InsetUnlock(BufferView *bv)
|
||||||
|
{
|
||||||
|
if (autocolapse) {
|
||||||
|
collapsed = true;
|
||||||
|
}
|
||||||
|
InsetText::InsetUnlock(bv);
|
||||||
|
UpdateLocal(bv, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetCollapsable::UpdateLocal(BufferView *bv, bool flag)
|
||||||
|
{
|
||||||
|
maxWidth = getMaxWidth(bv->getPainter()) -
|
||||||
|
width_collapsed(bv->getPainter(), labelfont);
|
||||||
|
InsetText::UpdateLocal(bv, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetCollapsable::InsetButtonPress(BufferView *bv,int x,int y,int button)
|
||||||
|
{
|
||||||
|
if ((x < button_x) &&
|
||||||
|
(y < (labelfont.maxDescent()+labelfont.maxAscent()))) {
|
||||||
|
collapsed = true;
|
||||||
|
UpdateLocal(bv, false);
|
||||||
|
bv->unlockInset(this);
|
||||||
|
} else if (x >= button_x) {
|
||||||
|
InsetText::InsetButtonPress(bv, x-top_x, y, button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetCollapsable::InsetButtonRelease(BufferView *bv, int x, int y, int button)
|
||||||
|
{
|
||||||
|
if (x >= button_x)
|
||||||
|
InsetText::InsetButtonRelease(bv, x-top_x, y, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetCollapsable::InsetMotionNotify(BufferView *bv, int x, int y, int button)
|
||||||
|
{
|
||||||
|
if (x >= button_x)
|
||||||
|
InsetText::InsetMotionNotify(bv, x-top_x, y, button);
|
||||||
|
}
|
101
src/insets/insetcollapsable.h
Normal file
101
src/insets/insetcollapsable.h
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright (C) 2000 The LyX Team.
|
||||||
|
*
|
||||||
|
*======================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INSETCOLLAPSABLE_H
|
||||||
|
#define INSETCOLLAPSABLE_H
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "insettext.h"
|
||||||
|
#include "lyxfont.h"
|
||||||
|
#include "LColor.h"
|
||||||
|
|
||||||
|
|
||||||
|
class Painter;
|
||||||
|
|
||||||
|
/** A colapsable text inset
|
||||||
|
|
||||||
|
*/
|
||||||
|
class InsetCollapsable : public InsetText {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
static int const TEXT_TO_TOP_OFFSET = 2;
|
||||||
|
///
|
||||||
|
static int const TEXT_TO_BOTTOM_OFFSET = 2;
|
||||||
|
///
|
||||||
|
InsetCollapsable(Buffer *);
|
||||||
|
///
|
||||||
|
~InsetCollapsable() {}
|
||||||
|
///
|
||||||
|
Inset * InsetCollapsable::Clone();
|
||||||
|
///
|
||||||
|
int ascent(Painter &, LyXFont const &) const;
|
||||||
|
///
|
||||||
|
int descent(Painter &, LyXFont const &) const;
|
||||||
|
///
|
||||||
|
int width(Painter &, LyXFont const & f) const;
|
||||||
|
///
|
||||||
|
void draw(Painter & pain, const LyXFont &, int , float &) const;
|
||||||
|
///
|
||||||
|
void Edit(BufferView *, int, int, unsigned int);
|
||||||
|
///
|
||||||
|
EDITABLE Editable() const;
|
||||||
|
///
|
||||||
|
void InsetUnlock(BufferView *);
|
||||||
|
///
|
||||||
|
bool display() const { return (!collapsed); }
|
||||||
|
///
|
||||||
|
void InsetButtonRelease(BufferView *, int, int, int);
|
||||||
|
///
|
||||||
|
void InsetButtonPress(BufferView *, int, int, int);
|
||||||
|
///
|
||||||
|
void InsetMotionNotify(BufferView *, int, int, int);
|
||||||
|
///
|
||||||
|
void setLabel(string const & l) { label = l; }
|
||||||
|
///
|
||||||
|
void setLabelFont(LyXFont & f) { labelfont = f; }
|
||||||
|
///
|
||||||
|
void setAutoCollapse(bool f) { autocolapse = f; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
///
|
||||||
|
int ascent_collapsed(Painter &, LyXFont const &) const;
|
||||||
|
///
|
||||||
|
int descent_collapsed(Painter &, LyXFont const &) const;
|
||||||
|
///
|
||||||
|
int width_collapsed(Painter &, LyXFont const & f) const;
|
||||||
|
///
|
||||||
|
void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
|
||||||
|
///
|
||||||
|
void UpdateLocal(BufferView *, bool);
|
||||||
|
|
||||||
|
///
|
||||||
|
bool collapsed;
|
||||||
|
///
|
||||||
|
LColor::color framecolor;
|
||||||
|
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
string label;
|
||||||
|
///
|
||||||
|
LyXFont labelfont;
|
||||||
|
///
|
||||||
|
bool autocolapse;
|
||||||
|
///
|
||||||
|
mutable int
|
||||||
|
top_baseline, top_x,
|
||||||
|
button_x;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -146,9 +146,9 @@ bool InsetError::AutoDelete() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char InsetError::Editable() const
|
Inset::EDITABLE InsetError::Editable() const
|
||||||
{
|
{
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int x, int y, unsigned int button);
|
void Edit(BufferView *, int x, int y, unsigned int button);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const;
|
EDITABLE Editable() const;
|
||||||
///
|
///
|
||||||
Inset * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
|
@ -17,15 +17,23 @@
|
|||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "lyxfont.h"
|
#include "lyxfont.h"
|
||||||
#include "Painter.h"
|
#include "Painter.h"
|
||||||
#include "lyx_gui_misc.h"
|
#include "buffer.h"
|
||||||
|
//#include "lyx_gui_misc.h"
|
||||||
|
|
||||||
|
|
||||||
InsetERT::InsetERT(Buffer * bf)
|
InsetERT::InsetERT(Buffer * bf)
|
||||||
: InsetText(bf)
|
: InsetCollapsable(bf)
|
||||||
{
|
{
|
||||||
closed = true;
|
setLabel(_("ERT"));
|
||||||
nomotion = false;
|
LyXFont font(LyXFont::ALL_SANE);
|
||||||
autoBreakRows = true;
|
font.setLatex (LyXFont::ON);
|
||||||
|
real_current_font = current_font = font;
|
||||||
|
LyXFont labelfont(LyXFont::ALL_SANE);
|
||||||
|
labelfont.decSize();
|
||||||
|
labelfont.decSize();
|
||||||
|
labelfont.setColor(LColor::ert);
|
||||||
|
setLabelFont(labelfont);
|
||||||
|
setAutoCollapse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -42,151 +50,13 @@ void InsetERT::Write(ostream & os) const
|
|||||||
WriteParagraphData(os);
|
WriteParagraphData(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InsetERT::InsertInset(BufferView *, Inset *)
|
||||||
int InsetERT::ascent_closed(Painter & pain, LyXFont const & f) const
|
|
||||||
{
|
|
||||||
int width, ascent, descent;
|
|
||||||
LyXFont font(LyXFont::ALL_SANE);
|
|
||||||
font.setSize(f.size());
|
|
||||||
font.decSize();
|
|
||||||
font.decSize();
|
|
||||||
pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
|
|
||||||
return ascent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int InsetERT::descent_closed(Painter & pain, LyXFont const & f) const
|
|
||||||
{
|
|
||||||
int width, ascent, descent;
|
|
||||||
LyXFont font(LyXFont::ALL_SANE);
|
|
||||||
font.setSize(f.size());
|
|
||||||
font.decSize();
|
|
||||||
font.decSize();
|
|
||||||
pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
|
|
||||||
return descent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int InsetERT::width_closed(Painter & pain, LyXFont const & f) const
|
|
||||||
{
|
|
||||||
int width, ascent, descent;
|
|
||||||
LyXFont font(LyXFont::ALL_SANE);
|
|
||||||
font.setSize(f.size());
|
|
||||||
font.decSize();
|
|
||||||
font.decSize();
|
|
||||||
pain.buttonText(TEXT_TO_INSET_OFFSET, 0, _("ERT"), font, false,
|
|
||||||
width, ascent, descent);
|
|
||||||
return width + (2*TEXT_TO_INSET_OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int InsetERT::ascent(Painter & pain, LyXFont const & font) const
|
|
||||||
{
|
|
||||||
if (closed)
|
|
||||||
return ascent_closed(pain, font);
|
|
||||||
else
|
|
||||||
return InsetText::ascent(pain, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int InsetERT::descent(Painter & pain, LyXFont const & font) const
|
|
||||||
{
|
|
||||||
|
|
||||||
if (closed)
|
|
||||||
return descent_closed(pain, font);
|
|
||||||
else
|
|
||||||
return InsetText::descent(pain, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int InsetERT::width(Painter & pain, LyXFont const & font) const
|
|
||||||
{
|
|
||||||
if (closed)
|
|
||||||
return width_closed(pain, font);
|
|
||||||
else
|
|
||||||
return InsetText::width(pain, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::draw_closed(Painter & pain, LyXFont const & f,
|
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
|
||||||
LyXFont font(LyXFont::ALL_SANE);
|
|
||||||
font.setSize(f.size());
|
|
||||||
font.decSize();
|
|
||||||
font.decSize();
|
|
||||||
font.setColor(LColor::ert);
|
|
||||||
int width;
|
|
||||||
pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET, baseline,
|
|
||||||
_("ERT"), font, true, width);
|
|
||||||
x += width + (2 * TEXT_TO_INSET_OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::draw(Painter & pain, LyXFont const & f,
|
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
|
||||||
if (closed) {
|
|
||||||
top_x = int(x);
|
|
||||||
top_baseline = baseline;
|
|
||||||
draw_closed(pain, f, baseline, x);
|
|
||||||
} else {
|
|
||||||
InsetText::draw(pain, f, baseline, x);
|
|
||||||
}
|
|
||||||
// resetPos(bv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::InsetButtonRelease(BufferView * bv, int x, int y, int button)
|
|
||||||
{
|
|
||||||
nomotion = false;
|
|
||||||
InsetText::InsetButtonRelease(bv, x, y, button);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::InsetButtonPress(BufferView * bv, int x, int y, int button)
|
|
||||||
{
|
|
||||||
nomotion = false;
|
|
||||||
InsetText::InsetButtonPress(bv, x, y, button);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::InsetMotionNotify(BufferView * bv, int x, int y, int button)
|
|
||||||
{
|
|
||||||
if (nomotion)
|
|
||||||
return;
|
|
||||||
InsetText::InsetMotionNotify(bv, x, y, button);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button)
|
|
||||||
{
|
|
||||||
closed = false;
|
|
||||||
nomotion = true;
|
|
||||||
LyXFont font(LyXFont::ALL_SANE);
|
|
||||||
font.setLatex (LyXFont::ON);
|
|
||||||
InsetText::Edit(bv, (x > (width_closed(bv->getPainter(),font)-5) ?
|
|
||||||
width(bv->getPainter(), font) : 0), y, button);
|
|
||||||
real_current_font = current_font = font;
|
|
||||||
bv->updateInset(this, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::InsetUnlock(BufferView * bv)
|
|
||||||
{
|
|
||||||
closed = true;
|
|
||||||
InsetText::InsetUnlock(bv);
|
|
||||||
bv->updateInset(this, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool InsetERT::InsertInset(Inset *)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::SetFont(LyXFont const &, bool)
|
void InsetERT::SetFont(BufferView *, LyXFont const &, bool)
|
||||||
{
|
{
|
||||||
WriteAlert(_("Impossible Operation!"),
|
WriteAlert(_("Impossible Operation!"),
|
||||||
_("Not permitted to change font-types inside ERT-insets!"),
|
_("Not permitted to change font-types inside ERT-insets!"),
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "insettext.h"
|
#include "insetcollapsable.h"
|
||||||
|
|
||||||
class Painter;
|
class Painter;
|
||||||
|
|
||||||
@ -27,60 +27,23 @@ class Painter;
|
|||||||
To write full ert (including styles and other insets) in a given
|
To write full ert (including styles and other insets) in a given
|
||||||
space.
|
space.
|
||||||
*/
|
*/
|
||||||
class InsetERT : public InsetText {
|
class InsetERT : public InsetCollapsable {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetERT(Buffer *);
|
InsetERT(Buffer *);
|
||||||
///
|
///
|
||||||
// InsetERT(InsetERT const &, Buffer *);
|
|
||||||
///
|
|
||||||
~InsetERT() {}
|
~InsetERT() {}
|
||||||
///
|
///
|
||||||
Inset * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
// void Read(LyXLex &);
|
|
||||||
///
|
|
||||||
void Write(ostream &) const;
|
void Write(ostream &) const;
|
||||||
///
|
///
|
||||||
int ascent(Painter &, LyXFont const &) const;
|
const char * EditMessage() const { return _("Opened ERT Inset");}
|
||||||
///
|
///
|
||||||
int descent(Painter &, LyXFont const &) const;
|
bool InsertInset(BufferView *, Inset *);
|
||||||
///
|
///
|
||||||
int width(Painter &, LyXFont const & f) const;
|
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
||||||
///
|
///
|
||||||
void draw(Painter & pain, const LyXFont &, int , float &) const;
|
|
||||||
///
|
|
||||||
//LString EditMessage() const;
|
|
||||||
///
|
|
||||||
void InsetButtonRelease(BufferView *, int, int, int);
|
|
||||||
///
|
|
||||||
void InsetButtonPress(BufferView *, int, int, int);
|
|
||||||
///
|
|
||||||
void InsetMotionNotify(BufferView *, int, int, int);
|
|
||||||
///
|
|
||||||
void Edit(BufferView *, int, int, unsigned int);
|
|
||||||
///
|
|
||||||
void InsetUnlock(BufferView *);
|
|
||||||
///
|
|
||||||
bool InsertInset(Inset *);
|
|
||||||
///
|
|
||||||
void SetFont(LyXFont const &, bool toggleall);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
///
|
|
||||||
int ascent_closed(Painter &, LyXFont const &) const;
|
|
||||||
///
|
|
||||||
int descent_closed(Painter &, LyXFont const &) const;
|
|
||||||
///
|
|
||||||
int width_closed(Painter &, LyXFont const & f) const;
|
|
||||||
///
|
|
||||||
void draw_closed(Painter & pain, LyXFont const &, int , float &) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
///
|
|
||||||
bool closed;
|
|
||||||
///
|
|
||||||
bool nomotion;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
114
src/insets/insetfoot.C
Normal file
114
src/insets/insetfoot.C
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 The LyX Team.
|
||||||
|
*
|
||||||
|
*======================================================*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "insetfoot.h"
|
||||||
|
#include "gettext.h"
|
||||||
|
#include "lyxfont.h"
|
||||||
|
#include "BufferView.h"
|
||||||
|
#include "lyxscreen.h"
|
||||||
|
#include "Painter.h"
|
||||||
|
|
||||||
|
|
||||||
|
InsetFoot::InsetFoot(Buffer * bf): InsetCollapsable(bf)
|
||||||
|
{
|
||||||
|
setLabel(_("foot"));
|
||||||
|
LyXFont font(LyXFont::ALL_SANE);
|
||||||
|
font.decSize();
|
||||||
|
font.decSize();
|
||||||
|
font.setColor(LColor::footnote);
|
||||||
|
setLabelFont(font);
|
||||||
|
setAutoCollapse(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InsetFoot * InsetFoot::Clone() const
|
||||||
|
{
|
||||||
|
InsetFoot * result = new InsetFoot(buffer);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char * InsetFoot::EditMessage() const
|
||||||
|
{
|
||||||
|
return _("Opened Footnote Inset");
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef USE_OSTREAM_ONLY
|
||||||
|
int InsetFoot::Latex(string & l, signed char fragile) const
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (fragile)
|
||||||
|
l += "\\footnotetext{";
|
||||||
|
else
|
||||||
|
l += "\\footnote{";
|
||||||
|
|
||||||
|
i = InsetText::Latex(l, fragile);
|
||||||
|
l += "}";
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int InsetFoot::Latex(ostream & os, signed char fragile) const
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (fragile)
|
||||||
|
os << "\\footnotetext{";
|
||||||
|
else
|
||||||
|
os << "\\footnote{";
|
||||||
|
|
||||||
|
i = InsetText::Latex(os, fragile);
|
||||||
|
os << "}";
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InsetFoot::Write(ostream & os) const
|
||||||
|
{
|
||||||
|
os << "Foot\n";
|
||||||
|
os << "\ncollapsed ";
|
||||||
|
if (display())
|
||||||
|
os << "false";
|
||||||
|
else
|
||||||
|
os << "true";
|
||||||
|
os << "\n";
|
||||||
|
WriteParagraphData(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InsetFoot::Read(LyXLex & lex)
|
||||||
|
{
|
||||||
|
if (lex.IsOK()) {
|
||||||
|
string token, tmptok;
|
||||||
|
|
||||||
|
lex.next();
|
||||||
|
token = lex.GetString();
|
||||||
|
if (token == "collapsed") {
|
||||||
|
lex.next();
|
||||||
|
collapsed = lex.GetBool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
InsetText::Read(lex);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InsetFoot::InsertInset(BufferView *bv, Inset * inset)
|
||||||
|
{
|
||||||
|
if ((inset->LyxCode() == Inset::FOOT_CODE) ||
|
||||||
|
(inset->LyxCode() == Inset::MARGIN_CODE)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return InsetText::InsertInset(bv, inset);
|
||||||
|
}
|
55
src/insets/insetfoot.h
Normal file
55
src/insets/insetfoot.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 The LyX Team.
|
||||||
|
*
|
||||||
|
*======================================================
|
||||||
|
*/
|
||||||
|
// The pristine updatable inset: Text
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INSETFOOT_H
|
||||||
|
#define INSETFOOT_H
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "insetcollapsable.h"
|
||||||
|
|
||||||
|
|
||||||
|
class Painter;
|
||||||
|
|
||||||
|
/** The footnote inset
|
||||||
|
|
||||||
|
*/
|
||||||
|
class InsetFoot : public InsetCollapsable {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
InsetFoot(Buffer *);
|
||||||
|
///
|
||||||
|
~InsetFoot() {}
|
||||||
|
///
|
||||||
|
InsetFoot * InsetFoot::Clone() const;
|
||||||
|
///
|
||||||
|
Inset::Code LyxCode() const { return Inset::FOOT_CODE; }
|
||||||
|
#ifndef USE_OSTREAM_ONLY
|
||||||
|
///
|
||||||
|
int Latex(string &, signed char) const;
|
||||||
|
#endif
|
||||||
|
///
|
||||||
|
int Latex(ostream &, signed char) const;
|
||||||
|
///
|
||||||
|
void Write(ostream &) const;
|
||||||
|
///
|
||||||
|
void Read(LyXLex &);
|
||||||
|
///
|
||||||
|
const char * EditMessage() const;
|
||||||
|
///
|
||||||
|
bool InsertInset(BufferView *, Inset * inset);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -59,9 +59,9 @@ void InsetGraphics::Edit(BufferView *, int, int, unsigned int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char InsetGraphics::Editable() const
|
Inset::EDITABLE InsetGraphics::Editable() const
|
||||||
{
|
{
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int, int, unsigned int);
|
void Edit(BufferView *, int, int, unsigned int);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const;
|
EDITABLE Editable() const;
|
||||||
///
|
///
|
||||||
void Write(ostream &) const;
|
void Write(ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -49,9 +49,9 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int x, int y, unsigned int button);
|
void Edit(BufferView *, int x, int y, unsigned int button);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const
|
EDITABLE Editable() const
|
||||||
{
|
{
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
/// With lyx3 we won't overload these 3 methods
|
/// With lyx3 we won't overload these 3 methods
|
||||||
void Write(ostream &) const;
|
void Write(ostream &) const;
|
||||||
|
@ -39,9 +39,9 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int, int, unsigned int);
|
void Edit(BufferView *, int, int, unsigned int);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const
|
EDITABLE Editable() const
|
||||||
{
|
{
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
string getScreenLabel() const;
|
string getScreenLabel() const;
|
||||||
@ -61,8 +61,8 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int, int, unsigned int) {}
|
void Edit(BufferView *, int, int, unsigned int) {}
|
||||||
///
|
///
|
||||||
unsigned char Editable() const{
|
EDITABLE Editable() const{
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
/// WHY is clone missing? (Lgb)
|
/// WHY is clone missing? (Lgb)
|
||||||
///
|
///
|
||||||
|
@ -165,9 +165,9 @@ int InsetInfo::DocBook(ostream &) const
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
unsigned char InsetInfo::Editable() const
|
Inset::EDITABLE InsetInfo::Editable() const
|
||||||
{
|
{
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int, int, unsigned int);
|
void Edit(BufferView *, int, int, unsigned int);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const;
|
EDITABLE Editable() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const;
|
Inset::Code LyxCode() const;
|
||||||
///
|
///
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
///
|
///
|
||||||
string getScreenLabel() const { return getContents(); }
|
string getScreenLabel() const { return getContents(); }
|
||||||
///
|
///
|
||||||
unsigned char Editable() const { return 0; }
|
EDITABLE Editable() const { return NOT_EDITABLE; }
|
||||||
///
|
///
|
||||||
int Latex(ostream &, signed char fragile) const;
|
int Latex(ostream &, signed char fragile) const;
|
||||||
#ifndef USE_OSTREAM_ONLY
|
#ifndef USE_OSTREAM_ONLY
|
||||||
|
@ -37,8 +37,8 @@ public:
|
|||||||
string getScreenLabel() const { return _("List of Algorithms"); }
|
string getScreenLabel() const { return _("List of Algorithms"); }
|
||||||
|
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 0; // not yet
|
return NOT_EDITABLE; // not yet
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
bool display() const { return true; }
|
bool display() const { return true; }
|
||||||
|
@ -35,8 +35,8 @@ public:
|
|||||||
string getScreenLabel() const { return _("List of Figures"); }
|
string getScreenLabel() const { return _("List of Figures"); }
|
||||||
|
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 0; // not yet
|
return NOT_EDITABLE; // not yet
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
bool display() const { return true; }
|
bool display() const { return true; }
|
||||||
|
@ -35,8 +35,8 @@ public:
|
|||||||
string getScreenLabel() const { return _("List of Tables"); }
|
string getScreenLabel() const { return _("List of Tables"); }
|
||||||
|
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 0; // not yet
|
return NOT_EDITABLE; // not yet
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
bool display() const { return true; }
|
bool display() const { return true; }
|
||||||
|
@ -46,8 +46,8 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int, int, unsigned int);
|
void Edit(BufferView *, int, int, unsigned int);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const { return Inset::PARENT_CODE; }
|
Inset::Code LyxCode() const { return Inset::PARENT_CODE; }
|
||||||
|
@ -47,8 +47,8 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int, int, unsigned int);
|
void Edit(BufferView *, int, int, unsigned int);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
bool display() const { return false; }
|
bool display() const { return false; }
|
||||||
|
@ -66,8 +66,9 @@ InsetText::InsetText(Buffer * buf)
|
|||||||
interline_space = 1;
|
interline_space = 1;
|
||||||
no_selection = false;
|
no_selection = false;
|
||||||
init_inset = true;
|
init_inset = true;
|
||||||
maxAscent = maxDescent = insetWidth = 0;
|
maxAscent = maxDescent = insetWidth = widthOffset = 0;
|
||||||
autoBreakRows = false;
|
autoBreakRows = false;
|
||||||
|
xpos = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,8 +83,9 @@ InsetText::InsetText(InsetText const & ins, Buffer * buf)
|
|||||||
interline_space = 1;
|
interline_space = 1;
|
||||||
no_selection = false;
|
no_selection = false;
|
||||||
init_inset = true;
|
init_inset = true;
|
||||||
maxAscent = maxDescent = insetWidth = 0;
|
maxAscent = maxDescent = insetWidth = widthOffset = 0;
|
||||||
autoBreakRows = false;
|
autoBreakRows = false;
|
||||||
|
xpos = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,7 +155,7 @@ void InsetText::Read(LyXLex & lex)
|
|||||||
int InsetText::ascent(Painter & pain, LyXFont const & font) const
|
int InsetText::ascent(Painter & pain, LyXFont const & font) const
|
||||||
{
|
{
|
||||||
if (init_inset) {
|
if (init_inset) {
|
||||||
computeTextRows(pain);
|
computeTextRows(pain, xpos);
|
||||||
init_inset = false;
|
init_inset = false;
|
||||||
}
|
}
|
||||||
if (maxAscent)
|
if (maxAscent)
|
||||||
@ -165,7 +167,7 @@ int InsetText::ascent(Painter & pain, LyXFont const & font) const
|
|||||||
int InsetText::descent(Painter & pain, LyXFont const & font) const
|
int InsetText::descent(Painter & pain, LyXFont const & font) const
|
||||||
{
|
{
|
||||||
if (init_inset) {
|
if (init_inset) {
|
||||||
computeTextRows(pain);
|
computeTextRows(pain, xpos);
|
||||||
init_inset = false;
|
init_inset = false;
|
||||||
}
|
}
|
||||||
if (maxDescent)
|
if (maxDescent)
|
||||||
@ -177,34 +179,18 @@ int InsetText::descent(Painter & pain, LyXFont const & font) const
|
|||||||
int InsetText::width(Painter & pain, LyXFont const &) const
|
int InsetText::width(Painter & pain, LyXFont const &) const
|
||||||
{
|
{
|
||||||
if (init_inset) {
|
if (init_inset) {
|
||||||
computeTextRows(pain);
|
computeTextRows(pain, xpos);
|
||||||
init_inset = false;
|
init_inset = false;
|
||||||
}
|
}
|
||||||
return insetWidth;
|
return insetWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetText::getMaxWidth(UpdatableInset * inset) const
|
|
||||||
{
|
|
||||||
if (!the_locking_inset) {
|
|
||||||
lyxerr << "Text: No locking inset in this inset.\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (the_locking_inset == inset)
|
|
||||||
return maxWidth;
|
|
||||||
|
|
||||||
return the_locking_inset->getMaxWidth(inset);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetText::draw(Painter & pain, LyXFont const & f,
|
void InsetText::draw(Painter & pain, LyXFont const & f,
|
||||||
int baseline, float & x) const
|
int baseline, float & x) const
|
||||||
{
|
{
|
||||||
// if (init_inset) {
|
xpos = x;
|
||||||
computeTextRows(pain, x);
|
computeTextRows(pain, x);
|
||||||
// init_inset = false;
|
|
||||||
// }
|
|
||||||
UpdatableInset::draw(pain, f, baseline, x);
|
UpdatableInset::draw(pain, f, baseline, x);
|
||||||
|
|
||||||
bool do_reset_pos = (x != top_x) || (baseline != top_baseline);
|
bool do_reset_pos = (x != top_x) || (baseline != top_baseline);
|
||||||
@ -324,7 +310,7 @@ void InsetText::InsetUnlock(BufferView * bv)
|
|||||||
HideInsetCursor(bv);
|
HideInsetCursor(bv);
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
}
|
}
|
||||||
the_locking_inset = 0;
|
the_locking_inset = 0;
|
||||||
no_selection = false;
|
no_selection = false;
|
||||||
@ -354,7 +340,7 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
|
|||||||
return the_locking_inset->UpdateInsetInInset(bv, inset);
|
return the_locking_inset->UpdateInsetInInset(bv, inset);
|
||||||
float x = inset_x;
|
float x = inset_x;
|
||||||
inset->draw(bv->getPainter(), real_current_font, inset_y, x);
|
inset->draw(bv->getPainter(), real_current_font, inset_y, x);
|
||||||
bv->updateInset(this, true);
|
UpdateLocal(bv, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +359,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
|
|||||||
{
|
{
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
}
|
}
|
||||||
no_selection = false;
|
no_selection = false;
|
||||||
if (the_locking_inset) {
|
if (the_locking_inset) {
|
||||||
@ -419,7 +405,7 @@ void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int button)
|
|||||||
setPos(bv, x, y, false);
|
setPos(bv, x, y, false);
|
||||||
selection_end = actpos;
|
selection_end = actpos;
|
||||||
if (old != selection_end)
|
if (old != selection_end)
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
}
|
}
|
||||||
no_selection = false;
|
no_selection = false;
|
||||||
}
|
}
|
||||||
@ -457,7 +443,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
result = the_locking_inset->LocalDispatch(bv, action, arg);
|
result = the_locking_inset->LocalDispatch(bv, action, arg);
|
||||||
if (result == DISPATCHED) {
|
if (result == DISPATCHED) {
|
||||||
the_locking_inset->ToggleInsetCursor(bv);
|
the_locking_inset->ToggleInsetCursor(bv);
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
the_locking_inset->ToggleInsetCursor(bv);
|
the_locking_inset->ToggleInsetCursor(bv);
|
||||||
return result;
|
return result;
|
||||||
} else if (result == FINISHED) {
|
} else if (result == FINISHED) {
|
||||||
@ -475,8 +461,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
case -1:
|
case -1:
|
||||||
par->InsertChar(actpos,arg[0]);
|
par->InsertChar(actpos,arg[0]);
|
||||||
par->SetFont(actpos,real_current_font);
|
par->SetFont(actpos,real_current_font);
|
||||||
computeTextRows(bv->getPainter());
|
UpdateLocal(bv, true);
|
||||||
bv->updateInset(this, true);
|
|
||||||
++actpos;
|
++actpos;
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
resetPos(bv);
|
resetPos(bv);
|
||||||
@ -485,13 +470,13 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
case LFUN_RIGHTSEL:
|
case LFUN_RIGHTSEL:
|
||||||
moveRight(bv, false);
|
moveRight(bv, false);
|
||||||
selection_end = actpos;
|
selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
break;
|
break;
|
||||||
case LFUN_RIGHT:
|
case LFUN_RIGHT:
|
||||||
result= DISPATCH_RESULT(moveRight(bv));
|
result= DISPATCH_RESULT(moveRight(bv));
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
} else {
|
} else {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
}
|
}
|
||||||
@ -499,13 +484,13 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
case LFUN_LEFTSEL:
|
case LFUN_LEFTSEL:
|
||||||
moveLeft(bv, false);
|
moveLeft(bv, false);
|
||||||
selection_end = actpos;
|
selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
break;
|
break;
|
||||||
case LFUN_LEFT:
|
case LFUN_LEFT:
|
||||||
result= DISPATCH_RESULT(moveLeft(bv));
|
result= DISPATCH_RESULT(moveLeft(bv));
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
} else {
|
} else {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
}
|
}
|
||||||
@ -513,13 +498,13 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
case LFUN_DOWNSEL:
|
case LFUN_DOWNSEL:
|
||||||
moveDown(bv, false);
|
moveDown(bv, false);
|
||||||
selection_end = actpos;
|
selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
break;
|
break;
|
||||||
case LFUN_DOWN:
|
case LFUN_DOWN:
|
||||||
result= DISPATCH_RESULT(moveDown(bv));
|
result= DISPATCH_RESULT(moveDown(bv));
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
} else {
|
} else {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
}
|
}
|
||||||
@ -527,13 +512,13 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
case LFUN_UPSEL:
|
case LFUN_UPSEL:
|
||||||
moveUp(bv, false);
|
moveUp(bv, false);
|
||||||
selection_end = actpos;
|
selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
break;
|
break;
|
||||||
case LFUN_UP:
|
case LFUN_UP:
|
||||||
result= DISPATCH_RESULT(moveUp(bv));
|
result= DISPATCH_RESULT(moveUp(bv));
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
} else {
|
} else {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
}
|
}
|
||||||
@ -542,7 +527,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
if (!actpos || par->IsNewline(actpos-1)) {
|
if (!actpos || par->IsNewline(actpos-1)) {
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -550,11 +535,10 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
case LFUN_DELETE:
|
case LFUN_DELETE:
|
||||||
if (Delete()) { // we need update
|
if (Delete()) { // we need update
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
computeTextRows(bv->getPainter());
|
UpdateLocal(bv, true);
|
||||||
bv->updateInset(this, true);
|
|
||||||
} else if (hasSelection()) {
|
} else if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LFUN_HOME:
|
case LFUN_HOME:
|
||||||
@ -563,7 +547,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
cx -= SingleWidth(bv->getPainter(), par, actpos);
|
cx -= SingleWidth(bv->getPainter(), par, actpos);
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
} else {
|
} else {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
}
|
}
|
||||||
@ -573,7 +557,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
cx += SingleWidth(bv->getPainter(), par, actpos);
|
cx += SingleWidth(bv->getPainter(), par, actpos);
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
} else {
|
} else {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
}
|
}
|
||||||
@ -582,7 +566,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
|||||||
InsertInset(bv, new InsetFormula);
|
InsertInset(bv, new InsetFormula);
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
bv->updateInset(this, false);
|
UpdateLocal(bv, false);
|
||||||
} else {
|
} else {
|
||||||
selection_start = selection_end = actpos;
|
selection_start = selection_end = actpos;
|
||||||
}
|
}
|
||||||
@ -959,10 +943,13 @@ bool InsetText::Delete()
|
|||||||
|
|
||||||
bool InsetText::InsertInset(BufferView * bv, Inset * inset)
|
bool InsetText::InsertInset(BufferView * bv, Inset * inset)
|
||||||
{
|
{
|
||||||
|
if (inset->Editable() == Inset::IS_EDITABLE) {
|
||||||
|
UpdatableInset *i = (UpdatableInset *)inset;
|
||||||
|
i->setOwner((UpdatableInset *)this);
|
||||||
|
}
|
||||||
par->InsertChar(actpos, LyXParagraph::META_INSET);
|
par->InsertChar(actpos, LyXParagraph::META_INSET);
|
||||||
par->InsertInset(actpos, inset);
|
par->InsertInset(actpos, inset);
|
||||||
computeTextRows(bv->getPainter());
|
UpdateLocal(bv, true);
|
||||||
bv->updateInset(this, true);
|
|
||||||
the_locking_inset = static_cast<UpdatableInset*>(inset);
|
the_locking_inset = static_cast<UpdatableInset*>(inset);
|
||||||
inset_x = cx - top_x;
|
inset_x = cx - top_x;
|
||||||
inset_y = cy;
|
inset_y = cy;
|
||||||
@ -1015,8 +1002,7 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
|
|||||||
SetCharFont(s_start, newfont);
|
SetCharFont(s_start, newfont);
|
||||||
++s_start;
|
++s_start;
|
||||||
}
|
}
|
||||||
computeTextRows(bv->getPainter());
|
UpdateLocal(bv, true);
|
||||||
bv->updateInset(this, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1051,28 +1037,6 @@ void InsetText::SetCharFont(int pos, LyXFont const & f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Ok, Jürgen. Here is my small secret message to you. As you can see I
|
|
||||||
// played a bit witht he Textinset. (But only through the InsetERT so far).
|
|
||||||
// As you can see below I have changed the code to use max/min instead of
|
|
||||||
// the if < construct, imo this makes it faster and easier to read. I have
|
|
||||||
// also changed rows[rows.size() - 1] to rows.back() makes it clearer that
|
|
||||||
// we speak about the last element in the vector. I added a second arg to
|
|
||||||
// to this func as well. This makes it possible to take the position of the
|
|
||||||
// inset into account when drawing the inset, this is especially needed when
|
|
||||||
// the ERT inset is first in a paragraph. I am not sure, but this might have
|
|
||||||
// made short ERT (less than one line, just a couple of words) draw
|
|
||||||
// incorrectly. You should perhaps have a look yourselves at this.
|
|
||||||
// Also (phu...) I use pain to get at paperWidth().
|
|
||||||
// This is beginning to look like a very nice Inset (speaking of the ERT
|
|
||||||
// inset that is), but in afterthought, do we really need it? Wouldn't a
|
|
||||||
// non dynamic inset working in the same way as the floats be more usefull
|
|
||||||
// and easier to work with? Jean-Marc has already aired this thought.
|
|
||||||
// I tested also a bit on the raw insettext, it seems that it can't break
|
|
||||||
// over several lines properly. Other than that it seems to create the basis
|
|
||||||
// for insetfloat, insetmarginal and insetfoot just fine. How about a
|
|
||||||
// updatable inset that does not open, unless you click on it? uff... I just
|
|
||||||
// ramble on. Feel free to remove my comments after you have read them.
|
|
||||||
// Lgb
|
|
||||||
void InsetText::computeTextRows(Painter & pain, float x) const
|
void InsetText::computeTextRows(Painter & pain, float x) const
|
||||||
{
|
{
|
||||||
int p,
|
int p,
|
||||||
@ -1088,7 +1052,6 @@ void InsetText::computeTextRows(Painter & pain, float x) const
|
|||||||
|
|
||||||
if (rows.size())
|
if (rows.size())
|
||||||
rows.clear();
|
rows.clear();
|
||||||
//rows.erase(rows.begin(),rows.end());
|
|
||||||
int width = wordAscent = wordDescent = 0;
|
int width = wordAscent = wordDescent = 0;
|
||||||
insetWidth = maxAscent = maxDescent = 0;
|
insetWidth = maxAscent = maxDescent = 0;
|
||||||
row.asc = 0;
|
row.asc = 0;
|
||||||
@ -1101,11 +1064,7 @@ void InsetText::computeTextRows(Painter & pain, float x) const
|
|||||||
insetWidth += SingleWidth(pain, par, p);
|
insetWidth += SingleWidth(pain, par, p);
|
||||||
SingleHeight(pain, par, p, asc, desc);
|
SingleHeight(pain, par, p, asc, desc);
|
||||||
maxAscent = max(maxAscent, asc);
|
maxAscent = max(maxAscent, asc);
|
||||||
//if (asc > maxAscent)
|
|
||||||
//maxAscent = asc;
|
|
||||||
maxDescent = max(maxDescent, desc);
|
maxDescent = max(maxDescent, desc);
|
||||||
//if (desc > maxDescent)
|
|
||||||
//maxDescent = desc;
|
|
||||||
}
|
}
|
||||||
rows[0].asc = maxAscent;
|
rows[0].asc = maxAscent;
|
||||||
rows[0].desc = maxDescent;
|
rows[0].desc = maxDescent;
|
||||||
@ -1119,25 +1078,20 @@ void InsetText::computeTextRows(Painter & pain, float x) const
|
|||||||
|
|
||||||
int cw, lastWordWidth = 0;
|
int cw, lastWordWidth = 0;
|
||||||
|
|
||||||
//maxWidth = buffer->getUser()->paperWidth();
|
maxWidth = UpdatableInset::getMaxWidth(pain) - widthOffset;
|
||||||
maxWidth = pain.paperWidth();
|
|
||||||
for(p = 0; p < par->Last(); ++p) {
|
for(p = 0; p < par->Last(); ++p) {
|
||||||
cw = SingleWidth(pain, par, p);
|
cw = SingleWidth(pain, par, p);
|
||||||
width += cw;
|
width += cw;
|
||||||
lastWordWidth += cw;
|
lastWordWidth += cw;
|
||||||
SingleHeight(pain, par, p, asc, desc);
|
SingleHeight(pain, par, p, asc, desc);
|
||||||
wordAscent = max(wordAscent, asc);
|
wordAscent = max(wordAscent, asc);
|
||||||
//if (asc > wordAscent)
|
|
||||||
// wordAscent = asc;
|
|
||||||
wordDescent = max(wordDescent, desc);
|
wordDescent = max(wordDescent, desc);
|
||||||
//if (desc > wordDescent)
|
|
||||||
// wordDescent = desc;
|
|
||||||
Inset const * inset = 0;
|
Inset const * inset = 0;
|
||||||
if (((p + 1) < par->Last()) &&
|
if (((p + 1) < par->Last()) &&
|
||||||
(par->GetChar(p + 1)==LyXParagraph::META_INSET))
|
(par->GetChar(p + 1)==LyXParagraph::META_INSET))
|
||||||
inset = par->GetInset(p + 1);
|
inset = par->GetInset(p + 1);
|
||||||
if (inset && inset->display()) {
|
if (inset && inset->display()) {
|
||||||
if (!is_first_word_in_row && (width >= maxWidth - x)) {
|
if (!is_first_word_in_row && (width >= (maxWidth - x))) {
|
||||||
// we have to split also the row above
|
// we have to split also the row above
|
||||||
rows.back().asc = oasc;
|
rows.back().asc = oasc;
|
||||||
rows.back().desc = odesc;
|
rows.back().desc = odesc;
|
||||||
@ -1146,17 +1100,11 @@ void InsetText::computeTextRows(Painter & pain, float x) const
|
|||||||
oasc = wordAscent;
|
oasc = wordAscent;
|
||||||
odesc = wordDescent;
|
odesc = wordDescent;
|
||||||
insetWidth = max(insetWidth, owidth);
|
insetWidth = max(insetWidth, owidth);
|
||||||
//if (insetWidth < owidth)
|
|
||||||
// insetWidth = owidth;
|
|
||||||
width = lastWordWidth;
|
width = lastWordWidth;
|
||||||
lastWordWidth = 0;
|
lastWordWidth = 0;
|
||||||
} else {
|
} else {
|
||||||
oasc = max(oasc, wordAscent);
|
oasc = max(oasc, wordAscent);
|
||||||
//if (oasc < wordAscent)
|
|
||||||
//oasc = wordAscent;
|
|
||||||
odesc = max(odesc, wordDescent);
|
odesc = max(odesc, wordDescent);
|
||||||
//if (odesc < wordDescent)
|
|
||||||
//odesc = wordDescent;
|
|
||||||
}
|
}
|
||||||
rows.back().asc = oasc;
|
rows.back().asc = oasc;
|
||||||
rows.back().desc = odesc;
|
rows.back().desc = odesc;
|
||||||
@ -1170,7 +1118,7 @@ void InsetText::computeTextRows(Painter & pain, float x) const
|
|||||||
oasc = odesc = width = lastWordWidth = 0;
|
oasc = odesc = width = lastWordWidth = 0;
|
||||||
is_first_word_in_row = true;
|
is_first_word_in_row = true;
|
||||||
wordAscent = wordDescent = 0;
|
wordAscent = wordDescent = 0;
|
||||||
x = 0.0;
|
// x = 0.0;
|
||||||
continue;
|
continue;
|
||||||
} else if (par->IsSeparator(p)) {
|
} else if (par->IsSeparator(p)) {
|
||||||
if (width >= maxWidth - x) {
|
if (width >= maxWidth - x) {
|
||||||
@ -1188,31 +1136,24 @@ void InsetText::computeTextRows(Painter & pain, float x) const
|
|||||||
oasc = wordAscent;
|
oasc = wordAscent;
|
||||||
odesc = wordDescent;
|
odesc = wordDescent;
|
||||||
insetWidth = max(insetWidth, owidth);
|
insetWidth = max(insetWidth, owidth);
|
||||||
//if (insetWidth < owidth)
|
|
||||||
//insetWidth = owidth;
|
|
||||||
width = lastWordWidth;
|
width = lastWordWidth;
|
||||||
}
|
}
|
||||||
wordAscent = wordDescent = lastWordWidth = 0;
|
wordAscent = wordDescent = lastWordWidth = 0;
|
||||||
nwp = p + 1;
|
nwp = p + 1;
|
||||||
x = 0.0;
|
// x = 0.0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
owidth = width;
|
owidth = width;
|
||||||
oasc = max(oasc, wordAscent);
|
oasc = max(oasc, wordAscent);
|
||||||
//if (oasc < wordAscent)
|
|
||||||
//oasc = wordAscent;
|
|
||||||
odesc = max(odesc, wordDescent);
|
odesc = max(odesc, wordDescent);
|
||||||
//if (odesc < wordDescent)
|
|
||||||
//odesc = wordDescent;
|
|
||||||
wordAscent = wordDescent = lastWordWidth = 0;
|
wordAscent = wordDescent = lastWordWidth = 0;
|
||||||
nwp = p + 1;
|
nwp = p + 1;
|
||||||
is_first_word_in_row = false;
|
is_first_word_in_row = false;
|
||||||
}
|
}
|
||||||
x = 0.0;
|
|
||||||
}
|
}
|
||||||
// if we have some data in the paragraph we have ascent/descent
|
// if we have some data in the paragraph we have ascent/descent
|
||||||
if (p) {
|
if (p) {
|
||||||
if (width >= maxWidth) {
|
if (width >= (maxWidth - x)) {
|
||||||
// assign upper row
|
// assign upper row
|
||||||
rows.back().asc = oasc;
|
rows.back().asc = oasc;
|
||||||
rows.back().desc = odesc;
|
rows.back().desc = odesc;
|
||||||
@ -1221,25 +1162,16 @@ void InsetText::computeTextRows(Painter & pain, float x) const
|
|||||||
rows.push_back(row);
|
rows.push_back(row);
|
||||||
rows.back().asc = wordAscent;
|
rows.back().asc = wordAscent;
|
||||||
rows.back().desc = wordDescent;
|
rows.back().desc = wordDescent;
|
||||||
insetWidth = max(insetWidth, owidth);
|
width -= lastWordWidth;
|
||||||
//if (insetWidth < owidth)
|
|
||||||
//insetWidth = owidth;
|
|
||||||
width -= owidth;
|
|
||||||
insetWidth = max(insetWidth, width);
|
|
||||||
//if (insetWidth < width)
|
|
||||||
//insetWidth = width;
|
|
||||||
} else {
|
} else {
|
||||||
// assign last row data
|
// assign last row data
|
||||||
oasc = max(oasc, wordAscent);
|
// width = lastWordWidth;
|
||||||
//if (oasc < wordAscent)
|
// lastWordWidth = 0;
|
||||||
//oasc = wordAscent;
|
rows.back().asc = max(oasc, wordAscent);
|
||||||
odesc = min(odesc, wordDescent);
|
rows.back().desc = max(odesc, wordDescent);
|
||||||
//if (odesc < wordDescent)
|
|
||||||
//odesc = wordDescent;
|
|
||||||
rows.back().asc = oasc;
|
|
||||||
rows.back().desc = odesc;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
insetWidth = max(insetWidth, width);
|
||||||
// alocate a dummy row for the endpos
|
// alocate a dummy row for the endpos
|
||||||
row.pos = par->Last();
|
row.pos = par->Last();
|
||||||
rows.push_back(row);
|
rows.push_back(row);
|
||||||
@ -1249,7 +1181,6 @@ void InsetText::computeTextRows(Painter & pain, float x) const
|
|||||||
for (RowList::size_type i = 1; i < rows.size() - 1; ++i) {
|
for (RowList::size_type i = 1; i < rows.size() - 1; ++i) {
|
||||||
maxDescent += rows[i].asc + rows[i].desc + interline_space;
|
maxDescent += rows[i].asc + rows[i].desc + interline_space;
|
||||||
}
|
}
|
||||||
lyxerr << "Rows: " << rows.size() << endl;
|
|
||||||
#if 0
|
#if 0
|
||||||
if (the_locking_inset) {
|
if (the_locking_inset) {
|
||||||
computeBaselines(top_baseline);
|
computeBaselines(top_baseline);
|
||||||
@ -1270,3 +1201,9 @@ void InsetText::computeBaselines(int baseline) const
|
|||||||
rows[i].asc + interline_space;
|
rows[i].asc + interline_space;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InsetText::UpdateLocal(BufferView *bv, bool flag)
|
||||||
|
{
|
||||||
|
init_inset = flag;
|
||||||
|
bv->updateInset(this, flag);
|
||||||
|
}
|
||||||
|
@ -21,10 +21,11 @@
|
|||||||
#include "lyxinset.h"
|
#include "lyxinset.h"
|
||||||
#include "lyxparagraph.h"
|
#include "lyxparagraph.h"
|
||||||
#include "LString.h"
|
#include "LString.h"
|
||||||
#include "buffer.h"
|
//#include "buffer.h"
|
||||||
|
|
||||||
class Painter;
|
class Painter;
|
||||||
class BufferView;
|
class BufferView;
|
||||||
|
class Buffer;
|
||||||
|
|
||||||
/** A text inset is like a TeX box
|
/** A text inset is like a TeX box
|
||||||
|
|
||||||
@ -54,8 +55,6 @@ public:
|
|||||||
///
|
///
|
||||||
int width(Painter &, LyXFont const & f) const;
|
int width(Painter &, LyXFont const & f) const;
|
||||||
///
|
///
|
||||||
int getMaxWidth(UpdatableInset *) const;
|
|
||||||
///
|
|
||||||
void draw(Painter & pain, LyXFont const &, int , float &) const;
|
void draw(Painter & pain, LyXFont const &, int , float &) const;
|
||||||
///
|
///
|
||||||
char const * EditMessage() const;
|
char const * EditMessage() const;
|
||||||
@ -66,8 +65,6 @@ public:
|
|||||||
///
|
///
|
||||||
bool UnlockInsetInInset(BufferView *, Inset *, bool lr = false);
|
bool UnlockInsetInInset(BufferView *, Inset *, bool lr = false);
|
||||||
///
|
///
|
||||||
//void UpdateLocal(bool flag=true);
|
|
||||||
///
|
|
||||||
bool UpdateInsetInInset(BufferView *, Inset *);
|
bool UpdateInsetInInset(BufferView *, Inset *);
|
||||||
///
|
///
|
||||||
void InsetButtonRelease(BufferView *, int, int, int);
|
void InsetButtonRelease(BufferView *, int, int, int);
|
||||||
@ -114,6 +111,8 @@ public:
|
|||||||
LyXParagraph * par;
|
LyXParagraph * par;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
///
|
||||||
|
void UpdateLocal(BufferView *, bool);
|
||||||
///
|
///
|
||||||
void WriteParagraphData(ostream &) const;
|
void WriteParagraphData(ostream &) const;
|
||||||
///
|
///
|
||||||
@ -127,7 +126,7 @@ protected:
|
|||||||
int SingleWidth(Painter &, LyXParagraph * par, int pos) const;
|
int SingleWidth(Painter &, LyXParagraph * par, int pos) const;
|
||||||
///
|
///
|
||||||
LyXFont GetFont(LyXParagraph * par, int pos) const;
|
LyXFont GetFont(LyXParagraph * par, int pos) const;
|
||||||
///
|
|
||||||
Buffer * buffer;
|
Buffer * buffer;
|
||||||
///
|
///
|
||||||
LyXFont current_font;
|
LyXFont current_font;
|
||||||
@ -142,6 +141,8 @@ protected:
|
|||||||
///
|
///
|
||||||
mutable int insetWidth;
|
mutable int insetWidth;
|
||||||
///
|
///
|
||||||
|
int widthOffset;
|
||||||
|
///
|
||||||
bool autoBreakRows;
|
bool autoBreakRows;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -202,6 +203,8 @@ private:
|
|||||||
///
|
///
|
||||||
bool no_selection;
|
bool no_selection;
|
||||||
///
|
///
|
||||||
|
mutable float xpos;
|
||||||
|
///
|
||||||
mutable bool init_inset;
|
mutable bool init_inset;
|
||||||
///
|
///
|
||||||
UpdatableInset * the_locking_inset;
|
UpdatableInset * the_locking_inset;
|
||||||
|
@ -36,8 +36,8 @@ public:
|
|||||||
/// On edit, we open the TOC pop-up
|
/// On edit, we open the TOC pop-up
|
||||||
void Edit(BufferView * bv, int, int, unsigned int);
|
void Edit(BufferView * bv, int, int, unsigned int);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
bool display() const { return true; }
|
bool display() const { return true; }
|
||||||
|
@ -54,8 +54,8 @@ public:
|
|||||||
///
|
///
|
||||||
void Edit(BufferView *, int, int, unsigned int);
|
void Edit(BufferView *, int, int, unsigned int);
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
EDITABLE Editable() const {
|
||||||
return 1;
|
return IS_EDITABLE;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
const char * EditMessage() const {return _("Opened Url");}
|
const char * EditMessage() const {return _("Opened Url");}
|
||||||
|
@ -82,7 +82,17 @@ public:
|
|||||||
///
|
///
|
||||||
TEXT_CODE,
|
TEXT_CODE,
|
||||||
///
|
///
|
||||||
SPECIALCHAR_CODE
|
FOOT_CODE,
|
||||||
|
///
|
||||||
|
MARGIN_CODE,
|
||||||
|
///
|
||||||
|
SPECIALCHAR_CODE,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EDITABLE {
|
||||||
|
NOT_EDITABLE = 0,
|
||||||
|
IS_EDITABLE,
|
||||||
|
HIGHLY_EDITABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -103,7 +113,7 @@ public:
|
|||||||
///
|
///
|
||||||
virtual void Edit(BufferView *, int x, int y, unsigned int button);
|
virtual void Edit(BufferView *, int x, int y, unsigned int button);
|
||||||
///
|
///
|
||||||
virtual unsigned char Editable() const;
|
virtual EDITABLE Editable() const;
|
||||||
///
|
///
|
||||||
virtual bool AutoDelete() const;
|
virtual bool AutoDelete() const;
|
||||||
///
|
///
|
||||||
@ -212,11 +222,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
UpdatableInset() { scx = mx_scx = 0; }
|
UpdatableInset() {
|
||||||
|
scx = mx_scx = 0;
|
||||||
|
owner_ = 0;
|
||||||
|
}
|
||||||
///
|
///
|
||||||
//virtual ~UpdatableInset() {}
|
//virtual ~UpdatableInset() {}
|
||||||
///
|
///
|
||||||
virtual unsigned char Editable() const;
|
virtual EDITABLE Editable() const;
|
||||||
|
|
||||||
/// may call ToggleLockedInsetCursor
|
/// may call ToggleLockedInsetCursor
|
||||||
virtual void ToggleInsetCursor(BufferView *);
|
virtual void ToggleInsetCursor(BufferView *);
|
||||||
@ -259,7 +272,12 @@ public:
|
|||||||
///
|
///
|
||||||
virtual bool isCursorVisible() const { return cursor_visible; }
|
virtual bool isCursorVisible() const { return cursor_visible; }
|
||||||
///
|
///
|
||||||
virtual int getMaxWidth(UpdatableInset *) const { return -1; }
|
virtual int getMaxWidth(Painter & pain) const;
|
||||||
|
///
|
||||||
|
virtual void setOwner(UpdatableInset * inset) { owner_ = inset; }
|
||||||
|
///
|
||||||
|
virtual UpdatableInset * owner() { return owner_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
// virtual void UpdateLocal(bool flag=true);
|
// virtual void UpdateLocal(bool flag=true);
|
||||||
@ -272,5 +290,8 @@ private:
|
|||||||
///
|
///
|
||||||
int mx_scx;
|
int mx_scx;
|
||||||
mutable int scx;
|
mutable int scx;
|
||||||
|
///
|
||||||
|
UpdatableInset * owner_;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include "insets/insettext.h"
|
#include "insets/insettext.h"
|
||||||
#include "insets/insetert.h"
|
#include "insets/insetert.h"
|
||||||
#include "insets/insetgraphics.h"
|
#include "insets/insetgraphics.h"
|
||||||
|
#include "insets/insetfoot.h"
|
||||||
#include "mathed/formulamacro.h"
|
#include "mathed/formulamacro.h"
|
||||||
#include "toolbar.h"
|
#include "toolbar.h"
|
||||||
#include "spellchecker.h" // RVDK_PATCH_5
|
#include "spellchecker.h" // RVDK_PATCH_5
|
||||||
@ -1313,7 +1314,7 @@ string LyXFunc::Dispatch(int ac,
|
|||||||
&& tmptext->cursor.par->GetChar(tmptext->cursor.pos)
|
&& tmptext->cursor.par->GetChar(tmptext->cursor.pos)
|
||||||
== LyXParagraph::META_INSET
|
== LyXParagraph::META_INSET
|
||||||
&& tmptext->cursor.par->GetInset(tmptext->cursor.pos)
|
&& tmptext->cursor.par->GetInset(tmptext->cursor.pos)
|
||||||
&& tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
|
&& tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == Inset::HIGHLY_EDITABLE){
|
||||||
Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
|
Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
|
||||||
setMessage(tmpinset->EditMessage());
|
setMessage(tmpinset->EditMessage());
|
||||||
tmpinset->Edit(owner->view(), 0, 0, 0);
|
tmpinset->Edit(owner->view(), 0, 0, 0);
|
||||||
@ -1341,7 +1342,7 @@ string LyXFunc::Dispatch(int ac,
|
|||||||
&& txt->cursor.par->GetChar(txt->cursor.pos)
|
&& txt->cursor.par->GetChar(txt->cursor.pos)
|
||||||
== LyXParagraph::META_INSET
|
== LyXParagraph::META_INSET
|
||||||
&& txt->cursor.par->GetInset(txt->cursor.pos)
|
&& txt->cursor.par->GetInset(txt->cursor.pos)
|
||||||
&& txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == 2) {
|
&& txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == Inset::HIGHLY_EDITABLE) {
|
||||||
Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
|
Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
|
||||||
setMessage(tmpinset->EditMessage());
|
setMessage(tmpinset->EditMessage());
|
||||||
tmpinset->Edit(owner->view(),
|
tmpinset->Edit(owner->view(),
|
||||||
@ -1929,6 +1930,12 @@ string LyXFunc::Dispatch(int ac,
|
|||||||
owner->view()->insertInset(new_inset);
|
owner->view()->insertInset(new_inset);
|
||||||
new_inset->Edit(owner->view(), 0, 0, 0);
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
case LFUN_INSET_FOOTNOTE:
|
||||||
|
{
|
||||||
|
InsetFoot * new_inset = new InsetFoot(owner->buffer());
|
||||||
|
owner->view()->insertInset(new_inset);
|
||||||
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// --- lyxserver commands ----------------------------
|
// --- lyxserver commands ----------------------------
|
||||||
|
@ -355,7 +355,7 @@ void LyXText::OpenStuff()
|
|||||||
&& cursor.par->GetInset(cursor.pos)->Editable()) {
|
&& cursor.par->GetInset(cursor.pos)->Editable()) {
|
||||||
owner_->owner()->getMiniBuffer()
|
owner_->owner()->getMiniBuffer()
|
||||||
->Set(cursor.par->GetInset(cursor.pos)->EditMessage());
|
->Set(cursor.par->GetInset(cursor.pos)->EditMessage());
|
||||||
if (cursor.par->GetInset(cursor.pos)->Editable() != 2)
|
if (cursor.par->GetInset(cursor.pos)->Editable() != Inset::HIGHLY_EDITABLE)
|
||||||
SetCursorParUndo();
|
SetCursorParUndo();
|
||||||
cursor.par->GetInset(cursor.pos)->Edit(owner_, 0, 0, 0);
|
cursor.par->GetInset(cursor.pos)->Edit(owner_, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user