From 28ad9602557a145bfd88c79dddecdc34c95c698c Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 11 Oct 2006 17:24:46 +0000 Subject: [PATCH] This commit cleans up everything related to singleton. The other important change is that lyx::dispatch() and lyx::getStatus become _the_ official way to use LyXFunc equivalent methods. * lyxfunc.h: - theLyXFunc(): new function in the global namespace. - lyx::dispatch(): new function in the lyx namespace. - lyx::getStatus(): new function in the lyx namespace. * bufferlist.h: - theBufferList(): new function in the global namespace. * Clipboard.h: - theClipboard(): new function in the global namespace. * Selection.h: - theSelection(): new function in the global namespace. * FontLoader.h: - theFontLoader(): new function in the global namespace. * FontMetrics.h: - theFontMetrics(LyXFont const &): new function in the global namespace. * Application.C: implements the functions defined above. * LyXView.h: - getLyXFunc(): deleted. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15298 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 26 ++++---- src/CutAndPaste.C | 7 +-- src/LaTeX.C | 4 +- src/MenuBackend.C | 6 +- src/buffer.C | 9 ++- src/buffer_funcs.C | 5 +- src/bufferlist.h | 2 + src/cursor.C | 6 +- src/dimension.C | 4 +- src/frontends/Application.C | 61 +++++++++++++++++-- src/frontends/Clipboard.h | 2 + src/frontends/FontLoader.h | 2 + src/frontends/FontMetrics.h | 4 ++ src/frontends/LyXView.C | 4 +- src/frontends/LyXView.h | 14 ----- src/frontends/Painter.C | 8 +-- src/frontends/Selection.h | 2 + src/frontends/Toolbars.C | 6 +- src/frontends/WorkArea.C | 5 +- .../controllers/ControlCommandBuffer.C | 2 +- src/frontends/controllers/ControlPrefs.C | 4 +- src/frontends/controllers/ControlRef.C | 10 ++- src/frontends/controllers/Dialog.C | 2 +- src/frontends/controllers/Kernel.C | 2 +- src/frontends/gtk/GMenubar.C | 2 +- src/frontends/gtk/GToolbar.C | 4 +- src/frontends/gtk/GView.C | 6 +- src/frontends/qt3/QLToolbar.C | 7 +-- src/frontends/qt3/QtView.C | 8 +-- src/frontends/qt4/Action.C | 4 +- src/frontends/qt4/GuiView.C | 9 ++- src/frontends/qt4/InsertTableWidget.C | 4 +- src/frontends/qt4/QLPainter.C | 1 - src/frontends/qt4/QLToolbar.C | 2 +- src/insets/insetbibitem.C | 5 +- src/insets/insetcaption.C | 6 +- src/insets/insetcharstyle.C | 6 +- src/insets/insetcollapsable.C | 4 +- src/insets/insetinclude.C | 17 +++--- src/insets/insetlatexaccent.C | 11 +--- src/insets/insetnewline.C | 8 +-- src/insets/insetpagebreak.C | 4 +- src/insets/insetquotes.C | 6 +- src/insets/insetref.C | 4 +- src/insets/insetspace.C | 6 +- src/insets/insetspecialchar.C | 6 +- src/insets/insettabular.C | 7 +-- src/insets/insetvspace.C | 6 +- src/insets/render_button.C | 4 +- src/insets/render_graphic.C | 10 ++- src/insets/render_preview.C | 6 +- src/lyx_cb.C | 4 +- src/lyx_main.C | 6 +- src/lyxfunc.C | 30 ++++----- src/lyxfunc.h | 9 +++ src/lyxlength.C | 2 +- src/mathed/InsetFormulaMacro.C | 7 +-- src/mathed/InsetMathBig.C | 5 +- src/mathed/InsetMathChar.C | 4 +- src/mathed/InsetMathHull.C | 2 +- src/mathed/InsetMathNest.C | 8 +-- src/mathed/MathFactory.C | 3 +- src/mathed/MathMacroTemplate.C | 6 +- src/mathed/MathSupport.C | 18 +++--- src/rowpainter.C | 30 ++++----- src/text.C | 35 +++++------ src/text2.C | 16 +++-- src/text3.C | 33 +++++----- 68 files changed, 275 insertions(+), 303 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index a88a68f94b..af1c147400 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -60,9 +60,7 @@ #include "insets/insettext.h" #include "frontends/Alert.h" -#include "frontends/Application.h" #include "frontends/FileDialog.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "graphics/Previews.h" @@ -188,7 +186,7 @@ void BufferView::setBuffer(Buffer * b) lyxerr[Debug::INFO] << BOOST_CURRENT_FUNCTION << " No Buffer!" << endl; // We are closing the buffer, use the first buffer as current - buffer_ = theApp->bufferList().first(); + buffer_ = theBufferList().first(); } else { // Set current buffer buffer_ = b; @@ -235,7 +233,7 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles) s = filename; // File already open? - if (theApp->bufferList().exists(s)) { + if (theBufferList().exists(s)) { docstring const file = makeDisplayPath(s, 20); docstring text = bformat(_("The document %1$s is already " "loaded.\n\nDo you want to revert " @@ -244,11 +242,11 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles) text, 0, 1, _("&Revert"), _("&Switch to document")); if (ret != 0) { - setBuffer(theApp->bufferList().getBuffer(s)); + setBuffer(theBufferList().getBuffer(s)); return true; } // FIXME: should be LFUN_REVERT - if (!theApp->bufferList().close(theApp->bufferList().getBuffer(s), false)) + if (!theBufferList().close(theBufferList().getBuffer(s), false)) return false; // Fall through to new load. (Asger) } @@ -256,9 +254,9 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles) Buffer * b = 0; if (found) { - b = theApp->bufferList().newBuffer(s); + b = theBufferList().newBuffer(s); if (!::loadLyXFile(b, s)) { - theApp->bufferList().release(b); + theBufferList().release(b); return false; } } else { @@ -312,7 +310,7 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles) void BufferView::reload() { string const fn = buffer_->fileName(); - if (theApp->bufferList().close(buffer_, false)) + if (theBufferList().close(buffer_, false)) loadLyXFile(fn); } @@ -333,8 +331,8 @@ void BufferView::resize() bool BufferView::fitCursor() { if (bv_funcs::status(this, cursor_) == bv_funcs::CUR_INSIDE) { - lyx::frontend::FontMetrics const & fm - = theApp->fontLoader().metrics(cursor_.getFont()); + lyx::frontend::FontMetrics const & fm = + theFontMetrics(cursor_.getFont()); int const asc = fm.maxAscent(); int const des = fm.maxDescent(); Point const p = bv_funcs::getPos(cursor_, cursor_.boundary()); @@ -538,10 +536,10 @@ void BufferView::restorePosition(unsigned int i) if (fname != buffer_->fileName()) { Buffer * b = 0; - if (theApp->bufferList().exists(fname)) - b = theApp->bufferList().getBuffer(fname); + if (theBufferList().exists(fname)) + b = theBufferList().getBuffer(fname); else { - b = theApp->bufferList().newBuffer(fname); + b = theBufferList().newBuffer(fname); // Don't ask, just load it ::loadLyXFile(b, fname); } diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 846c4041fb..20c3f85bd8 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -44,7 +44,6 @@ #include "support/lstrings.h" -#include "frontends/Application.h" #include "frontends/Clipboard.h" #include @@ -510,8 +509,8 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut) // solved by running the line below only when the selection has // finished. The solution used currently just works, to make it // faster we need to be more clever and probably also have more - // calls to theApp->selection().put. (Lgb) -// theApp->selection().put(cur.selectionAsString(true)); + // calls to theSelection().put. (Lgb) +// theSelection().put(cur.selectionAsString(true)); // make sure that the depth behind the selection are restored, too @@ -575,7 +574,7 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut) void copySelection(LCursor & cur) { // stuff the selection onto the X clipboard, from an explicit copy request - theApp->clipboard().put(cur.selectionAsString(true)); + theClipboard().put(cur.selectionAsString(true)); // this doesn't make sense, if there is no selection if (!cur.selection()) diff --git a/src/LaTeX.C b/src/LaTeX.C index 17854a217a..5588e6bb45 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -21,8 +21,6 @@ #include "debug.h" #include "DepTable.h" -#include "frontends/Application.h" - #include "support/filetools.h" #include "support/convert.h" #include "support/lstrings.h" @@ -180,7 +178,7 @@ int LaTeX::run(TeXErrors & terr) bool rerun = false; // rerun requested // The class LaTeX does not know the temp path. - theApp->bufferList().updateIncludedTeXfiles(getcwd(), runparams); + theBufferList().updateIncludedTeXfiles(getcwd(), runparams); // Never write the depfile if an error was encountered. diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 35de35677d..c099129f15 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -37,8 +37,6 @@ #include "lyxlex.h" #include "toc.h" -#include "frontends/Application.h" - #include "support/filetools.h" #include "support/lstrings.h" #include "support/convert.h" @@ -169,7 +167,7 @@ Menu & Menu::addWithStatusCheck(MenuItem const & i) case MenuItem::Command: { FuncStatus status = - theApp->lyxFunc().getStatus(i.func()); + lyx::getStatus(i.func()); if (status.unknown() || (!status.enabled() && i.optional())) break; @@ -449,7 +447,7 @@ void expandLastfiles(Menu & tomenu) void expandDocuments(Menu & tomenu) { typedef vector Strings; - Strings const names = theApp->bufferList().getFileNames(); + Strings const names = theBufferList().getFileNames(); if (names.empty()) { tomenu.add(MenuItem(MenuItem::Command, _("No Documents Open!"), diff --git a/src/buffer.C b/src/buffer.C index aab0435001..473075ff7f 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -60,7 +60,6 @@ #include "mathed/MathSupport.h" #include "frontends/Alert.h" -#include "frontends/Application.h" #include "graphics/Previews.h" @@ -1482,8 +1481,8 @@ void Buffer::setParentName(string const & name) Buffer const * Buffer::getMasterBuffer() const { if (!params().parentname.empty() - && theApp->bufferList().exists(params().parentname)) { - Buffer const * buf = theApp->bufferList().getBuffer(params().parentname); + && theBufferList().exists(params().parentname)) { + Buffer const * buf = theBufferList().getBuffer(params().parentname); if (buf) return buf->getMasterBuffer(); } @@ -1495,8 +1494,8 @@ Buffer const * Buffer::getMasterBuffer() const Buffer * Buffer::getMasterBuffer() { if (!params().parentname.empty() - && theApp->bufferList().exists(params().parentname)) { - Buffer * buf = theApp->bufferList().getBuffer(params().parentname); + && theBufferList().exists(params().parentname)) { + Buffer * buf = theBufferList().getBuffer(params().parentname); if (buf) return buf->getMasterBuffer(); } diff --git a/src/buffer_funcs.C b/src/buffer_funcs.C index ce0f60c7d1..706f0ccf81 100644 --- a/src/buffer_funcs.C +++ b/src/buffer_funcs.C @@ -36,7 +36,6 @@ #include "toc.h" #include "frontends/Alert.h" -#include "frontends/Application.h" #include "insets/insetbibitem.h" @@ -180,7 +179,7 @@ Buffer * newFile(string const & filename, string const & templatename, bool const isNamed) { // get a free buffer - Buffer * b = theApp->bufferList().newBuffer(filename); + Buffer * b = theBufferList().newBuffer(filename); BOOST_ASSERT(b); string tname; @@ -197,7 +196,7 @@ Buffer * newFile(string const & filename, string const & templatename, _("The specified document template\n%1$s\ncould not be read."), file); Alert::error(_("Could not read template"), text); - theApp->bufferList().release(b); + theBufferList().release(b); return 0; } } diff --git a/src/bufferlist.h b/src/bufferlist.h index 2ca9fefe55..c948d1b1ce 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -99,4 +99,6 @@ private: void emergencyWrite(Buffer * buf); }; +extern BufferList & theBufferList(); + #endif // BUFFERLIST_H diff --git a/src/cursor.C b/src/cursor.C index c93d642390..fb66b06f54 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -43,8 +43,6 @@ #include "support/limited_stack.h" -#include "frontends/Application.h" - #include #include #include @@ -1105,13 +1103,13 @@ void LCursor::handleFont(string const & font) void LCursor::message(docstring const & msg) const { - theApp->lyxFunc().setMessage(msg); + theLyXFunc().setMessage(msg); } void LCursor::errorMessage(docstring const & msg) const { - theApp->lyxFunc().setErrorMessage(msg); + theLyXFunc().setErrorMessage(msg); } diff --git a/src/dimension.C b/src/dimension.C index 1edb794ebc..ab374347c3 100644 --- a/src/dimension.C +++ b/src/dimension.C @@ -11,8 +11,6 @@ #include #include "dimension.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" @@ -28,7 +26,7 @@ void Dimension::operator+=(Dimension const & dim) void Dimension::clear(LyXFont const & font) { - lyx::frontend::FontMetrics const & fm = theApp->fontLoader().metrics(font); + lyx::frontend::FontMetrics const & fm = theFontMetrics(font); asc = fm.maxAscent(); des = fm.maxDescent(); wid = 0; diff --git a/src/frontends/Application.C b/src/frontends/Application.C index 66fcbfbd7c..545b15e33a 100644 --- a/src/frontends/Application.C +++ b/src/frontends/Application.C @@ -10,15 +10,19 @@ #include -#include "Application.h" +#include "frontends/Application.h" -#include "Gui.h" -#include "LyXView.h" -#include "WorkArea.h" +#include "frontends/FontLoader.h" +#include "frontends/FontMetrics.h" +#include "frontends/Gui.h" +#include "frontends/LyXView.h" +#include "frontends/WorkArea.h" #include "bufferlist.h" #include "funcrequest.h" +#include "FuncStatus.h" #include "LyXAction.h" +#include "lyxfont.h" #include "lyxfunc.h" #include "lyxrc.h" #include "lyxserver.h" @@ -151,4 +155,53 @@ int Application::start(std::string const & batch) } // namespace frontend + + +FuncStatus getStatus(FuncRequest const & action) +{ + return theApp->lyxFunc().getStatus(action); +} + + +void dispatch(FuncRequest const & action) +{ + theApp->lyxFunc().dispatch(action); +} + } // namespace lyx + + +LyXFunc & theLyXFunc() +{ + return theApp->lyxFunc(); +} + + +BufferList & theBufferList() +{ + return theApp->bufferList(); +} + + +lyx::frontend::FontLoader & theFontLoader() +{ + return theApp->fontLoader(); +} + + +lyx::frontend::FontMetrics const & theFontMetrics(LyXFont const & f) +{ + return theApp->fontLoader().metrics(f); +} + + +lyx::frontend::Clipboard & theClipboard() +{ + return theApp->clipboard(); +} + + +lyx::frontend::Selection & theSelection() +{ + return theApp->selection(); +} diff --git a/src/frontends/Clipboard.h b/src/frontends/Clipboard.h index c49bd4b0c6..d75f3cf4a4 100644 --- a/src/frontends/Clipboard.h +++ b/src/frontends/Clipboard.h @@ -44,4 +44,6 @@ public: } // namespace frontend } // namespace lyx +extern lyx::frontend::Clipboard & theClipboard(); + #endif // BASE_CLIPBOARD_H diff --git a/src/frontends/FontLoader.h b/src/frontends/FontLoader.h index e674a26ff1..9000353cf3 100644 --- a/src/frontends/FontLoader.h +++ b/src/frontends/FontLoader.h @@ -41,4 +41,6 @@ public: } // namespace frontend } // namespace lyx +extern lyx::frontend::FontLoader & theFontLoader(); + #endif // QFONT_LOADER_H diff --git a/src/frontends/FontMetrics.h b/src/frontends/FontMetrics.h index 9a190f4393..16dbf00f70 100644 --- a/src/frontends/FontMetrics.h +++ b/src/frontends/FontMetrics.h @@ -114,4 +114,8 @@ public: } // namespace frontend } // namespace lyx +class LyXFont; + +extern lyx::frontend::FontMetrics const & theFontMetrics(LyXFont const & f); + #endif // FONT_METRICS_H diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index 0eeaacee03..9598c5fbe1 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -280,7 +280,7 @@ void LyXView::updateToolbars() { bool const math = work_area_->bufferView().cursor().inMathed(); bool const table = - getLyXFunc().getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled(); + lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled(); toolbars_->update(math, table); // update redaonly status of open dialogs. This could also be in // updateMenubar(), but since updateToolbars() and updateMenubar() @@ -367,7 +367,7 @@ void LyXView::updateWindowTitle() void LyXView::dispatch(FuncRequest const & cmd) { - getLyXFunc().dispatch(cmd); + lyx::dispatch(cmd); } diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index a52d484c20..07d83edb9f 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -93,20 +93,6 @@ public: /// return the buffer currently shown in this window Buffer * buffer() const; - /* FIXME: Abdel 22/09/71 - there is only one lyxFunc() for now but there is maybe a need - for more in the feature. Something like that: - - LyXFunc & getLyXFunc() { return theApp->lyxFunc(id_); } - - where id_ would be the this LyXView ID. - That's the reason why I didn't remove these methods for now. - */ - /// return the LyX function handler for this view - LyXFunc & getLyXFunc() { return theApp->lyxFunc(); } - /// - LyXFunc const & getLyXFunc() const { return theApp->lyxFunc(); } - /// return the toolbar for this view Toolbars & getToolbars() { return *toolbars_.get(); } /// diff --git a/src/frontends/Painter.C b/src/frontends/Painter.C index 8d14ae3cf0..25f8edf2be 100644 --- a/src/frontends/Painter.C +++ b/src/frontends/Painter.C @@ -13,8 +13,6 @@ #include "frontends/Painter.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "LColor.h" @@ -62,7 +60,7 @@ void Painter::rectText(int x, int y, int ascent; int descent; - FontMetrics const & fm = theApp->fontLoader().metrics(font); + FontMetrics const & fm = theFontMetrics(font); fm.rectText(str, width, ascent, descent); if (back != LColor::none) @@ -82,7 +80,7 @@ void Painter::buttonText(int x, int y, docstring const & str, LyXFont const & fo int ascent; int descent; - FontMetrics const & fm = theApp->fontLoader().metrics(font); + FontMetrics const & fm = theFontMetrics(font); fm.buttonText(str, width, ascent, descent); button(x, y - ascent, width, descent + ascent); @@ -92,7 +90,7 @@ void Painter::buttonText(int x, int y, docstring const & str, LyXFont const & fo void Painter::underline(LyXFont const & f, int x, int y, int width) { - FontMetrics const & fm = theApp->fontLoader().metrics(f); + FontMetrics const & fm = theFontMetrics(f); int const below = max(fm.maxDescent() / 2, 2); int const height = max((fm.maxDescent() / 4) - 1, 1); diff --git a/src/frontends/Selection.h b/src/frontends/Selection.h index cc24d44450..c281d72cc5 100644 --- a/src/frontends/Selection.h +++ b/src/frontends/Selection.h @@ -48,4 +48,6 @@ public: } // namespace frontend } // namespace lyx +extern lyx::frontend::Selection & theSelection(); + #endif // BASE_SELECTION_H diff --git a/src/frontends/Toolbars.C b/src/frontends/Toolbars.C index 3d1bf5e1f0..7f56328427 100644 --- a/src/frontends/Toolbars.C +++ b/src/frontends/Toolbars.C @@ -149,8 +149,8 @@ void Toolbars::update() for (; it != end; ++it) it->second->update(); - bool const enable = owner_.getLyXFunc(). - getStatus(FuncRequest(LFUN_LAYOUT)).enabled(); + bool const enable = + lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled(); if (layout_) layout_->setEnabled(enable); @@ -169,7 +169,7 @@ void layoutSelected(LyXView & lv, string const & name) if (lyx::to_utf8(_(itname)) == name) { FuncRequest const func(LFUN_LAYOUT, itname, FuncRequest::UI); - lv.getLyXFunc().dispatch(func); + lv.dispatch(func); return; } } diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index 0f6d88d689..548cc276a5 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -16,7 +16,6 @@ #include "frontends/WorkArea.h" #include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "funcrequest.h" @@ -235,7 +234,7 @@ void WorkArea::processKeySym(LyXKeySymPtr key, key_modifier::state state) { hideCursor(); - lyx_view_.getLyXFunc().processKeySym(key, state); + theLyXFunc().processKeySym(key, state); /* This is perhaps a bit of a hack. When we move * around, or type, it's nice to be able to see @@ -375,7 +374,7 @@ void WorkArea::showCursor() shape = BAR_SHAPE; LyXFont const font = buffer_view_->cursor().getFont(); - FontMetrics const & fm = theApp->fontLoader().metrics(font); + FontMetrics const & fm = theFontMetrics(font); int const asc = fm.maxAscent(); int const des = fm.maxDescent(); int h = asc + des; diff --git a/src/frontends/controllers/ControlCommandBuffer.C b/src/frontends/controllers/ControlCommandBuffer.C index a5ad6fada5..e6d0d7ef16 100644 --- a/src/frontends/controllers/ControlCommandBuffer.C +++ b/src/frontends/controllers/ControlCommandBuffer.C @@ -133,7 +133,7 @@ void ControlCommandBuffer::dispatch(string const & str) history_pos_ = history_.end(); FuncRequest func = lyxaction.lookupFunc(str); func.origin = FuncRequest::COMMANDBUFFER; - lv_.getLyXFunc().dispatch(func); + lv_.dispatch(func); } } // namespace frontend diff --git a/src/frontends/controllers/ControlPrefs.C b/src/frontends/controllers/ControlPrefs.C index e8a9b2926b..6e0b360eec 100644 --- a/src/frontends/controllers/ControlPrefs.C +++ b/src/frontends/controllers/ControlPrefs.C @@ -21,8 +21,6 @@ #include "paper.h" #include "LColor.h" -#include "frontends/Application.h" - #include "support/filefilterlist.h" #include @@ -69,7 +67,7 @@ void ControlPrefs::dispatchParams() kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str())); // FIXME: these need lfuns - theApp->bufferList().setCurrentAuthor(rc_.user_name, rc_.user_email); + theBufferList().setCurrentAuthor(rc_.user_name, rc_.user_email); ::formats = formats_; diff --git a/src/frontends/controllers/ControlRef.C b/src/frontends/controllers/ControlRef.C index 69b705306b..37a9b33e8c 100644 --- a/src/frontends/controllers/ControlRef.C +++ b/src/frontends/controllers/ControlRef.C @@ -17,8 +17,6 @@ #include "bufferlist.h" #include "funcrequest.h" -#include "frontends/Application.h" - #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath using std::vector; @@ -38,7 +36,7 @@ ControlRef::ControlRef(Dialog & d) vector const ControlRef::getLabelList(string const & name) const { - Buffer const & buf = *theApp->bufferList().getBuffer(makeAbsPath(name)); + Buffer const & buf = *theBufferList().getBuffer(makeAbsPath(name)); vector list; buf.getLabelList(list); return list; @@ -60,7 +58,7 @@ void ControlRef::gotoBookmark() vector const ControlRef::getBufferList() const { - vector buffers = theApp->bufferList().getFileNames(); + vector buffers = theBufferList().getFileNames(); for (vector::iterator it = buffers.begin(); it != buffers.end(); ++it) { *it = lyx::to_utf8(makeDisplayPath(*it)); @@ -72,7 +70,7 @@ vector const ControlRef::getBufferList() const int ControlRef::getBufferNum() const { - vector buffers = theApp->bufferList().getFileNames(); + vector buffers = theBufferList().getFileNames(); string const name = kernel().buffer().fileName(); vector::const_iterator cit = find(buffers.begin(), buffers.end(), name); @@ -83,7 +81,7 @@ int ControlRef::getBufferNum() const string const ControlRef::getBufferName(int num) const { - return theApp->bufferList().getFileNames()[num]; + return theBufferList().getFileNames()[num]; } } // namespace frontend diff --git a/src/frontends/controllers/Dialog.C b/src/frontends/controllers/Dialog.C index a25f9bcdef..f90baf2ceb 100644 --- a/src/frontends/controllers/Dialog.C +++ b/src/frontends/controllers/Dialog.C @@ -208,7 +208,7 @@ Dialog::Controller::Controller(Dialog & parent) bool Dialog::Controller::canApply() const { FuncRequest const fr(getLfun(), dialog().name()); - FuncStatus const fs(kernel().lyxview().getLyXFunc().getStatus(fr)); + FuncStatus const fs(lyx::getStatus(fr)); return fs.enabled(); } diff --git a/src/frontends/controllers/Kernel.C b/src/frontends/controllers/Kernel.C index c604f767b0..b01657e6d2 100644 --- a/src/frontends/controllers/Kernel.C +++ b/src/frontends/controllers/Kernel.C @@ -32,7 +32,7 @@ Kernel::Kernel(LyXView & lyxview) void Kernel::dispatch(FuncRequest const & fr) const { - lyxview_.getLyXFunc().dispatch(fr); + lyxview_.dispatch(fr); } diff --git a/src/frontends/gtk/GMenubar.C b/src/frontends/gtk/GMenubar.C index e397af9d01..9cd7322574 100644 --- a/src/frontends/gtk/GMenubar.C +++ b/src/frontends/gtk/GMenubar.C @@ -268,7 +268,7 @@ void GMenubar::onSubMenuActivate(MenuItem const * item, void GMenubar::onCommandActivate(MenuItem const * item, Gtk::MenuItem * /*gitem*/) { - view_->getLyXFunc().dispatch(item->func()); + view_.dispatch(item->func()); } } // namespace frontend diff --git a/src/frontends/gtk/GToolbar.C b/src/frontends/gtk/GToolbar.C index 70485a9f8c..e79005d25d 100644 --- a/src/frontends/gtk/GToolbar.C +++ b/src/frontends/gtk/GToolbar.C @@ -274,7 +274,7 @@ void GToolbar::add(FuncRequest const & func, lyx::docstring const & tooltip) void GToolbar::clicked(FuncRequest func) { - owner_.getLyXFunc().dispatch(func); + owner_.dispatch(func); } @@ -300,7 +300,7 @@ void GToolbar::update() FuncRequest const * func = reinterpret_cast( item->get_data(gToolData)); if (func) { - FuncStatus const status = owner_.getLyXFunc().getStatus(*func); + FuncStatus const status = lyx::getStatus(*func); item->set_sensitive(status.enabled()); } } diff --git a/src/frontends/gtk/GView.C b/src/frontends/gtk/GView.C index 73edeb76e3..b16c0c853a 100644 --- a/src/frontends/gtk/GView.C +++ b/src/frontends/gtk/GView.C @@ -162,7 +162,7 @@ bool GView::on_delete_event(GdkEventAny * /*event*/) // trigger LFUN_LYX_QUIT instead of quit directly // since LFUN_LYX_QUIT may have more cleanup stuff // - getLyXFunc().dispatch(FuncRequest(LFUN_LYX_QUIT)); + dispatch(FuncRequest(LFUN_LYX_QUIT)); return true; } @@ -197,7 +197,7 @@ void GView::message(docstring const & msg) void GView::updateStatusBar() { - message(lyx::from_utf8(getLyXFunc().viewStatusMessage())); + message(lyx::from_utf8(theLyXFunc().viewStatusMessage())); } @@ -225,7 +225,7 @@ void GView::busy(bool yes) const void GView::clearMessage() { - message(lyx::from_utf8(getLyXFunc().viewStatusMessage())); + message(lyx::from_utf8(theLyXFunc().viewStatusMessage())); } diff --git a/src/frontends/qt3/QLToolbar.C b/src/frontends/qt3/QLToolbar.C index b29397da05..c10210d55a 100644 --- a/src/frontends/qt3/QLToolbar.C +++ b/src/frontends/qt3/QLToolbar.C @@ -192,7 +192,7 @@ void QLToolbar::add(FuncRequest const & func, lyx::docstring const & tooltip) toolbar_->setHorizontalStretchable(true); break; default: { - if (owner_.getLyXFunc().getStatus(func).unknown()) + if (lyx::getStatus(func).unknown()) break; QPixmap p = QPixmap(toolbarbackend.getIcon(func).c_str()); QToolButton * button = @@ -227,8 +227,7 @@ void QLToolbar::update() QToolButton * button = p->first; FuncRequest const & func = p->second; - FuncStatus const status = - owner_.getLyXFunc().getStatus(func); + FuncStatus const status = lyx::getStatus(func); button->setToggleButton(true); button->setOn(status.onoff(true)); @@ -247,7 +246,7 @@ void QLToolbar::clicked() ButtonMap::const_iterator it = map_.find(button); if (it != map_.end()) - owner_.getLyXFunc().dispatch(it->second); + owner_.dispatch(it->second); else lyxerr << "non existent tool button selected !" << endl; } diff --git a/src/frontends/qt3/QtView.C b/src/frontends/qt3/QtView.C index 8b62a9c844..dc0927df48 100644 --- a/src/frontends/qt3/QtView.C +++ b/src/frontends/qt3/QtView.C @@ -152,7 +152,7 @@ void QtView::focus_command_widget() void QtView::update_view_state_qt() { - statusBar()->message(toqstr(getLyXFunc().viewStatusMessage())); + statusBar()->message(toqstr(theLyXFunc().viewStatusMessage())); statusbar_timer_.stop(); } @@ -163,13 +163,13 @@ void QtView::updateStatusBar() if (statusbar_timer_.isActive()) return; - statusBar()->message(toqstr(getLyXFunc().viewStatusMessage())); + statusBar()->message(toqstr(theLyXFunc().viewStatusMessage())); } void QtView::activated(FuncRequest const & func) { - getLyXFunc().dispatch(func); + dispatch(func); } @@ -223,7 +223,7 @@ void QtView::closeEvent(QCloseEvent *) } // trigger LFUN_LYX_QUIT instead of quit directly // since LFUN_LYX_QUIT may have more cleanup stuff - getLyXFunc().dispatch(FuncRequest(LFUN_LYX_QUIT)); + dispatch(FuncRequest(LFUN_LYX_QUIT)); } diff --git a/src/frontends/qt4/Action.C b/src/frontends/qt4/Action.C index 47774486c6..504012308e 100644 --- a/src/frontends/qt4/Action.C +++ b/src/frontends/qt4/Action.C @@ -72,7 +72,7 @@ void Action::setAction(FuncRequest const & func) void Action::update() { - FuncStatus const status = lyxView_.getLyXFunc().getStatus(func_); + FuncStatus const status = lyx::getStatus(func_); if (status.onoff(true)) { setCheckable(true); @@ -92,7 +92,7 @@ void Action::action() { // lyxerr[Debug::ACTION] << "calling LyXFunc::dispatch: func_: " << func_ << endl; - lyxView_.getLyXFunc().dispatch(func_); + lyxView_.dispatch(func_); } } // namespace frontend diff --git a/src/frontends/qt4/GuiView.C b/src/frontends/qt4/GuiView.C index 14f9a1bfd8..aeeba51e1f 100644 --- a/src/frontends/qt4/GuiView.C +++ b/src/frontends/qt4/GuiView.C @@ -36,7 +36,6 @@ #include "GuiView.h" #include "QLMenubar.h" #include "QLToolbar.h" -#include "FontLoader.h" #include "QCommandBuffer.h" #include "qt_helpers.h" @@ -181,7 +180,7 @@ void GuiView::focus_command_widget() void GuiView::update_view_state_qt() { - statusBar()->showMessage(toqstr(getLyXFunc().viewStatusMessage())); + statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage())); statusbar_timer_.stop(); } @@ -192,13 +191,13 @@ void GuiView::updateStatusBar() if (statusbar_timer_.isActive()) return; - statusBar()->showMessage(toqstr(getLyXFunc().viewStatusMessage())); + statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage())); } void GuiView::activated(FuncRequest const & func) { - getLyXFunc().dispatch(func); + dispatch(func); } @@ -254,7 +253,7 @@ void GuiView::closeEvent(QCloseEvent *) } // trigger LFUN_LYX_QUIT instead of quit directly // since LFUN_LYX_QUIT may have more cleanup stuff - getLyXFunc().dispatch(FuncRequest(LFUN_LYX_QUIT)); + dispatch(FuncRequest(LFUN_LYX_QUIT)); } diff --git a/src/frontends/qt4/InsertTableWidget.C b/src/frontends/qt4/InsertTableWidget.C index 424b5dbb1f..8b6b01efbf 100644 --- a/src/frontends/qt4/InsertTableWidget.C +++ b/src/frontends/qt4/InsertTableWidget.C @@ -108,7 +108,7 @@ void InsertTableWidget::mouseReleaseEvent(QMouseEvent * /*event*/) { if (underMouse_) { QString const data = QString("%1 %2").arg(bottom_).arg(right_); - lyxView_.getLyXFunc().dispatch(FuncRequest(LFUN_TABULAR_INSERT, fromqstr(data))); + lyxView_.dispatch(FuncRequest(LFUN_TABULAR_INSERT, fromqstr(data))); } // emit signal visible(false); @@ -147,7 +147,7 @@ void InsertTableWidget::drawGrid(int const rows, int const cols, Qt::GlobalColor void InsertTableWidget::updateParent() { - bool status = lyxView_.getLyXFunc().getStatus(FuncRequest(LFUN_TABULAR_INSERT)).enabled(); + bool status = lyx::getStatus(FuncRequest(LFUN_TABULAR_INSERT)).enabled(); parentWidget()->setEnabled(status); } diff --git a/src/frontends/qt4/QLPainter.C b/src/frontends/qt4/QLPainter.C index 9bd17c44b4..ca6aebcbb3 100644 --- a/src/frontends/qt4/QLPainter.C +++ b/src/frontends/qt4/QLPainter.C @@ -16,7 +16,6 @@ #include "GuiApplication.h" #include "GuiWorkArea.h" #include "QLImage.h" -#include "FontLoader.h" #include "GuiApplication.h" #include "qt_helpers.h" diff --git a/src/frontends/qt4/QLToolbar.C b/src/frontends/qt4/QLToolbar.C index 8a28f36bf1..311646b5c7 100644 --- a/src/frontends/qt4/QLToolbar.C +++ b/src/frontends/qt4/QLToolbar.C @@ -192,7 +192,7 @@ void QLToolbar::add(FuncRequest const & func, docstring const & tooltip) break; } default: { - if (owner_.getLyXFunc().getStatus(func).unknown()) + if (lyx::getStatus(func).unknown()) break; Action * action = new Action(owner_, toolbarbackend.getIcon(func), lyx::docstring(), func, tooltip); diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 294839b6fd..f81d02e456 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -21,8 +21,6 @@ #include "paragraph.h" #include "ParagraphList.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "support/lstrings.h" @@ -144,8 +142,7 @@ string const bibitemWidest(Buffer const & buffer) InsetBibitem const * bitem = 0; // FIXME font is used unitialized, is that correct? LyXFont font; - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + lyx::frontend::FontMetrics const & fm = theFontMetrics(font); ParagraphList::const_iterator it = buffer.paragraphs().begin(); ParagraphList::const_iterator end = buffer.paragraphs().end(); diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index 6c6c1755b4..3b8818faaa 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -26,8 +26,6 @@ #include "metricsinfo.h" #include "paragraph.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -127,7 +125,7 @@ void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const LCursor cur = mi.base.bv->cursor(); setLabel(cur); docstring dlab(label.begin(), label.end()); - labelwidth_ = theApp->fontLoader().metrics(mi.base.font).width(dlab); + labelwidth_ = theFontMetrics(mi.base.font).width(dlab); dim.wid = labelwidth_; Dimension textdim; InsetText::metrics(mi, textdim); @@ -157,7 +155,7 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const docstring dlab(label.begin(), label.end()); // FXIME: instead of using the fontLoader metrics, we should make // painter::text() returns the drawn text witdh. - labelwidth_ = theApp->fontLoader().metrics(pi.base.font).width(dlab); + labelwidth_ = theFontMetrics(pi.base.font).width(dlab); pi.pain.text(x, y, dlab, pi.base.font); InsetText::draw(pi, x + labelwidth_, y); setPosCache(pi, x, y); diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index 77bb8698db..d509beb1ea 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -31,8 +31,6 @@ #include "paragraph_funcs.h" #include "sgml.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -159,7 +157,7 @@ void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const // FIXME UNICODE s = lyx::to_utf8(_("Undef: ")) + s; docstring ds(s.begin(), s.end()); - theApp->fontLoader().metrics(font).rectText(ds, w, a, d); + theFontMetrics(font).rectText(ds, w, a, d); dim.wid = max(dim.wid, w); } dim.asc += TEXT_TO_INSET_OFFSET; @@ -207,7 +205,7 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const // FIXME UNICODE s = lyx::to_utf8(_("Undef: ")) + s; docstring ds(s.begin(), s.end()); - theApp->fontLoader().metrics(font).rectText(ds, w, a, d); + theFontMetrics(font).rectText(ds, w, a, d); pi.pain.rectText(x + (dim_.wid - w) / 2, y + desc + a, ds, font, LColor::none, LColor::none); } diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 3607e42d32..16b0d68f75 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -29,8 +29,6 @@ #include "metricsinfo.h" #include "paragraph.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -127,7 +125,7 @@ Dimension InsetCollapsable::dimensionCollapsed() const { Dimension dim; docstring dlab(label.begin(), label.end()); - theApp->fontLoader().metrics(labelfont_).buttonText( + theFontMetrics(labelfont_).buttonText( dlab, dim.wid, dim.asc, dim.des); return dim; } diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index daa2a43678..47198006c2 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -32,7 +32,6 @@ #include "outputparams.h" #include "frontends/Alert.h" -#include "frontends/Application.h" #include "frontends/Painter.h" #include "graphics/PreviewImage.h" @@ -319,7 +318,7 @@ Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params if (!isLyXFilename(included_file)) return 0; - return theApp->bufferList().getBuffer(included_file); + return theBufferList().getBuffer(included_file); } @@ -333,12 +332,12 @@ bool loadIfNeeded(Buffer const & buffer, InsetCommandParams const & params) if (!isLyXFilename(included_file)) return false; - Buffer * buf = theApp->bufferList().getBuffer(included_file); + Buffer * buf = theBufferList().getBuffer(included_file); if (!buf) { // the readonly flag can/will be wrong, not anymore I think. if (!fs::exists(included_file)) return false; - buf = theApp->bufferList().newBuffer(included_file); + buf = theBufferList().newBuffer(included_file); if (!loadLyXFile(buf, included_file)) return false; } @@ -386,7 +385,7 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os, // Don't try to load or copy the file ; else if (loadIfNeeded(buffer, params_)) { - Buffer * tmp = theApp->bufferList().getBuffer(included_file); + Buffer * tmp = theBufferList().getBuffer(included_file); if (tmp->params().textclass != m_buffer->params().textclass) { // FIXME UNICODE @@ -499,7 +498,7 @@ int InsetInclude::docbook(Buffer const & buffer, ostream & os, string writefile = changeExtension(included_file, ".sgml"); if (loadIfNeeded(buffer, params_)) { - Buffer * tmp = theApp->bufferList().getBuffer(included_file); + Buffer * tmp = theBufferList().getBuffer(included_file); string const mangled = FileName(writefile).mangledFilename(); writefile = makeAbsPath(mangled, @@ -560,7 +559,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const // to be loaded: if (loadIfNeeded(buffer, params_)) { // a file got loaded - Buffer * const tmp = theApp->bufferList().getBuffer(included_file); + Buffer * const tmp = theBufferList().getBuffer(included_file); if (tmp) { // We must temporarily change features.buffer, // otherwise it would always be the master buffer, @@ -578,7 +577,7 @@ void InsetInclude::getLabelList(Buffer const & buffer, { if (loadIfNeeded(buffer, params_)) { string const included_file = includedFilename(buffer, params_); - Buffer * tmp = theApp->bufferList().getBuffer(included_file); + Buffer * tmp = theBufferList().getBuffer(included_file); tmp->setParentName(""); tmp->getLabelList(list); tmp->setParentName(parentFilename(buffer)); @@ -591,7 +590,7 @@ void InsetInclude::fillWithBibKeys(Buffer const & buffer, { if (loadIfNeeded(buffer, params_)) { string const included_file = includedFilename(buffer, params_); - Buffer * tmp = theApp->bufferList().getBuffer(included_file); + Buffer * tmp = theBufferList().getBuffer(included_file); tmp->setParentName(""); tmp->fillWithBibKeys(keys); tmp->setParentName(parentFilename(buffer)); diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 9f15861be3..429bfbea58 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -19,8 +19,6 @@ #include "lyxrc.h" #include "metricsinfo.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -246,8 +244,7 @@ void InsetLatexAccent::checkContents() void InsetLatexAccent::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont & font = mi.base.font; - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + lyx::frontend::FontMetrics const & fm = theFontMetrics(font); // This function is a bit too simplistic and is just a // "try to make a fit for all accents" approach, to @@ -331,8 +328,7 @@ void InsetLatexAccent::drawAccent(PainterInfo const & pi, int x, int y, char_type accent) const { LyXFont const & font = pi.base.font; - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + lyx::frontend::FontMetrics const & fm = theFontMetrics(font); x -= fm.center(accent); y -= fm.ascent(ic); @@ -356,8 +352,7 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) font.setLanguage(english_language); - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + lyx::frontend::FontMetrics const & fm = theFontMetrics(font); if (candisp) { int x2 = int(x + (fm.rbearing(ic) - fm.lbearing(ic)) / 2); diff --git a/src/insets/insetnewline.C b/src/insets/insetnewline.C index e9fa97b89e..7b09eae190 100644 --- a/src/insets/insetnewline.C +++ b/src/insets/insetnewline.C @@ -19,8 +19,6 @@ #include "paragraph.h" #include "paragraph_funcs.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -42,8 +40,8 @@ void InsetNewline::write(Buffer const &, ostream & os) const void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const { - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(mi.base.font); + lyx::frontend::FontMetrics const & fm + = theFontMetrics(mi.base.font); dim.asc = fm.maxAscent(); dim.des = fm.maxDescent(); dim.wid = fm.width('n'); @@ -78,7 +76,7 @@ int InsetNewline::docbook(Buffer const &, std::ostream & os, void InsetNewline::draw(PainterInfo & pi, int x, int y) const { lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(pi.base.font); + theFontMetrics(pi.base.font); int const wid = fm.width('n'); int const asc = fm.maxAscent(); diff --git a/src/insets/insetpagebreak.C b/src/insets/insetpagebreak.C index 037e9b7293..96d27662de 100644 --- a/src/insets/insetpagebreak.C +++ b/src/insets/insetpagebreak.C @@ -18,8 +18,6 @@ #include "metricsinfo.h" #include "gettext.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -62,7 +60,7 @@ void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const int w = 0; int a = 0; int d = 0; - theApp->fontLoader().metrics(font).rectText(label, w, a, d); + theFontMetrics(font).rectText(label, w, a, d); int const text_start = int(x + (dim_.wid - w) / 2); int const text_end = text_start + w; diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 26f5e53916..de8ec48032 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -24,8 +24,6 @@ #include "paragraph.h" #include "paragraph_funcs.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -202,7 +200,7 @@ void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont & font = mi.base.font; lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + theFontMetrics(font); dim.asc = fm.maxAscent(); dim.des = fm.maxDescent(); dim.wid = 0; @@ -239,7 +237,7 @@ void InsetQuotes::draw(PainterInfo & pi, int x, int y) const if (text.length() == 2 && text[0] == text[1]) { pi.pain.text(x, y, text[0], pi.base.font); - int const t = theApp->fontLoader().metrics(pi.base.font) + int const t = theFontMetrics(pi.base.font) .width(','); pi.pain.text(x + t, y, text[0], pi.base.font); } else { diff --git a/src/insets/insetref.C b/src/insets/insetref.C index 3ca4803bda..11a24ffe0a 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -21,8 +21,6 @@ #include "outputparams.h" #include "sgml.h" -#include "frontends/Application.h" - #include "support/lstrings.h" @@ -48,7 +46,7 @@ void InsetRef::doDispatch(LCursor & cur, FuncRequest & cmd) case LFUN_MOUSE_PRESS: // Eventually trigger dialog with button 3 not 1 if (cmd.button() == mouse_button::button3) - theApp->lyxFunc().dispatch(FuncRequest(LFUN_LABEL_GOTO, getContents())); + lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, getContents())); else { InsetCommandMailer("ref", *this).showDialog(&cur.bv()); cur.undispatched(); diff --git a/src/insets/insetspace.C b/src/insets/insetspace.C index 9be6ee484a..8ececce4e5 100644 --- a/src/insets/insetspace.C +++ b/src/insets/insetspace.C @@ -21,8 +21,6 @@ #include "metricsinfo.h" #include "outputparams.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -51,7 +49,7 @@ InsetSpace::Kind InsetSpace::kind() const void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const { lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(mi.base.font); + theFontMetrics(mi.base.font); dim.asc = fm.maxAscent(); dim.des = fm.maxDescent(); @@ -82,7 +80,7 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const void InsetSpace::draw(PainterInfo & pi, int x, int y) const { int const w = width(); - int const h = theApp->fontLoader().metrics(pi.base.font) + int const h = theFontMetrics(pi.base.font) .ascent('x'); int xp[4], yp[4]; diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index edf1053557..b2c01b68a8 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -20,8 +20,6 @@ #include "lyxlex.h" #include "metricsinfo.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -46,7 +44,7 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const { lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(mi.base.font); + theFontMetrics(mi.base.font); dim.asc = fm.maxAscent(); dim.des = fm.maxDescent(); @@ -100,7 +98,7 @@ void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const case MENU_SEPARATOR: { lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + theFontMetrics(font); // A triangle the width and height of an 'x' int w = fm.width(lyx::char_type('x')); diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 95fc6310a5..39fc6c32f1 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -37,7 +37,6 @@ #include "support/convert.h" #include "frontends/Alert.h" -#include "frontends/Application.h" #include "frontends/Clipboard.h" #include "frontends/Painter.h" #include "frontends/Selection.h" @@ -701,8 +700,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd) case LFUN_CLIPBOARD_PASTE: case LFUN_PRIMARY_SELECTION_PASTE: { docstring const clip = (cmd.action == LFUN_CLIPBOARD_PASTE) ? - theApp->clipboard().get() : - theApp->selection().get(); + theClipboard().get() : + theSelection().get(); if (clip.empty()) break; // pass to InsertAsciiString, but @@ -1792,7 +1791,7 @@ bool InsetTabular::copySelection(LCursor & cur) ostringstream os; OutputParams const runparams; paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t'); - theApp->clipboard().put(lyx::from_utf8(os.str())); + theClipboard().put(lyx::from_utf8(os.str())); // mark tabular stack dirty // FIXME: this is a workaround for bug 1919. Should be removed for 1.5, // when we (hopefully) have a one-for-all paste mechanism. diff --git a/src/insets/insetvspace.C b/src/insets/insetvspace.C index 7a42d5024d..e5cb547a9c 100644 --- a/src/insets/insetvspace.C +++ b/src/insets/insetvspace.C @@ -23,8 +23,6 @@ #include "lyxtext.h" #include "metricsinfo.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -133,7 +131,7 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const int d = 0; string lab = label(); docstring dlab(lab.begin(), lab.end()); - theApp->fontLoader().metrics(font).rectText(dlab, w, a, d); + theFontMetrics(font).rectText(dlab, w, a, d); height = max(height, a + d); @@ -185,7 +183,7 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const font.decSize(); string lab = label(); docstring dlab(lab.begin(), lab.end()); - theApp->fontLoader().metrics(font).rectText(dlab, w, a, d); + theFontMetrics(font).rectText(dlab, w, a, d); pi.pain.rectText(x + 2 * arrow_size + 5, start + (end - start) / 2 + (a - d) / 2, diff --git a/src/insets/render_button.C b/src/insets/render_button.C index 883b6244fe..16a153fcdf 100644 --- a/src/insets/render_button.C +++ b/src/insets/render_button.C @@ -15,8 +15,6 @@ #include "LColor.h" #include "metricsinfo.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -49,7 +47,7 @@ void RenderButton::metrics(MetricsInfo &, Dimension & dim) const LyXFont font(LyXFont::ALL_SANE); font.decSize(); lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + theFontMetrics(font); docstring dtext(text_.begin(), text_.end()); diff --git a/src/insets/render_graphic.C b/src/insets/render_graphic.C index 3b470bde30..73cdf27c5d 100644 --- a/src/insets/render_graphic.C +++ b/src/insets/render_graphic.C @@ -20,8 +20,6 @@ #include "lyxrc.h" #include "metricsinfo.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -165,7 +163,7 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const docstring djust(justname.begin(), justname.end()); if (!justname.empty()) { msgFont.setSize(LyXFont::SIZE_FOOTNOTE); - font_width = theApp->fontLoader().metrics(msgFont) + font_width = theFontMetrics(msgFont) .width(djust); } @@ -173,8 +171,8 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const if (!msg.empty()) { docstring dmsg(msg.begin(), msg.end()); msgFont.setSize(LyXFont::SIZE_TINY); - font_width = std::max(font_width, theApp->fontLoader() - .metrics(msgFont).width(dmsg)); + font_width = std::max(font_width, + theFontMetrics(msgFont).width(dmsg)); } dim.wid = std::max(50, font_width + 15); @@ -219,7 +217,7 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const docstring djust(justname.begin(), justname.end()); msgFont.setSize(LyXFont::SIZE_FOOTNOTE); pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6, - y - theApp->fontLoader().metrics(msgFont).maxAscent() - 4, + y - theFontMetrics(msgFont).maxAscent() - 4, djust, msgFont); } diff --git a/src/insets/render_preview.C b/src/insets/render_preview.C index c6532a4e55..d219e39c10 100644 --- a/src/insets/render_preview.C +++ b/src/insets/render_preview.C @@ -21,8 +21,6 @@ #include "lyxrc.h" #include "metricsinfo.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -135,7 +133,7 @@ void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const font.setSize(LyXFont::SIZE_FOOTNOTE); string stat = statusMessage(mi.base.bv, snippet_); docstring dstat(stat.begin(), stat.end()); - dim.wid = 15 + theApp->fontLoader().metrics(font).width(dstat); + dim.wid = 15 + theFontMetrics(font).width(dstat); } dim_ = dim; @@ -170,7 +168,7 @@ void RenderPreview::draw(PainterInfo & pi, int x, int y) const string stat = statusMessage(pi.base.bv, snippet_); docstring dstat(stat.begin(), stat.end()); pi.pain.text(x + offset + 6, - y - theApp->fontLoader().metrics(font).maxAscent() - 4, + y - theFontMetrics(font).maxAscent() - 4, dstat, font); } } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 341aa45c36..6cbe384d13 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -193,7 +193,7 @@ void quitLyX(bool noask) lyxerr[Debug::INFO] << "Running QuitLyX." << endl; if (lyx_gui::use_gui) { - if (!noask && !theApp->bufferList().quitWriteAll()) + if (!noask && !theBufferList().quitWriteAll()) return; LyX::cref().session().writeFile(); @@ -204,7 +204,7 @@ void quitLyX(bool noask) quitting = true; // close buffers first - theApp->bufferList().closeAll(); + theBufferList().closeAll(); // do any other cleanup procedures now lyxerr[Debug::INFO] << "Deleting tmp dir " << package().temp_dir() << endl; diff --git a/src/lyx_main.C b/src/lyx_main.C index 6e2b8ba530..0f98482706 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -279,7 +279,7 @@ int LyX::exec2(int & argc, char * argv[]) if (b) last_loaded = b; } else { - Buffer * buf = theApp->bufferList().newBuffer(s, false); + Buffer * buf = theBufferList().newBuffer(s, false); if (loadLyXFile(buf, s)) { last_loaded = buf; ErrorList const & el = buf->errorList("Parse"); @@ -288,7 +288,7 @@ int LyX::exec2(int & argc, char * argv[]) boost::bind(&LyX::printError, this, _1)); } else - theApp->bufferList().release(buf); + theBufferList().release(buf); } } @@ -668,7 +668,7 @@ void LyX::emergencyCleanup() const // contain documents etc. which might be helpful on // a crash - theApp->bufferList().emergencyWriteAll(); + theBufferList().emergencyWriteAll(); theApp->server().emergencyCleanup(); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 923d61f669..6d25032ddc 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1079,15 +1079,15 @@ void LyXFunc::dispatch(FuncRequest const & cmd) // --- buffers ---------------------------------------- case LFUN_BUFFER_SWITCH: - owner->setBuffer(theApp->bufferList().getBuffer(argument)); + owner->setBuffer(theBufferList().getBuffer(argument)); break; case LFUN_BUFFER_NEXT: - owner->setBuffer(theApp->bufferList().next(view()->buffer())); + owner->setBuffer(theBufferList().next(view()->buffer())); break; case LFUN_BUFFER_PREVIOUS: - owner->setBuffer(theApp->bufferList().previous(view()->buffer())); + owner->setBuffer(theBufferList().previous(view()->buffer())); break; case LFUN_FILE_NEW: @@ -1127,14 +1127,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd) if (prefixIs(file_name, package().temp_dir())) { // Needed by inverse dvi search. If it is a file // in tmpdir, call the apropriated function - owner->setBuffer(theApp->bufferList().getBufferFromTmp(file_name)); + owner->setBuffer(theBufferList().getBufferFromTmp(file_name)); } else { // Must replace extension of the file to be .lyx // and get full path string const s = changeExtension(file_name, ".lyx"); // Either change buffer or load the file - if (theApp->bufferList().exists(s)) { - owner->setBuffer(theApp->bufferList().getBuffer(s)); + if (theBufferList().exists(s)) { + owner->setBuffer(theBufferList().getBuffer(s)); } else { owner->loadLyXFile(s); } @@ -1284,8 +1284,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd) makeDisplayPath(filename) + lyx::from_ascii("...")); view()->savePosition(0); string const parentfilename = owner->buffer()->fileName(); - if (theApp->bufferList().exists(filename)) - owner->setBuffer(theApp->bufferList().getBuffer(filename)); + if (theBufferList().exists(filename)) + owner->setBuffer(theBufferList().getBuffer(filename)); else owner->loadLyXFile(filename); // Set the parent name of the child document. @@ -1350,7 +1350,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) case LFUN_SCREEN_FONT_UPDATE: // handle the screen font changes. lyxrc.set_font_norm_type(); - theApp->fontLoader().update(); + theFontLoader().update(); // All visible buffers will need resize view()->resize(); break; @@ -1696,7 +1696,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate) if (filename.empty()) { filename = addName(lyxrc.document_path, "newfile" + convert(++newfile_number) + ".lyx"); - while (theApp->bufferList().exists(filename) || fs::is_readable(filename)) { + while (theBufferList().exists(filename) || fs::is_readable(filename)) { ++newfile_number; filename = addName(lyxrc.document_path, "newfile" + convert(newfile_number) + @@ -1855,8 +1855,8 @@ void LyXFunc::doImport(string const & argument) string const lyxfile = changeExtension(filename, ".lyx"); // Check if the document already is open - if (lyx_gui::use_gui && theApp->bufferList().exists(lyxfile)) { - if (!theApp->bufferList().close(theApp->bufferList().getBuffer(lyxfile), true)) { + if (lyx_gui::use_gui && theBufferList().exists(lyxfile)) { + if (!theBufferList().close(theBufferList().getBuffer(lyxfile), true)) { owner->message(_("Canceled.")); return; } @@ -1889,14 +1889,14 @@ void LyXFunc::closeBuffer() // save current cursor position LyX::ref().session().saveFilePosition(owner->buffer()->fileName(), boost::tie(view()->cursor().pit(), view()->cursor().pos()) ); - if (theApp->bufferList().close(owner->buffer(), true) && !quitting) { - if (theApp->bufferList().empty()) { + if (theBufferList().close(owner->buffer(), true) && !quitting) { + if (theBufferList().empty()) { // need this otherwise SEGV may occur while // trying to set variables that don't exist // since there's no current buffer owner->getDialogs().hideBufferDependent(); } else { - owner->setBuffer(theApp->bufferList().first()); + owner->setBuffer(theBufferList().first()); } } } diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 47c0108eed..f557e7787a 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -112,4 +112,13 @@ private: bool ensureBufferClean(BufferView * bv); }; +extern LyXFunc & theLyXFunc(); + +namespace lyx { + +extern FuncStatus getStatus(FuncRequest const & action); + +extern void dispatch(FuncRequest const & action); +} + #endif diff --git a/src/lyxlength.C b/src/lyxlength.C index f08d9191a4..d139a4793d 100644 --- a/src/lyxlength.C +++ b/src/lyxlength.C @@ -136,7 +136,7 @@ int LyXLength::inPixels(int text_width, int em_width_base) const ? em_width_base : 10*(dpi/72.27)*zoom; // A different estimate for em_width is - // theApp->fontLoader().metrics(LyXFont(LyXFont::ALL_SANE)).width('M') + // theFontMetrics(LyXFont(LyXFont::ALL_SANE)).width('M') // but this estimate might not be more accurate as the screen font // is different then the latex font. diff --git a/src/mathed/InsetFormulaMacro.C b/src/mathed/InsetFormulaMacro.C index 3b644b65e4..ea9076f75f 100644 --- a/src/mathed/InsetFormulaMacro.C +++ b/src/mathed/InsetFormulaMacro.C @@ -24,8 +24,6 @@ #include "lyxlex.h" #include "outputparams.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -129,8 +127,7 @@ void InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const tmpl()->metrics(mi, dim); dim.asc += 5; dim.des += 5; - dim.wid += 10 - + theApp->fontLoader().metrics(mi.base.font).width(prefix()); + dim.wid += 10 + theFontMetrics(mi.base.font).width(prefix()); dim_ = dim; } @@ -166,7 +163,7 @@ void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const // body tmpl()->draw(pi, - x + theApp->fontLoader().metrics(p.base.font).width(prefix()) + 5, + x + theFontMetrics(p.base.font).width(prefix()) + 5, y); setPosCache(pi, x, y); diff --git a/src/mathed/InsetMathBig.C b/src/mathed/InsetMathBig.C index 3b8b87abe3..90900360df 100644 --- a/src/mathed/InsetMathBig.C +++ b/src/mathed/InsetMathBig.C @@ -15,8 +15,6 @@ #include "MathMLStream.h" #include "MathStream.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "support/lstrings.h" @@ -65,8 +63,7 @@ double InsetMathBig::increase() const void InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const { - double const h - = theApp->fontLoader().metrics(mi.base.font).ascent('I'); + double const h = theFontMetrics(mi.base.font).ascent('I'); double const f = increase(); dim_.wid = 6; dim_.asc = int(h + f * h); diff --git a/src/mathed/InsetMathChar.C b/src/mathed/InsetMathChar.C index 2d3c12026d..9307a721ee 100644 --- a/src/mathed/InsetMathChar.C +++ b/src/mathed/InsetMathChar.C @@ -20,8 +20,6 @@ #include "support/lstrings.h" #include "TextPainter.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" using std::auto_ptr; @@ -80,7 +78,7 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const whichFont(font_, code_, mi); mathed_char_dim(font_, char_, dim_); if (isBinaryOp(char_, code_)) - width_ += 2 * theApp->fontLoader().metrics(font_).width(' '); + width_ += 2 * theFontMetrics(font_).width(' '); lyxerr << "InsetMathChar::metrics: " << dim << endl; #endif width_ = dim.wid; diff --git a/src/mathed/InsetMathHull.C b/src/mathed/InsetMathHull.C index 547ad9a108..c6f12f3523 100644 --- a/src/mathed/InsetMathHull.C +++ b/src/mathed/InsetMathHull.C @@ -1275,7 +1275,7 @@ void InsetMathHull::mutateToText() view_->getIntl()->getTransManager().TranslateAndInsert(*cit, lt); // remove ourselves - //theApp->lyxFunc().dispatch(LFUN_ESCAPE); + //lyx::dispatch(LFUN_ESCAPE); #endif } diff --git a/src/mathed/InsetMathNest.C b/src/mathed/InsetMathNest.C index 1a0bbb8d2b..b23dc673d7 100644 --- a/src/mathed/InsetMathNest.C +++ b/src/mathed/InsetMathNest.C @@ -49,12 +49,10 @@ #include "support/lstrings.h" -#include "frontends/Application.h" #include "frontends/Painter.h" #include "frontends/Selection.h" #include "frontends/nullpainter.h" -//#include "bufferlist.h" #include "funcrequest.h" #include "lyxserver.h" #include "lyxsocket.h" @@ -67,8 +65,6 @@ using lyx::cap::cutSelection; using lyx::cap::replaceSelection; using lyx::cap::selClearOrDel; -using lyx::frontend::Clipboard; - using std::endl; using std::string; using std::istringstream; @@ -1110,7 +1106,7 @@ void InsetMathNest::lfunMousePress(LCursor & cur, FuncRequest & cmd) if (cur.selection()) asArray(lyx::to_utf8(bv.cursor().selectionAsString(false)), ar); else - asArray(lyx::to_utf8(theApp->selection().get()), ar); + asArray(lyx::to_utf8(theSelection().get()), ar); cur.insert(ar); bv.mouseSetCursor(cur); @@ -1141,7 +1137,7 @@ void InsetMathNest::lfunMouseRelease(LCursor & cur, FuncRequest & cmd) //lyxerr << "## lfunMouseRelease: buttons: " << cmd.button() << endl; if (cmd.button() == mouse_button::button1) { - //theApp->selection().put(cur.grabSelection()); + //theSelection().put(cur.grabSelection()); return; } diff --git a/src/mathed/MathFactory.C b/src/mathed/MathFactory.C index e9e40b4f49..6bc40bbea9 100644 --- a/src/mathed/MathFactory.C +++ b/src/mathed/MathFactory.C @@ -60,7 +60,6 @@ #include "support/filetools.h" // LibFileSearch #include "support/lstrings.h" -#include "frontends/Application.h" #include "frontends/FontLoader.h" #include @@ -89,7 +88,7 @@ bool math_font_available(string & name) augmentFont(f, name); // Do we have the font proper? - if (theApp->fontLoader().available(f)) + if (theFontLoader().available(f)) return true; // can we fake it? diff --git a/src/mathed/MathMacroTemplate.C b/src/mathed/MathMacroTemplate.C index 32e7bc885b..b546e76720 100644 --- a/src/mathed/MathMacroTemplate.C +++ b/src/mathed/MathMacroTemplate.C @@ -21,8 +21,6 @@ #include "lyxlex.h" #include "LColor.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -119,7 +117,7 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const cell(1).metrics(mi); docstring dp = prefix(); dim.wid = cell(0).width() + cell(1).width() + 20 - + theApp->fontLoader().metrics(mi.base.font).width(dp); + + theFontMetrics(mi.base.font).width(dp); dim.asc = std::max(cell(0).ascent(), cell(1).ascent()) + 7; dim.des = std::max(cell(0).descent(), cell(1).descent()) + 7; dim_ = dim; @@ -158,7 +156,7 @@ void MathMacroTemplate::draw(PainterInfo & p, int x, int y) const docstring dp = prefix(); pi.pain.text(x + 2, y, dp, font); // FIXME: Painter text should retain the drawn text width - x += theApp->fontLoader().metrics(font).width(dp) + 6; + x += theFontMetrics(font).width(dp) + 6; int const w0 = cell(0).width(); int const w1 = cell(1).width(); diff --git a/src/mathed/MathSupport.C b/src/mathed/MathSupport.C index f89289b5b7..02c224ffff 100644 --- a/src/mathed/MathSupport.C +++ b/src/mathed/MathSupport.C @@ -20,7 +20,6 @@ #include "debug.h" #include "LColor.h" -#include "frontends/Application.h" #include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -368,8 +367,7 @@ deco_struct const * search_deco(string const & name) void mathed_char_dim(LyXFont const & font, unsigned char c, Dimension & dim) { - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + lyx::frontend::FontMetrics const & fm = theFontMetrics(font); dim.des = fm.descent(c); dim.asc = fm.ascent(c); dim.wid = fm.width(c); @@ -378,14 +376,13 @@ void mathed_char_dim(LyXFont const & font, unsigned char c, Dimension & dim) int mathed_char_width(LyXFont const & font, unsigned char c) { - return theApp->fontLoader().metrics(font).width(c); + return theFontMetrics(font).width(c); } void mathed_string_dim(LyXFont const & font, string const & s, Dimension & dim) { - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + lyx::frontend::FontMetrics const & fm = theFontMetrics(font); #if 1 dim.asc = 0; dim.des = 0; @@ -405,7 +402,7 @@ void mathed_string_dim(LyXFont const & font, string const & s, Dimension & dim) int mathed_string_width(LyXFont const & font, string const & s) { docstring ds(s.begin(), s.end()); - return theApp->fontLoader().metrics(font).width(ds); + return theFontMetrics(font).width(ds); } @@ -499,8 +496,7 @@ void drawStrBlack(PainterInfo & pi, int x, int y, string const & str) void math_font_max_dim(LyXFont const & font, int & asc, int & des) { - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + lyx::frontend::FontMetrics const & fm = theFontMetrics(font); asc = fm.maxAscent(); des = fm.maxDescent(); } @@ -665,9 +661,9 @@ void augmentFont(LyXFont & font, string const & name) if (!initialized) { initialized = true; // fake fonts if necessary - if (!theApp->fontLoader().available(getFont("mathfrak"))) + if (!theFontLoader().available(getFont("mathfrak"))) fakeFont("mathfrak", "lyxfakefrak"); - if (!theApp->fontLoader().available(getFont("mathcal"))) + if (!theFontLoader().available(getFont("mathcal"))) fakeFont("mathcal", "lyxfakecal"); } fontinfo * info = searchFont(name); diff --git a/src/rowpainter.C b/src/rowpainter.C index 10ecef35b9..bb35ab8ad0 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -32,8 +32,6 @@ #include "ParagraphParameters.h" #include "vspace.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/nullpainter.h" #include "frontends/Painter.h" @@ -202,7 +200,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos, LyXFont const & font) str += c; ++vpos; - int const width = theApp->fontLoader().metrics(font).width(c); + int const width = theFontMetrics(font).width(c); int dx = 0; for (pos_type i = pos - 1; i >= 0; --i) { @@ -237,7 +235,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos, LyXFont const & font) str += c; ++vpos; - int const width = theApp->fontLoader().metrics(font).width(c); + int const width = theFontMetrics(font).width(c); int dx = 0; for (pos_type i = pos - 1; i >= 0; --i) { @@ -463,7 +461,7 @@ int RowPainter::paintAppendixStart(int y) int a = 0; int d = 0; docstring dlab(label.begin(), label.end()); - theApp->fontLoader().metrics(pb_font).rectText(dlab, w, a, d); + theFontMetrics(pb_font).rectText(dlab, w, a, d); int const text_start = int(xo_ + (width_ - w) / 2); int const text_end = text_start + w; @@ -518,8 +516,7 @@ void RowPainter::paintFirst() || is_seq)) { LyXFont const font = getLabelFont(); - FontMetrics const & fm = - theApp->fontLoader().metrics(font); + FontMetrics const & fm = theFontMetrics(font); string const str = par_.getLabelstring(); if (!str.empty()) { @@ -579,8 +576,7 @@ void RowPainter::paintFirst() else spacing_val = buffer.params().spacing().getValue(); - FontMetrics const & fm = - theApp->fontLoader().metrics(font); + FontMetrics const & fm = theFontMetrics(font); int const labeladdon = int(fm.maxHeight() * layout->spacing.getValue() * spacing_val); @@ -614,7 +610,7 @@ void RowPainter::paintLast() case END_LABEL_BOX: case END_LABEL_FILLED_BOX: { LyXFont const font = getLabelFont(); - FontMetrics const & fm = theApp->fontLoader().metrics(font); + FontMetrics const & fm = theFontMetrics(font); int const size = int(0.75 * fm.maxAscent()); int const y = yo_ - size; int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size; @@ -631,7 +627,7 @@ void RowPainter::paintLast() case END_LABEL_STATIC: { LyXFont font = getLabelFont(); - FontMetrics const & fm = theApp->fontLoader().metrics(font); + FontMetrics const & fm = theFontMetrics(font); string const & str = par_.layout()->endlabelstring(); docstring dstr(str.begin(), str.end()); double const x = is_rtl ? @@ -706,8 +702,8 @@ void RowPainter::paintText() // We also don't paint across things like tables if (running_strikeout && (highly_editable_inset || !is_struckout)) { // Calculate 1/3 height of the buffer's default font - FontMetrics const & fm = theApp->fontLoader().metrics( - bv_.buffer()->params().getFont()); + FontMetrics const & fm + = theFontMetrics(bv_.buffer()->params().getFont()); int const middle = yo_ - fm.maxAscent() / 3; pain_.line(last_strikeout_x, middle, int(x_), middle, LColor::strikeout, Painter::line_solid, Painter::line_thin); @@ -717,8 +713,8 @@ void RowPainter::paintText() if (body_pos > 0 && pos == body_pos - 1) { string lab = layout->labelsep; docstring dlab(lab.begin(), lab.end()); - int const lwidth = - theApp->fontLoader().metrics(getLabelFont()).width(dlab); + int const lwidth + = theFontMetrics(getLabelFont()).width(dlab); x_ += label_hfill_ + lwidth - width_pos; } @@ -762,8 +758,8 @@ void RowPainter::paintText() // if we reach the end of a struck out range, paint it if (running_strikeout) { // calculate 1/3 height of the buffer's default font - FontMetrics const & fm = theApp->fontLoader().metrics( - bv_.buffer()->params().getFont()); + FontMetrics const & fm + = theFontMetrics(bv_.buffer()->params().getFont()); int const middle = yo_ - fm.maxAscent() / 3; pain_.line(last_strikeout_x, middle, int(x_), middle, LColor::strikeout, Painter::line_solid, Painter::line_thin); diff --git a/src/text.C b/src/text.C index 26b3190511..a224f124ac 100644 --- a/src/text.C +++ b/src/text.C @@ -51,8 +51,6 @@ #include "vspace.h" #include "WordLangTuple.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -466,13 +464,13 @@ int LyXText::singleWidth(Paragraph const & par, Encodings::isComposeChar_hebrew(c)) return 0; } - return theApp->fontLoader().metrics(font).width(c); + return theFontMetrics(font).width(c); } if (c == Paragraph::META_INSET) return par.getInset(pos)->width(); - return theApp->fontLoader().metrics(font).width(c); + return theFontMetrics(font).width(c); } @@ -505,7 +503,7 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const string leftm = tclass.leftmargin(); docstring dleft(leftm.begin(), leftm.end()); - l_margin += theApp->fontLoader().metrics(params.getFont()).signedWidth(dleft); + l_margin += theFontMetrics(params.getFont()).signedWidth(dleft); if (par.getDepth() != 0) { // find the next level paragraph @@ -531,14 +529,14 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const parindent.erase(); LyXFont const labelfont = getLabelFont(par); - FontMetrics const & labelfont_metrics = theApp->fontLoader().metrics(labelfont); + FontMetrics const & labelfont_metrics = theFontMetrics(labelfont); switch (layout->margintype) { case MARGIN_DYNAMIC: if (!layout->leftmargin.empty()) { string leftm = layout->leftmargin; docstring dleft(leftm.begin(), leftm.end()); - l_margin += theApp->fontLoader().metrics(params.getFont()).signedWidth(dleft); + l_margin += theFontMetrics(params.getFont()).signedWidth(dleft); } if (!par.getLabelstring().empty()) { string labin = layout->labelindent; @@ -574,8 +572,7 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const case MARGIN_STATIC: { string leftm = layout->leftmargin; docstring dleft(leftm.begin(), leftm.end()); - l_margin += - theApp->fontLoader().metrics(params.getFont()).signedWidth(dleft) + l_margin += theFontMetrics(params.getFont()).signedWidth(dleft) * 4 / (par.getDepth() + 4); break; } @@ -629,7 +626,7 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const for ( ; rit != end; ++rit) if (rit->fill() < minfill) minfill = rit->fill(); - l_margin += theApp->fontLoader().metrics(params.getFont()).signedWidth(layout->leftmargin); + l_margin += theFontMetrics(params.getFont()).signedWidth(layout->leftmargin); l_margin += minfill; #endif // also wrong, but much shorter. @@ -669,7 +666,7 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const BufferParams::PARSEP_INDENT)) { docstring din(parindent.begin(), parindent.end()); - l_margin += theApp->fontLoader().metrics(params.getFont()).signedWidth(din); + l_margin += theFontMetrics(params.getFont()).signedWidth(din); } return l_margin; @@ -691,7 +688,7 @@ int LyXText::rightMargin(Paragraph const & par) const docstring dtrmarg(trmarg.begin(), trmarg.end()); string lrmarg = par.layout()->rightmargin; docstring dlrmarg(lrmarg.begin(), lrmarg.end()); - FontMetrics const & fm = theApp->fontLoader().metrics(params.getFont()); + FontMetrics const & fm = theFontMetrics(params.getFont()); int const r_margin = ::rightMargin() + fm.signedWidth(dtrmarg) @@ -769,7 +766,7 @@ void LyXText::rowBreakPoint(pit_type const pit, Row & row) const FontIterator fi = FontIterator(*this, par, pos); pos_type point = end; pos_type i = pos; - FontMetrics const & fm = theApp->fontLoader().metrics(getLabelFont(par)); + FontMetrics const & fm = theFontMetrics(getLabelFont(par)); for ( ; i < end; ++i, ++fi) { char_type const c = par.getChar(i); int thiswidth = singleWidth(par, i, c, *fi); @@ -858,7 +855,7 @@ void LyXText::setRowWidth(pit_type const pit, Row & row) const pos_type const body_pos = par.beginOfBody(); pos_type i = row.pos(); - FontMetrics const & fm = theApp->fontLoader().metrics(getLabelFont(par)); + FontMetrics const & fm = theFontMetrics(getLabelFont(par)); if (i < end) { FontIterator fi = FontIterator(*this, par, i); @@ -909,7 +906,7 @@ int LyXText::labelFill(Paragraph const & par, Row const & row) const docstring dlab(label.begin(), label.end()); - FontMetrics const & fm = theApp->fontLoader().metrics(getLabelFont(par)); + FontMetrics const & fm = theFontMetrics(getLabelFont(par)); return max(0, fm.width(dlab) - w); } @@ -946,8 +943,8 @@ void LyXText::setHeightOfRow(pit_type const pit, Row & row) LyXFont labelfont = getLabelFont(par); - FontMetrics const & labelfont_metrics = theApp->fontLoader().metrics(labelfont); - FontMetrics const & fontmetrics = theApp->fontLoader().metrics(font); + FontMetrics const & labelfont_metrics = theFontMetrics(labelfont); + FontMetrics const & fontmetrics = theFontMetrics(font); // these are minimum values double const spacing_val = layout->spacing.getValue() * spacing(par); @@ -1396,7 +1393,7 @@ LyXText::computeRowMetrics(pit_type const pit, Row const & row) const { string lsep = layout->labelsep; docstring dlsep(lsep.begin(), lsep.end()); - result.x += theApp->fontLoader().metrics(getLabelFont(par)).width(dlsep); + result.x += theFontMetrics(getLabelFont(par)).width(dlsep); if (body_pos <= end) result.x += result.label_hfill; } @@ -2300,7 +2297,7 @@ int LyXText::cursorX(CursorSlice const & sl, bool boundary) const // Use font span to speed things up, see below FontSpan font_span; LyXFont font; - FontMetrics const & labelfm = theApp->fontLoader().metrics(getLabelFont(par)); + FontMetrics const & labelfm = theFontMetrics(getLabelFont(par)); for (pos_type vpos = row_pos; vpos < cursor_vpos; ++vpos) { pos_type pos = bidi.vis2log(vpos); diff --git a/src/text2.C b/src/text2.C index 2ce03f2d09..f9f4134399 100644 --- a/src/text2.C +++ b/src/text2.C @@ -50,8 +50,6 @@ #include "undo.h" #include "vspace.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "insets/insetenv.h" @@ -371,13 +369,13 @@ void LyXText::setLayout(LCursor & cur, string const & layout) if (lyxlayout->is_environment) { // move everything in a new environment inset lyxerr[Debug::DEBUG] << "setting layout " << layout << endl; - theApp->lyxFunc().dispatch(FuncRequest(LFUN_LINE_BEGIN)); - theApp->lyxFunc().dispatch(FuncRequest(LFUN_LINE_END_SELECT)); - theApp->lyxFunc().dispatch(FuncRequest(LFUN_CUT)); + lyx::dispatch(FuncRequest(LFUN_LINE_BEGIN)); + lyx::dispatch(FuncRequest(LFUN_LINE_END_SELECT)); + lyx::dispatch(FuncRequest(LFUN_CUT)); InsetBase * inset = new InsetEnvironment(params, layout); insertInset(cur, inset); //inset->edit(cur, true); - //theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE)); + //lyx::dispatch(FuncRequest(LFUN_PASTE)); return; } @@ -805,8 +803,8 @@ pos_type LyXText::getColumnNearX(pit_type const pit, return 0; } - lyx::frontend::FontMetrics const & fm = theApp->fontLoader().metrics( - getLabelFont(par)); + lyx::frontend::FontMetrics const & fm + = theFontMetrics(getLabelFont(par)); while (vc < end && tmpx <= x) { c = bidi.vis2log(vc); @@ -1345,5 +1343,5 @@ void LyXText::recUndo(pit_type par) const int defaultRowHeight() { - return int(theApp->fontLoader().metrics(LyXFont(LyXFont::ALL_SANE)).maxHeight() * 1.2); + return int(theFontMetrics(LyXFont(LyXFont::ALL_SANE)).maxHeight() * 1.2); } diff --git a/src/text3.C b/src/text3.C index 47fc8ceab0..7de85b6c6f 100644 --- a/src/text3.C +++ b/src/text3.C @@ -47,7 +47,6 @@ #include "vspace.h" #include "pariterator.h" -#include "frontends/Application.h" #include "frontends/Clipboard.h" #include "frontends/Selection.h" @@ -123,7 +122,7 @@ namespace { if (selecting || cur.mark()) cur.setSelection(); if (!cur.selection()) - theApp->selection().haveSelection(false); + theSelection().haveSelection(false); cur.bv().switchKeyMap(); } @@ -264,7 +263,7 @@ bool doInsertInset(LCursor & cur, LyXText * text, recordUndo(cur); bool gotsel = false; if (cur.selection()) { - theApp->lyxFunc().dispatch(FuncRequest(LFUN_CUT)); + lyx::dispatch(FuncRequest(LFUN_CUT)); gotsel = true; } text->insertInset(cur, inset); @@ -273,7 +272,7 @@ bool doInsertInset(LCursor & cur, LyXText * text, inset->edit(cur, true); if (gotsel && pastesel) { - theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE)); + lyx::dispatch(FuncRequest(LFUN_PASTE)); // reset first par to default if (cur.lastpit() != 0 || cur.lastpos() != 0) { LyXLayout_ptr const layout = @@ -882,7 +881,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_CLIPBOARD_PASTE: { cur.clearSelection(); - docstring const clip = theApp->clipboard().get(); + docstring const clip = theClipboard().get(); if (!clip.empty()) { recordUndo(cur); if (cmd.argument() == "paragraph") @@ -895,7 +894,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_PRIMARY_SELECTION_PASTE: { cur.clearSelection(); - docstring const clip = theApp->selection().get(); + docstring const clip = theSelection().get(); if (!clip.empty()) { recordUndo(cur); if (cmd.argument() == "paragraph") @@ -935,16 +934,16 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) cur.posRight(); } else - theApp->lyxFunc().dispatch(FuncRequest(LFUN_SELF_INSERT, "\"")); + lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\"")); break; } case LFUN_DATE_INSERT: if (cmd.argument().empty()) - theApp->lyxFunc().dispatch(FuncRequest(LFUN_SELF_INSERT, + lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, lyx::formatted_time(lyx::current_time()))); else - theApp->lyxFunc().dispatch(FuncRequest(LFUN_SELF_INSERT, + lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, lyx::formatted_time(lyx::current_time(), lyx::to_utf8(cmd.argument())))); break; @@ -955,7 +954,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) cursorEnd(cur); cur.setSelection(); bv->cursor() = cur; - theApp->selection().haveSelection(cur.selection()); + theSelection().haveSelection(cur.selection()); } break; @@ -963,7 +962,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) if (cmd.button() == mouse_button::button1) { selectWord(cur, lyx::WHOLE_WORD_STRICT); bv->cursor() = cur; - theApp->selection().haveSelection(cur.selection()); + theSelection().haveSelection(cur.selection()); } break; @@ -979,7 +978,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) // we have to check this first bool paste_internally = false; if (cmd.button() == mouse_button::button2 && cur.selection()) { - theApp->lyxFunc().dispatch(FuncRequest(LFUN_COPY)); + lyx::dispatch(FuncRequest(LFUN_COPY)); paste_internally = true; } @@ -990,9 +989,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) // insert this if (cmd.button() == mouse_button::button2) { if (paste_internally) - theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE)); + lyx::dispatch(FuncRequest(LFUN_PASTE)); else - theApp->lyxFunc().dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph")); + lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph")); } break; @@ -1045,7 +1044,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) // finish selection if (cmd.button() == mouse_button::button1) - theApp->selection().haveSelection(cur.selection()); + theSelection().haveSelection(cur.selection()); bv->switchKeyMap(); break; @@ -1064,7 +1063,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) if (lyxrc.auto_region_delete) { if (cur.selection()) cutSelection(cur, false, false); - theApp->selection().haveSelection(false); + theSelection().haveSelection(false); } cur.clearSelection(); @@ -1381,7 +1380,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_ACCENT_HUNGARIAN_UMLAUT: case LFUN_ACCENT_CIRCLE: case LFUN_ACCENT_OGONEK: - theApp->lyxFunc().handleKeyFunc(cmd.action); + theLyXFunc().handleKeyFunc(cmd.action); if (!cmd.argument().empty()) // FIXME: Are all these characters encoded in one byte in utf8? bv->getIntl().getTransManager() -- 2.39.2