Anybody interested in stuff like that? [Not finished, I guess... the paragraph dialog would need some adjustment...]
I think none of the pagebreak/line/vspace stuff belongs to the paragraph but are entities of their own. Andre'
Index: lib/ui/stdmenus.ui =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ui/stdmenus.ui,v retrieving revision 1.13 diff -u -p -r1.13 stdmenus.ui --- lib/ui/stdmenus.ui 19 Jun 2003 16:49:45 -0000 1.13 +++ lib/ui/stdmenus.ui 8 Jul 2003 16:21:31 -0000 @@ -254,6 +254,7 @@ Menuset Item "End of Sentence|E" "end-of-sentence-period-insert" Item "Ordinary Quote|Q" "self-insert \"" Item "Menu Separator|M" "menu-separator-insert" + Item "Page Break|B" "pagebreak-insert" End Menu "insert_math" Index: src/BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.386 diff -u -p -r1.386 BufferView_pimpl.C --- src/BufferView_pimpl.C 7 Jul 2003 08:36:55 -0000 1.386 +++ src/BufferView_pimpl.C 8 Jul 2003 16:21:31 -0000 @@ -1397,7 +1397,6 @@ bool BufferView::Pimpl::insertInset(Inse bv_->text->setLayout(lay); bv_->text->setParagraph(0, 0, - 0, 0, VSpace(VSpace::NONE), VSpace(VSpace::NONE), Spacing(), LYX_ALIGN_LAYOUT, Index: src/LyXAction.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.174 diff -u -p -r1.174 LyXAction.C --- src/LyXAction.C 30 Jun 2003 23:55:49 -0000 1.174 +++ src/LyXAction.C 8 Jul 2003 16:21:31 -0000 @@ -260,6 +260,7 @@ void LyXAction::init() { LFUN_CELL_BACKWARD, "cell-backward", Noop }, { LFUN_CELL_FORWARD, "cell-forward", Noop }, { LFUN_CELL_SPLIT, "cell-split", Noop }, + { LFUN_PAGEBREAK_INSERT, "pagebreak-insert", Noop }, { LFUN_TABULAR_INSERT, "tabular-insert", Noop }, { LFUN_TABULAR_FEATURE, "tabular-feature", Noop }, #if 0 Index: src/ParagraphParameters.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ParagraphParameters.C,v retrieving revision 1.21 diff -u -p -r1.21 ParagraphParameters.C --- src/ParagraphParameters.C 30 Jun 2003 23:55:49 -0000 1.21 +++ src/ParagraphParameters.C 8 Jul 2003 16:21:31 -0000 @@ -38,8 +38,6 @@ 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); @@ -57,11 +55,9 @@ bool ParagraphParameters::sameLayout(Par { 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 && @@ -160,34 +156,6 @@ void ParagraphParameters::lineBottom(boo } -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; @@ -308,10 +276,6 @@ void ParagraphParameters::read(LyXLex & 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") { @@ -388,12 +352,6 @@ void ParagraphParameters::write(ostream 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 "; @@ -433,8 +391,6 @@ void setParagraphParams(BufferView & bv, LyXText * text = bv.getLyXText(); text->setParagraph(params.lineTop(), params.lineBottom(), - params.pagebreakTop(), - params.pagebreakBottom(), params.spaceTop(), params.spaceBottom(), params.spacing(), Index: src/ParameterStruct.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ParameterStruct.h,v retrieving revision 1.8 diff -u -p -r1.8 ParameterStruct.h --- src/ParameterStruct.h 13 Feb 2003 16:52:21 -0000 1.8 +++ src/ParameterStruct.h 8 Jul 2003 16:21:31 -0000 @@ -27,10 +27,6 @@ struct ParameterStruct { /// bool line_bottom; /// - bool pagebreak_top; - /// - bool pagebreak_bottom; - /// LyXAlignment align; /// depth_type depth; @@ -50,15 +46,13 @@ struct ParameterStruct { inline ParameterStruct::ParameterStruct() : noindent(false), line_top(false), line_bottom(false), - pagebreak_top(false), pagebreak_bottom(false), align(LYX_ALIGN_BLOCK), depth(0), start_of_appendix(false), appendix(false) {} inline -bool operator==(ParameterStruct const & ps1, - ParameterStruct const & ps2) +bool operator==(ParameterStruct const & ps1, ParameterStruct const & ps2) { return ps1.added_space_top == ps2.added_space_top && ps1.added_space_bottom == ps2.added_space_bottom @@ -66,8 +60,6 @@ bool operator==(ParameterStruct const & && 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 Index: src/buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.491 diff -u -p -r1.491 buffer.C --- src/buffer.C 7 Jul 2003 08:36:57 -0000 1.491 +++ src/buffer.C 8 Jul 2003 16:21:31 -0000 @@ -768,8 +768,6 @@ string const Buffer::asciiParagraph(Para /* some lines? */ - /* some pagebreaks? */ - /* noindent ? */ /* what about the alignment */ Index: src/factory.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/factory.C,v retrieving revision 1.34 diff -u -p -r1.34 factory.C --- src/factory.C 30 Jun 2003 23:55:52 -0000 1.34 +++ src/factory.C 8 Jul 2003 16:21:31 -0000 @@ -38,6 +38,7 @@ #include "insets/insetminipage.h" #include "insets/insetnote.h" #include "insets/insetoptarg.h" +#include "insets/insetpagebreak.h" #include "insets/insetref.h" #include "insets/insetspace.h" #include "insets/insettabular.h" @@ -109,6 +110,9 @@ Inset * createInset(FuncRequest const & return new InsetWrap(params, cmd.argument); lyxerr << "Non-existent floatflt type: " << cmd.argument << endl; return 0; + + case LFUN_PAGEBREAK_INSERT: + return new InsetPagebreak(); case LFUN_INDEX_INSERT: { // Try and generate a valid index entry. Index: src/lfuns.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v retrieving revision 1.15 diff -u -p -r1.15 lfuns.h --- src/lfuns.h 19 Jun 2003 16:49:44 -0000 1.15 +++ src/lfuns.h 8 Jul 2003 16:21:31 -0000 @@ -321,6 +321,7 @@ enum kb_action { LFUN_PARAGRAPH_UPDATE, LFUN_EXTERNAL_EDIT, // 245 + LFUN_PAGEBREAK_INSERT, LFUN_LASTACTION // end of the table }; Index: src/lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.184 diff -u -p -r1.184 lyxtext.h --- src/lyxtext.h 1 Jul 2003 11:51:18 -0000 1.184 +++ src/lyxtext.h 8 Jul 2003 16:21:31 -0000 @@ -376,7 +376,6 @@ public: duplicate themself (and you cannnot make dirty things with them! ) */ void setParagraph(bool line_top, bool line_bottom, - bool pagebreak_top, bool pagebreak_bottom, VSpace const & space_top, VSpace const & space_bottom, Spacing const & spacing, Index: src/paragraph_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.C,v retrieving revision 1.48 diff -u -p -r1.48 paragraph_funcs.C --- src/paragraph_funcs.C 7 Jul 2003 08:37:00 -0000 1.48 +++ src/paragraph_funcs.C 8 Jul 2003 16:21:31 -0000 @@ -33,6 +33,7 @@ #include "insets/insettabular.h" #include "insets/insethfill.h" #include "insets/insetnewline.h" +#include "insets/insetpagebreak.h" extern string bibitemWidest(Buffer const *); @@ -81,8 +82,6 @@ void breakParagraph(BufferParams const & 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)); @@ -120,7 +119,6 @@ void breakParagraph(BufferParams const & return; tmp->params().lineTop(par->params().lineTop()); - tmp->params().pagebreakTop(par->params().pagebreakTop()); tmp->params().spaceTop(par->params().spaceTop()); par->params().clear(); @@ -183,7 +181,6 @@ void mergeParagraph(BufferParams const & // 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(); @@ -458,7 +455,7 @@ TeXOnePar(Buffer const * buf, // lenght (all in one row) if that is true then we don't allow // any special options in the paragraph and also we don't allow // any environment other then "Standard" to be valid! - if ((in == 0) || !in->forceDefaultParagraphs(in)) { + if (in == 0 || !in->forceDefaultParagraphs(in)) { style = pit->layout(); if (pit->params().startOfAppendix()) { @@ -477,10 +474,6 @@ 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; @@ -643,11 +636,6 @@ TeXOnePar(Buffer const * buf, further_blank_line = true; } - if (pit->params().pagebreakBottom()) { - os << "\\newpage"; - further_blank_line = true; - } - if (further_blank_line) { os << '\n'; texrow.newline(); @@ -971,6 +959,10 @@ int readParToken(Buffer & buf, Paragraph par.insertChar(par.size(), '\\', font, change); } else if (token == "\\newline") { Inset * inset = new InsetNewline; + inset->read(&buf, lex); + par.insertInset(par.size(), inset, font, change); + } else if (token == "\\newpage") { + Inset * inset = new InsetPagebreak; inset->read(&buf, lex); par.insertInset(par.size(), inset, font, change); } else if (token == "\\LyXTable") { Index: src/rowpainter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v retrieving revision 1.21 diff -u -p -r1.21 rowpainter.C --- src/rowpainter.C 30 Jun 2003 23:55:57 -0000 1.21 +++ src/rowpainter.C 8 Jul 2003 16:21:31 -0000 @@ -564,30 +564,6 @@ int RowPainter::paintLengthMarker(string } -int RowPainter::paintPageBreak(string const & label, int y) -{ - LyXFont pb_font; - pb_font.setColor(LColor::pagebreak).decSize(); - - int w = 0; - int a = 0; - int d = 0; - font_metrics::rectText(label, pb_font, w, a, d); - - int const text_start = xo_ + ((width_ - w) / 2); - int const text_end = text_start + w; - - pain_.rectText(text_start, y + d, label, pb_font); - - pain_.line(xo_, y, text_start, y, - LColor::pagebreak, Painter::line_onoffdash); - pain_.line(text_end, y, xo_ + width_, y, - LColor::pagebreak, Painter::line_onoffdash); - - return 3 * defaultRowHeight(); -} - - int RowPainter::paintAppendixStart(int y) { LyXFont pb_font; @@ -626,12 +602,6 @@ void RowPainter::paintFirst() if (row_ == text_.rows().begin() && !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); @@ -774,12 +744,6 @@ void RowPainter::paintLast() y_bottom -= PAPER_MARGIN; 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()); Index: src/text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.374 diff -u -p -r1.374 text.C --- src/text.C 1 Jul 2003 11:51:18 -0000 1.374 +++ src/text.C 8 Jul 2003 16:21:32 -0000 @@ -1138,12 +1138,8 @@ void LyXText::setHeightOfRow(RowList::it // 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(bv()->buffer(), pit, 0)); - // and now the pagebreaks - if (pit->params().pagebreakTop()) - maxasc += 3 * defaultRowHeight(); if (pit->params().startOfAppendix()) maxasc += 3 * defaultRowHeight(); @@ -1197,39 +1193,37 @@ void LyXText::setHeightOfRow(RowList::it // 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 (rit != rows().begin()) { - tmptop = layout->topsep; - - if (boost::prior(pit)->getDepth() >= pit->getDepth()) - tmptop -= boost::prior(rit)->par()->layout()->bottomsep; - - if (tmptop > 0) - layoutasc = (tmptop * defaultRowHeight()); - } else if (pit->params().lineTop()) { - tmptop = layout->topsep; - - 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()); - } + 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 (rit != rows().begin()) { + tmptop = layout->topsep; + + if (boost::prior(pit)->getDepth() >= pit->getDepth()) + tmptop -= boost::prior(rit)->par()->layout()->bottomsep; + + if (tmptop > 0) + layoutasc = (tmptop * defaultRowHeight()); + } else if (pit->params().lineTop()) { + tmptop = layout->topsep; + + 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()); } } } @@ -1255,15 +1249,10 @@ void LyXText::setHeightOfRow(RowList::it 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; @@ -2359,8 +2348,8 @@ void LyXText::backspace() // is it an empty paragraph? - if ((lastpos == 0 - || (lastpos == 1 && cursor.par()->isSeparator(0)))) { + if (lastpos == 0 + || (lastpos == 1 && cursor.par()->isSeparator(0))) { // This is an empty paragraph and we delete it just by moving the cursor one step // left and let the DeleteEmptyParagraphMechanism handle the actual deletion // of the paragraph. @@ -2373,7 +2362,6 @@ void LyXText::backspace() // (the one we are deleting) tmppit->params().lineBottom(cursor.par()->params().lineBottom()); tmppit->params().spaceBottom(cursor.par()->params().spaceBottom()); - tmppit->params().pagebreakBottom(cursor.par()->params().pagebreakBottom()); } cursorLeft(bv()); Index: src/text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.379 diff -u -p -r1.379 text2.C --- src/text2.C 7 Jul 2003 08:37:00 -0000 1.379 +++ src/text2.C 8 Jul 2003 16:21:32 -0000 @@ -889,7 +889,6 @@ string LyXText::getStringToIndex() // them! void LyXText::setParagraph(bool line_top, bool line_bottom, - bool pagebreak_top, bool pagebreak_bottom, VSpace const & space_top, VSpace const & space_bottom, Spacing const & spacing, @@ -933,8 +932,6 @@ void LyXText::setParagraph(bool line_top 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); Index: src/text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.86 diff -u -p -r1.86 text3.C --- src/text3.C 1 Jul 2003 11:51:19 -0000 1.86 +++ src/text3.C 8 Jul 2003 16:21:32 -0000 @@ -761,8 +761,6 @@ Inset::RESULT LyXText::dispatch(FuncRequ setParagraph( cur.par()->params().lineTop(), cur.par()->params().lineBottom(), - cur.par()->params().pagebreakTop(), - cur.par()->params().pagebreakBottom(), VSpace(VSpace::NONE), cur.par()->params().spaceBottom(), cur.par()->params().spacing(), @@ -815,8 +813,6 @@ Inset::RESULT LyXText::dispatch(FuncRequ setParagraph( cur.par()->params().lineTop(), cur.par()->params().lineBottom(), - cur.par()->params().pagebreakTop(), - cur.par()->params().pagebreakBottom(), VSpace(VSpace::NONE), cur.par()->params().spaceBottom(), cur.par()->params().spacing(), cur.par()->params().align(), @@ -861,8 +857,6 @@ Inset::RESULT LyXText::dispatch(FuncRequ setParagraph( cur.par()->params().lineTop(), cur.par()->params().lineBottom(), - cur.par()->params().pagebreakTop(), - cur.par()->params().pagebreakBottom(), VSpace(VSpace::DEFSKIP), cur.par()->params().spaceBottom(), cur.par()->params().spacing(), cur.par()->params().align(), @@ -1599,6 +1593,7 @@ Inset::RESULT LyXText::dispatch(FuncRequ case LFUN_INSET_OPTARG: case LFUN_INSET_WIDE_FLOAT: case LFUN_INSET_WRAP: + case LFUN_PAGEBREAK_INSERT: case LFUN_TABULAR_INSERT: case LFUN_ENVIRONMENT_INSERT: // Open the inset, and move the current selection Index: src/frontends/xforms/FormParagraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormParagraph.C,v retrieving revision 1.90 diff -u -p -r1.90 FormParagraph.C --- src/frontends/xforms/FormParagraph.C 30 Jun 2003 23:56:13 -0000 1.90 +++ src/frontends/xforms/FormParagraph.C 8 Jul 2003 16:21:32 -0000 @@ -83,7 +83,6 @@ void FormParagraph::build() // 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); @@ -93,7 +92,6 @@ void FormParagraph::build() 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,8 +147,6 @@ void FormParagraph::build() // 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."); tooltips().init(dialog_->choice_space_above, str); str = _("Never suppress space (e.g. at top of page or new page)."); @@ -158,8 +154,6 @@ void FormParagraph::build() 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)."); @@ -212,22 +206,13 @@ void FormParagraph::apply() controller().params().spaceBottom(space_below); - // lines and pagebreaks + // lines 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()); @@ -333,20 +318,11 @@ 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()); Index: src/insets/Makefile.am =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/Makefile.am,v retrieving revision 1.64 diff -u -p -r1.64 Makefile.am --- src/insets/Makefile.am 21 Jun 2003 08:50:06 -0000 1.64 +++ src/insets/Makefile.am 8 Jul 2003 16:21:32 -0000 @@ -75,6 +75,8 @@ libinsets_la_SOURCES = \ insetnote.h \ insetoptarg.C \ insetoptarg.h \ + insetpagebreak.C \ + insetpagebreak.h \ insetquotes.C \ insetquotes.h \ insetref.C \ Index: src/insets/inset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v retrieving revision 1.103 diff -u -p -r1.103 inset.h --- src/insets/inset.h 4 Jul 2003 08:23:21 -0000 1.103 +++ src/insets/inset.h 8 Jul 2003 16:21:32 -0000 @@ -130,7 +130,9 @@ public: /// HFILL_CODE, /// - NEWLINE_CODE + NEWLINE_CODE, + /// + PAGEBREAK_CODE }; /// Index: src/insets/insetpagebreak.C =================================================================== RCS file: src/insets/insetpagebreak.C diff -N src/insets/insetpagebreak.C --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/insets/insetpagebreak.C 8 Jul 2003 16:21:32 -0000 @@ -0,0 +1,101 @@ +/** + * \file insetpagebreak.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 "BufferView.h" +#include "debug.h" +#include "dimension.h" +#include "paragraph.h" +#include "lyxtext.h" +#include "gettext.h" +#include "metricsinfo.h" +#include "support/LOstream.h" +#include "frontends/Painter.h" +#include "frontends/font_metrics.h" + +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 = int(1.5 * defaultRowHeight() + 1); + dim.des = int(1.5 * defaultRowHeight() + 1); + dim.wid = mi.base.textwidth; // any fixed amount will do +} + + +void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const +{ + LyXFont font; + font.setColor(LColor::pagebreak).decSize(); + + string const label = _("Page Break"); + int w = 0; + int a = 0; + int d = 0; + font_metrics::rectText(label, font, w, a, d); + + int const width = pi.base.textwidth; + int const text_start = x + (width - w) / 2; + int const text_end = text_start + w; + + pi.pain.rectText(text_start, y + d, label, font); + + pi.pain.line(0, y, text_start, y, + LColor::pagebreak, Painter::line_onoffdash); + pi.pain.line(text_end, y, pi.base.bv->workWidth(), y, + LColor::pagebreak, Painter::line_onoffdash); +} + + +int InsetPagebreak::latex(Buffer const *, ostream & os, + LatexRunParams const &) const +{ + os << "\\newpage\n"; + return 1; +} + + +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; +} + + Index: src/insets/insetpagebreak.h =================================================================== RCS file: src/insets/insetpagebreak.h diff -N src/insets/insetpagebreak.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/insets/insetpagebreak.h 8 Jul 2003 16:21:32 -0000 @@ -0,0 +1,49 @@ +// -*- 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 Inset { +public: + + InsetPagebreak() {} + + InsetBase * clone() const { return new InsetPagebreak; } + + Inset::Code lyxCode() const { return Inset::PAGEBREAK_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