mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
Added inline functionallity to InsetERT. Fixed cache.clear() problem in
InsetText. Small fixes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2393 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
28f47d9c7e
commit
a622bb6efa
@ -10,8 +10,8 @@ src/CutAndPaste.C
|
||||
src/debug.C
|
||||
src/exporter.C
|
||||
src/ext_l10n.h
|
||||
src/figureForm.C
|
||||
src/figure_form.C
|
||||
src/figureForm.C
|
||||
src/FontLoader.C
|
||||
src/frontends/controllers/biblio.C
|
||||
src/frontends/controllers/ButtonController.h
|
||||
@ -50,69 +50,71 @@ src/frontends/qt2/paragraphdlgimpl.C
|
||||
src/frontends/qt2/tabularcreatedlgimpl.C
|
||||
src/frontends/xforms/combox.C
|
||||
src/frontends/xforms/FileDialog.C
|
||||
src/frontends/xforms/FormAboutlyx.C
|
||||
src/frontends/xforms/form_aboutlyx.C
|
||||
src/frontends/xforms/FormBibitem.C
|
||||
src/frontends/xforms/FormAboutlyx.C
|
||||
src/frontends/xforms/form_bibitem.C
|
||||
src/frontends/xforms/FormBibtex.C
|
||||
src/frontends/xforms/FormBibitem.C
|
||||
src/frontends/xforms/form_bibtex.C
|
||||
src/frontends/xforms/FormBibtex.C
|
||||
src/frontends/xforms/form_browser.C
|
||||
src/frontends/xforms/FormCharacter.C
|
||||
src/frontends/xforms/form_character.C
|
||||
src/frontends/xforms/FormCitation.C
|
||||
src/frontends/xforms/FormCharacter.C
|
||||
src/frontends/xforms/form_citation.C
|
||||
src/frontends/xforms/FormDocument.C
|
||||
src/frontends/xforms/FormCitation.C
|
||||
src/frontends/xforms/form_document.C
|
||||
src/frontends/xforms/FormError.C
|
||||
src/frontends/xforms/FormDocument.C
|
||||
src/frontends/xforms/form_error.C
|
||||
src/frontends/xforms/FormExternal.C
|
||||
src/frontends/xforms/FormError.C
|
||||
src/frontends/xforms/form_external.C
|
||||
src/frontends/xforms/FormFiledialog.C
|
||||
src/frontends/xforms/FormExternal.C
|
||||
src/frontends/xforms/form_filedialog.C
|
||||
src/frontends/xforms/FormGraphics.C
|
||||
src/frontends/xforms/FormFiledialog.C
|
||||
src/frontends/xforms/form_float.C
|
||||
src/frontends/xforms/FormFloat.C
|
||||
src/frontends/xforms/form_graphics.C
|
||||
src/frontends/xforms/FormInclude.C
|
||||
src/frontends/xforms/FormGraphics.C
|
||||
src/frontends/xforms/form_include.C
|
||||
src/frontends/xforms/FormIndex.C
|
||||
src/frontends/xforms/FormInclude.C
|
||||
src/frontends/xforms/form_index.C
|
||||
src/frontends/xforms/FormIndex.C
|
||||
src/frontends/xforms/FormLog.C
|
||||
src/frontends/xforms/FormMathsBitmap.C
|
||||
src/frontends/xforms/FormMathsDeco.C
|
||||
src/frontends/xforms/form_maths_deco.C
|
||||
src/frontends/xforms/FormMathsDelim.C
|
||||
src/frontends/xforms/FormMathsDeco.C
|
||||
src/frontends/xforms/form_maths_delim.C
|
||||
src/frontends/xforms/FormMathsMatrix.C
|
||||
src/frontends/xforms/FormMathsDelim.C
|
||||
src/frontends/xforms/form_maths_matrix.C
|
||||
src/frontends/xforms/FormMathsPanel.C
|
||||
src/frontends/xforms/FormMathsMatrix.C
|
||||
src/frontends/xforms/form_maths_panel.C
|
||||
src/frontends/xforms/FormMathsSpace.C
|
||||
src/frontends/xforms/FormMathsPanel.C
|
||||
src/frontends/xforms/form_maths_space.C
|
||||
src/frontends/xforms/FormMinipage.C
|
||||
src/frontends/xforms/FormMathsSpace.C
|
||||
src/frontends/xforms/form_minipage.C
|
||||
src/frontends/xforms/FormParagraph.C
|
||||
src/frontends/xforms/FormMinipage.C
|
||||
src/frontends/xforms/form_paragraph.C
|
||||
src/frontends/xforms/FormPreamble.C
|
||||
src/frontends/xforms/FormParagraph.C
|
||||
src/frontends/xforms/form_preamble.C
|
||||
src/frontends/xforms/FormPreferences.C
|
||||
src/frontends/xforms/FormPreamble.C
|
||||
src/frontends/xforms/form_preferences.C
|
||||
src/frontends/xforms/FormPrint.C
|
||||
src/frontends/xforms/FormPreferences.C
|
||||
src/frontends/xforms/form_print.C
|
||||
src/frontends/xforms/FormRef.C
|
||||
src/frontends/xforms/FormPrint.C
|
||||
src/frontends/xforms/form_ref.C
|
||||
src/frontends/xforms/FormSearch.C
|
||||
src/frontends/xforms/FormRef.C
|
||||
src/frontends/xforms/form_search.C
|
||||
src/frontends/xforms/FormSpellchecker.C
|
||||
src/frontends/xforms/FormSearch.C
|
||||
src/frontends/xforms/form_spellchecker.C
|
||||
src/frontends/xforms/FormTabular.C
|
||||
src/frontends/xforms/FormSpellchecker.C
|
||||
src/frontends/xforms/form_tabular.C
|
||||
src/frontends/xforms/FormTabularCreate.C
|
||||
src/frontends/xforms/FormTabular.C
|
||||
src/frontends/xforms/form_tabular_create.C
|
||||
src/frontends/xforms/FormThesaurus.C
|
||||
src/frontends/xforms/FormTabularCreate.C
|
||||
src/frontends/xforms/form_thesaurus.C
|
||||
src/frontends/xforms/FormToc.C
|
||||
src/frontends/xforms/FormThesaurus.C
|
||||
src/frontends/xforms/form_toc.C
|
||||
src/frontends/xforms/FormUrl.C
|
||||
src/frontends/xforms/FormToc.C
|
||||
src/frontends/xforms/form_url.C
|
||||
src/frontends/xforms/FormUrl.C
|
||||
src/frontends/xforms/FormVCLog.C
|
||||
src/frontends/xforms/input_validators.C
|
||||
src/frontends/xforms/Menubar_pimpl.C
|
||||
@ -132,6 +134,7 @@ src/insets/insetfoot.C
|
||||
src/insets/insetgraphics.C
|
||||
src/insets/insetinclude.C
|
||||
src/insets/insetindex.C
|
||||
src/insets/insetinfo.C
|
||||
src/insets/insetlabel.C
|
||||
src/insets/insetlist.C
|
||||
src/insets/insetmarginal.C
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-07-31 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* text.C (getVisibleRow): minor clear row changes (still not perfect).
|
||||
|
||||
2001-07-30 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* converter.[hC] + affected fiels: move to (inital-char)lowercase
|
||||
|
@ -1,3 +1,28 @@
|
||||
2001-07-31 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insetcollapsable.h: removed inline variable and moved it over
|
||||
to the only user InsetERT.
|
||||
|
||||
* insetcollapsable.C (insetButtonRelease): fixed uncollpasing the
|
||||
inset opening immediately therein lying insets dialogs!
|
||||
|
||||
* insetert.C (localDispatch): set the font also if we don't have any
|
||||
chars in this paragraph, otherwise if we delete all of em and start
|
||||
writing we have the wrong font.
|
||||
(inlined): added
|
||||
(draw): implemented for inline support
|
||||
(insetButtonRelease): ditto.
|
||||
|
||||
2001-07-30 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insettext.C (reinitLyXText): new function to reinit the insets
|
||||
text after lot's of paragraph changes. Use this instead of the
|
||||
cache.clear() which is VERY dangerous.
|
||||
|
||||
* insetfloat.C (insetButtonRelease): we should only show the dialog
|
||||
if we press on the label otherwise we have problems to open mouse
|
||||
button 3 dialogs inside this float (f.ex. of a tabular!)
|
||||
|
||||
2001-07-30 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* insetert.C: change back to "ERT"
|
||||
|
@ -37,12 +37,11 @@ using std::max;
|
||||
InsetCollapsable::InsetCollapsable(bool collapsed)
|
||||
: UpdatableInset(), collapsed_(collapsed),
|
||||
button_length(0), button_top_y(0), button_bottom_y(0),
|
||||
label("Label"),
|
||||
need_update(FULL), label("Label"),
|
||||
#if 0
|
||||
autocollapse(false),
|
||||
#endif
|
||||
oldWidth(0), need_update(FULL),
|
||||
inlined(false)
|
||||
oldWidth(0)
|
||||
{
|
||||
inset.setOwner(this);
|
||||
inset.setAutoBreakRows(true);
|
||||
@ -56,12 +55,11 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & in, bool same_id)
|
||||
: UpdatableInset(in, same_id), collapsed_(in.collapsed_),
|
||||
framecolor(in.framecolor), labelfont(in.labelfont),
|
||||
button_length(0), button_top_y(0), button_bottom_y(0),
|
||||
label(in.label),
|
||||
need_update(FULL), label(in.label),
|
||||
#if 0
|
||||
autocollapse(in.autocollapse),
|
||||
autocollapse(in.autocollapse),
|
||||
#endif
|
||||
oldWidth(0), need_update(FULL),
|
||||
inlined(in.inlined)
|
||||
oldWidth(0)
|
||||
{
|
||||
inset.init(&(in.inset), same_id);
|
||||
inset.setOwner(this);
|
||||
@ -189,7 +187,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
||||
button_bottom_y = -ascent(bv, f) + ascent_collapsed() +
|
||||
descent_collapsed();
|
||||
|
||||
if (collapsed_) {
|
||||
if (!isOpen()) {
|
||||
draw_collapsed(pain, baseline, x);
|
||||
x += TEXT_TO_INSET_OFFSET;
|
||||
return;
|
||||
@ -197,49 +195,30 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
||||
|
||||
float old_x = x;
|
||||
|
||||
#if 0
|
||||
UpdatableInset::draw(bv, f, baseline, x, cleared);
|
||||
#else
|
||||
if (!owner())
|
||||
x += static_cast<float>(scroll());
|
||||
#endif
|
||||
|
||||
if (!cleared && (inset.need_update == InsetText::FULL ||
|
||||
inset.need_update == InsetText::INIT ||
|
||||
top_x != int(x) ||
|
||||
top_baseline != baseline))
|
||||
inset.need_update == InsetText::INIT ||
|
||||
top_x != int(x) ||
|
||||
top_baseline != baseline))
|
||||
{
|
||||
#if 1
|
||||
// we don't need anymore to clear here we just have to tell
|
||||
// the underlying LyXText that it should do the RowClear!
|
||||
inset.setUpdateStatus(bv, InsetText::FULL);
|
||||
bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
|
||||
return;
|
||||
#else
|
||||
int w = owner() ? width(bv, f) : pain.paperWidth();
|
||||
int h = ascent(bv, f) + descent(bv, f);
|
||||
int const tx = (needFullRow() && !owner()) ? 0 : int(x);
|
||||
int const ty = max(0, baseline - ascent(bv, f));
|
||||
|
||||
if ((ty + h) > pain.paperHeight())
|
||||
h = pain.paperHeight();
|
||||
if ((top_x + w) > pain.paperWidth())
|
||||
w = pain.paperWidth();
|
||||
if (baseline < 0)
|
||||
h += (baseline - ascent(bv, f));
|
||||
pain.fillRectangle(tx, ty - 1, w, h + 2);
|
||||
cleared = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
top_x = int(x);
|
||||
top_baseline = baseline;
|
||||
|
||||
int const bl = baseline - ascent(bv, f) + ascent_collapsed();
|
||||
|
||||
|
||||
draw_collapsed(pain, bl, old_x);
|
||||
inset.draw(bv, f,
|
||||
bl + descent_collapsed() + inset.ascent(bv, f),
|
||||
x, cleared);
|
||||
bl + descent_collapsed() + inset.ascent(bv, f),
|
||||
x, cleared);
|
||||
need_update = NONE;
|
||||
}
|
||||
|
||||
@ -253,7 +232,7 @@ void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
|
||||
collapsed_ = false;
|
||||
if (!bv->lockInset(this))
|
||||
return;
|
||||
bv->updateInset(this, false);
|
||||
bv->updateInset(this, true);
|
||||
inset.edit(bv);
|
||||
} else {
|
||||
if (!bv->lockInset(this))
|
||||
@ -281,7 +260,7 @@ void InsetCollapsable::edit(BufferView * bv, bool front)
|
||||
if (!bv->lockInset(this))
|
||||
return;
|
||||
inset.setUpdateStatus(bv, InsetText::FULL);
|
||||
bv->updateInset(this, false);
|
||||
bv->updateInset(this, true);
|
||||
inset.edit(bv, front);
|
||||
} else {
|
||||
if (!bv->lockInset(this))
|
||||
@ -318,8 +297,8 @@ void InsetCollapsable::insetUnlock(BufferView * bv)
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::insetButtonPress(BufferView * bv, int x, int y,
|
||||
int button)
|
||||
void InsetCollapsable::insetButtonPress(BufferView * bv,
|
||||
int x, int y, int button)
|
||||
{
|
||||
if (!collapsed_ && (y > button_bottom_y)) {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
@ -333,19 +312,21 @@ void InsetCollapsable::insetButtonPress(BufferView * bv, int x, int y,
|
||||
|
||||
|
||||
void InsetCollapsable::insetButtonRelease(BufferView * bv,
|
||||
int x, int y, int button)
|
||||
int x, int y, int button)
|
||||
{
|
||||
if ((x >= 0) && (x < button_length) &&
|
||||
(y >= button_top_y) && (y <= button_bottom_y)) {
|
||||
(y >= button_top_y) && (y <= button_bottom_y))
|
||||
{
|
||||
if (collapsed_) {
|
||||
collapsed_ = false;
|
||||
inset.insetButtonRelease(bv, 0, 0, button);
|
||||
// should not be called on inset open!
|
||||
// inset.insetButtonRelease(bv, 0, 0, button);
|
||||
inset.setUpdateStatus(bv, InsetText::FULL);
|
||||
bv->updateInset(this, false);
|
||||
bv->updateInset(this, true);
|
||||
} else {
|
||||
collapsed_ = true;
|
||||
bv->unlockInset(this);
|
||||
bv->updateInset(this, false);
|
||||
bv->updateInset(this, true);
|
||||
}
|
||||
} else if (!collapsed_ && (y > button_bottom_y)) {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
@ -359,7 +340,7 @@ void InsetCollapsable::insetButtonRelease(BufferView * bv,
|
||||
|
||||
|
||||
void InsetCollapsable::insetMotionNotify(BufferView * bv,
|
||||
int x, int y, int state)
|
||||
int x, int y, int state)
|
||||
{
|
||||
if (y > button_bottom_y) {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
@ -586,16 +567,17 @@ void InsetCollapsable::open(BufferView * bv)
|
||||
if (!collapsed_) return;
|
||||
|
||||
collapsed_ = false;
|
||||
bv->updateInset(this, false);
|
||||
bv->updateInset(this, true);
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::close(BufferView * bv)
|
||||
{
|
||||
if (collapsed_) return;
|
||||
if (collapsed_)
|
||||
return;
|
||||
|
||||
collapsed_ = true;
|
||||
bv->updateInset(this, false);
|
||||
bv->updateInset(this, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
///
|
||||
void insetUnlock(BufferView *);
|
||||
///
|
||||
bool needFullRow() const { return !collapsed_; }
|
||||
bool needFullRow() const { return isOpen(); }
|
||||
///
|
||||
bool lockInsetInInset(BufferView *, UpdatableInset *);
|
||||
///
|
||||
@ -223,6 +223,11 @@ protected:
|
||||
mutable int button_top_y;
|
||||
///
|
||||
mutable int button_bottom_y;
|
||||
///
|
||||
mutable int topx;
|
||||
mutable int topbaseline;
|
||||
mutable UpdateCodes need_update;
|
||||
|
||||
private:
|
||||
///
|
||||
string label;
|
||||
@ -232,12 +237,6 @@ private:
|
||||
#endif
|
||||
///
|
||||
mutable int oldWidth;
|
||||
///
|
||||
mutable int topx;
|
||||
mutable int topbaseline;
|
||||
mutable UpdateCodes need_update;
|
||||
///
|
||||
bool inlined;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "lyx_gui_misc.h"
|
||||
#include "BufferView.h"
|
||||
#include "LyXView.h"
|
||||
#include "lyxtext.h"
|
||||
|
||||
using std::ostream;
|
||||
|
||||
@ -114,18 +115,14 @@ void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall)
|
||||
void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
|
||||
{
|
||||
InsetCollapsable::edit(bv, x, y, button);
|
||||
|
||||
LyXFont font(LyXFont::ALL_INHERIT);
|
||||
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
|
||||
font.setColor(LColor::latex);
|
||||
|
||||
inset.setFont(bv, font);
|
||||
set_latex_font(bv);
|
||||
}
|
||||
|
||||
|
||||
void InsetERT::edit(BufferView * bv, bool)
|
||||
void InsetERT::edit(BufferView * bv, bool front)
|
||||
{
|
||||
edit(bv, 0, 0, 0);
|
||||
InsetCollapsable::edit(bv, front);
|
||||
set_latex_font(bv);
|
||||
}
|
||||
|
||||
|
||||
@ -133,14 +130,35 @@ void InsetERT::insetButtonRelease(BufferView * bv,
|
||||
int x, int y, int button)
|
||||
{
|
||||
if ((x >= 0) && (x < button_length) &&
|
||||
(y >= button_top_y) && (y <= button_bottom_y)) {
|
||||
(y >= button_top_y) && (y <= button_bottom_y))
|
||||
{
|
||||
if (button == 2) {
|
||||
inlined(bv, !inlined());
|
||||
return;
|
||||
}
|
||||
if (collapsed_) {
|
||||
setLabel(_("ERT"));
|
||||
} else {
|
||||
setLabel(get_new_label());
|
||||
}
|
||||
if (collapsed_) {
|
||||
collapsed_ = false;
|
||||
inset.insetButtonRelease(bv, 0, 0, button);
|
||||
inset.setUpdateStatus(bv, InsetText::FULL);
|
||||
bv->updateInset(this, true);
|
||||
} else {
|
||||
collapsed_ = true;
|
||||
bv->unlockInset(this);
|
||||
bv->updateInset(this, true);
|
||||
}
|
||||
} else if (!collapsed_ && (y > button_bottom_y)) {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
int yy = ascent(bv, font) + y -
|
||||
(ascent_collapsed() +
|
||||
descent_collapsed() +
|
||||
inset.ascent(bv, font));
|
||||
inset.insetButtonRelease(bv, x, yy, button);
|
||||
}
|
||||
InsetCollapsable::insetButtonRelease(bv, x, y, button);
|
||||
}
|
||||
|
||||
|
||||
@ -191,7 +209,11 @@ UpdatableInset::RESULT
|
||||
InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg)
|
||||
{
|
||||
UpdatableInset::RESULT result = DISPATCHED_NOUPDATE;
|
||||
|
||||
|
||||
if (!inset.paragraph()->size()) {
|
||||
set_latex_font(bv);
|
||||
}
|
||||
|
||||
switch(action) {
|
||||
case LFUN_LAYOUT:
|
||||
bv->owner()->setLayout(inset.paragraph()->getLayout());
|
||||
@ -202,13 +224,8 @@ InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg)
|
||||
switch(action) {
|
||||
case LFUN_BREAKPARAGRAPH:
|
||||
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
|
||||
{
|
||||
LyXFont font(LyXFont::ALL_INHERIT);
|
||||
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
|
||||
font.setColor(LColor::latex);
|
||||
inset.setFont(bv, font);
|
||||
}
|
||||
break;
|
||||
set_latex_font(bv);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -260,3 +277,72 @@ bool InsetERT::checkInsertChar(LyXFont & font)
|
||||
font.setColor(LColor::latex);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void InsetERT::inlined(BufferView * bv, bool flag)
|
||||
{
|
||||
if (flag != inset.getAutoBreakRows())
|
||||
return;
|
||||
|
||||
inset.setAutoBreakRows(!flag);
|
||||
bv->updateInset(this, true);
|
||||
}
|
||||
|
||||
void InsetERT::draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x, bool cleared) const
|
||||
{
|
||||
Painter & pain = bv->painter();
|
||||
|
||||
button_length = width_collapsed();
|
||||
button_top_y = -ascent(bv, f);
|
||||
button_bottom_y = -ascent(bv, f) + ascent_collapsed() +
|
||||
descent_collapsed();
|
||||
|
||||
if (!isOpen()) {
|
||||
draw_collapsed(pain, baseline, x);
|
||||
x += TEXT_TO_INSET_OFFSET;
|
||||
return;
|
||||
}
|
||||
|
||||
float old_x = x;
|
||||
|
||||
if (!owner())
|
||||
x += static_cast<float>(scroll());
|
||||
|
||||
if (!cleared && (inset.need_update == InsetText::FULL ||
|
||||
inset.need_update == InsetText::INIT ||
|
||||
top_x != int(x) ||
|
||||
top_baseline != baseline))
|
||||
{
|
||||
// we don't need anymore to clear here we just have to tell
|
||||
// the underlying LyXText that it should do the RowClear!
|
||||
inset.setUpdateStatus(bv, InsetText::FULL);
|
||||
bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
|
||||
return;
|
||||
}
|
||||
|
||||
top_x = int(x);
|
||||
top_baseline = baseline;
|
||||
|
||||
int const bl = baseline - ascent(bv, f) + ascent_collapsed();
|
||||
|
||||
if (inlined()) {
|
||||
inset.draw(bv, f, baseline, x, cleared);
|
||||
} else {
|
||||
draw_collapsed(pain, bl, old_x);
|
||||
inset.draw(bv, f,
|
||||
bl + descent_collapsed() + inset.ascent(bv, f),
|
||||
x, cleared);
|
||||
}
|
||||
need_update = NONE;
|
||||
}
|
||||
|
||||
|
||||
void InsetERT::set_latex_font(BufferView * bv)
|
||||
{
|
||||
LyXFont font(LyXFont::ALL_INHERIT);
|
||||
|
||||
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
|
||||
font.setColor(LColor::latex);
|
||||
inset.setFont(bv, font);
|
||||
}
|
||||
|
@ -71,6 +71,18 @@ public:
|
||||
string const &);
|
||||
///
|
||||
bool checkInsertChar(LyXFont &);
|
||||
///
|
||||
// this are needed here because of the label/inlined functionallity
|
||||
///
|
||||
bool needFullRow() const { return !collapsed_ && !inlined(); }
|
||||
///
|
||||
bool isOpen() const { return !collapsed_ || inlined(); }
|
||||
///
|
||||
bool inlined() const { return !inset.getAutoBreakRows(); }
|
||||
///
|
||||
void inlined(BufferView *, bool flag);
|
||||
///
|
||||
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
|
||||
|
||||
private:
|
||||
///
|
||||
@ -79,6 +91,8 @@ private:
|
||||
string const get_new_label() const;
|
||||
///
|
||||
void setButtonLabel();
|
||||
///
|
||||
void set_latex_font(BufferView *);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -273,26 +273,21 @@ bool InsetFloat::showInsetDialog(BufferView * bv) const
|
||||
|
||||
void InsetFloat::insetButtonRelease(BufferView * bv, int x, int y, int button)
|
||||
{
|
||||
#if 0
|
||||
if (x >= top_x
|
||||
&& x < button_length
|
||||
&& y >= button_top_y
|
||||
&& y < button_bottom_y
|
||||
&& button == 3) {
|
||||
// This obviously need to change.
|
||||
lyxerr << "InsetFloat: Let's edit this floats parameters!"
|
||||
<< endl;
|
||||
//bv->owner()->getDialogs()->showFloat(this);
|
||||
} else {
|
||||
InsetCollapsable::insetButtonRelease(bv, x, y, button);
|
||||
#if 1
|
||||
if ((x >= 0) && (x < button_length) &&
|
||||
(y >= button_top_y) && (y <= button_bottom_y) &&
|
||||
(button == 3))
|
||||
{
|
||||
showInsetDialog(bv);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (button == 3) {
|
||||
showInsetDialog(bv);
|
||||
return;
|
||||
}
|
||||
InsetCollapsable::insetButtonRelease(bv, x, y, button);
|
||||
#endif
|
||||
InsetCollapsable::insetButtonRelease(bv, x, y, button);
|
||||
}
|
||||
|
||||
|
||||
|
@ -190,17 +190,13 @@ InsetText::~InsetText()
|
||||
|
||||
void InsetText::clear()
|
||||
{
|
||||
cached_bview = 0;
|
||||
|
||||
// now also delete all caches this should be safe, hopefully
|
||||
cache.clear();
|
||||
|
||||
while (par) {
|
||||
Paragraph * tmp = par->next();
|
||||
delete par;
|
||||
par = tmp;
|
||||
}
|
||||
par = new Paragraph;
|
||||
reinitLyXText();
|
||||
}
|
||||
|
||||
|
||||
@ -305,6 +301,8 @@ int InsetText::width(BufferView * bv, LyXFont const &) const
|
||||
|
||||
int InsetText::textWidth(BufferView * bv) const
|
||||
{
|
||||
if (!autoBreakRows)
|
||||
return -1;
|
||||
int const w = getMaxWidth(bv, this);
|
||||
return w;
|
||||
}
|
||||
@ -332,18 +330,8 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
|
||||
}
|
||||
|
||||
xpos = x;
|
||||
#if 0
|
||||
UpdatableInset::draw(bv, f, baseline, x, cleared);
|
||||
#else
|
||||
if (!owner())
|
||||
x += static_cast<float>(scroll());
|
||||
#endif
|
||||
#if 0
|
||||
// update insetWidth and insetHeight with dummy calls
|
||||
(void)ascent(bv, f);
|
||||
(void)descent(bv, f);
|
||||
(void)width(bv, f);
|
||||
#endif
|
||||
|
||||
// if top_x differs we have a rule down and we don't have to clear anything
|
||||
if (!cleared && (top_x == int(x)) &&
|
||||
@ -464,8 +452,11 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
|
||||
void InsetText::drawFrame(Painter & pain, bool cleared) const
|
||||
{
|
||||
if (!frame_is_visible || cleared) {
|
||||
pain.rectangle(top_x + 1, top_baseline - insetAscent + 1,
|
||||
insetWidth - 1, insetAscent + insetDescent - 1,
|
||||
frame_x = top_x + 1;
|
||||
frame_y = top_baseline - insetAscent + 1;
|
||||
frame_w = insetWidth - 1;
|
||||
frame_h = insetAscent + insetDescent - 1;
|
||||
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
|
||||
frame_color);
|
||||
frame_is_visible = true;
|
||||
}
|
||||
@ -476,8 +467,7 @@ void InsetText::clearFrame(Painter & pain, bool cleared) const
|
||||
{
|
||||
if (frame_is_visible) {
|
||||
if (!cleared) {
|
||||
pain.rectangle(top_x + 1, top_baseline - insetAscent + 1,
|
||||
insetWidth - 1, insetAscent + insetDescent - 1,
|
||||
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
|
||||
backgroundColor());
|
||||
}
|
||||
frame_is_visible = false;
|
||||
@ -1664,11 +1654,6 @@ int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const
|
||||
|
||||
void InsetText::setParagraphData(Paragraph * p)
|
||||
{
|
||||
cached_bview = 0;
|
||||
|
||||
// now also delete all caches this should be safe, hopefully
|
||||
cache.clear();
|
||||
|
||||
while (par) {
|
||||
Paragraph * tmp = par->next();
|
||||
delete par;
|
||||
@ -1685,8 +1670,7 @@ void InsetText::setParagraphData(Paragraph * p)
|
||||
np = np->next();
|
||||
np->setInsetOwner(this);
|
||||
}
|
||||
|
||||
need_update = INIT;
|
||||
reinitLyXText();
|
||||
}
|
||||
|
||||
|
||||
@ -1706,6 +1690,7 @@ void InsetText::setAutoBreakRows(bool flag)
|
||||
need_update = FULL;
|
||||
if (!flag)
|
||||
removeNewlines();
|
||||
reinitLyXText();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1885,6 +1870,37 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
|
||||
}
|
||||
|
||||
|
||||
void InsetText::reinitLyXText() const
|
||||
{
|
||||
for(Cache::iterator it = cache.begin(); it != cache.end(); ++it) {
|
||||
lyx::Assert(it->second.text.get());
|
||||
|
||||
LyXText * t = it->second.text.get();
|
||||
BufferView * bv = it->first;
|
||||
|
||||
saveLyXTextState(t);
|
||||
for (Paragraph * p = par; p; p = p->next()) {
|
||||
p->resizeInsetsLyXText(bv);
|
||||
}
|
||||
t->init(bv, true);
|
||||
restoreLyXTextState(bv, t);
|
||||
if (the_locking_inset) {
|
||||
inset_x = cx(bv) - top_x + drawTextXOffset;
|
||||
inset_y = cy(bv) + drawTextYOffset;
|
||||
}
|
||||
if (bv->screen()) {
|
||||
t->first = bv->screen()->topCursorVisible(t);
|
||||
}
|
||||
if (!owner())
|
||||
updateLocal(bv, FULL, false);
|
||||
else
|
||||
need_update = FULL;
|
||||
// this will scroll the screen such that the cursor becomes visible
|
||||
bv->updateScrollbar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetText::removeNewlines()
|
||||
{
|
||||
for (Paragraph * p = par; p; p = p->next()) {
|
||||
|
@ -182,6 +182,8 @@ public:
|
||||
///
|
||||
void setAutoBreakRows(bool);
|
||||
///
|
||||
bool getAutoBreakRows() const { return autoBreakRows; }
|
||||
///
|
||||
void setDrawFrame(BufferView *, DrawFrame);
|
||||
///
|
||||
void setFrameColor(BufferView *, LColor::color);
|
||||
@ -293,7 +295,7 @@ private:
|
||||
bool checkAndActivateInset(BufferView * bv, bool behind);
|
||||
///
|
||||
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
|
||||
int button = 0);
|
||||
int button = 0);
|
||||
///
|
||||
void removeNewlines();
|
||||
///
|
||||
@ -317,6 +319,8 @@ private:
|
||||
///
|
||||
void saveLyXTextState(LyXText *) const;
|
||||
void restoreLyXTextState(BufferView *, LyXText *) const;
|
||||
///
|
||||
void reinitLyXText() const;
|
||||
|
||||
/* Private structures and variables */
|
||||
///
|
||||
@ -383,5 +387,12 @@ private:
|
||||
// this is needed globally so we know that we're using it actually and
|
||||
// so the LyXText-Cache is not erased until used!
|
||||
mutable LyXText * lt;
|
||||
///
|
||||
// to remember old painted frame dimensions to clear it on the right spot!
|
||||
///
|
||||
mutable int frame_x;
|
||||
mutable int frame_y;
|
||||
mutable int frame_w;
|
||||
mutable int frame_h;
|
||||
};
|
||||
#endif
|
||||
|
@ -661,25 +661,27 @@ LyXFont const Paragraph::getFont(BufferParams const & bparams,
|
||||
/// Returns the height of the highest font in range
|
||||
LyXFont::FONT_SIZE
|
||||
Paragraph::highestFontInRange(Paragraph::size_type startpos,
|
||||
Paragraph::size_type endpos) const
|
||||
Paragraph::size_type endpos) const
|
||||
{
|
||||
LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
|
||||
if (pimpl_->fontlist.empty())
|
||||
return maxsize;
|
||||
|
||||
Pimpl::FontTable end_search(endpos, LyXFont());
|
||||
Pimpl::FontList::const_iterator end_it = lower_bound(pimpl_->fontlist.begin(),
|
||||
pimpl_->fontlist.end(),
|
||||
end_search, Pimpl::matchFT());
|
||||
Pimpl::FontList::const_iterator end_it =
|
||||
lower_bound(pimpl_->fontlist.begin(),
|
||||
pimpl_->fontlist.end(),
|
||||
end_search, Pimpl::matchFT());
|
||||
if (end_it != pimpl_->fontlist.end())
|
||||
++end_it;
|
||||
|
||||
Pimpl::FontTable start_search(startpos, LyXFont());
|
||||
for (Pimpl::FontList::const_iterator cit =
|
||||
lower_bound(pimpl_->fontlist.begin(),
|
||||
pimpl_->fontlist.end(),
|
||||
start_search, Pimpl::matchFT());
|
||||
cit != end_it; ++cit) {
|
||||
lower_bound(pimpl_->fontlist.begin(),
|
||||
pimpl_->fontlist.end(),
|
||||
start_search, Pimpl::matchFT());
|
||||
cit != end_it; ++cit)
|
||||
{
|
||||
LyXFont::FONT_SIZE size = cit->font().size();
|
||||
if (size > maxsize && size <= LyXFont::SIZE_HUGER)
|
||||
maxsize = size;
|
||||
|
15
src/text.C
15
src/text.C
@ -2964,20 +2964,27 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
pain.fillRectangle(x, y, w, h, backgroundColor());
|
||||
} else if (inset != 0) {
|
||||
int h = row_ptr->baseline() - inset->ascent(bview, font);
|
||||
// first clear the whole row above the inset!
|
||||
if (h > 0) {
|
||||
#if 0
|
||||
int const w = (inset_owner ?
|
||||
inset_owner->width(bview, font) : ww);
|
||||
pain.fillRectangle(x_offset, y_offset, w, h,
|
||||
backgroundColor());
|
||||
#endif
|
||||
pain.fillRectangle(x_offset, y_offset, ww, h,
|
||||
backgroundColor());
|
||||
}
|
||||
h += inset->ascent(bview, font) + inset->descent(bview, font);
|
||||
// clear the space below the inset!
|
||||
if ((row_ptr->height() - h) > 0) {
|
||||
#if 0
|
||||
int const w = (inset_owner ?
|
||||
inset_owner->width(bview, font) : ww);
|
||||
#endif
|
||||
pain.fillRectangle(x_offset, y_offset + h,
|
||||
w, row_ptr->height() - h,
|
||||
backgroundColor());
|
||||
ww, row_ptr->height() - h,
|
||||
backgroundColor());
|
||||
}
|
||||
// clear the space behind the inset, if needed
|
||||
if (!inset_owner && !inset->display() && !inset->needFullRow())
|
||||
{
|
||||
int const w = inset->width(bview, font) + int(x);
|
||||
|
Loading…
Reference in New Issue
Block a user