* lfuns.h: new LFUN_REPEAT, LFUN_INSERT_LINE, LFUN_INSERT_PAGEBREAK

* factory.C: handle new InsetPagebreak, InsetLine

	* ParagraphParameters.h: remove [line|pagebreak]_[above|below]
	and move handling into new InsetPagebreak, InsetLine

	* BufferView_pimpl.C:
	* LyXAction.C:
	* ParagraphParameters.C:
	* ParameterStruct.h:
	* lyxfunc.C:
	* lyxtext.h:
	* paragraph.C:
	* paragraph.h:
	* paragraph_funcs.C:
	* paragraph_pimpl.C:
	* rowpainter.C:
	* text.C:
	* text2.C:
	* text3.C: adjust

etc


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7985 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-10-27 12:41:26 +00:00
parent 5be51b4fb7
commit 69fae0531d
31 changed files with 568 additions and 622 deletions

View File

@ -1323,8 +1323,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
bv_->text->setLayout(lay);
bv_->text->setParagraph(0, 0,
0, 0,
bv_->text->setParagraph(
VSpace(VSpace::NONE), VSpace(VSpace::NONE),
Spacing(),
LYX_ALIGN_LAYOUT,

View File

@ -1,3 +1,27 @@
2003-10-27 André Pönitz <poenitz@gmx.net>
* lfuns.h: new LFUN_REPEAT, LFUN_INSERT_LINE, LFUN_INSERT_PAGEBREAK
* factory.C: handle new InsetPagebreak, InsetLine
* ParagraphParameters.h: remove [line|pagebreak]_[above|below]
and move handling into new InsetPagebreak, InsetLine
* BufferView_pimpl.C:
* LyXAction.C:
* ParagraphParameters.C:
* ParameterStruct.h:
* lyxfunc.C:
* lyxtext.h:
* paragraph.C:
* paragraph.h:
* paragraph_funcs.C:
* paragraph_pimpl.C:
* rowpainter.C:
* text.C:
* text2.C:
* text3.C: adjust
2003-10-27 Alfredo Braunstein <abraunst@libero.it>
* text.C:

View File

@ -186,6 +186,8 @@ void LyXAction::init()
{ LFUN_INSERT_LABEL, "label-insert", Noop },
{ LFUN_INSET_OPTARG, "optional-insert", Noop },
{ LFUN_INSERT_BIBITEM, "bibitem-insert", Noop },
{ LFUN_INSERT_LINE, "line-insert", Noop },
{ LFUN_INSERT_PAGEBREAK, "pagebreak-insert", Noop },
{ LFUN_LANGUAGE, "language", Noop },
{ LFUN_LAYOUT, "layout", Noop },
{ LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", ReadOnly },
@ -320,6 +322,7 @@ void LyXAction::init()
{ LFUN_PARAGRAPH_APPLY, "paragraph-params-apply", Noop },
{ LFUN_PARAGRAPH_UPDATE, "", Noop },
{ LFUN_EXTERNAL_EDIT, "external-edit", Noop },
{ LFUN_REPEAT, "repeat", NoBuffer },
{ LFUN_NOACTION, "", Noop }
};

View File

@ -53,10 +53,6 @@ ParagraphParameters::ParagraphParameters()
void ParagraphParameters::clear()
{
ParameterStruct tmp(*param);
tmp.line_top = false;
tmp.line_bottom = false;
tmp.pagebreak_top = false;
tmp.pagebreak_bottom = false;
tmp.added_space_top = VSpace(VSpace::NONE);
tmp.added_space_bottom = VSpace(VSpace::NONE);
tmp.spacing.set(Spacing::Default);
@ -79,12 +75,7 @@ ParagraphParameters::depth_type ParagraphParameters::depth() const
bool ParagraphParameters::sameLayout(ParagraphParameters const & pp) const
{
return param->align == pp.param->align &&
param->line_bottom == pp.param->line_bottom &&
param->pagebreak_bottom == pp.param->pagebreak_bottom &&
param->added_space_bottom == pp.param->added_space_bottom &&
param->line_top == pp.param->line_top &&
param->pagebreak_top == pp.param->pagebreak_top &&
param->added_space_top == pp.param->added_space_top &&
param->spacing == pp.param->spacing &&
param->noindent == pp.param->noindent &&
@ -155,62 +146,6 @@ void ParagraphParameters::noindent(bool ni)
}
bool ParagraphParameters::lineTop() const
{
return param->line_top;
}
void ParagraphParameters::lineTop(bool lt)
{
ParameterStruct tmp(*param);
tmp.line_top = lt;
set_from_struct(tmp);
}
bool ParagraphParameters::lineBottom() const
{
return param->line_bottom;
}
void ParagraphParameters::lineBottom(bool lb)
{
ParameterStruct tmp(*param);
tmp.line_bottom = lb;
set_from_struct(tmp);
}
bool ParagraphParameters::pagebreakTop() const
{
return param->pagebreak_top;
}
void ParagraphParameters::pagebreakTop(bool pbt)
{
ParameterStruct tmp(*param);
tmp.pagebreak_top = pbt;
set_from_struct(tmp);
}
bool ParagraphParameters::pagebreakBottom() const
{
return param->pagebreak_bottom;
}
void ParagraphParameters::pagebreakBottom(bool pbb)
{
ParameterStruct tmp(*param);
tmp.pagebreak_bottom = pbb;
set_from_struct(tmp);
}
LyXAlignment ParagraphParameters::align() const
{
return param->align;
@ -327,14 +262,6 @@ void ParagraphParameters::read(LyXLex & lex)
spaceTop(VSpace(VSpace::VFILL));
} else if (token == "\\fill_bottom") {
spaceBottom(VSpace(VSpace::VFILL));
} else if (token == "\\line_top") {
lineTop(true);
} else if (token == "\\line_bottom") {
lineBottom(true);
} else if (token == "\\pagebreak_top") {
pagebreakTop(true);
} else if (token == "\\pagebreak_bottom") {
pagebreakBottom(true);
} else if (token == "\\start_of_appendix") {
startOfAppendix(true);
} else if (token == "\\paragraph_spacing") {
@ -405,18 +332,6 @@ void ParagraphParameters::write(ostream & os) const
os << "\\labelwidthstring "
<< labelWidthString() << '\n';
// Lines above or below?
if (lineTop())
os << "\\line_top ";
if (lineBottom())
os << "\\line_bottom ";
// Pagebreaks above or below?
if (pagebreakTop())
os << "\\pagebreak_top ";
if (pagebreakBottom())
os << "\\pagebreak_bottom ";
// Start of appendix?
if (startOfAppendix())
os << "\\start_of_appendix ";
@ -455,10 +370,7 @@ void setParagraphParams(BufferView & bv, string const & data)
params.read(lex);
LyXText * text = bv.getLyXText();
text->setParagraph(params.lineTop(),
params.lineBottom(),
params.pagebreakTop(),
params.pagebreakBottom(),
text->setParagraph(
params.spaceTop(),
params.spaceBottom(),
params.spacing(),

View File

@ -56,22 +56,6 @@ public:
///
void noindent(bool);
///
bool lineTop() const;
///
void lineTop(bool);
///
bool lineBottom() const;
///
void lineBottom(bool);
///
bool pagebreakTop() const;
///
void pagebreakTop(bool);
///
bool pagebreakBottom() const;
///
void pagebreakBottom(bool);
///
LyXAlignment align() const;
///
void align(LyXAlignment);

View File

@ -35,14 +35,6 @@ struct ParameterStruct {
///
bool noindent;
///
bool line_top;
///
bool line_bottom;
///
bool pagebreak_top;
///
bool pagebreak_bottom;
///
LyXAlignment align;
///
depth_type depth;
@ -61,8 +53,7 @@ struct ParameterStruct {
inline
ParameterStruct::ParameterStruct()
: noindent(false), line_top(false), line_bottom(false),
pagebreak_top(false), pagebreak_bottom(false),
: noindent(false),
align(LYX_ALIGN_BLOCK), depth(0), start_of_appendix(false),
appendix(false)
{}
@ -76,10 +67,6 @@ bool operator==(ParameterStruct const & ps1,
&& ps1.added_space_bottom == ps2.added_space_bottom
&& ps1.spacing == ps2.spacing
&& ps1.noindent == ps2.noindent
&& ps1.line_top == ps2.line_top
&& ps1.line_bottom == ps2.line_bottom
&& ps1.pagebreak_top == ps2.pagebreak_top
&& ps1.pagebreak_bottom == ps2.pagebreak_bottom
&& ps1.align == ps2.align
&& ps1.depth == ps2.depth
&& ps1.start_of_appendix == ps2.start_of_appendix
@ -87,7 +74,6 @@ bool operator==(ParameterStruct const & ps1,
&& ps1.labelstring == ps2.labelstring
&& ps1.labelwidthstring == ps2.labelwidthstring
&& ps1.leftindent == ps2.leftindent;
}
#endif

View File

@ -36,12 +36,14 @@
#include "insets/insetinclude.h"
#include "insets/insetindex.h"
#include "insets/insetlabel.h"
#include "insets/insetline.h"
#include "insets/insetmarginal.h"
#include "insets/insetminipage.h"
#include "insets/insetnote.h"
#include "insets/insetbox.h"
#include "insets/insetbranch.h"
#include "insets/insetoptarg.h"
#include "insets/insetpagebreak.h"
#include "insets/insetref.h"
#include "insets/insetspace.h"
#include "insets/insettabular.h"
@ -73,30 +75,35 @@ InsetOld * createInset(FuncRequest const & cmd)
case LFUN_HFILL:
return new InsetHFill;
case LFUN_INSERT_LINE:
return new InsetLine;
case LFUN_INSERT_PAGEBREAK:
return new InsetPagebreak;
case LFUN_INSET_MINIPAGE:
return new InsetMinipage(params);
case LFUN_INSERT_NOTE:
{
string arg = cmd.getArg(0);
if (arg.empty())
arg = "Note";
return new InsetNote(params, arg);
}
case LFUN_INSERT_BOX:
{
string arg = cmd.getArg(0);
if (arg.empty())
arg = "Boxed";
return new InsetBox(params, arg);
}
case LFUN_INSERT_BRANCH:
{
string arg = cmd.getArg(0);
if (arg.empty())
arg = "none";
return new InsetBranch(params, arg);
}
case LFUN_INSERT_NOTE: {
string arg = cmd.getArg(0);
if (arg.empty())
arg = "Note";
return new InsetNote(params, arg);
}
case LFUN_INSERT_BOX: {
string arg = cmd.getArg(0);
if (arg.empty())
arg = "Boxed";
return new InsetBox(params, arg);
}
case LFUN_INSERT_BRANCH: {
string arg = cmd.getArg(0);
if (arg.empty())
arg = "none";
return new InsetBranch(params, arg);
}
case LFUN_INSET_ERT:
return new InsetERT(params);

View File

@ -1,3 +1,9 @@
2003-10-27 André Pönitz <poenitz@gmx.net>
* QParagraph.C:
* ui/QParagraphDialogBase.ui: partially remove [line|pagebreak]_[above|below]
2003-10-27 Juergen Spitzmueller <j.spitzmueller@gmx.de>
* QDocument.[Ch]:

View File

@ -207,11 +207,6 @@ void QParagraph::apply()
Spacing const spacing(linespacing, other);
params.spacing(spacing);
// lines and pagebreaks
params.lineTop(dialog_->lineAbove->isChecked());
params.lineBottom(dialog_->lineBelow->isChecked());
params.pagebreakTop(dialog_->pagebreakAbove->isChecked());
params.pagebreakBottom(dialog_->pagebreakBelow->isChecked());
// label width
params.labelWidthString(fromqstr(dialog_->labelWidth->text()));
// indendation
@ -328,16 +323,6 @@ void QParagraph::update_contents()
//LyXAlignment alignpos = controller().alignPossible();
// no inset-text-owned paragraph may have pagebreaks
bool ininset = controller().inInset();
dialog_->pagebreakAbove->setEnabled(!ininset);
dialog_->pagebreakBelow->setEnabled(!ininset);
// lines, pagebreaks and indent
dialog_->lineAbove->setChecked(params.lineTop());
dialog_->lineBelow->setChecked(params.lineBottom());
dialog_->pagebreakAbove->setChecked(params.pagebreakTop());
dialog_->pagebreakBelow->setChecked(params.pagebreakBottom());
dialog_->indentCB->setChecked(!params.noindent());
// linespacing

View File

@ -928,10 +928,6 @@
<tabstop>valueBelow</tabstop>
<tabstop>unitBelow</tabstop>
<tabstop>keepBelow</tabstop>
<tabstop>lineAbove</tabstop>
<tabstop>lineBelow</tabstop>
<tabstop>pagebreakAbove</tabstop>
<tabstop>pagebreakBelow</tabstop>
<tabstop>labelWidth</tabstop>
<tabstop>restorePB</tabstop>
<tabstop>okPB</tabstop>

View File

@ -1,3 +1,9 @@
2003-10-27 André Pönitz <poenitz@gmx.net>
* FormParagraph.C:
* forms/form_paragraph.fd: remove [line|pagebreak]_[above|below]
2003-10-24 Martin Vermeer <martin.vermeer@hut.fi>
* FormMathsDelimiters.C: fixed borkage of this panel

View File

@ -84,8 +84,6 @@ void FormParagraph::build()
bcview().setRestore(dialog_->button_restore);
// disable for read-only documents
bcview().addReadOnly(dialog_->check_line_above);
bcview().addReadOnly(dialog_->check_pagebreak_above);
bcview().addReadOnly(dialog_->choice_space_above);
bcview().addReadOnly(dialog_->input_space_above);
bcview().addReadOnly(dialog_->check_space_above);
@ -94,8 +92,6 @@ void FormParagraph::build()
bcview().addReadOnly(dialog_->choice_linespacing);
bcview().addReadOnly(dialog_->input_linespacing);
bcview().addReadOnly(dialog_->check_line_below);
bcview().addReadOnly(dialog_->check_pagebreak_below);
bcview().addReadOnly(dialog_->choice_space_below);
bcview().addReadOnly(dialog_->input_space_below);
bcview().addReadOnly(dialog_->check_space_below);
@ -149,19 +145,11 @@ void FormParagraph::build()
fl_addto_choice(dialog_->choice_unit_space_below, units.c_str());
// set up the tooltips
string str = _("Add a separator line above this paragraph.");
tooltips().init(dialog_->check_line_above, str);
str = _("Enforce a page break above this paragraph.");
tooltips().init(dialog_->check_pagebreak_above, str);
str = _("Add additional space above this paragraph.");
string str = _("Add additional space above this paragraph.");
tooltips().init(dialog_->choice_space_above, str);
str = _("Never suppress space (e.g. at top of page or new page).");
tooltips().init(dialog_->check_space_above, str);
str = _("Add a separator line below this paragraph.");
tooltips().init(dialog_->check_line_below, str);
str = _("Enforce a page break below this paragraph.");
tooltips().init(dialog_->check_pagebreak_below, str);
str = _("Add additional space below this paragraph.");
tooltips().init(dialog_->choice_space_below, str);
str = _("Never suppress space (e.g. at bottom of page or new page).");
@ -214,22 +202,6 @@ void FormParagraph::apply()
controller().params().spaceBottom(space_below);
// lines and pagebreaks
bool const line_above = fl_get_button(dialog_->check_line_above);
controller().params().lineTop(line_above);
bool const line_below = fl_get_button(dialog_->check_line_below);
controller().params().lineBottom(line_below);
bool const pagebreak_above =
fl_get_button(dialog_->check_pagebreak_above);
controller().params().pagebreakTop(pagebreak_above);
bool const pagebreak_below =
fl_get_button(dialog_->check_pagebreak_below);
controller().params().pagebreakBottom(pagebreak_below);
// alignment
LyXAlignment const alignment =
static_cast<LyXAlignment>(alignment_.get());
@ -335,20 +307,7 @@ void FormParagraph::update()
setEnabled(dialog_->radio_align_right,
bool(alignpos & LYX_ALIGN_RIGHT));
// no inset-text-owned paragraph may have pagebreaks
bool ininset = controller().inInset();
setEnabled(dialog_->check_pagebreak_above, !ininset);
setEnabled(dialog_->check_pagebreak_below, !ininset);
// lines, pagebreaks and indent
fl_set_button(dialog_->check_line_above,
controller().params().lineTop());
fl_set_button(dialog_->check_line_below,
controller().params().lineBottom());
fl_set_button(dialog_->check_pagebreak_above,
controller().params().pagebreakTop());
fl_set_button(dialog_->check_pagebreak_below,
controller().params().pagebreakBottom());
fl_set_button(dialog_->check_noindent,
controller().params().noindent());

View File

@ -11,7 +11,7 @@ SnapGrid: 5
Name: form_paragraph
Width: 395
Height: 405
Number of Objects: 31
Number of Objects: 27
--------------------
class: FL_BOX
@ -103,78 +103,6 @@ name:
callback:
argument:
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 20 25 100 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Line|#i
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_line_above
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 20 250 100 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Line|#n
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_line_below
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 20 65 105 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Page break|#g
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_pagebreak_above
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 20 290 100 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Page break|#b
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_pagebreak_below
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE

View File

@ -1,3 +1,13 @@
2003-10-27 André Pönitz <poenitz@gmx.net>
* insetpagebreak.[Ch]: new inset for page breaks
* insetline.[Ch]: new inset for vertical lines
* Makefile.am:
* inset.h: adjust
2003-10-25 Angus Leeming <leeming@lyx.org>
* render_base.h (asButton, asGraphic, asPreview, asMonitoredPreview):

View File

@ -76,6 +76,8 @@ libinsets_la_SOURCES = \
insetlabel.h \
insetlatexaccent.C \
insetlatexaccent.h \
insetline.C \
insetline.h \
insetmarginal.h \
insetmarginal.C \
insetminipage.C \
@ -86,6 +88,8 @@ libinsets_la_SOURCES = \
insetnote.h \
insetoptarg.C \
insetoptarg.h \
insetpagebreak.C \
insetpagebreak.h \
insetquotes.C \
insetquotes.h \
insetref.C \

View File

@ -131,7 +131,9 @@ public:
///
NEWLINE_CODE,
///
BRANCH_CODE,
LINE_CODE,
///
BRANCH_CODE, // 40
///
BOX_CODE
};

94
src/insets/insetline.C Normal file
View File

@ -0,0 +1,94 @@
/**
* \file insetline.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "insetline.h"
#include "debug.h"
#include "LColor.h"
#include "lyxtext.h"
#include "metricsinfo.h"
#include "LaTeXFeatures.h"
#include "frontends/Painter.h"
using std::endl;
using std::ostream;
void InsetLine::read(Buffer const &, LyXLex &)
{
/* Nothing to read */
}
void InsetLine::write(Buffer const &, ostream & os) const
{
os << "\n\\lyxline \n";
}
void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
{
dim.asc = 3;
dim.des = 3;
dim.wid = mi.base.textwidth;
dim_ = dim;
}
void InsetLine::draw(PainterInfo & pi, int x, int y) const
{
pi.pain.line(x, y, x + dim_.wid, y, LColor::topline, Painter::line_solid,
Painter::line_thick);
}
int InsetLine::latex(Buffer const &, ostream & os,
LatexRunParams const &) const
{
os << "\\lyxline{}";
/* was:
os << "\\lyxline{\\"
<< pit->getFont(bparams, 0, outerFont(pit, paragraphs)).latexSize()
<< "}\\vspace{-1\\parskip}";
*/
return 0;
}
int InsetLine::ascii(Buffer const &, ostream & os, int) const
{
os << "-------------------------------------------";
return 0;
}
int InsetLine::linuxdoc(Buffer const &, std::ostream & os) const
{
os << '\n';
return 0;
}
int InsetLine::docbook(Buffer const &, std::ostream & os, bool) const
{
os << '\n';
return 0;
}
void InsetLine::validate(LaTeXFeatures & features) const
{
features.require("lyxline");
}

53
src/insets/insetline.h Normal file
View File

@ -0,0 +1,53 @@
// -*- C++ -*-
/**
* \file insetline.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef INSET_LINE_H
#define INSET_LINE_H
#include "inset.h"
class InsetLine : public InsetOld {
public:
InsetLine() {}
std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetLine);
}
InsetOld::Code lyxCode() const { return InsetOld::LINE_CODE; }
void metrics(MetricsInfo &, Dimension &) const;
void draw(PainterInfo & pi, int x, int y) const;
int latex(Buffer const &, std::ostream &,
LatexRunParams const &) const;
int ascii(Buffer const &, std::ostream &, int linelen) const;
int linuxdoc(Buffer const &, std::ostream &) const;
int docbook(Buffer const &, std::ostream &, bool) const;
void read(Buffer const &, LyXLex & lex);
void write(Buffer const & buf, std::ostream & os) const;
/// We don't need \begin_inset and \end_inset
bool directWrite() const { return true; }
bool display() const { return true; }
///
void validate(LaTeXFeatures & features) const;
};
#endif // INSET_NEWLINE_H

103
src/insets/insetpagebreak.C Normal file
View File

@ -0,0 +1,103 @@
/**
* \file insetline.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "insetpagebreak.h"
#include "debug.h"
#include "LColor.h"
#include "lyxtext.h"
#include "metricsinfo.h"
#include "gettext.h"
#include "frontends/Painter.h"
#include "frontends/font_metrics.h"
using std::endl;
using std::ostream;
void InsetPagebreak::read(Buffer const &, LyXLex &)
{
/* Nothing to read */
}
void InsetPagebreak::write(Buffer const &, ostream & os) const
{
os << "\n\\newpage \n";
}
void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
{
dim.asc = defaultRowHeight();
dim.des = defaultRowHeight();
dim.wid = mi.base.textwidth;
dim_ = dim;
}
void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
{
static std::string const label = _("Page Break");
pi.pain.line(x, y, x + dim_.wid, y, LColor::topline, Painter::line_solid,
Painter::line_thick);
LyXFont font;
font.setColor(LColor::pagebreak);
font.decSize();
int w = 0;
int a = 0;
int d = 0;
font_metrics::rectText(label, font, w, a, d);
int const text_start = int(x + (dim_.wid - w) / 2);
int const text_end = text_start + w;
pi.pain.rectText(text_start, y + d, label, font,
LColor::none, LColor::none);
pi.pain.line(x, y, text_start, y,
LColor::pagebreak, Painter::line_onoffdash);
pi.pain.line(text_end, y, int(x + dim_.wid), y,
LColor::pagebreak, Painter::line_onoffdash);
}
int InsetPagebreak::latex(Buffer const &, ostream & os,
LatexRunParams const &) const
{
os << "\\newpage{}";
return 0;
}
int InsetPagebreak::ascii(Buffer const &, ostream & os, int) const
{
os << "-------------------------------------------";
return 0;
}
int InsetPagebreak::linuxdoc(Buffer const &, std::ostream & os) const
{
os << '\n';
return 0;
}
int InsetPagebreak::docbook(Buffer const &, std::ostream & os, bool) const
{
os << '\n';
return 0;
}

View File

@ -0,0 +1,51 @@
// -*- C++ -*-
/**
* \file insetpagebreak.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef INSET_PAGEBREAK_H
#define INSET_PAGEBREAK_H
#include "inset.h"
class InsetPagebreak : public InsetOld {
public:
InsetPagebreak() {}
std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetPagebreak);
}
InsetOld::Code lyxCode() const { return InsetOld::LINE_CODE; }
void metrics(MetricsInfo &, Dimension &) const;
void draw(PainterInfo & pi, int x, int y) const;
int latex(Buffer const &, std::ostream &,
LatexRunParams const &) const;
int ascii(Buffer const &, std::ostream &, int linelen) const;
int linuxdoc(Buffer const &, std::ostream &) const;
int docbook(Buffer const &, std::ostream &, bool) const;
void read(Buffer const &, LyXLex & lex);
void write(Buffer const & buf, std::ostream & os) const;
/// We don't need \begin_inset and \end_inset
bool directWrite() const { return true; }
bool display() const { return true; }
};
#endif // INSET_NEWLINE_H

View File

@ -324,6 +324,10 @@ enum kb_action {
LFUN_INSERT_BRANCH,
LFUN_INSET_DIALOG_SHOW,
LFUN_INSERT_BOX,
LFUN_INSERT_LINE,
LFUN_INSERT_PAGEBREAK,
// 250
LFUN_REPEAT,
LFUN_LASTACTION // end of the table
};

View File

@ -1266,18 +1266,15 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
// --- version control -------------------------------
case LFUN_VC_REGISTER:
{
if (!ensureBufferClean(view()))
break;
if (!owner->buffer()->lyxvc().inUse()) {
owner->buffer()->lyxvc().registrer();
view()->reload();
}
}
break;
break;
case LFUN_VC_CHECKIN:
{
if (!ensureBufferClean(view()))
break;
if (owner->buffer()->lyxvc().inUse()
@ -1285,11 +1282,9 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
owner->buffer()->lyxvc().checkIn();
view()->reload();
}
}
break;
break;
case LFUN_VC_CHECKOUT:
{
if (!ensureBufferClean(view()))
break;
if (owner->buffer()->lyxvc().inUse()
@ -1297,22 +1292,17 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
owner->buffer()->lyxvc().checkOut();
view()->reload();
}
}
break;
break;
case LFUN_VC_REVERT:
{
owner->buffer()->lyxvc().revert();
view()->reload();
}
break;
break;
case LFUN_VC_UNDO:
{
owner->buffer()->lyxvc().undoLast();
view()->reload();
}
break;
break;
// --- buffers ----------------------------------------
@ -1328,20 +1318,19 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
open(argument);
break;
case LFUN_LAYOUT_TABULAR:
if (view()->theLockingInset()) {
if (view()->theLockingInset()->lyxCode()== InsetOld::TABULAR_CODE) {
InsetTabular * inset = static_cast<InsetTabular *>
(view()->theLockingInset());
inset->openLayoutDialog(view());
} else if (view()->theLockingInset()->
getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)!=0) {
InsetTabular * inset = static_cast<InsetTabular *>(
view()->theLockingInset()->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
inset->openLayoutDialog(view());
case LFUN_LAYOUT_TABULAR: {
UpdatableInset * tli = view()->theLockingInset();
if (tli) {
if (tli->lyxCode() == InsetOld::TABULAR_CODE) {
static_cast<InsetTabular *>(tli)->openLayoutDialog(view());
} else if (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)) {
static_cast<InsetTabular *>(
tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE))
->openLayoutDialog(view());
}
}
}
break;
break;
}
case LFUN_DROP_LAYOUTS_CHOICE:
owner->getToolbar().openLayoutList();
@ -1362,18 +1351,15 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
break;
case LFUN_NOTIFY:
{
dispatch_buffer = keyseq.print();
lyxserver->notifyClient(dispatch_buffer);
}
break;
break;
case LFUN_GOTOFILEROW:
{
case LFUN_GOTOFILEROW: {
string file_name;
int row;
istringstream istr(argument.c_str());
istr >> file_name >> row;
istringstream is(argument);
is >> file_name >> row;
if (prefixIs(file_name, getTmpDir())) {
// Needed by inverse dvi search. If it is a file
// in tmpdir, call the apropriated function
@ -1381,7 +1367,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
} else {
// Must replace extension of the file to be .lyx
// and get full path
string const s(ChangeExtension(file_name, ".lyx"));
string const s = ChangeExtension(file_name, ".lyx");
// Either change buffer or load the file
if (bufferlist.exists(s)) {
view()->buffer(bufferlist.getBuffer(s));
@ -1395,15 +1381,13 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
view()->center();
// see BufferView_pimpl::center()
view()->updateScrollbar();
break;
}
break;
case LFUN_GOTO_PARAGRAPH:
{
istringstream istr(argument.c_str());
case LFUN_GOTO_PARAGRAPH: {
istringstream is(argument);
int id;
istr >> id;
is >> id;
ParIterator par = owner->buffer()->getParFromID(id);
if (par == owner->buffer()->par_iterator_end()) {
lyxerr[Debug::INFO] << "No matching paragraph found! ["
@ -1442,15 +1426,14 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
case LFUN_MATH_NUMBER:
case LFUN_MATH_NONUMBER:
case LFUN_MATH_LIMITS:
{
setErrorMessage(N_("This is only allowed in math mode!"));
}
break;
break;
// passthrough hat and underscore outside mathed:
case LFUN_SUBSCRIPT:
dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
break;
case LFUN_SUPERSCRIPT:
dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
break;
@ -1499,22 +1482,18 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
data = InsetCommandMailer::params2string(name, p);
}
owner->getDialogs().show(name, data, 0);
break;
}
break;
case LFUN_DIALOG_SHOW_NEXT_INSET: {
}
break;
case LFUN_DIALOG_SHOW_NEXT_INSET:
break;
case LFUN_INSET_DIALOG_SHOW: {
LyXText * lt = view()->getLyXText();
InsetOld * inset = lt->getInset();
if (inset) {
FuncRequest cmd(view(), LFUN_INSET_DIALOG_SHOW);
inset->dispatch(cmd);
}
InsetOld * inset = view()->getLyXText()->getInset();
if (inset)
inset->dispatch(FuncRequest(view(), LFUN_INSET_DIALOG_SHOW));
break;
}
break;
case LFUN_DIALOG_UPDATE: {
string const & name = argument;
@ -1527,8 +1506,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
} else if (name == "paragraph") {
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
}
break;
}
break;
case LFUN_DIALOG_HIDE:
Dialogs::hide(argument, 0);
@ -1538,8 +1517,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
owner->getDialogs().disconnect(argument);
break;
case LFUN_CHILDOPEN:
{
case LFUN_CHILDOPEN: {
string const filename =
MakeAbsPath(argument, owner->buffer()->filePath());
setMessage(N_("Opening child document ") +
@ -1549,8 +1527,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
view()->buffer(bufferlist.getBuffer(filename));
else
view()->loadLyXFile(filename);
break;
}
break;
case LFUN_TOGGLECURSORFOLLOW:
lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
@ -1572,44 +1550,51 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
owner->getIntl().ToggleKeyMap();
break;
case LFUN_REPEAT: {
// repeat command
string countstr;
argument = split(argument, countstr, ' ');
istringstream is(countstr);
int count = 0;
is >> count;
lyxerr << "repeat: count: " << count << " cmd: " << argument << endl;
for (int i = 0; i < count; ++i)
dispatch(lyxaction.lookupFunc(argument));
break;
}
case LFUN_SEQUENCE:
{
// argument contains ';'-terminated commands
while (!argument.empty()) {
string first;
argument = split(argument, first, ';');
dispatch(lyxaction.lookupFunc(first));
}
}
break;
break;
case LFUN_SAVEPREFERENCES:
{
case LFUN_SAVEPREFERENCES: {
Path p(user_lyxdir());
lyxrc.write("preferences");
break;
}
break;
case LFUN_SCREEN_FONT_UPDATE:
{
// handle the screen font changes.
lyxrc.set_font_norm_type();
lyx_gui::update_fonts();
// All visible buffers will need resize
view()->resize();
view()->update();
}
break;
break;
case LFUN_SET_COLOR:
{
case LFUN_SET_COLOR: {
string lyx_name;
string const x11_name = split(argument, lyx_name, ' ');
if (lyx_name.empty() || x11_name.empty()) {
setErrorMessage(N_("Syntax: set-color <lyx_name>"
" <x11_name>"));
break;
}
}
bool const graphicsbg_changed =
(lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
@ -1630,9 +1615,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
#warning FIXME!! The graphics cache no longer has a changeDisplay method.
#endif
#if 0
lyx::graphics::GCache & gc =
lyx::graphics::GCache::get();
gc.changeDisplay(true);
lyx::graphics::GCache::get().changeDisplay(true);
#endif
}
@ -1645,24 +1628,20 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
break;
case LFUN_FORKS_KILL:
{
if (!isStrInt(argument))
break;
pid_t const pid = strToInt(argument);
ForkedcallsController & fcc = ForkedcallsController::get();
fcc.kill(pid);
if (isStrInt(argument)) {
pid_t const pid = strToInt(argument);
ForkedcallsController & fcc = ForkedcallsController::get();
fcc.kill(pid);
}
break;
}
case LFUN_TOOLTIPS_TOGGLE:
owner->getDialogs().toggleTooltips();
break;
case LFUN_EXTERNAL_EDIT: {
case LFUN_EXTERNAL_EDIT:
InsetExternal().dispatch(FuncRequest(view(), action, argument));
break;
}
default:
// Then if it was none of the above

View File

@ -298,11 +298,9 @@ public:
/** the DTP switches for paragraphs. LyX will store the top settings
always in the first physical paragraph, the bottom settings in the
last. When a paragraph is broken, the top settings rest, the bottom
settings are given to the new one. So I can make shure, they do not
duplicate themself (and you cannnot make dirty things with them! )
settings are given to the new one.
*/
void setParagraph(bool line_top, bool line_bottom,
bool pagebreak_top, bool pagebreak_bottom,
void setParagraph(
VSpace const & space_top,
VSpace const & space_bottom,
Spacing const & spacing,
@ -376,10 +374,6 @@ public:
/// return the color of the canvas
LColor_color backgroundColor() const;
unsigned char transformChar(unsigned char c, Paragraph const & par,
lyx::pos_type pos) const;
/**
* Returns the left beginning of the text.
* This information cannot be taken from the layout object, because
@ -466,6 +460,10 @@ private:
///TextCursor cursor_;
/// prohibit this as long as there are back pointers...
LyXText(LyXText const &);
// cache for cursorPar()
mutable ParagraphList::iterator cache_par_;
mutable int cache_pos_;
};
/// return the default height of a row in pixels, considering font zoom

View File

@ -1433,3 +1433,38 @@ RowList::iterator Paragraph::getRow(pos_type pos)
return rit;
}
unsigned char Paragraph::transformChar(unsigned char c, pos_type pos) const
{
if (!Encodings::is_arabic(c))
if (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 && IsDigit(c))
return c + (0xb0 - '0');
else
return c;
unsigned char const prev_char = pos > 0 ? getChar(pos - 1) : ' ';
unsigned char next_char = ' ';
for (pos_type i = pos + 1, end = size(); i < end; ++i) {
unsigned char const par_char = getChar(i);
if (!Encodings::IsComposeChar_arabic(par_char)) {
next_char = par_char;
break;
}
}
if (Encodings::is_arabic(next_char)) {
if (Encodings::is_arabic(prev_char) &&
!Encodings::is_arabic_special(prev_char))
return Encodings::TransformChar(c, Encodings::FORM_MEDIAL);
else
return Encodings::TransformChar(c, Encodings::FORM_INITIAL);
} else {
if (Encodings::is_arabic(prev_char) &&
!Encodings::is_arabic_special(prev_char))
return Encodings::TransformChar(c, Encodings::FORM_FINAL);
else
return Encodings::TransformChar(c, Encodings::FORM_ISOLATED);
}
}

View File

@ -290,7 +290,8 @@ public:
/// return true if we allow this par to stay empty
bool allowEmpty() const;
////
unsigned char transformChar(unsigned char c, lyx::pos_type pos) const;
///
ParagraphParameters & params();
///

View File

@ -31,7 +31,9 @@
#include "insets/insetbibitem.h"
#include "insets/insethfill.h"
#include "insets/insetlatexaccent.h"
#include "insets/insetline.h"
#include "insets/insetnewline.h"
#include "insets/insetpagebreak.h"
#include "insets/insetoptarg.h"
#include "insets/insetspace.h"
#include "insets/insetspecialchar.h"
@ -118,10 +120,6 @@ void breakParagraph(BufferParams const & bparams,
tmp->params().align(par->params().align());
tmp->setLabelWidthString(par->params().labelWidthString());
tmp->params().lineBottom(par->params().lineBottom());
par->params().lineBottom(false);
tmp->params().pagebreakBottom(par->params().pagebreakBottom());
par->params().pagebreakBottom(false);
tmp->params().spaceBottom(par->params().spaceBottom());
par->params().spaceBottom(VSpace(VSpace::NONE));
@ -157,8 +155,6 @@ void breakParagraph(BufferParams const & bparams,
if (pos)
return;
tmp->params().lineTop(par->params().lineTop());
tmp->params().pagebreakTop(par->params().pagebreakTop());
tmp->params().spaceTop(par->params().spaceTop());
par->params().clear();
@ -216,9 +212,7 @@ void mergeParagraph(BufferParams const & bparams,
ParagraphList::iterator the_next = boost::next(par);
// first the DTP-stuff
par->params().lineBottom(the_next->params().lineBottom());
par->params().spaceBottom(the_next->params().spaceBottom());
par->params().pagebreakBottom(the_next->params().pagebreakBottom());
pos_type pos_end = the_next->size() - 1;
pos_type pos_insert = par->size();
@ -510,23 +504,11 @@ TeXOnePar(Buffer const & buf,
texrow.newline();
}
if (pit->params().pagebreakTop()) {
os << "\\newpage";
further_blank_line = true;
}
if (pit->params().spaceTop().kind() != VSpace::NONE) {
os << pit->params().spaceTop().asLatexCommand(bparams);
further_blank_line = true;
}
if (pit->params().lineTop()) {
os << "\\lyxline{\\"
<< pit->getFont(bparams, 0, outerFont(pit, paragraphs)).latexSize()
<< '}'
<< "\\vspace{-1\\parskip}";
further_blank_line = true;
}
if (further_blank_line) {
os << '\n';
texrow.newline();
@ -666,21 +648,12 @@ TeXOnePar(Buffer const & buf,
if (in == 0 || !in->forceDefaultParagraphs(in)) {
further_blank_line = false;
if (pit->params().lineBottom()) {
os << "\\lyxline{\\" << font.latexSize() << '}';
further_blank_line = true;
}
if (pit->params().spaceBottom().kind() != VSpace::NONE) {
os << pit->params().spaceBottom().asLatexCommand(bparams);
further_blank_line = true;
}
if (pit->params().pagebreakBottom()) {
os << "\\newpage";
further_blank_line = true;
}
if (further_blank_line) {
os << '\n';
texrow.newline();
@ -969,6 +942,10 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
par.insertInset(par.size(), inset, font, change);
} else if (token == "\\hfill") {
par.insertInset(par.size(), new InsetHFill, font, change);
} else if (token == "\\lyxline") {
par.insertInset(par.size(), new InsetLine, font, change);
} else if (token == "\\newpage") {
par.insertInset(par.size(), new InsetPagebreak, font, change);
} else if (token == "\\change_unchanged") {
// Hack ! Needed for empty paragraphs :/
// FIXME: is it still ??

View File

@ -736,8 +736,6 @@ void Paragraph::Pimpl::validate(LaTeXFeatures & features,
BufferParams const & bparams = features.bufferParams();
// check the params.
if (params.lineTop() || params.lineBottom())
features.require("lyxline");
if (!params.spacing().isDefault())
features.require("setspace");

View File

@ -81,7 +81,6 @@ private:
void paintHebrewComposeChar(lyx::pos_type & vpos);
void paintArabicComposeChar(lyx::pos_type & vpos);
void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
int paintPageBreak(string const & label, int y);
int paintAppendixStart(int y);
int paintLengthMarker(string const & prefix, VSpace const & vsp, int start);
void paintText();
@ -97,8 +96,6 @@ private:
/// return the label font for this row
LyXFont const getLabelFont() const;
char const transformChar(char c, lyx::pos_type pos) const;
/// return pixel width for the given pos
int singleWidth(lyx::pos_type pos) const;
int singleWidth(lyx::pos_type pos, char c) const;
@ -135,7 +132,12 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
ParagraphList::iterator pit, RowList::iterator rit,
int y_offset, int x_offset, int y)
: bv_(bv), pain_(bv_.painter()), text_(text), rit_(rit), row_(*rit),
pit_(pit), xo_(x_offset), yo_(y_offset), y_(y)
pit_(pit), xo_(x_offset), yo_(y_offset),
x_(row_.x()), y_(y),
width_(text_.workWidth()),
separator_(row_.fill_separator()),
hfill_(row_.fill_hfill()),
label_hfill_(row_.fill_label_hfill())
{}
@ -165,12 +167,6 @@ LyXFont const RowPainter::getLabelFont() const
}
char const RowPainter::transformChar(char c, lyx::pos_type pos) const
{
return text_.transformChar(c, *pit_, pos);
}
int RowPainter::leftMargin() const
{
return text_.leftMargin(pit_, row_);
@ -231,7 +227,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos)
// first char
char c = pit_->getChar(pos);
c = transformChar(c, pos);
c = pit_->transformChar(c, pos);
str +=c;
++vpos;
@ -265,7 +261,7 @@ void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
str += pit_->getChar(pos);
if (arabic) {
unsigned char c = str[0];
str[0] = transformChar(c, pos);
str[0] = pit_->transformChar(c, pos);
}
bool prev_struckout = isDeletedText(*pit_, pos);
@ -296,16 +292,15 @@ void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
break;
if (arabic)
c = transformChar(c, pos);
c = pit_->transformChar(c, pos);
str += c;
++vpos;
}
if (prev_struckout) {
if (prev_struckout)
orig_font.setColor(LColor::strikeout);
} else if (prev_newtext) {
else if (prev_newtext)
orig_font.setColor(LColor::newtext);
}
// Draw text and set the new x position
//lyxerr << "paint row: yo_ " << yo_ << " baseline: " << row_.baseline()
@ -394,23 +389,22 @@ void RowPainter::paintSelection()
ParagraphList::iterator endpit = text_.getPar(text_.selection.end);
RowList::iterator startrow = startpit->getRow(text_.selection.start.pos());
RowList::iterator endrow = endpit->getRow(text_.selection.end.pos());
int const h = row_.height();
if (text_.bidi.same_direction()) {
int x;
int y = yo_;
int w;
int h = row_.height();
if (startrow == rit_ && endrow == rit_) {
if (startx < endx) {
x = int(xo_) + startx;
w = endx - startx;
pain_.fillRectangle(x, y, w, h, LColor::selection);
} else {
x = int(xo_) + endx;
w = startx - endx;
pain_.fillRectangle(x, y, w, h, LColor::selection);
}
pain_.fillRectangle(x, y, w, h, LColor::selection);
} else if (startrow == rit_) {
int const x = is_rtl ? int(xo_) : int(xo_ + startx);
int const w = is_rtl ? startx : (width_ - startx);
@ -423,10 +417,11 @@ void RowPainter::paintSelection()
pain_.fillRectangle(int(xo_), y, width_, h, LColor::selection);
}
return;
} else if (startrow != rit_ && endrow != rit_) {
}
if (startrow != rit_ && endrow != rit_) {
if (y_ > starty && y_ < endy) {
int w = width_;
int h = row_.height();
pain_.fillRectangle(int(xo_), yo_, w, h, LColor::selection);
}
return;
@ -434,7 +429,7 @@ void RowPainter::paintSelection()
if ((startrow != rit_ && !is_rtl) || (endrow != rit_ && is_rtl))
pain_.fillRectangle(int(xo_), yo_,
int(x_), row_.height(), LColor::selection);
int(x_), h, LColor::selection);
pos_type const body_pos = pit_->beginningOfBody();
pos_type const end = row_.endpos();
@ -473,15 +468,13 @@ void RowPainter::paintSelection()
(endrow != rit_ || pos < text_.selection.end.pos())) {
// Here we do not use x_ as xo_ was added to x_.
pain_.fillRectangle(int(old_tmpx), yo_,
int(tmpx - old_tmpx + 1),
row_.height(), LColor::selection);
int(tmpx - old_tmpx + 1), h, LColor::selection);
}
}
if ((startrow != rit_ && is_rtl) || (endrow != rit_ && !is_rtl)) {
pain_.fillRectangle(int(xo_ + tmpx),
yo_, int(bv_.workWidth() - tmpx),
row_.height(), LColor::selection);
yo_, int(bv_.workWidth() - tmpx), h, LColor::selection);
}
}
@ -547,7 +540,7 @@ void RowPainter::paintDepthBar()
int const w = PAPER_MARGIN / 5;
int x = int(w * i + xo_);
// only consider the changebar space if we're drawing outer left
if (!xo_)
if (xo_ == 0)
x += CHANGEBAR_MARGIN;
int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
@ -561,7 +554,8 @@ void RowPainter::paintDepthBar()
}
int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp, int start)
int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp,
int start)
{
if (vsp.kind() == VSpace::NONE)
return 0;
@ -627,31 +621,6 @@ int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp, int
}
int RowPainter::paintPageBreak(string const & label, int y)
{
LyXFont pb_font;
pb_font.setColor(LColor::pagebreak);
pb_font.decSize();
int w = 0;
int a = 0;
int d = 0;
font_metrics::rectText(label, pb_font, w, a, d);
int const text_start = int(xo_ + (width_ - w) / 2);
int const text_end = text_start + w;
pain_.rectText(text_start, y + d, label, pb_font, LColor::none, LColor::none);
pain_.line(int(xo_), y, text_start, y,
LColor::pagebreak, Painter::line_onoffdash);
pain_.line(text_end, y, int(xo_ + width_), y,
LColor::pagebreak, Painter::line_onoffdash);
return 3 * defaultRowHeight();
}
int RowPainter::paintAppendixStart(int y)
{
LyXFont pb_font;
@ -690,11 +659,6 @@ void RowPainter::paintFirst()
if (text_.isFirstRow(pit_, row_) && !text_.isInInset())
y_top += PAPER_MARGIN;
// draw a top pagebreak
if (parparams.pagebreakTop())
y_top += paintPageBreak(_("Page Break (top)"),
yo_ + y_top + 2 * defaultRowHeight());
// draw the additional space if needed:
y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
yo_ + y_top);
@ -722,21 +686,6 @@ void RowPainter::paintFirst()
int const ww = bv_.workWidth();
// draw a top line
if (parparams.lineTop()) {
int const asc = font_metrics::ascent('x', getFont(0));
y_top += asc;
int const w = (text_.isInInset() ? text_.inset_owner->width() : ww);
int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
pain_.line(xp, yo_ + y_top, xp + w, yo_ + y_top,
LColor::topline, Painter::line_solid,
Painter::line_thick);
y_top += asc;
}
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
bool const is_seq = isFirstInSequence(pit_, text_.ownerParagraphs());
//lyxerr << "paintFirst: " << pit_->id() << " is_seq: " << is_seq << std::endl;
@ -839,33 +788,11 @@ void RowPainter::paintLast()
int const ww = bv_.workWidth();
// draw a bottom pagebreak
if (parparams.pagebreakBottom()) {
y_bottom -= paintPageBreak(_("Page Break (bottom)"),
yo_ + y_bottom - 2 * defaultRowHeight());
}
// draw the additional space if needed:
int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
yo_ + y_bottom - height);
// draw a bottom line
if (parparams.lineBottom()) {
int const asc = font_metrics::ascent('x',
getFont(max(pos_type(0), pit_->size() - 1)));
y_bottom -= asc;
int const w = text_.isInInset() ? text_.inset_owner->width() : ww;
int const xp = int(text_.isInInset() ? xo_ : 0);
int const y = yo_ + y_bottom;
pain_.line(xp, y, xp + w, y, LColor::topline, Painter::line_solid,
Painter::line_thick);
y_bottom -= asc;
}
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
int const endlabel = getEndLabel(pit_, text_.ownerParagraphs());
@ -919,10 +846,10 @@ void RowPainter::paintText()
bool is_struckout = false;
int last_strikeout_x = 0;
pos_type vpos = row_.pos();
while (vpos < end) {
for (pos_type vpos = row_.pos(); vpos <= end; ) {
if (x_ > bv_.workWidth())
break;
pos_type pos = text_.bidi.vis2log(vpos);
if (pos >= pit_->size()) {
@ -949,8 +876,7 @@ void RowPainter::paintText()
// if we reach the end of a struck out range, paint it
// we also don't paint across things like tables
if (running_strikeout && (highly_editable_inset || !is_struckout)) {
int const middle = yo_ + row_.top_of_text()
+ (row_.baseline() - row_.top_of_text()) / 2;
int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
pain_.line(last_strikeout_x, middle, int(x_), middle,
LColor::strikeout, Painter::line_solid, Painter::line_thin);
running_strikeout = false;
@ -1001,8 +927,7 @@ void RowPainter::paintText()
// if we reach the end of a struck out range, paint it
if (running_strikeout) {
int const middle = yo_ + row_.top_of_text()
+ ((row_.baseline() - row_.top_of_text()) / 2);
int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
pain_.line(last_strikeout_x, middle, int(x_), middle,
LColor::strikeout, Painter::line_solid, Painter::line_thin);
running_strikeout = false;
@ -1012,18 +937,11 @@ void RowPainter::paintText()
void RowPainter::paint()
{
width_ = text_.workWidth();
x_ = row_.x();
separator_ = row_.fill_separator();
hfill_ = row_.fill_hfill();
label_hfill_ = row_.fill_label_hfill();
// FIXME: what is this fixing ?
if (text_.isInInset() && x_ < 0)
x_ = 0;
x_ += xo_;
// If we're *not* at the top-level of rows, then the
// background has already been cleared.
if (&text_ == bv_.text)
paintBackground();

View File

@ -130,44 +130,6 @@ int LyXText::getRealCursorX() const
}
#warning FIXME This function seems to belong outside of LyxText.
unsigned char LyXText::transformChar(unsigned char c, Paragraph const & par,
pos_type pos) const
{
if (!Encodings::is_arabic(c))
if (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 && IsDigit(c))
return c + (0xb0 - '0');
else
return c;
unsigned char const prev_char = pos > 0 ? par.getChar(pos - 1) : ' ';
unsigned char next_char = ' ';
pos_type const par_size = par.size();
for (pos_type i = pos + 1; i < par_size; ++i) {
unsigned char const par_char = par.getChar(i);
if (!Encodings::IsComposeChar_arabic(par_char)) {
next_char = par_char;
break;
}
}
if (Encodings::is_arabic(next_char)) {
if (Encodings::is_arabic(prev_char) &&
!Encodings::is_arabic_special(prev_char))
return Encodings::TransformChar(c, Encodings::FORM_MEDIAL);
else
return Encodings::TransformChar(c, Encodings::FORM_INITIAL);
} else {
if (Encodings::is_arabic(prev_char) &&
!Encodings::is_arabic_special(prev_char))
return Encodings::TransformChar(c, Encodings::FORM_FINAL);
else
return Encodings::TransformChar(c, Encodings::FORM_ISOLATED);
}
}
// This is the comments that some of the warnings below refers to.
// There are some issues in this file and I don't think they are
// really related to the FIX_DOUBLE_SPACE patch. I'd rather think that
@ -223,7 +185,7 @@ int LyXText::singleWidth(ParagraphList::iterator pit,
if (Encodings::IsComposeChar_arabic(c))
return 0;
else
c = transformChar(c, *pit, pos);
c = pit->transformChar(c, pos);
} else if (font.language()->lang() == "hebrew" &&
Encodings::IsComposeChar_hebrew(c))
return 0;
@ -803,15 +765,6 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
// add the vertical spaces, that the user added
maxasc += getLengthMarkerHeight(*bv(), pit->params().spaceTop());
// do not forget the DTP-lines!
// there height depends on the font of the nearest character
if (pit->params().lineTop())
maxasc += 2 * font_metrics::ascent('x', getFont(pit, 0));
// and now the pagebreaks
if (pit->params().pagebreakTop())
maxasc += 3 * defaultRowHeight();
if (pit->params().startOfAppendix())
maxasc += 3 * defaultRowHeight();
@ -860,36 +813,29 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
// a section, or between the items of a itemize or enumerate
// environment.
if (!pit->params().pagebreakTop()) {
ParagraphList::iterator prev =
depthHook(pit, ownerParagraphs(),
pit->getDepth());
if (prev != pit && prev->layout() == layout &&
prev->getDepth() == pit->getDepth() &&
prev->getLabelWidthString() == pit->getLabelWidthString())
{
layoutasc = (layout->itemsep * defaultRowHeight());
} else if (pit != ownerParagraphs().begin() || row.pos() != 0) {
tmptop = layout->topsep;
ParagraphList::iterator prev =
depthHook(pit, ownerParagraphs(),
pit->getDepth());
if (prev != pit && prev->layout() == layout &&
prev->getDepth() == pit->getDepth() &&
prev->getLabelWidthString() == pit->getLabelWidthString())
{
layoutasc = (layout->itemsep * defaultRowHeight());
} else if (pit != ownerParagraphs().begin() || row.pos() != 0) {
tmptop = layout->topsep;
if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight());
} else if (pit->params().lineTop()) {
tmptop = layout->topsep;
if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight());
}
if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight());
}
prev = outerHook(pit, ownerParagraphs());
if (prev != ownerParagraphs().end()) {
maxasc += int(prev->layout()->parsep * defaultRowHeight());
} else if (pit != ownerParagraphs().begin()) {
ParagraphList::iterator prior_pit = boost::prior(pit);
if (prior_pit->getDepth() != 0 ||
prior_pit->layout() == layout) {
maxasc += int(layout->parsep * defaultRowHeight());
}
prev = outerHook(pit, ownerParagraphs());
if (prev != ownerParagraphs().end()) {
maxasc += int(prev->layout()->parsep * defaultRowHeight());
} else if (pit != ownerParagraphs().begin()) {
ParagraphList::iterator prior_pit = boost::prior(pit);
if (prior_pit->getDepth() != 0 ||
prior_pit->layout() == layout) {
maxasc += int(layout->parsep * defaultRowHeight());
}
}
}
@ -904,21 +850,10 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
// add the vertical spaces, that the user added
maxdesc += getLengthMarkerHeight(*bv(), pit->params().spaceBottom());
// do not forget the DTP-lines!
// there height depends on the font of the nearest character
if (pit->params().lineBottom())
maxdesc += 2 * font_metrics::ascent('x',
getFont(pit, max(pos_type(0), pit->size() - 1)));
// and now the pagebreaks
if (pit->params().pagebreakBottom())
maxdesc += 3 * defaultRowHeight();
// and now the layout spaces, for example before and after
// a section, or between the items of a itemize or enumerate
// environment
if (!pit->params().pagebreakBottom()
&& nextpit != ownerParagraphs().end()) {
if (nextpit != ownerParagraphs().end()) {
ParagraphList::iterator comparepit = pit;
float usual = 0;
float unusual = 0;
@ -1678,9 +1613,7 @@ void LyXText::backspace()
&& cursorPar()->getAlign() == tmppit->getAlign()) {
// Inherit bottom DTD from the paragraph below.
// (the one we are deleting)
tmppit->params().lineBottom(cursorPar()->params().lineBottom());
tmppit->params().spaceBottom(cursorPar()->params().spaceBottom());
tmppit->params().pagebreakBottom(cursorPar()->params().pagebreakBottom());
}
cursorLeft(bv());
@ -1752,7 +1685,11 @@ void LyXText::backspace()
ParagraphList::iterator LyXText::cursorPar() const
{
return getPar(cursor.par());
if (cursor.par() != cache_pos_) {
cache_pos_ = cursor.par();
cache_par_ = getPar(cache_pos_);
}
return cache_par_;
}

View File

@ -72,7 +72,8 @@ LyXText::LyXText(BufferView * bv, InsetText * inset, bool ininset,
ParagraphList & paragraphs)
: height(0), width(0), anchor_y_(0),
inset_owner(inset), the_locking_inset(0), bv_owner(bv),
in_inset_(ininset), paragraphs_(&paragraphs)
in_inset_(ininset), paragraphs_(&paragraphs),
cache_pos_(-1)
{
}
@ -90,6 +91,7 @@ void LyXText::init(BufferView * bview)
height = 0;
anchor_y_ = 0;
cache_pos_ = -1;
current_font = getFont(beg, 0);
@ -653,8 +655,7 @@ string LyXText::getStringToIndex()
// they do not duplicate themself and you cannnot make dirty things with
// them!
void LyXText::setParagraph(bool line_top, bool line_bottom,
bool pagebreak_top, bool pagebreak_bottom,
void LyXText::setParagraph(
VSpace const & space_top,
VSpace const & space_bottom,
Spacing const & spacing,
@ -693,14 +694,10 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
ParagraphList::iterator const pit = cursorPar();
ParagraphParameters & params = pit->params();
params.lineTop(line_top);
params.lineBottom(line_bottom);
params.pagebreakTop(pagebreak_top);
params.pagebreakBottom(pagebreak_bottom);
params.spaceTop(space_top);
params.spaceBottom(space_bottom);
params.spacing(spacing);
// does the layout allow the new alignment?
LyXLayout_ptr const & layout = pit->layout();

View File

@ -720,10 +720,6 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd)
if (cursor.pos() == 0
&& !(params.spaceTop() == VSpace (VSpace::NONE))) {
setParagraph(
params.lineTop(),
params.lineBottom(),
params.pagebreakTop(),
params.pagebreakBottom(),
VSpace(VSpace::NONE),
params.spaceBottom(),
params.spacing(),
@ -768,10 +764,6 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd)
ParagraphParameters & params = cursorPar()->params();
if (cursor.pos() == 0 && !(params.spaceTop() == VSpace(VSpace::NONE))) {
setParagraph(
params.lineTop(),
params.lineBottom(),
params.pagebreakTop(),
params.pagebreakBottom(),
VSpace(VSpace::NONE),
params.spaceBottom(),
params.spacing(),
@ -816,10 +808,6 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd)
ParagraphParameters & params = getPar(cur)->params();
if (params.spaceTop() == VSpace(VSpace::NONE)) {
setParagraph(
params.lineTop(),
params.lineBottom(),
params.pagebreakTop(),
params.pagebreakBottom(),
VSpace(VSpace::DEFSKIP), params.spaceBottom(),
params.spacing(),
params.align(),
@ -1525,6 +1513,8 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd)
case LFUN_INDEX_PRINT:
case LFUN_TOC_INSERT:
case LFUN_HFILL:
case LFUN_INSERT_LINE:
case LFUN_INSERT_PAGEBREAK:
// do nothing fancy
doInsertInset(this, cmd, false, false);
break;