This patch adds two LFUNs to zoom in and zoom-out. Ok ?
Vincent
Index: src/LyXAction.cpp =================================================================== --- src/LyXAction.cpp (revision 29066) +++ src/LyXAction.cpp (working copy) @@ -3204,6 +3204,24 @@ */ { LFUN_COPY_LABEL_AS_REF, "copy-label-as-reference", ReadOnly | NoUpdate, Edit }, +/*! + * \var lyx::FuncCode lyx::LFUN_BUFFER_ZOOM_IN + * \li Action: Increases the zoom of the screen fonts. + * \li Syntax: buffer-zoom-in + * \li Origin: vfr, 30 Mar 2009 + * \endvar + */ + { LFUN_BUFFER_ZOOM_IN, "buffer-zoom-in", ReadOnly, Buffer }, + +/*! + * \var lyx::FuncCode lyx::LFUN_BUFFER_ZOOM_OUT + * \li Action: Decreases the zoom of the screen fonts. + * \li Syntax: buffer-zoom-out + * \li Origin: vfr, 30 Mar 2009 + * \endvar + */ + { LFUN_BUFFER_ZOOM_OUT, "buffer-zoom-out", ReadOnly, Buffer }, + { LFUN_NOACTION, "", Noop, Hidden } #ifndef DOXYGEN_SHOULD_SKIP_THIS }; Index: src/frontends/qt4/GuiView.cpp =================================================================== --- src/frontends/qt4/GuiView.cpp (revision 29066) +++ src/frontends/qt4/GuiView.cpp (working copy) @@ -17,6 +17,7 @@ #include "Dialog.h" #include "FileDialog.h" +#include "FontLoader.h" #include "GuiApplication.h" #include "GuiCommandBuffer.h" #include "GuiCompleter.h" @@ -55,13 +56,14 @@ #include "Toolbars.h" #include "version.h" -#include "support/lassert.h" +#include "support/convert.h" #include "support/debug.h" #include "support/ExceptionMessage.h" #include "support/FileName.h" #include "support/filetools.h" #include "support/gettext.h" #include "support/ForkedCalls.h" +#include "support/lassert.h" #include "support/lstrings.h" #include "support/os.h" #include "support/Package.h" @@ -1326,13 +1328,21 @@ enable = false; break; - case LFUN_COMPLETION_CANCEL: + case LFUN_COMPLETION_CANCEL: if (!d.current_work_area_ || (!d.current_work_area_->completer().popupVisible() && !d.current_work_area_->completer().inlineVisible())) enable = false; break; + case LFUN_BUFFER_ZOOM_OUT: + enable = buf && lyxrc.zoom > 10; + break; + + case LFUN_BUFFER_ZOOM_IN: + enable = buf; + break; + default: return false; } @@ -2202,7 +2212,26 @@ d.current_work_area_->completer().activate(); break; + case LFUN_BUFFER_ZOOM_IN: + case LFUN_BUFFER_ZOOM_OUT: + if (cmd.argument().empty()) { + if (cmd.action == LFUN_BUFFER_ZOOM_IN) + lyxrc.zoom += 20; + else + lyxrc.zoom -= 20; + } else + lyxrc.zoom += convert<int>(cmd.argument()); + if (lyxrc.zoom < 10) + lyxrc.zoom = 10; + + // The global QPixmapCache is used in GuiPainter to cache text + // painting so we must reset it. + QPixmapCache::clear(); + guiApp->fontLoader().update(); + lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE)); + break; + default: dispatched = false; break; Index: src/frontends/qt4/GuiWorkArea.cpp =================================================================== --- src/frontends/qt4/GuiWorkArea.cpp (revision 29066) +++ src/frontends/qt4/GuiWorkArea.cpp (working copy) @@ -43,6 +43,7 @@ #include "graphics/GraphicsImage.h" #include "graphics/GraphicsLoader.h" +#include "support/convert.h" #include "support/debug.h" #include "support/gettext.h" #include "support/FileName.h" @@ -810,15 +811,8 @@ // documentation of QWheelEvent) int const delta = ev->delta() / 120; if (ev->modifiers() & Qt::ControlModifier) { - lyxrc.zoom += 5 * delta; - if (lyxrc.zoom < 10) - lyxrc.zoom = 10; - // The global QPixmapCache is used in GuiPainter to cache text - // painting so we must reset it. - QPixmapCache::clear(); - guiApp->fontLoader().update(); - ev->accept(); - lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE)); + docstring arg = convert<docstring>(5 * delta); + lyx::dispatch(FuncRequest(LFUN_BUFFER_ZOOM_IN, arg)); return; } Index: src/FuncCode.h =================================================================== --- src/FuncCode.h (revision 29066) +++ src/FuncCode.h (working copy) @@ -423,6 +423,8 @@ LFUN_INSET_BEGIN_SELECT, // JMarc, 20090316 LFUN_INSET_END_SELECT, // JMarc, 20090316 LFUN_SCREEN_SHOW_CURSOR, // vfr, 20090325 + LFUN_BUFFER_ZOOM_IN, // vfr, 20090330 + LFUN_BUFFER_ZOOM_OUT, // vfr, 20090330 LFUN_LASTACTION // end of the table