diff --git a/po/ChangeLog b/po/ChangeLog index 8dec61c41b..ce2468a84a 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2001-11-04 John Levon + + * Makefile.in.in: consider Qt2 dialogs for translation + 2001-10-08 gettextize * Makefile.in.in: Upgrade to gettext-0.10.40. diff --git a/po/Makefile.in.in b/po/Makefile.in.in index 0012e62d9a..6e414efdbd 100644 --- a/po/Makefile.in.in +++ b/po/Makefile.in.in @@ -214,6 +214,8 @@ $(top_srcdir)/src/ext_l10n.h: $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/l sed -n -e 's/^[sS]tyle[ ]*\([^ ]*\)$$/_("\1");/p' | \ sort | uniq >> $@ sed < $(top_srcdir)/lib/languages -e '/^#/d' -e 's/[^"]*\("[A-Za-z0-9][^"]*"\).*/_(\1);/' >> $@ + cat $(top_srcdir)/src/frontends/qt2/ui/*.ui | grep '..*' | \ + sed 's,&,\&,;s,^.*,_(",;s,,"),;' | uniq >> $@ # Tell versions [3.59,3.63) of GNU make not to export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/po/POTFILES.in b/po/POTFILES.in index 57027f7668..525ba0e7c2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -31,6 +31,7 @@ src/frontends/controllers/ControlSearch.C src/frontends/controllers/ControlSpellchecker.C src/frontends/controllers/ControlTexinfo.C src/frontends/controllers/ControlThesaurus.C +src/frontends/controllers/ControlVCLog.C src/frontends/controllers/biblio.C src/frontends/controllers/character.C src/frontends/controllers/helper_funcs.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 082bfb463e..34814ff384 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -622,8 +622,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, updateScrollbar(); // Single left click in math inset? - if ((inset_hit != 0) && - (inset_hit->editable()==Inset::HIGHLY_EDITABLE)) { + if (isHighlyEditableInset(inset_hit)) { // Highly editable inset, like math UpdatableInset * inset = static_cast(inset_hit); selection_possible = false; @@ -792,7 +791,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, owner_->message(inset_hit->editMessage()); - if (inset_hit->editable()==Inset::HIGHLY_EDITABLE) { + if (isHighlyEditableInset(inset_hit)) { // Highly editable inset, like math UpdatableInset *inset = (UpdatableInset *)inset_hit; inset->insetButtonRelease(bv_, x, y, button); @@ -856,9 +855,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, if (cursor.pos() < cursor.par()->size() - && cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET - && cursor.par()->getInset(cursor.pos()) - && cursor.par()->getInset(cursor.pos())->editable()) { + && isMetaInset(cursor.par(), cursor.pos()) + && isEditableInset(cursor.par()->getInset(cursor.pos()))) { // Check whether the inset really was hit Inset * tmpinset = cursor.par()->getInset(cursor.pos()); @@ -882,9 +880,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, } if ((cursor.pos() - 1 >= 0) && - (cursor.par()->getChar(cursor.pos()-1) == Paragraph::META_INSET) && - (cursor.par()->getInset(cursor.pos() - 1)) && - (cursor.par()->getInset(cursor.pos() - 1)->editable())) { + isMetaInset(cursor.par(), cursor.pos() - 1) && + isEditableInset(cursor.par()->getInset(cursor.pos() - 1))) { Inset * tmpinset = cursor.par()->getInset(cursor.pos()-1); LyXFont font = text->getFont(buffer_, cursor.par(), cursor.pos() - 1); @@ -1777,7 +1774,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_INSERT_LABEL: MenuInsertLabel(bv_, argument); break; - + case LFUN_REF_INSERT: if (argument.empty()) { InsetCommandParams p("ref"); @@ -1836,10 +1833,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) if (is_rtl) lt->cursorLeft(bv_, false); if (lt->cursor.pos() < lt->cursor.par()->size() - && lt->cursor.par()->getChar(lt->cursor.pos()) - == Paragraph::META_INSET - && lt->cursor.par()->getInset(lt->cursor.pos()) - && lt->cursor.par()->getInset(lt->cursor.pos())->editable() == Inset::HIGHLY_EDITABLE){ + && isMetaInset(lt->cursor.par(), lt->cursor.pos()) + && isHighlyEditableInset(lt->cursor.par()->getInset(lt->cursor.pos()))) { Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos()); owner_->getLyXFunc()->setMessage(tmpinset->editMessage()); if (is_rtl) @@ -1870,12 +1865,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) lt->cursorLeft(bv_, false); if ((is_rtl || cur != lt->cursor) && // only if really moved! lt->cursor.pos() < lt->cursor.par()->size() && - (lt->cursor.par()->getChar(lt->cursor.pos()) == - Paragraph::META_INSET) && - lt->cursor.par()->getInset(lt->cursor.pos()) && - (lt->cursor.par()->getInset(lt->cursor.pos())->editable() - == Inset::HIGHLY_EDITABLE)) - { + isMetaInset(lt->cursor.par(), lt->cursor.pos()) && + isHighlyEditableInset(lt->cursor.par()->getInset(lt->cursor.pos()))) { Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos()); owner_->getLyXFunc()->setMessage(tmpinset->editMessage()); if (is_rtl) @@ -3411,16 +3402,19 @@ void BufferView::Pimpl::gotoInset(vector const & codes, beforeChange(bv_->text); update(bv_->text, BufferView::SELECT|BufferView::FITCUR); + LyXCursor const & cursor = bv_->text->cursor; + string contents; if (same_content && - bv_->text->cursor.par()->getChar(bv_->text->cursor.pos()) == Paragraph::META_INSET) { - Inset const * inset = bv_->text->cursor.par()->getInset(bv_->text->cursor.pos()); + isMetaInset(cursor.par(), cursor.pos())) { + Inset const * inset = cursor.par()->getInset(cursor.pos()); if (find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()) contents = static_cast(inset)->getContents(); } + if (!bv_->text->gotoNextInset(bv_, codes, contents)) { if (bv_->text->cursor.pos() || bv_->text->cursor.par() != bv_->text->firstParagraph()) { diff --git a/src/ChangeLog b/src/ChangeLog index cf8bc8388f..f2b2dd7646 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,34 @@ +2001-11-07 John Levon + + * BufferView_pimpl.C: use inline helpers + + * LaTeXFeatures.h: + * LaTeXFeatures.C: fix typos + + * Spacing.h: + * Spacing.C: move spacing_string into class + + * ToolbarDefaults.C: move stuff into namespace anon + + * layout.h: update enum + + * lyxfunc.C: use better debug + + * minibuffer.h: fix typo + + * debug.h: + * debug.C: + * WorkArea.C: add and use Debug::WORKAREA + + * lyxtext.h: + * text.C: + * text2.C: code re-organisation, inline helpers + +2001-11-09 Michael A. Koziarski + + * Layout.C: replaced a few cases of std::vector.size() == 0 with + std::vector.empty(). + 2001-11-09 Allan Rae * paragraph.C (TeXOnePar): remove old, now-irrelevent comments about diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index f9f2e3638f..15ae1996ff 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -472,8 +472,8 @@ void LaTeXFeatures::getFloatDefinitions(std::ostream & os) const << name << "}\n"; // What missing here is to code to minimalize the code - // outputted so that the same flotastyle will not be - // used several times. when the same style is still in + // outputted so that the same floatstyle will not be + // used several times, when the same style is still in // effect. (Lgb) } } diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 3f8005eef6..f08002369d 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -35,7 +35,7 @@ struct Language; struct LaTeXFeatures { /// LaTeXFeatures(BufferParams const &, LyXTextClass::size_type n) ; - /// The packaes needed by the document + /// The packages needed by the document string const getPackages() const; /// The macros definitions needed by the document string const getMacros() const; diff --git a/src/Spacing.C b/src/Spacing.C index 90d73d52f7..30dd365a8f 100644 --- a/src/Spacing.C +++ b/src/Spacing.C @@ -21,14 +21,9 @@ using std::ios; using std::ostream; -/// how can I put this inside of Spacing (class) -namespace { - -char const * const spacing_string[] = {"single", "onehalf", "double", "other"}; - -} // namespace anon - - +string const Spacing::spacing_string[] + = {"single", "onehalf", "double", "other"}; + float Spacing::getValue() const { switch (space) { diff --git a/src/Spacing.h b/src/Spacing.h index 9c8fdec9d4..2a3bb755dd 100644 --- a/src/Spacing.h +++ b/src/Spacing.h @@ -63,11 +63,14 @@ public: string const writeEnvirBegin() const; /// string const writeEnvirEnd() const; + private: /// Space space; /// float value; + /// names of line spacing + static string const spacing_string[]; }; diff --git a/src/ToolbarDefaults.C b/src/ToolbarDefaults.C index 83a45ce48c..b81d79bd84 100644 --- a/src/ToolbarDefaults.C +++ b/src/ToolbarDefaults.C @@ -27,6 +27,28 @@ using std::endl; extern LyXAction lyxaction; ToolbarDefaults toolbardefaults; +namespace { + +enum _tooltags { + TO_ADD = 1, + TO_ENDTOOLBAR, + TO_SEPARATOR, + TO_LAYOUTS, + TO_NEWLINE, + TO_LAST +}; + + +struct keyword_item toolTags[TO_LAST - 1] = { + { "end", TO_ENDTOOLBAR }, + { "icon", TO_ADD }, + { "layouts", TO_LAYOUTS }, + { "newline", TO_NEWLINE }, + { "separator", TO_SEPARATOR } +}; + +}; // end of anon namespace + ToolbarDefaults::ToolbarDefaults() { @@ -73,25 +95,6 @@ void ToolbarDefaults::init() } -enum _tooltags { - TO_ADD = 1, - TO_ENDTOOLBAR, - TO_SEPARATOR, - TO_LAYOUTS, - TO_NEWLINE, - TO_LAST -}; - - -struct keyword_item toolTags[TO_LAST - 1] = { - { "end", TO_ENDTOOLBAR }, - { "icon", TO_ADD }, - { "layouts", TO_LAYOUTS }, - { "newline", TO_NEWLINE }, - { "separator", TO_SEPARATOR } -}; - - void ToolbarDefaults::read(LyXLex & lex) { //consistency check @@ -134,8 +137,6 @@ void ToolbarDefaults::read(LyXLex & lex) break; case TO_ENDTOOLBAR: - // should not set automatically - //set(); quit = true; break; default: diff --git a/src/WorkArea.C b/src/WorkArea.C index 6141f22dc3..a6fc52ddb0 100644 --- a/src/WorkArea.C +++ b/src/WorkArea.C @@ -74,7 +74,7 @@ WorkArea::WorkArea(int xpos, int ypos, int width, int height) figinset_canvas = 0; - if (lyxerr.debugging(Debug::GUI)) + if (lyxerr.debugging(Debug::WORKAREA)) lyxerr << "Creating work area: +" << xpos << '+' << ypos << ' ' << width << 'x' << height << endl; @@ -91,7 +91,7 @@ WorkArea::WorkArea(int xpos, int ypos, int width, int height) fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity); // a box - if (lyxerr.debugging(Debug::GUI)) + if (lyxerr.debugging(Debug::WORKAREA)) lyxerr << "\tbackground box: +" << xpos << '+' << ypos << ' ' << width - 15 << 'x' << height << endl; @@ -154,7 +154,7 @@ WorkArea::WorkArea(int xpos, int ypos, int width, int height) // We add this object as late as possible to avoit problems // with drawing. - if (lyxerr.debugging(Debug::GUI)) + if (lyxerr.debugging(Debug::WORKAREA)) lyxerr << "\tfree object: +" << xpos + bw << '+' << ypos + bw << ' ' << width - 15 - 2 * bw << 'x' @@ -195,12 +195,6 @@ bool WorkArea::belowMouse() const if (x > ulx && y > uly && x < ulx + h && y < uly + w) return true; return false; - - - //lyxerr << "Mouse: (" << x << ", " << y <<") button = " << button << endl; - //lyxerr << "Workarea: (" << work_area->x + work_area->form->x << ", " << work_area->y + work_area->form->y << ", " << work_area->w << ", " << work_area->h << ")" << endl; - //lyxerr << "Below mouse: " << work_area->belowmouse << endl; - //return work_area->belowmouse; } @@ -270,7 +264,7 @@ void WorkArea::createPixmap(int width, int height) if (workareapixmap) XFreePixmap(fl_get_display(), workareapixmap); - if (lyxerr.debugging(Debug::GUI)) + if (lyxerr.debugging(Debug::WORKAREA)) lyxerr << "Creating pixmap (" << width << 'x' << height << ")" << endl; @@ -279,7 +273,7 @@ void WorkArea::createPixmap(int width, int height) width, height, fl_get_visual_depth()); - if (lyxerr.debugging(Debug::GUI)) + if (lyxerr.debugging(Debug::WORKAREA)) lyxerr << "\tpixmap=" << workareapixmap << endl; } @@ -351,7 +345,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, if (!area->work_area || !area->work_area->form->visible) return 1; - lyxerr[Debug::GUI] << "Workarea event: DRAW" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: DRAW" << endl; area->createPixmap(area->workWidth(), area->height()); Lgb_bug_find_hack = true; area->workAreaExpose(); @@ -360,7 +354,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, case FL_PUSH: if (!ev || ev->xbutton.button == 0) break; // Should really have used xbutton.state - lyxerr[Debug::GUI] << "Workarea event: PUSH" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl; area->workAreaButtonPress(ev->xbutton.x - ob->x, ev->xbutton.y - ob->y, ev->xbutton.button); @@ -369,7 +363,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, case FL_RELEASE: if (!ev || ev->xbutton.button == 0) break; // Should really have used xbutton.state - lyxerr[Debug::GUI] << "Workarea event: RELEASE" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl; area->workAreaButtonRelease(ev->xbutton.x - ob->x, ev->xbutton.y - ob->y, ev->xbutton.button); @@ -384,7 +378,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, ev->xmotion.y != y_old || fl_get_scrollbar_value(area->scrollbar) != scrollbar_value_old ) { - lyxerr[Debug::GUI] << "Workarea event: MOUSE" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: MOUSE" << endl; area->workAreaMotionNotify(ev->xmotion.x - ob->x, ev->xmotion.y - ob->y, ev->xbutton.state); @@ -396,7 +390,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, case FL_KEYPRESS: #endif { - lyxerr[Debug::KEY] << "Workarea event: KEYBOARD" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: KEYBOARD" << endl; KeySym keysym = 0; char dummy[1]; @@ -414,9 +408,9 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, string const stm = (tmp ? tmp : ""); string const stm2 = (tmp2 ? tmp2 : ""); - lyxerr << "WorkArea: Key is `" << stm << "' [" + lyxerr[Debug::KEY] << "WorkArea: Key is `" << stm << "' [" << key << "]" << endl; - lyxerr << "WorkArea: Keysym is `" << stm2 << "' [" + lyxerr[Debug::KEY] << "WorkArea: Keysym is `" << stm2 << "' [" << keysym << "]" << endl; } @@ -499,44 +493,43 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, #if FL_REVISION >= 89 case FL_KEYRELEASE: - lyxerr << "Workarea event: KEYRELEASE" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: KEYRELEASE" << endl; break; #endif case FL_FOCUS: - lyxerr[Debug::GUI] << "Workarea event: FOCUS" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: FOCUS" << endl; area->workAreaFocus(); break; case FL_UNFOCUS: - lyxerr[Debug::GUI] << "Workarea event: UNFOCUS" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: UNFOCUS" << endl; area->workAreaUnfocus(); break; case FL_ENTER: - lyxerr[Debug::GUI] << "Workarea event: ENTER" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: ENTER" << endl; area->workAreaEnter(); break; case FL_LEAVE: - lyxerr[Debug::GUI] << "Workarea event: LEAVE" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: LEAVE" << endl; area->workAreaLeave(); break; case FL_DBLCLICK: if (!ev) break; - lyxerr[Debug::GUI] << "Workarea event: DBLCLICK" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl; area->workAreaDoubleClick(ev->xbutton.x - ob->x, ev->xbutton.y - ob->y, ev->xbutton.button); break; case FL_TRPLCLICK: if (!ev) break; - lyxerr[Debug::GUI] << "Workarea event: TRPLCLICK" << endl; + lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl; area->workAreaTripleClick(ev->xbutton.x - ob->x, ev->xbutton.y - ob->y, ev->xbutton.button); break; case FL_OTHER: if (!ev) break; - lyxerr[Debug::GUI] << "Workarea event: OTHER" << endl; - + lyxerr[Debug::WORKAREA] << "Workarea event: OTHER" << endl; break; } @@ -581,8 +574,10 @@ string const WorkArea::getClipboard() const while (!clipboard_read) { if (fl_check_forms() == FL_EVENT) { - lyxerr << "LyX: This shouldn't happen..." << endl; fl_XNextEvent(&ev); + lyxerr << "Received unhandled X11 event" << endl; + lyxerr << "Type: 0x" << std::hex << ev.xany.type << + "Target: 0x" << std::hex << ev.xany.window << endl; } } return clipboard_selection; diff --git a/src/debug.C b/src/debug.C index 6a77781768..321700a67f 100644 --- a/src/debug.C +++ b/src/debug.C @@ -53,6 +53,7 @@ error_item errorTags[] = { { Debug::DEPEND, "depend", N_("Dependency information")}, { Debug::INSETS, "insets", N_("LyX Insets")}, { Debug::FILES, "files", N_("Files used by LyX")}, + { Debug::WORKAREA, "workarea", N_("Workarea events")}, { Debug::ANY, "any", N_("All debugging messages")} }; @@ -67,7 +68,7 @@ Debug::type const Debug::ANY = Debug::type( Debug::PARSER | Debug::LYXRC | Debug::KBMAP | Debug::LATEX | Debug::MATHED | Debug::FONT | Debug::TCLASS | Debug::LYXVC | Debug::LYXSERVER | Debug::ROFF | Debug::ACTION | Debug::LYXLEX | - Debug::DEPEND | Debug::INSETS | Debug::FILES); + Debug::DEPEND | Debug::INSETS | Debug::FILES | Debug::WORKAREA); Debug::type Debug::value(string const & val) diff --git a/src/debug.h b/src/debug.h index e58ed1ccb6..e92d3c1f69 100644 --- a/src/debug.h +++ b/src/debug.h @@ -66,15 +66,11 @@ struct Debug { /// INSETS = (1 << 17), /// - FILES = (1 << 18) + FILES = (1 << 18), + /// + WORKAREA = (1 << 19) }; /// -// static const type ANY = type(INFO | INIT | KEY | GUI | -// PARSER | LYXRC | KBMAP | LATEX | -// MATHED | FONT | TCLASS | LYXVC | -// LYXSERVER | ROFF | ACTION | LYXLEX | -// DEPEND | INSETS); - /// static type const ANY; /** A function to convert symbolic string names on debug levels diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index c7084dd46a..44322f635a 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2001-11-04 John Levon + + * ControlVCLog.C: use _() + 2001-10-23 Jean-Marc Lasgouttes * ControlSpellchecker.C: include since FreeBSD needs diff --git a/src/frontends/controllers/ControlVCLog.C b/src/frontends/controllers/ControlVCLog.C index cc0ad7f779..2282365572 100644 --- a/src/frontends/controllers/ControlVCLog.C +++ b/src/frontends/controllers/ControlVCLog.C @@ -29,6 +29,7 @@ #include "Dialogs.h" #include "lyxrc.h" #include "support/lyxlib.h" +#include "gettext.h" using SigC::slot; using std::endl; @@ -61,7 +62,7 @@ stringstream & ControlVCLog::getVCLogFile(stringstream & ss) const } if (!found) - ss << "No version control log file found." << endl; + ss << _("No version control log file found.") << endl; lyx::unlink(name); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index af1d16a7a9..084358601e 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2001-11-04 John Levon + + * inset.h: new inline helpers + + * insettext.C: use new helpers + 2001-11-07 José Matos * insettext.C (docbook): full support for paragraphs inside insettext. diff --git a/src/insets/inset.h b/src/insets/inset.h index 3e9e04f452..49e38c05de 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -513,4 +513,22 @@ private: /// mutable bool block_drawing_; }; + +/** + * returns true if pointer argument is valid + * and points to an editable inset + */ +inline bool isEditableInset(Inset * i) +{ + return i && i->editable(); +} + +/** + * returns true if poiinter argument is valid + * and points to a highly editable inset + */ +inline bool isHighlyEditableInset(Inset * i) +{ + return i && i->editable() == Inset::HIGHLY_EDITABLE; +} #endif diff --git a/src/insets/insetbutton.h b/src/insets/insetbutton.h index 35c85c4f23..26e2952e71 100644 --- a/src/insets/insetbutton.h +++ b/src/insets/insetbutton.h @@ -38,4 +38,3 @@ protected: }; #endif - diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 7c3b972e08..936bec1f8c 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -876,7 +876,7 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) the_locking_inset = 0; } if (bv->theLockingInset()) { - if (inset && inset->editable() == Inset::HIGHLY_EDITABLE) { + if (isHighlyEditableInset(inset)) { UpdatableInset * uinset = static_cast(inset); inset_x = cx(bv) - top_x + drawTextXOffset; inset_y = cy(bv) + drawTextYOffset; @@ -940,9 +940,9 @@ void InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button) x - inset_x, y - inset_y, button); } else { - if (cpar(bv)->getChar(cpos(bv)) == Paragraph::META_INSET) { + if (isMetaInset(cpar(bv), cpos(bv))) { inset = static_cast(cpar(bv)->getInset(cpos(bv))); - if (inset->editable() == Inset::HIGHLY_EDITABLE) { + if (isHighlyEditableInset(inset)) { inset->insetButtonRelease(bv, x - inset_x, y - inset_y, button); @@ -1745,7 +1745,7 @@ bool InsetText::insertInset(BufferView * bv, Inset * inset) } lt->insertInset(bv, inset); #if 0 - if ((cpar(bv)->getChar(cpos(bv)) != Paragraph::META_INSET) || + if ((!isMetaInset(cpar(bv), cpos(bv))) || (cpar(bv)->getInset(cpos(bv)) != inset)) lt->cursorLeft(bv); #endif @@ -1845,12 +1845,12 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall, bool InsetText::checkAndActivateInset(BufferView * bv, bool behind) { - if (cpar(bv)->getChar(cpos(bv)) == Paragraph::META_INSET) { + if (isMetaInset(cpar(bv), cpos(bv))) { unsigned int x; unsigned int y; Inset * inset = static_cast(cpar(bv)->getInset(cpos(bv))); - if (!inset || inset->editable() != Inset::HIGHLY_EDITABLE) + if (!isHighlyEditableInset(inset)) return false; LyXFont const font = getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv)); diff --git a/src/layout.C b/src/layout.C index b4fb05f733..484f3a34cc 100644 --- a/src/layout.C +++ b/src/layout.C @@ -1291,7 +1291,7 @@ string const & LyXTextClassList::NameOfClass(LyXTextClassList::size_type number) const { static string const dummy("dummy"); - if (classlist.size() == 0) { + if (classlist.empty()) { return dummy; } lyx::Assert(number < classlist.size()); @@ -1305,7 +1305,7 @@ LyXTextClassList::LatexnameOfClass(LyXTextClassList::size_type number) const { static string const dummy("dummy"); classlist[number].load(); - if (classlist.size() == 0) { + if (classlist.empty()) { return dummy; } lyx::Assert(number < classlist.size()); @@ -1318,7 +1318,7 @@ string const & LyXTextClassList::DescOfClass(LyXTextClassList::size_type number) const { static string const dummy("dummy"); - if (classlist.size() == 0) { + if (classlist.empty()) { return dummy; } lyx::Assert(number < classlist.size()); @@ -1427,7 +1427,7 @@ bool LyXTextClassList::Read () } lyxerr[Debug::TCLASS] << "End of parsing of textclass.lst" << endl; - if (classlist.size() == 0) { + if (classlist.empty()) { lyxerr << "LyXTextClassList::Read: no textclasses found!" << endl; WriteAlert(_("LyX wasn't able to find any layout description!"), diff --git a/src/layout.h b/src/layout.h index a4141c70da..cea07e1e19 100644 --- a/src/layout.h +++ b/src/layout.h @@ -26,15 +26,11 @@ class LyXLeX; /// Reads the style files extern void LyXSetStyle(); -/// -enum no_good_name_for_this { - /// - LYX_ENVIRONMENT_DEFAULT = 97, +enum layout_default { /// LYX_LAYOUT_DEFAULT = 99 }; - // Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has // the same value? (Lgb) /// diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 529038d8b7..dcd18e2877 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -807,7 +807,7 @@ string const LyXFunc::dispatch(int ac, // We cannot use this function here if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled) { - lyxerr << "LyXFunc::Dispatch: " + lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: " << lyxaction.getActionName(ac) << " [" << ac << "] is disabled at this location" << endl; diff --git a/src/lyxtext.h b/src/lyxtext.h index 32b8a7d344..c61c94a617 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -546,6 +546,55 @@ private: float & fill_label_hfill, bool bidi = true) const; + /// A struct used for drawing routines + struct DrawRowParams { + // the bufferview + BufferView * bv; + // the row + Row * row; + // the painter to use + Painter * pain; + // has the background been cleared + bool cleared; + /// x offset + int xo; + /// y offset + int yo; + /// FIXME + float x; + /// FIXME + int y; + /// the inset/view full width + int width; + /// hfill size + float hfill; + /// label hfill size + float label_hfill; + /// fill separator size + float separator; + }; + + /// paint the background + bool paintRowBackground(DrawRowParams & p); + + /// paint the selection background + void paintRowSelection(DrawRowParams & p); + + /// paint appendix marker + void paintRowAppendix(DrawRowParams & p); + + /// paint env depth bar + void paintRowDepthBar(DrawRowParams & p); + + /// paint a first row in a paragraph + void paintFirstRow(DrawRowParams & p); + + /// paint a last row in a paragraph + void paintLastRow(DrawRowParams & p); + + /// paint text + void paintRowText(DrawRowParams & p); + // fix the cursor `cur' after a characters has been deleted at `where' // position. Called by deleteEmptyParagraphMechanism void fixCursorAfterDelete(BufferView * bview, diff --git a/src/minibuffer.h b/src/minibuffer.h index 464b05690a..bf4ade1668 100644 --- a/src/minibuffer.h +++ b/src/minibuffer.h @@ -47,7 +47,7 @@ public: /** Makes the minibuffer wait for a string to be inserted. Waits for a string to be inserted into the minibuffer, when - the string has been insterted the signal stringReady is + the string has been inserted the signal stringReady is emitted. */ void getString(State space, diff --git a/src/paragraph.h b/src/paragraph.h index 604c9f034d..c1c58ac2bf 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -415,4 +415,10 @@ private: Pimpl * pimpl_; }; + +inline bool isMetaInset(Paragraph const * par, Paragraph::size_type const pos) +{ + return par->getChar(pos) == Paragraph::META_INSET; +} + #endif diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 74201625ad..37cd8d2d7c 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,9 @@ +2001-11-04 John Levon + + * filetools.C: remove dead code + + * syscall.C: show prog in fail case + 2001-10-24 Andre Poenitz * filetools.C: code style cleanup diff --git a/src/support/filetools.C b/src/support/filetools.C index 761ef5f0a8..3a332bd536 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -134,8 +134,7 @@ bool IsFileReadable (string const & path) int IsFileWriteable (string const & path) { FileInfo fi(path); - //lyxerr << "fi : " << fi << endl; - //lyxerr << "fi.exists" << fi.exist() << endl; + if (fi.access(FileInfo::wperm|FileInfo::rperm)) // read-write return 1; if (fi.readable()) // read-only diff --git a/src/support/syscall.C b/src/support/syscall.C index 60afc42935..597dd362de 100644 --- a/src/support/syscall.C +++ b/src/support/syscall.C @@ -181,7 +181,7 @@ pid_t Systemcalls::fork() #ifndef __EMX__ execvp(syscmd, argv); // If something goes wrong, we end up here: - lyxerr << "LyX: execvp failed: " + lyxerr << "LyX: execvp(" << syscmd << ") failed: " << strerror(errno) << endl; } else if (cpid < 0) { // error #else diff --git a/src/text.C b/src/text.C index b859f46b55..f219950b13 100644 --- a/src/text.C +++ b/src/text.C @@ -2945,642 +2945,654 @@ void LyXText::backspace(BufferView * bview) } -void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset, - Row * row_ptr, int y, bool cleared) +bool LyXText::paintRowBackground(DrawRowParams & p) { - // returns a printed row - Painter & pain = bview->painter(); - - bool const is_rtl = - row_ptr->par()->isRightToLeftPar(bview->buffer()->params); - - Paragraph::size_type const last = rowLastPrintable(row_ptr); - - Paragraph::size_type vpos; - Paragraph::size_type pos; - - float tmpx; - + bool clear_area = true; + Inset * inset = 0; LyXFont font(LyXFont::ALL_SANE); - int maxdesc; - if (row_ptr->height() <= 0) { + + Paragraph::size_type const last = rowLastPrintable(p.row); + + if (!p.bv->screen()->forceClear() && last == p.row->pos() + && isMetaInset(p.row->par(), p.row->pos())) { + inset = p.row->par()->getInset(p.row->pos()); + if (inset) { + clear_area = inset->doClearArea(); + } + } + + if (p.cleared) { + return true; + } + + if (clear_area) { + int const x = p.xo; + int const y = p.yo < 0 ? 0 : p.yo; + int const h = p.yo < 0 ? p.row->height() + p.yo : p.row->height(); + p.pain->fillRectangle(x, y, p.width, h, backgroundColor()); + return true; + } + + if (inset == 0) + return false; + + int h = p.row->baseline() - inset->ascent(p.bv, font); + + // first clear the whole row above the inset! + if (h > 0) { + p.pain->fillRectangle(p.xo, p.yo, p.width, h, backgroundColor()); + } + + // clear the space below the inset! + h += inset->ascent(p.bv, font) + inset->descent(p.bv, font); + if ((p.row->height() - h) > 0) { + p.pain->fillRectangle(p.xo, p.yo + h, + p.width, p.row->height() - h, backgroundColor()); + } + + // clear the space behind the inset, if needed + if (!inset->display() && !inset->needFullRow()) { + int const xp = int(p.x) + inset->width(p.bv, font); + if (p.width - xp > 0) { + p.pain->fillRectangle(xp, p.yo, p.width - xp, + p.row->height(), backgroundColor()); + } + } + + return false; +} + + +void LyXText::paintRowSelection(DrawRowParams & p) +{ + bool const is_rtl = p.row->par()->isRightToLeftPar(p.bv->buffer()->params); + + // the current selection + int const startx = selection.start.x(); + int const endx = selection.end.x(); + int const starty = selection.start.y(); + int const endy = selection.end.y(); + Row const * startrow = selection.start.row(); + Row const * endrow = selection.end.row(); + + Row * row = p.row; + + if (bidi_same_direction) { + int x; + int y = p.yo; + int w; + int h = row->height(); + + if (startrow == row && endrow == row) { + if (startx < endx) { + x = p.xo + startx; + w = endx - startx; + p.pain->fillRectangle(x, y, w, h, LColor::selection); + } else { + x = p.xo + endx; + w = startx - endx; + p.pain->fillRectangle(x, y, w, h, LColor::selection); + } + } else if (startrow == row) { + int const x = (is_rtl) ? p.xo : (p.xo + startx); + int const w = (is_rtl) ? startx : (p.width - startx); + p.pain->fillRectangle(x, y, w, h, LColor::selection); + } else if (endrow == row) { + int const x = (is_rtl) ? (p.xo + endx) : p.xo; + int const w = (is_rtl) ? (p.width - endx) : endx; + p.pain->fillRectangle(x, y, w, h, LColor::selection); + } else if (p.y > starty && p.y < endy) { + p.pain->fillRectangle(p.xo, y, p.width, h, LColor::selection); + } + return; + } else if (startrow != row && endrow != row) { + int w = p.width; + int h = row->height(); + if (p.y > starty && p.y < endy) { + p.pain->fillRectangle(p.xo, p.yo, w, h, LColor::selection); + } + return; + } + + if (!((startrow != row && !is_rtl) || (endrow != row && is_rtl))) { + return; + } + + float tmpx = p.x; + + p.pain->fillRectangle(p.xo, p.yo, int(p.x), row->height(), LColor::selection); + + Buffer const * buffer = p.bv->buffer(); + Paragraph * par = row->par(); + Paragraph::size_type main_body = beginningOfMainBody(buffer, par); + Paragraph::size_type const last = rowLastPrintable(row); + + for (Paragraph::size_type vpos = row->pos(); vpos <= last; ++vpos) { + Paragraph::size_type pos = vis2log(vpos); + float const old_tmpx = tmpx; + if (main_body > 0 && pos == main_body - 1) { + LyXLayout const & layout = textclasslist.Style(buffer->params.textclass, + par->getLayout()); + LyXFont const lfont = getLabelFont(buffer, par); + + + tmpx += p.label_hfill + lyxfont::width(layout.labelsep, lfont); + + if (par->isLineSeparator(main_body - 1)) + tmpx -= singleWidth(p.bv, par, main_body - 1); + } + + if (hfillExpansion(buffer, row, pos)) { + tmpx += singleWidth(p.bv, par, pos); + if (pos >= main_body) + tmpx += p.hfill; + else + tmpx += p.label_hfill; + } + + else if (par->isSeparator(pos)) { + tmpx += singleWidth(p.bv, par, pos); + if (pos >= main_body) + tmpx += p.separator; + } else { + tmpx += singleWidth(p.bv, par, pos); + } + + if ((startrow != row || selection.start.pos() <= pos) && + (endrow != row || pos < selection.end.pos())) { + // Here we do not use p.x as p.xo was added to p.x. + p.pain->fillRectangle(int(old_tmpx), p.yo, + int(tmpx - old_tmpx + 1), + row->height(), LColor::selection); + } + + if ((startrow != row && is_rtl) || (endrow != row && !is_rtl)) { + p.pain->fillRectangle(p.xo + int(tmpx), + p.yo, int(p.bv->workWidth() - tmpx), + row->height(), LColor::selection); + } + } +} + + +void LyXText::paintRowAppendix(DrawRowParams & p) +{ + // FIXME: can be just p.width ? + int const ww = p.bv->workWidth(); + Paragraph * firstpar = p.row->par(); + + if (firstpar->params().appendix()) { + p.pain->line(1, p.yo, 1, p.yo + p.row->height(), LColor::appendixline); + p.pain->line(ww - 2, p.yo, ww - 2, p.yo + p.row->height(), LColor::appendixline); + } +} + + +void LyXText::paintRowDepthBar(DrawRowParams & p) +{ + Paragraph::depth_type const depth = p.row->par()->getDepth(); + + if (depth <= 0) + return; + + Paragraph::depth_type prev_depth = 0; + if (p.row->previous()) + prev_depth = p.row->previous()->par()->getDepth(); + Paragraph::depth_type next_depth = 0; + if (p.row->next()) + next_depth = p.row->next()->par()->getDepth(); + + for (Paragraph::depth_type i = 1; i <= depth; ++i) { + int const x = (LYX_PAPER_MARGIN / 5) * i + p.xo; + int const h = p.yo + p.row->height() - 1 - (i - next_depth - 1) * 3; + + p.pain->line(x, p.yo, x, h, LColor::depthbar); + + int const w = LYX_PAPER_MARGIN / 5; + + if (i > prev_depth) { + p.pain->fillRectangle(x, p.yo, w, 2, LColor::depthbar); + } + if (i > next_depth) { + p.pain->fillRectangle(x, h, w, 2, LColor::depthbar); + } + } +} + + +void LyXText::paintFirstRow(DrawRowParams & p) +{ + Paragraph * par = p.row->par(); + ParagraphParameters const & parparams = par->params(); + + // start of appendix? + if (parparams.startOfAppendix()) { + p.pain->line(1, p.yo, p.width - 2, p.yo, LColor::appendixline); + } + + int y_top = 0; + + // think about the margins + if (!p.row->previous() && bv_owner) + y_top += LYX_PAPER_MARGIN; + + // draw a top pagebreak + if (parparams.pagebreakTop()) { + int const y = p.yo + y_top + 2*defaultHeight(); + p.pain->line(0, y, p.width, y, LColor::pagebreak, Painter::line_onoffdash); + + int w = 0; + int a = 0; + int d = 0; + + LyXFont pb_font; + pb_font.setColor(LColor::pagebreak).decSize(); + lyxfont::rectText(_("Page Break (top)"), pb_font, w, a, d); + p.pain->rectText((p.width - w)/2, y + d, + _("Page Break (top)"), pb_font, + backgroundColor(), + backgroundColor()); + y_top += 3 * defaultHeight(); + } + + // draw a vfill top + if (parparams.spaceTop().kind() == VSpace::VFILL) { + int const y1 = p.yo + y_top + 3 * defaultHeight(); + int const y2 = p.yo + 2 + y_top; + + p.pain->line(0, y1, LYX_PAPER_MARGIN, y1, LColor::vfillline); + + p.pain->line(0, y2, LYX_PAPER_MARGIN, y2, LColor::vfillline); + + int const x = LYX_PAPER_MARGIN / 2; + + p.pain->line(x, y2, x, y1, LColor::vfillline); + + y_top += 3 * defaultHeight(); + } + + // think about user added space + y_top += int(parparams.spaceTop().inPixels(p.bv)); + + Buffer const * buffer = p.bv->buffer(); + + LyXLayout const & layout = + textclasslist.Style(buffer->params.textclass, par->getLayout()); + + // think about the parskip + // some parskips VERY EASY IMPLEMENTATION + if (buffer->params.paragraph_separation == BufferParams::PARSEP_SKIP) { + if (par->previous()) { + if (layout.latextype == LATEX_PARAGRAPH + && !par->getDepth()) { + y_top += buffer->params.getDefSkip().inPixels(p.bv); + } else { + LyXLayout const & playout = + textclasslist.Style(buffer->params.textclass, + par->previous()->getLayout()); + if (playout.latextype == LATEX_PARAGRAPH + && !par->previous()->getDepth()) { + // is it right to use defskip here, too? (AS) + y_top += buffer->params.getDefSkip().inPixels(p.bv); + } + } + } + } + + int const ww = p.bv->workWidth(); + + // draw a top line + if (parparams.lineTop()) { + LyXFont font(LyXFont::ALL_SANE); + int const asc = lyxfont::ascent('x', getFont(buffer, par, 0)); + + y_top += asc; + + int const w = (inset_owner ? inset_owner->width(p.bv, font) : ww); + int const xp = static_cast(inset_owner ? p.x : 0); + p.pain->line(xp, p.yo + y_top, w, p.yo + y_top, + LColor::topline, Painter::line_solid, + Painter::line_thick); + + y_top += asc; + } + + bool const is_rtl = p.row->par()->isRightToLeftPar(p.bv->buffer()->params); + + // should we print a label? + if (layout.labeltype >= LABEL_STATIC + && (layout.labeltype != LABEL_STATIC + || layout.latextype != LATEX_ENVIRONMENT + || par->isFirstInSequence())) { + + LyXFont font = getLabelFont(buffer, par); + if (!par->getLabelstring().empty()) { + float x = p.x; + string const str = par->getLabelstring(); + + // this is special code for the chapter layout. This is + // printed in an extra row and has a pagebreak at + // the top. + if (layout.labeltype == LABEL_COUNTER_CHAPTER) { + if (buffer->params.secnumdepth >= 0) { + float spacing_val = 1.0; + if (!parparams.spacing().isDefault()) { + spacing_val = parparams.spacing().getValue(); + } else { + spacing_val = buffer->params.spacing.getValue(); + } + + int const maxdesc = + int(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val) + + int(layout.parsep) * defaultHeight(); + + if (is_rtl) { + x = ww - leftMargin(p.bv, p.row) - + lyxfont::width(str, font); + } + + p.pain->text(int(x), p.yo + + p.yo + p.row->baseline() - + p.row->ascent_of_text() - maxdesc, + str, font); + } + } else { + if (is_rtl) { + x = ww - leftMargin(p.bv, p.row) + + lyxfont::width(layout.labelsep, font); + } else + x = p.x - lyxfont::width(layout.labelsep, font) + - lyxfont::width(str, font); + + p.pain->text(int(x), p.yo + p.row->baseline(), str, font); + } + } + // the labels at the top of an environment. + // More or less for bibliography + } else if (par->isFirstInSequence() && + (layout.labeltype == LABEL_TOP_ENVIRONMENT || + layout.labeltype == LABEL_BIBLIO || + layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) { + LyXFont font = getLabelFont(buffer, par); + if (!par->getLabelstring().empty()) { + string const str = par->getLabelstring(); + float spacing_val = 1.0; + if (!parparams.spacing().isDefault()) { + spacing_val = parparams.spacing().getValue(); + } else { + spacing_val = buffer->params.spacing.getValue(); + } + + int maxdesc = + int(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val + + (layout.labelbottomsep * defaultHeight())); + + float x = p.x; + if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) { + x = ((is_rtl ? leftMargin(p.bv, p.row) : p.x) + + ww - rightMargin(buffer, p.row) ) / 2; + x -= lyxfont::width(str, font) / 2; + } else if (is_rtl) { + x = ww - leftMargin(p.bv, p.row) - + lyxfont::width(str, font); + } + p.pain->text(int(x), p.yo + p.row->baseline() + - p.row->ascent_of_text() - maxdesc, + str, font); + } + } + + if (layout.labeltype == LABEL_BIBLIO && par->bibkey) { + LyXFont font = getLayoutFont(buffer, par); + float x; + if (is_rtl) { + x = ww - leftMargin(p.bv, p.row) + + lyxfont::width(layout.labelsep, font); + } else { + x = p.x - lyxfont::width(layout.labelsep, font) + - par->bibkey->width(p.bv, font); + } + par->bibkey->draw(p.bv, font, p.yo + p.row->baseline(), x, p.cleared); + } +} + + +void LyXText::paintLastRow(DrawRowParams & p) +{ + Paragraph * par = p.row->par(); + ParagraphParameters const & parparams = par->params(); + int y_bottom = p.row->height(); + + // think about the margins + if (!p.row->next() && bv_owner) + y_bottom -= LYX_PAPER_MARGIN; + + int const ww = p.bv->workWidth(); + + // draw a bottom pagebreak + if (parparams.pagebreakBottom()) { + LyXFont pb_font; + pb_font.setColor(LColor::pagebreak).decSize(); + int const y = p.yo + y_bottom - 2 * defaultHeight(); + + p.pain->line(0, y, ww, y, LColor::pagebreak, Painter::line_onoffdash); + + int w = 0; + int a = 0; + int d = 0; + lyxfont::rectText(_("Page Break (bottom)"), pb_font, w, a, d); + p.pain->rectText((ww - w) / 2, y + d, + _("Page Break (bottom)"), + pb_font, backgroundColor(), backgroundColor()); + + y_bottom -= 3 * defaultHeight(); + } + + // draw a vfill bottom + if (parparams.spaceBottom().kind() == VSpace::VFILL) { + int const x = LYX_PAPER_MARGIN / 2; + int const x2 = LYX_PAPER_MARGIN; + int const y = p.yo + y_bottom - 3 * defaultHeight(); + int const y2 = p.yo + y_bottom - 2; + + p.pain->line(0, y, x2, y, LColor::vfillline); + p.pain->line(0, y2, x2, y2, LColor::vfillline); + p.pain->line(x, y, x, y2, LColor::vfillline); + + y_bottom -= 3 * defaultHeight(); + } + + // think about user added space + y_bottom -= int(parparams.spaceBottom().inPixels(p.bv)); + + Buffer const * buffer = p.bv->buffer(); + + // draw a bottom line + if (parparams.lineBottom()) { + LyXFont font(LyXFont::ALL_SANE); + int const asc = lyxfont::ascent('x', + getFont(buffer, par, + max(Paragraph::size_type(0), par->size() - 1))); + + y_bottom -= asc; + + int const w = (inset_owner ? inset_owner->width(p.bv, font) : ww); + int const xp = static_cast(inset_owner ? p.x : 0); + int const y = p.yo + y_bottom; + p.pain->line(xp, y, w, y, LColor::topline, Painter::line_solid, + Painter::line_thick); + + y_bottom -= asc; + } + + Paragraph::size_type const last = rowLastPrintable(p.row); + bool const is_rtl = p.row->par()->isRightToLeftPar(p.bv->buffer()->params); + int const endlabel = par->getEndLabel(buffer->params); + + // draw an endlabel + switch (endlabel) { + case END_LABEL_BOX: + case END_LABEL_FILLED_BOX: + { + LyXFont const font = getFont(buffer, par, last); + int const size = int(0.75 * lyxfont::maxAscent(font)); + int const y = (p.yo + p.row->baseline()) - size; + int x = is_rtl ? LYX_PAPER_MARGIN : ww - LYX_PAPER_MARGIN - size; + + if (p.row->fill() <= size) + x += (size - p.row->fill() + 1) * (is_rtl ? -1 : 1); + + if (endlabel == END_LABEL_BOX) { + p.pain->line(x, y, x, y + size, LColor::eolmarker); + p.pain->line(x + size, y, x + size , y + size, LColor::eolmarker); + p.pain->line(x, y, x + size, y, LColor::eolmarker); + p.pain->line(x, y + size, x + size, y + size, LColor::eolmarker); + } else { + p.pain->fillRectangle(x, y, size, size, LColor::eolmarker); + } + break; + } + case END_LABEL_STATIC: + { + LyXFont font(LyXFont::ALL_SANE); + LyXTextClass::LayoutList::size_type layout = par->getLayout(); + string const str = textclasslist. + Style(buffer->params.textclass, layout).endlabelstring(); + font = getLabelFont(buffer, par); + int const x = is_rtl ? + int(p.x) - lyxfont::width(str, font) + : ww - rightMargin(buffer, p.row) - p.row->fill(); + p.pain->text(x, p.yo + p.row->baseline(), str, font); + break; + } + case END_LABEL_NO_LABEL: + break; + } +} + +void LyXText::paintRowText(DrawRowParams & p) +{ + Paragraph * par = p.row->par(); + Buffer const * buffer = p.bv->buffer(); + + Paragraph::size_type const last = rowLastPrintable(p.row); + Paragraph::size_type main_body = + beginningOfMainBody(buffer, par); + if (main_body > 0 && + (main_body - 1 > last || + !par->isLineSeparator(main_body - 1))) { + main_body = 0; + } + + LyXLayout const & layout = + textclasslist.Style(buffer->params.textclass, par->getLayout()); + + Paragraph::size_type vpos = p.row->pos(); + while (vpos <= last) { + Paragraph::size_type pos = vis2log(vpos); + if (main_body > 0 && pos == main_body - 1) { + int const lwidth = lyxfont::width(layout.labelsep, + getLabelFont(buffer, par)); + + p.x += p.label_hfill + lwidth + - singleWidth(p.bv, par, main_body - 1); + } + + if (par->isHfill(pos)) { + p.x += 1; + + int const y1 = p.yo + p.row->baseline() - defaultHeight() / 2; + + p.pain->line(int(p.x), y1, int(p.x), p.yo + p.row->baseline(), + LColor::vfillline); + + int const y2 = y1 / 2; + + if (hfillExpansion(buffer, p.row, pos)) { + if (pos >= main_body) { + p.pain->line(int(p.x), y2, + int(p.x + p.hfill), y2, + LColor::vfillline, + Painter::line_onoffdash); + p.x += p.hfill; + } else { + p.pain->line(int(p.x), y2, + int(p.x + p.label_hfill), y2, + LColor::vfillline, + Painter::line_onoffdash); + p.x += p.label_hfill; + } + p.pain->line(int(p.x), y1, + int(p.x), p.yo + p.row->baseline(), + LColor::vfillline); + } + p.x += 2; + ++vpos; + } else if (par->isSeparator(pos)) { + p.x += singleWidth(p.bv, par, pos); + if (pos >= main_body) + p.x += p.separator; + ++vpos; + } else { + draw(p.bv, p.row, vpos, p.yo, p.x, p.cleared); + } + } +} + + +void LyXText::getVisibleRow(BufferView * bv, int y_offset, int x_offset, + Row * row, int y, bool cleared) +{ + if (row->height() <= 0) { lyxerr << "LYX_ERROR: row.height: " - << row_ptr->height() << endl; + << row->height() << endl; return; } - float x; - float fill_separator; - float fill_hfill; - float fill_label_hfill; - prepareToPrint(bview, row_ptr, x, fill_separator, - fill_hfill, fill_label_hfill); - - if (inset_owner && (x < 0)) - x = 0; - x += x_offset; - - // clear the area where we want to paint/print - int const ww = bview->workWidth(); + DrawRowParams p; - bool clear_area = true; - Inset * inset = 0; + // set up drawing parameters + p.bv = bv; + p.pain = &bv->painter(); + p.row = row; + p.xo = x_offset; + p.yo = y_offset; + prepareToPrint(bv, row, p.x, p.separator, p.hfill, p.label_hfill); + if (inset_owner && (p.x < 0)) + p.x = 0; + p.x += p.xo; + p.y = y; + p.width = inset_owner ? inset_owner->textWidth(bv, true) : bv->workWidth(); + p.cleared = cleared; + + // start painting - if (!bview->screen()->forceClear() && last == row_ptr->pos() - && row_ptr->par()->getChar(row_ptr->pos()) == Paragraph::META_INSET - && (inset = row_ptr->par()->getInset(row_ptr->pos()))) { - clear_area = inset->doClearArea(); - } - // we don't need to clear it's already done!!! - if (cleared) { - clear_area = true; - } else if (clear_area) { - int const y = y_offset < 0 ? 0 : y_offset; - int const h = y_offset < 0 ? - row_ptr->height() + y_offset : row_ptr->height(); - int const w = inset_owner ? - inset_owner->textWidth(bview, true) : ww; - int const x = 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) { - int const w = (inset_owner ? - inset_owner->textWidth(bview, true) : ww); - pain.fillRectangle(x_offset, y_offset, w, h, - backgroundColor()); - } - h += inset->ascent(bview, font) + inset->descent(bview, font); - // clear the space below the inset! - if ((row_ptr->height() - h) > 0) { - int const w = (inset_owner ? - inset_owner->textWidth(bview, true) : ww); - pain.fillRectangle(x_offset, y_offset + h, - w, row_ptr->height() - h, - backgroundColor()); - } - // clear the space behind the inset, if needed - if (!inset->display() && !inset->needFullRow()) { - int const w = (inset_owner ? - inset_owner->textWidth(bview, true) : ww); - int const xp = int(x) + inset->width(bview, font); - if (w-xp > 0) { - pain.fillRectangle(xp, y_offset, - w-xp, row_ptr->height(), - backgroundColor()); - } - } - } + // clear to background if necessary + p.cleared = paintRowBackground(p); + // paint the selection background if (selection.set()) { - int const w = (inset_owner ? - inset_owner->textWidth(bview, true) : ww); - // selection code - if (bidi_same_direction) { - if (selection.start.row() == row_ptr && - selection.end.row() == row_ptr) { - if (selection.start.x() < selection.end.x()) - pain.fillRectangle(x_offset + selection.start.x(), - y_offset, - selection.end.x() - selection.start.x(), - row_ptr->height(), - LColor::selection); - else - pain.fillRectangle(x_offset + selection.end.x(), - y_offset, - selection.start.x() - selection.end.x(), - row_ptr->height(), - LColor::selection); - } else if (selection.start.row() == row_ptr) { - if (is_rtl) - pain.fillRectangle(x_offset, y_offset, - selection.start.x(), - row_ptr->height(), - LColor::selection); - else - pain.fillRectangle(x_offset + selection.start.x(), - y_offset, - w - selection.start.x(), - row_ptr->height(), - LColor::selection); - } else if (selection.end.row() == row_ptr) { - if (is_rtl) - pain.fillRectangle(x_offset + selection.end.x(), - y_offset, - w - selection.end.x(), - row_ptr->height(), - LColor::selection); - else - pain.fillRectangle(x_offset, y_offset, - selection.end.x(), - row_ptr->height(), - LColor::selection); - } else if (y > selection.start.y() - && y < selection.end.y()) { - pain.fillRectangle(x_offset, y_offset, w, - row_ptr->height(), - LColor::selection); - } - } else if (selection.start.row() != row_ptr && - selection.end.row() != row_ptr && - y > selection.start.y() - && y < selection.end.y()) { - pain.fillRectangle(x_offset, y_offset, w, - row_ptr->height(), - LColor::selection); - } else if (selection.start.row() == row_ptr || - selection.end.row() == row_ptr) { - float tmpx = x; - if ((selection.start.row() != row_ptr && !is_rtl) || - (selection.end.row() != row_ptr && is_rtl)) - pain.fillRectangle(x_offset, y_offset, - int(tmpx), - row_ptr->height(), - LColor::selection); - Paragraph::size_type main_body = - beginningOfMainBody(bview->buffer(), - row_ptr->par()); - - for (vpos = row_ptr->pos(); vpos <= last; ++vpos) { - pos = vis2log(vpos); - float const old_tmpx = tmpx; - if (main_body > 0 && pos == main_body-1) { - tmpx += fill_label_hfill + - lyxfont::width(textclasslist.Style(bview->buffer()->params.textclass, - row_ptr->par()->getLayout()).labelsep, - getLabelFont(bview->buffer(),row_ptr->par())); - if (row_ptr->par()->isLineSeparator(main_body-1)) - tmpx -= singleWidth(bview, row_ptr->par(), main_body-1); - } - if (hfillExpansion(bview->buffer(), row_ptr, pos)) { - tmpx += singleWidth(bview, row_ptr->par(), pos); - if (pos >= main_body) - tmpx += fill_hfill; - else - tmpx += fill_label_hfill; - } - else if (row_ptr->par()->isSeparator(pos)) { - tmpx += singleWidth(bview, row_ptr->par(), pos); - if (pos >= main_body) - tmpx += fill_separator; - } else - tmpx += singleWidth(bview, row_ptr->par(), pos); - - if ((selection.start.row() != row_ptr || - selection.start.pos() <= pos) && - (selection.end.row() != row_ptr || - pos < selection.end.pos()) ) - // Here we do not use x_offset as x_offset was - // added to x. - pain.fillRectangle(int(old_tmpx), - y_offset, - int(tmpx - old_tmpx + 1), - row_ptr->height(), - LColor::selection); - } - - if ((selection.start.row() != row_ptr && is_rtl) || - (selection.end.row() != row_ptr && !is_rtl) ) - pain.fillRectangle(x_offset + int(tmpx), - y_offset, - int(ww - tmpx), - row_ptr->height(), - LColor::selection); - } + paintRowSelection(p); } - int box_x = 0; + // vertical lines for appendix + paintRowAppendix(p); - // Draw appendix lines - Paragraph * firstpar = row_ptr->par(); - - if (firstpar->params().appendix()) { - pain.line(1, y_offset, - 1, y_offset + row_ptr->height(), - LColor::appendixline); - pain.line(ww - 2, y_offset, - ww - 2, y_offset + row_ptr->height(), - LColor::appendixline); + // environment depth brackets + paintRowDepthBar(p); + + // draw any stuff wanted for a first row of a paragraph + if (!row->pos()) { + paintFirstRow(p); } - // Draw depth lines - Paragraph::depth_type const depth = firstpar->getDepth(); - if (depth > 0) { - Paragraph::depth_type next_depth = 0; - Paragraph::depth_type prev_depth = 0; - if (row_ptr->next()) - next_depth = row_ptr->next()->par()->getDepth(); - if (row_ptr->previous()) - prev_depth = row_ptr->previous()->par()->getDepth(); + // draw any stuff wanted for the last row of a paragraph + if (!row->next() || (row->next()->par() != row->par())) { + paintLastRow(p); + } - for (Paragraph::depth_type i = 1; i <= depth; ++i) { - int const line_x = (LYX_PAPER_MARGIN / 5) * - i + box_x + x_offset; - pain.line(line_x, y_offset, line_x, - y_offset + row_ptr->height() - 1 - (i - next_depth - 1) * 3, - LColor::depthbar); - - if (i > prev_depth) - pain.fillRectangle(line_x, y_offset, LYX_PAPER_MARGIN / 5, 2, - LColor::depthbar); - if (i > next_depth) - pain.fillRectangle(line_x, - y_offset + row_ptr->height() - 2 - (i - next_depth - 1) * 3, - LYX_PAPER_MARGIN / 5, 2, - LColor::depthbar); - } - } - - - LyXLayout const & layout = - textclasslist.Style(bview->buffer()->params.textclass, - row_ptr->par()->getLayout()); - - int y_top = 0; - int y_bottom = row_ptr->height(); - - // is it a first row? - if (!row_ptr->pos() && (row_ptr->par() == firstpar)) { - - // start of appendix? - if (row_ptr->par()->params().startOfAppendix()) { - pain.line(1, y_offset, - ww - 2, y_offset, - LColor::appendixline); - } - - // think about the margins - if (!row_ptr->previous() && bv_owner) - y_top += LYX_PAPER_MARGIN; - - // draw a top pagebreak - if (row_ptr->par()->params().pagebreakTop()) { - LyXFont pb_font; - pb_font.setColor(LColor::pagebreak).decSize(); - int w = 0; - int a = 0; - int d = 0; - pain.line(0, y_offset + y_top + 2*defaultHeight(), - ww, - y_offset + y_top + 2 * defaultHeight(), - LColor::pagebreak, - Painter::line_onoffdash); - lyxfont::rectText(_("Page Break (top)"), pb_font, - w, a, d); - pain.rectText((ww - w)/2, - y_offset + y_top + 2 * defaultHeight() + d, - _("Page Break (top)"), - pb_font, - backgroundColor(), - backgroundColor()); - y_top += 3 * defaultHeight(); - } - - if (row_ptr->par()->params().spaceTop().kind() == VSpace::VFILL) { - // draw a vfill top - pain.line(0, y_offset + 2 + y_top, - LYX_PAPER_MARGIN, y_offset + 2 + y_top, - LColor::vfillline); - - pain.line(0, y_offset + y_top + 3 * defaultHeight(), - LYX_PAPER_MARGIN, - y_offset + y_top + 3 * defaultHeight(), - LColor::vfillline); - - pain.line(LYX_PAPER_MARGIN / 2, y_offset + 2 + y_top, - LYX_PAPER_MARGIN / 2, - y_offset + y_top + 3 * defaultHeight(), - LColor::vfillline); - - y_top += 3 * defaultHeight(); - } - - // think about user added space - y_top += int(row_ptr->par()->params().spaceTop().inPixels(bview)); - - // think about the parskip - // some parskips VERY EASY IMPLEMENTATION - if (bview->buffer()->params.paragraph_separation == BufferParams::PARSEP_SKIP) { - if (layout.latextype == LATEX_PARAGRAPH - && firstpar->getDepth() == 0 - && firstpar->previous()) - y_top += bview->buffer()->params.getDefSkip().inPixels(bview); - else if (firstpar->previous() - && textclasslist.Style(bview->buffer()->params.textclass, - firstpar->previous()->getLayout()).latextype == LATEX_PARAGRAPH - && firstpar->previous()->getDepth() == 0) - // is it right to use defskip here, too? (AS) - y_top += bview->buffer()->params.getDefSkip().inPixels(bview); - } - - if (row_ptr->par()->params().lineTop()) { - // draw a top line - y_top += lyxfont::ascent('x', - getFont(bview->buffer(), - row_ptr->par(), 0)); - int const w = (inset_owner ? - inset_owner->width(bview, font) : ww); - int const xp = static_cast(inset_owner ? x : 0); - pain.line(xp, y_offset + y_top, - w, y_offset + y_top, - LColor::topline, - Painter::line_solid, - Painter::line_thick); - - y_top += lyxfont::ascent('x',getFont(bview->buffer(), - row_ptr->par(), 0)); - } - - // should we print a label? - if (layout.labeltype >= LABEL_STATIC - && (layout.labeltype != LABEL_STATIC - || layout.latextype != LATEX_ENVIRONMENT - || row_ptr->par()->isFirstInSequence())) { - font = getLabelFont(bview->buffer(), row_ptr->par()); - if (!row_ptr->par()->getLabelstring().empty()) { - tmpx = x; - string const tmpstring = - row_ptr->par()->getLabelstring(); - - if (layout.labeltype == LABEL_COUNTER_CHAPTER) { - if (bview->buffer()->params.secnumdepth >= 0) { - // this is special code for - // the chapter layout. This is - // printed in an extra row - // and has a pagebreak at - // the top. - float spacing_val = 1.0; - if (!row_ptr->par()->params().spacing().isDefault()) { - spacing_val = row_ptr->par()->params().spacing().getValue(); - } else { - spacing_val = bview->buffer()->params.spacing.getValue(); - } - - maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val) - + int(layout.parsep) * defaultHeight(); - if (is_rtl) - tmpx = ww - leftMargin(bview, row_ptr) - - lyxfont::width(tmpstring, font); - pain.text(int(tmpx), - y_offset + row_ptr->baseline() - row_ptr->ascent_of_text() - maxdesc, - tmpstring, font); - } - } else { - if (is_rtl) { - tmpx = ww - leftMargin(bview, row_ptr) - + lyxfont::width(layout.labelsep, font); - } else - tmpx = x - lyxfont::width(layout.labelsep, font) - - lyxfont::width(tmpstring, font); - - // draw it! - pain.text(int(tmpx), - y_offset + row_ptr->baseline(), - tmpstring, font); - } - } - // the labels at the top of an environment. - // More or less for bibliography - } else if (layout.labeltype == LABEL_TOP_ENVIRONMENT || - layout.labeltype == LABEL_BIBLIO || - layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) { - if (row_ptr->par()->isFirstInSequence()) { - font = getLabelFont(bview->buffer(), - row_ptr->par()); - if (!row_ptr->par()->getLabelstring().empty()) { - string const tmpstring = - row_ptr->par()->getLabelstring(); - float spacing_val = 1.0; - if (!row_ptr->par()->params().spacing().isDefault()) { - spacing_val = row_ptr->par()->params().spacing().getValue(); - } else { - spacing_val = bview->buffer()->params.spacing.getValue(); - } - - maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val - + (layout.labelbottomsep * defaultHeight())); - - tmpx = x; - if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT){ - tmpx = ( (is_rtl ? leftMargin(bview, row_ptr) : x) - + ww - rightMargin(bview->buffer(), row_ptr) ) / 2; - tmpx -= lyxfont::width(tmpstring, font) / 2; - } else if (is_rtl) - tmpx = ww - leftMargin(bview, row_ptr) - - lyxfont::width(tmpstring, font); - pain.text(int(tmpx), - y_offset + row_ptr->baseline() - - row_ptr->ascent_of_text() - - maxdesc, - tmpstring, font); - } - } - } - if (layout.labeltype == LABEL_BIBLIO && row_ptr->par()->bibkey) { - font = getLayoutFont(bview->buffer(), row_ptr->par()); - if (is_rtl) - tmpx = ww - leftMargin(bview, row_ptr) - + lyxfont::width(layout.labelsep, font); - else - tmpx = x - lyxfont::width(layout.labelsep, font) - - row_ptr->par()->bibkey->width(bview, font); - row_ptr->par()->bibkey->draw(bview, font, - y_offset + row_ptr->baseline(), - tmpx, clear_area); - } - } - - // is it a last row? - Paragraph * par = row_ptr->par(); - if (row_ptr->par() == par - && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) { - // think about the margins - if (!row_ptr->next() && bv_owner) - y_bottom -= LYX_PAPER_MARGIN; - - // draw a bottom pagebreak - if (firstpar->params().pagebreakBottom()) { - LyXFont pb_font; - pb_font.setColor(LColor::pagebreak).decSize(); - int const y_place = y_offset + y_bottom - - 2 * defaultHeight(); - - int w = 0; - int a = 0; - int d = 0; - pain - .line(0, y_place, ww, y_place, - LColor::pagebreak, - Painter::line_onoffdash); - lyxfont::rectText(_("Page Break (bottom)"), pb_font, - w, a, d); - pain.rectText((ww - w) / 2, y_place + d, - _("Page Break (bottom)"), - pb_font, - backgroundColor(), - backgroundColor()); - y_bottom -= 3 * defaultHeight(); - } - - if (firstpar->params().spaceBottom().kind() == VSpace::VFILL) { - // draw a vfill bottom - int const y_place = y_offset + y_bottom - - 3 * defaultHeight(); - - pain.line(0, y_place, - LYX_PAPER_MARGIN, y_place, - LColor::vfillline); - pain.line(0, y_offset + y_bottom - 2, - LYX_PAPER_MARGIN, - y_offset + y_bottom - 2, - LColor::vfillline); - pain.line(LYX_PAPER_MARGIN / 2, - y_place, - LYX_PAPER_MARGIN / 2, - y_offset + y_bottom - 2, - LColor::vfillline); - y_bottom -= 3 * defaultHeight(); - } - - // think about user added space - y_bottom -= int(firstpar->params().spaceBottom().inPixels(bview)); - - if (firstpar->params().lineBottom()) { - // draw a bottom line - y_bottom -= lyxfont::ascent('x', - getFont(bview->buffer(), - par, - max(Paragraph::size_type(0), par->size() - 1))); - int const w = (inset_owner ? - inset_owner->width(bview, font) : ww); - int const xp = static_cast(inset_owner ? x : 0); - pain.line(xp, y_offset + y_bottom, - w, y_offset + y_bottom, - LColor::topline, Painter::line_solid, - Painter::line_thick); - y_bottom -= lyxfont::ascent('x', - getFont(bview->buffer(), - par, - max(Paragraph::size_type(0), par->size() - 1))); - } - - // draw an endlabel - int const endlabel = - row_ptr->par()->getEndLabel(bview->buffer()->params); - switch (endlabel) { - case END_LABEL_BOX: - case END_LABEL_FILLED_BOX: - { - LyXFont const font = getFont(bview->buffer(), - row_ptr->par(), last); - int const size = int(0.75 * lyxfont::maxAscent(font)); - int const y = (y_offset + row_ptr->baseline()) - size; - int x = is_rtl ? LYX_PAPER_MARGIN - : ww - LYX_PAPER_MARGIN - size; - - if (row_ptr->fill() <= size) - x += (size - row_ptr->fill() + 1) * (is_rtl ? -1 : 1); - if (endlabel == END_LABEL_BOX) { - pain.line(x, y, x, y + size, - LColor::eolmarker); - pain.line(x + size, y, x + size , y + size, - LColor::eolmarker); - pain.line(x, y, x + size, y, - LColor::eolmarker); - pain.line(x, y + size, x + size, y + size, - LColor::eolmarker); - } else - pain.fillRectangle(x, y, size, size, - LColor::eolmarker); - break; - } - case END_LABEL_STATIC: - { - LyXTextClass::LayoutList::size_type layout = row_ptr->par()->getLayout(); - string const tmpstring = textclasslist. - Style(bview->buffer()->params.textclass, - layout).endlabelstring(); - font = getLabelFont(bview->buffer(), row_ptr->par()); - int const tmpx = is_rtl ? - int(x) - lyxfont::width(tmpstring, font) - : ww - rightMargin(bview->buffer(), row_ptr) - row_ptr->fill(); - pain.text( tmpx, y_offset + row_ptr->baseline(), tmpstring, font); - break; - } - case END_LABEL_NO_LABEL: - break; - } - } - - // draw the text in the pixmap - - vpos = row_ptr->pos(); - - Paragraph::size_type main_body = - beginningOfMainBody(bview->buffer(), row_ptr->par()); - if (main_body > 0 && - (main_body-1 > last || - !row_ptr->par()->isLineSeparator(main_body - 1))) - main_body = 0; - - while (vpos <= last) { - pos = vis2log(vpos); - if (main_body > 0 && pos == main_body - 1) { - x += fill_label_hfill - + lyxfont::width(layout.labelsep, - getLabelFont(bview->buffer(), - row_ptr->par())) - - singleWidth(bview, - row_ptr->par(), - main_body - 1); - } - - if (row_ptr->par() ->isHfill(pos)) { - x += 1; - pain.line(int(x), - y_offset + row_ptr->baseline() - defaultHeight() / 2, - int(x), - y_offset + row_ptr->baseline(), - LColor::vfillline); - - if (hfillExpansion(bview->buffer(), - row_ptr, pos)) { - if (pos >= main_body) { - pain.line(int(x), - y_offset + row_ptr->baseline() - defaultHeight() / 4, - int(x + fill_hfill), - y_offset + row_ptr->baseline() - defaultHeight() / 4, - LColor::vfillline, - Painter::line_onoffdash); - x += fill_hfill; - } else { - pain.line(int(x), - y_offset + row_ptr->baseline() - defaultHeight() / 4, - int(x + fill_label_hfill), - y_offset + row_ptr->baseline() - defaultHeight() / 4, - LColor::vfillline, - Painter::line_onoffdash); - - x += fill_label_hfill; - } - pain.line(int(x), - y_offset + row_ptr->baseline() - defaultHeight() / 2, - int(x), - y_offset + row_ptr->baseline(), - LColor::vfillline); - } - x += 2; - ++vpos; - } else if (row_ptr->par()->isSeparator(pos)) { - x += singleWidth(bview, - row_ptr->par(), pos); - if (pos >= main_body) - x += fill_separator; - ++vpos; - } else - draw(bview, row_ptr, vpos, y_offset, x, clear_area); - } + // paint text + paintRowText(p); } diff --git a/src/text2.C b/src/text2.C index 500b2a7a53..ecfbae47fa 100644 --- a/src/text2.C +++ b/src/text2.C @@ -246,14 +246,12 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par, LyXFont font = getFont(buf, par, pos); font.update(fnt, buf->params.language, toggleall); // Let the insets convert their font - if (par->getChar(pos) == Paragraph::META_INSET) { + if (isMetaInset(par, pos)) { Inset * inset = par->getInset(pos); - if (inset) { - if (inset->editable()==Inset::IS_EDITABLE) { - UpdatableInset * uinset = - static_cast(inset); - uinset->setFont(bv, fnt, toggleall, true); - } + if (isEditableInset(inset)) { + UpdatableInset * uinset = + static_cast(inset); + uinset->setFont(bv, fnt, toggleall, true); } } @@ -451,7 +449,7 @@ Inset * LyXText::getInset() const if (cursor.pos() == 0 && cursor.par()->bibkey) { inset = cursor.par()->bibkey; } else if (cursor.pos() < cursor.par()->size() - && cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) { + && isMetaInset(cursor.par(), cursor.pos())) { inset = cursor.par()->getInset(cursor.pos()); } return inset; @@ -461,12 +459,12 @@ Inset * LyXText::getInset() const void LyXText::toggleInset(BufferView * bview) { Inset * inset = getInset(); - if (!inset->editable()) + if (!isEditableInset(inset)) return; //bview->owner()->message(inset->editMessage()); // do we want to keep this?? (JMarc) - if (inset->editable() != Inset::HIGHLY_EDITABLE) + if (!isHighlyEditableInset(inset)) setCursorParUndo(bview); if (inset->isOpen()) { @@ -1697,7 +1695,7 @@ void LyXText::insertInset(BufferView * bview, Inset * inset) // inset now after the Undo LyX tries to call inset->Edit(...) again // and cannot do this as the cursor is behind the inset and GetInset // does not return the inset! - if (inset->editable() == Inset::HIGHLY_EDITABLE) { + if (isHighlyEditableInset(inset)) { cursorLeft(bview, true); } #endif @@ -1967,7 +1965,7 @@ bool LyXText::gotoNextInset(BufferView * bview, } } while (res.par() && - !(res.par()->getChar(res.pos()) == Paragraph::META_INSET + !(isMetaInset(res.par(), res.pos()) && (inset = res.par()->getInset(res.pos())) != 0 && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() @@ -1976,7 +1974,7 @@ bool LyXText::gotoNextInset(BufferView * bview, == contents))); if (res.par()) { - setCursor(bview, res.par(), res.pos()); + setCursor(bview, res.par(), res.pos(), false); return true; } return false; @@ -2115,7 +2113,7 @@ void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par, y += row->baseline(); // y is now the cursor baseline cur.y(y); - + // now get the cursors x position float x; float fill_separator; diff --git a/src/vspace.h b/src/vspace.h index 30aa427ab4..d11dfdc88b 100644 --- a/src/vspace.h +++ b/src/vspace.h @@ -52,6 +52,7 @@ public: MU, /// Percent of columnwidth both "%" or "%c" PW, + /// PE, /// Percent of pagewidth PP,