I just committed this patch to the "younes" Branch.
Log: API cleanup: * lyx::frontend::BaseFrontend -> lyx::Gui * lyx::frontend::BaseClipboard -> lyx::Clipboard putClipboard -> put getClipboard -> get * lyx::frontend::BaseWorkArea -> lyx::WorkArea workWidth -> width workHeight -> height * lyx::frontend::FrontendCursor -> lyx::GuiCursor * frontend/qt4/: adaptation to new API
Index: BufferView.C =================================================================== --- BufferView.C (revision 14030) +++ BufferView.C (working copy) @@ -41,7 +41,7 @@ #include "frontends/Alert.h" #include "frontends/Dialogs.h" #include "frontends/LyXView.h" -#include "frontends/BaseFrontend.h" +#include "frontends/Gui.h" #include "insets/insetcommand.h" // ChangeRefs #include "insets/insettext.h" @@ -193,7 +193,7 @@ int BufferView::workWidth() const { - return pimpl_->workarea().workWidth(); + return pimpl_->workarea().width(); } @@ -205,7 +205,7 @@ string const BufferView::getClipboard() const { - return pimpl_->clipboard().getClipboard(); + return pimpl_->clipboard().get(); } @@ -310,7 +310,7 @@ void BufferView::hideCursor() { - pimpl_->frontend().cursor().hide(); + pimpl_->gui().cursor().hide(); } LyXText * BufferView::getLyXText() @@ -337,7 +337,7 @@ int BufferView::workHeight() const { - return pimpl_->workarea().workHeight(); + return pimpl_->workarea().height(); } Index: BufferView_pimpl.C =================================================================== --- BufferView_pimpl.C (revision 14026) +++ BufferView_pimpl.C (working copy) @@ -62,7 +62,7 @@ #include "frontends/FileDialog.h" #include "frontends/font_metrics.h" #include "frontends/LyXView.h" -#include "frontends/BaseFrontend.h" +#include "frontends/Gui.h" #include "graphics/Previews.h" @@ -79,9 +79,9 @@ #include <functional> #include <vector> -using lyx::frontend::BaseWorkArea; -using lyx::frontend::BaseClipboard; -using lyx::frontend::BaseFrontend; +using lyx::WorkArea; +using lyx::Clipboard; +using lyx::Gui; using lyx::pos_type; @@ -142,8 +142,8 @@ { xsel_cache_.set = false; - work_area_id_ = owner_->frontend().newWorkArea(width, height); - work_area_ = & owner_->frontend().workArea(work_area_id_); + work_area_id_ = owner_->gui().newWorkArea(width, height); + work_area_ = & owner_->gui().workArea(work_area_id_); // Setup the signals timecon = cursor_timeout.timeout @@ -314,21 +314,21 @@ } -BaseFrontend & BufferView::Pimpl::frontend() const +lyx::Gui & BufferView::Pimpl::gui() const { - return owner_->frontend(); + return owner_->gui(); } -BaseWorkArea & BufferView::Pimpl::workarea() const +WorkArea & BufferView::Pimpl::workarea() const { return *work_area_; } -BaseClipboard & BufferView::Pimpl::clipboard() const +Clipboard & BufferView::Pimpl::clipboard() const { - return owner_->frontend().clipboard(); + return owner_->gui().clipboard(); } @@ -479,7 +479,7 @@ // estimated average paragraph height: if (wh_ == 0) - wh_ = workarea().workHeight() / 4; + wh_ = workarea().height() / 4; int h = t.getPar(anchor_ref_).height(); // Normalize anchor/offset (MV): @@ -492,7 +492,7 @@ int sumh = 0; int nh = 0; for (lyx::pit_type pit = anchor_ref_; pit <= parsize; ++pit) { - if (sumh > workarea().workHeight()) + if (sumh > workarea().height()) break; int const h2 = t.getPar(pit).height(); sumh += h2; @@ -517,7 +517,7 @@ if (!buffer_) return; - owner_->frontend().cursor().hide(); + owner_->gui().cursor().hide(); LyXText & t = *bv_->text(); @@ -536,7 +536,7 @@ int const height = 2 * defaultRowHeight(); int const first = height; - int const last = workarea().workHeight() - height; + int const last = workarea().height() - height; LCursor & cur = cursor_; bv_funcs::CurStatus st = bv_funcs::status(bv_, cur); @@ -597,7 +597,7 @@ * dispatch() itself, because that's called recursively. */ if (available()) - owner_->frontend().cursor().show(*bv_); + owner_->gui().cursor().show(*bv_); } @@ -624,7 +624,7 @@ xsel_cache_.set = cur.selection(); sel = cur.selectionAsString(false); if (!sel.empty()) - clipboard().putClipboard(sel); + clipboard().put(sel); } } @@ -632,7 +632,7 @@ void BufferView::Pimpl::selectionLost() { if (available()) { - owner_->frontend().cursor().hide(); + owner_->gui().cursor().hide(); cursor_.clearSelection(); xsel_cache_.set = false; } @@ -644,12 +644,12 @@ static int work_area_width; static int work_area_height; - bool const widthChange = workarea().workWidth() != work_area_width; - bool const heightChange = workarea().workHeight() != work_area_height; + bool const widthChange = workarea().width() != work_area_width; + bool const heightChange = workarea().height() != work_area_height; // Update from work area - work_area_width = workarea().workWidth(); - work_area_height = workarea().workHeight(); + work_area_width = workarea().width(); + work_area_height = workarea().height(); if (buffer_ && widthChange) { // The visible LyXView need a resize @@ -672,7 +672,7 @@ int const asc = font_metrics::maxAscent(font); int const des = font_metrics::maxDescent(font); Point const p = bv_funcs::getPos(cursor_, cursor_.boundary()); - if (p.y_ - asc >= 0 && p.y_ + des < workarea().workHeight()) + if (p.y_ - asc >= 0 && p.y_ + des < workarea().height()) return false; } center(); @@ -746,7 +746,7 @@ void BufferView::Pimpl::cursorToggle() { if (buffer_) { - owner_->frontend().cursor().toggle(*bv_); + owner_->gui().cursor().toggle(*bv_); // Use this opportunity to deal with any child processes that // have finished but are waiting to communicate this fact @@ -873,13 +873,13 @@ Paragraph const & par = bot.text()->paragraphs()[pit]; anchor_ref_ = pit; offset_ref_ = bv_funcs::coordOffset(cursor_, cursor_.boundary()).y_ - + par.ascent() - workarea().workHeight() / 2; + + par.ascent() - workarea().height() / 2; } void BufferView::Pimpl::stuffClipboard(string const & content) const { - clipboard().putClipboard(content); + clipboard().put(content); } @@ -1004,13 +1004,13 @@ if (!available()) return false; - owner_->frontend().cursor().hide(); + owner_->gui().cursor().hide(); // Either the inset under the cursor or the // surrounding LyXText will handle this event. // Build temporary cursor. - cmd.y = min(max(cmd.y,-1), workarea().workHeight()); + cmd.y = min(max(cmd.y,-1), workarea().height()); InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y); //lyxerr << BOOST_CURRENT_FUNCTION // << " * hit inset at tip: " << inset << endl; @@ -1042,7 +1042,7 @@ // See workAreaKeyPress cursor_timeout.restart(); - owner_->frontend().cursor().show(*bv_); + owner_->gui().cursor().show(*bv_); // Skip these when selecting if (cmd.action != LFUN_MOUSE_MOTION) { Index: BufferView_pimpl.h =================================================================== --- BufferView_pimpl.h (revision 14026) +++ BufferView_pimpl.h (working copy) @@ -45,13 +45,11 @@ class ViewMetricsInfo; namespace lyx { -namespace frontend { -class BaseFrontend; -class BaseWorkArea; -class BaseClipboard; -class Cursor; +class Gui; +class WorkArea; +class Clipboard; +class GuiCursor; } -} /// @@ -119,11 +117,11 @@ void repaintAll(bool r) {refresh_inside_ = r; } /// the frontend - lyx::frontend::BaseFrontend & frontend() const; + lyx::Gui & gui() const; /// our workarea - lyx::frontend::BaseWorkArea & workarea() const; + lyx::WorkArea & workarea() const; /// the clipboard - lyx::frontend::BaseClipboard & clipboard() const; + lyx::Clipboard & clipboard() const; private: /// An error list (replaces the error insets) @@ -192,7 +190,7 @@ /// void menuInsertLyXFile(std::string const & filen); - lyx::frontend::BaseWorkArea * work_area_; + lyx::WorkArea * work_area_; size_t work_area_id_; /// this is used to handle XSelection events in the right manner Index: frontends/BaseClipboard.h =================================================================== --- frontends/BaseClipboard.h (revision 14030) +++ frontends/BaseClipboard.h (working copy) @@ -1,41 +0,0 @@ -// -*- C++ -*- -/** - * \file BaseClipboard.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author unknown - * \author John Levon - * \author Abdelrazak Younes - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef BASE_CLIPBOARD_H -#define BASE_CLIPBOARD_H - -#include <string> - -namespace lyx { -namespace frontend { - -/** - * A BaseClipboard class manages the clipboard. - */ -class BaseClipboard -{ -public: - virtual ~BaseClipboard() {} - - /// a selection exists - virtual void haveSelection(bool) = 0; - /// get the X clipboard contents - virtual std::string const getClipboard() const = 0; - /// fill the clipboard - virtual void putClipboard(std::string const &) = 0; -}; - -} // namespace frontend -} // namespace lyx - -#endif // BASE_CLIPBOARD_H Index: frontends/BaseFrontend.h =================================================================== --- frontends/BaseFrontend.h (revision 14030) +++ frontends/BaseFrontend.h (working copy) @@ -1,51 +0,0 @@ -// -*- C++ -*- -/** - * \file BaseFrontend.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author unknown - * \author John Levon - * \author Abdelrazak Younes - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef BASE_FRONTEND_H -#define BASE_FRONTEND_H - -#include "frontends/BaseClipboard.h" -#include "frontends/BaseWorkArea.h" -#include "frontends/FrontendCursor.h" - -namespace lyx { -namespace frontend { - -/** - * A BaseFrontend class manages the different frontend elements. - */ -class BaseFrontend -{ -public: - virtual ~BaseFrontend() {} - - /// - virtual BaseClipboard& clipboard() = 0; - /// - virtual size_t newWorkArea(int w, int h) = 0; - /// - virtual BaseWorkArea& workArea(size_t id) = 0; - /// - virtual void destroyWorkArea(size_t id) = 0; - - /// - FrontendCursor & cursor() {return cursor_;} - -private: - FrontendCursor cursor_; -}; - -} // namespace frontend -} // namespace lyx - -#endif // BASE_FRONTEND_H Index: frontends/BaseWorkArea.C =================================================================== --- frontends/BaseWorkArea.C (revision 14030) +++ frontends/BaseWorkArea.C (working copy) @@ -1,187 +0,0 @@ -/** - * \file BaseWorkArea.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author John Levon - * \author Abdelrazak Younes - * - * Full author contact details are available in file CREDITS. - * - * Splash screen code added by Angus Leeming - */ - -#include <config.h> - -#include "BaseWorkArea.h" - -#include "font_metrics.h" -#include "lyx_gui.h" -#include "Painter.h" - -#include "BufferView.h" -#include "buffer.h" -#include "bufferparams.h" -#include "coordcache.h" -#include "cursor.h" -#include "debug.h" -#include "language.h" -#include "LColor.h" -#include "lyxfont.h" -#include "lyxrc.h" -#include "lyxrow.h" -#include "lyxtext.h" -#include "metricsinfo.h" -#include "paragraph.h" -#include "rowpainter.h" -#include "version.h" - -#include "graphics/GraphicsImage.h" -#include "graphics/GraphicsLoader.h" - -#include "support/filetools.h" // LibFileSearch - -#include <boost/utility.hpp> -#include <boost/bind.hpp> -#include <boost/signals/trackable.hpp> - -using lyx::support::libFileSearch; - -using std::endl; -using std::min; -using std::max; -using std::string; - - -namespace lyx { -namespace frontend { - -class SplashScreen : boost::noncopyable, boost::signals::trackable { -public: - /// This is a singleton class. Get the instance. - static SplashScreen const & get(); - /// - lyx::graphics::Image const * image() const { return loader_.image(); } - /// - string const & text() const { return text_; } - /// - LyXFont const & font() const { return font_; } - /// - void connect(lyx::graphics::Loader::slot_type const & slot) const { - loader_.connect(slot); - } - /// - void startLoading() const { - if (loader_.status() == lyx::graphics::WaitingToLoad) - loader_.startLoading(); - } - -private: - /** Make the c-tor private so we can control how many objects - * are instantiated. - */ - SplashScreen(); - - /// - lyx::graphics::Loader loader_; - /// The text to be written on top of the pixmap - string const text_; - /// in this font... - LyXFont font_; -}; - - -SplashScreen const & SplashScreen::get() -{ - static SplashScreen singleton; - return singleton; -} - - -SplashScreen::SplashScreen() - : text_(lyx_version ? lyx_version : "unknown") -{ - if (!lyxrc.show_banner) - return; - - string const file = libFileSearch("images", "banner", "ppm"); - if (file.empty()) - return; - - // The font used to display the version info - font_.setFamily(LyXFont::SANS_FAMILY); - font_.setSeries(LyXFont::BOLD_SERIES); - font_.setSize(LyXFont::SIZE_NORMAL); - font_.setColor(LColor::yellow); - - // Load up the graphics file - loader_.reset(file); -} - -BaseWorkArea::BaseWorkArea(LyXView & owner, int w, int h) - : greyed_out_(true) -{ - // Start loading the pixmap as soon as possible - if (lyxrc.show_banner) { - SplashScreen const & splash = SplashScreen::get(); - splash.connect(boost::bind(&BaseWorkArea::checkAndGreyOut, this)); - splash.startLoading(); - } -} - - -void BaseWorkArea::checkAndGreyOut() -{ - if (greyed_out_) - greyOut(); -} - - -void BaseWorkArea::redraw(BufferView & bv, ViewMetricsInfo const & vi) -{ - greyed_out_ = false; - getPainter().start(); - paintText(bv, vi); - lyxerr[Debug::DEBUG] << "Redraw screen" << endl; - int const ymin = std::max(vi.y1, 0); - int const ymax = - ( vi.p2 < vi.size - 1 ? vi.y2 : workHeight() ); - expose(0, ymin, workWidth(), ymax - ymin); - getPainter().end(); - theCoords.doneUpdating(); -} - - -void BaseWorkArea::greyOut() -{ - greyed_out_ = true; - getPainter().start(); - - getPainter().fillRectangle(0, 0, - workWidth(), - workHeight(), - LColor::bottomarea); - - // Add a splash screen to the centre of the work area - SplashScreen const & splash = SplashScreen::get(); - lyx::graphics::Image const * const splash_image = splash.image(); - if (splash_image) { - int const w = splash_image->getWidth(); - int const h = splash_image->getHeight(); - - int x = (workWidth() - w) / 2; - int y = (workHeight() - h) / 2; - - getPainter().image(x, y, w, h, *splash_image); - - x += 260; - y += 265; - - getPainter().text(x, y, splash.text(), splash.font()); - } - expose(0, 0, workWidth(), workHeight()); - getPainter().end(); -} - -} // namespace frontend -} // namespace lyx Index: frontends/BaseWorkArea.h =================================================================== --- frontends/BaseWorkArea.h (revision 14030) +++ frontends/BaseWorkArea.h (working copy) @@ -1,88 +0,0 @@ -// -*- C++ -*- -/** - * \file BaseWorkArea.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author unknown - * \author John Levon - * \author Abdelrazak Younes - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef BASE_WORKAREA_H -#define BASE_WORKAREA_H - -#include "frontends/FrontendCursor.h" - -#include "frontends/key_state.h" -#include "frontends/LyXKeySym.h" - -class LyXView; -class Painter; -class FuncRequest; -class BufferView; -class ViewMetricsInfo; - -namespace lyx { -namespace frontend { - -/** - * The work area class represents the widget that provides the - * view onto a document. It is owned by the BufferView, and - * is responsible for handing events back to its owning BufferView. - * It works in concert with the BaseScreen class to update the - * widget view of a document. - */ -class BaseWorkArea { -public: - BaseWorkArea(LyXView & owner, int w, int h); - - virtual ~BaseWorkArea() {} - - /// return the painter object for this work area - virtual Painter & getPainter() = 0; - - /// return the width of the work area in pixels - virtual int workWidth() const = 0; - - /// return the height of the work area in pixels - virtual int workHeight() const = 0; - - /** - * Update the scrollbar. - * @param height the total document height in pixels - * @param pos the current position in the document, in pixels - * @param line_height the line-scroll amount, in pixels - */ - virtual void setScrollbarParams(int height, int pos, int line_height) = 0; - - /// redraw the screen, without using existing pixmap - virtual void redraw(BufferView & bv, ViewMetricsInfo const & vi); - - /// grey out (no buffer) - void greyOut(); - - /// paint the cursor and store the background - virtual void showCursor(int x, int y, int h, FrontendCursor::Cursor_Shape shape) = 0; - - /// hide the cursor - virtual void removeCursor() = 0; - -protected: - /// cause the display of the given area of the work area - virtual void expose(int x, int y, int w, int h) = 0; - -private: - /// - void checkAndGreyOut(); - - /// - bool greyed_out_; -}; - -} // namespace frontend -} // namespace lyx - -#endif // BASE_WORKAREA_H Index: frontends/Clipboard.h =================================================================== --- frontends/Clipboard.h (revision 14026) +++ frontends/Clipboard.h (working copy) @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file BaseClipboard.h + * \file Clipboard.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -17,25 +17,23 @@ #include <string> namespace lyx { -namespace frontend { /** - * A BaseClipboard class manages the clipboard. + * A Clipboard class manages the clipboard. */ -class BaseClipboard +class Clipboard { public: - virtual ~BaseClipboard() {} + virtual ~Clipboard() {} /// a selection exists virtual void haveSelection(bool) = 0; /// get the X clipboard contents - virtual std::string const getClipboard() const = 0; + virtual std::string const get() const = 0; /// fill the clipboard - virtual void putClipboard(std::string const &) = 0; + virtual void put(std::string const &) = 0; }; -} // namespace frontend } // namespace lyx #endif // BASE_CLIPBOARD_H Index: frontends/FrontendCursor.C =================================================================== --- frontends/FrontendCursor.C (revision 14030) +++ frontends/FrontendCursor.C (working copy) @@ -1,146 +0,0 @@ -/** - * \file FrontendCursor.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author John Levon - * \author Abdelrazak Younes - * - * Full author contact details are available in file CREDITS. - * - * Splash screen code added by Angus Leeming - */ - -#include <config.h> - -#include "frontends/FrontendCursor.h" - -#include "font_metrics.h" -#include "lyx_gui.h" -#include "Painter.h" -#include "BaseWorkArea.h" - -#include "BufferView.h" -#include "buffer.h" -#include "bufferparams.h" -#include "coordcache.h" -#include "cursor.h" -#include "debug.h" -#include "language.h" -#include "LColor.h" -#include "lyxfont.h" -#include "lyxrc.h" -#include "lyxrow.h" -#include "lyxtext.h" -#include "metricsinfo.h" -#include "paragraph.h" -#include "rowpainter.h" -#include "version.h" - -#include "graphics/GraphicsImage.h" -#include "graphics/GraphicsLoader.h" - -#include "support/filetools.h" // LibFileSearch - -#include <boost/utility.hpp> -#include <boost/bind.hpp> -#include <boost/signals/trackable.hpp> - -using lyx::support::libFileSearch; - -using std::endl; -using std::min; -using std::max; -using std::string; - -namespace lyx { -namespace frontend { - -FrontendCursor::FrontendCursor() - : cursor_visible_(false), work_area_(NULL) -{ -} - - -FrontendCursor::~FrontendCursor() -{ -} - -void FrontendCursor::connect(BaseWorkArea * work_area) -{ - work_area_ = work_area; -} - - -void FrontendCursor::show(BufferView & bv) -{ - if (cursor_visible_) - return; - - if (!bv.available()) - return; - - Cursor_Shape shape = BAR_SHAPE; - - LyXText const & text = *bv.getLyXText(); - LyXFont const & realfont = text.real_current_font; - BufferParams const & bp = bv.buffer()->params(); - bool const samelang = realfont.language() == bp.language; - bool const isrtl = realfont.isVisibleRightToLeft(); - - if (!samelang || isrtl != bp.language->rightToLeft()) { - shape = L_SHAPE; - if (isrtl) - shape = REVERSED_L_SHAPE; - } - - // The ERT language hack needs fixing up - if (realfont.language() == latex_language) - shape = BAR_SHAPE; - - LyXFont const font = bv.cursor().getFont(); - int const asc = font_metrics::maxAscent(font); - int const des = font_metrics::maxDescent(font); - int h = asc + des; - int x = 0; - int y = 0; - bv.cursor().getPos(x, y); - y -= asc; - //lyxerr << "Cursor::show x: " << x << " y: " << y << endl; - - // if it doesn't touch the screen, don't try to show it - if (y + h < 0 || y >= work_area_->workHeight()) - return; - - cursor_visible_ = true; - work_area_->showCursor(x, y, h, shape); -} - - -void FrontendCursor::hide() -{ - if (!cursor_visible_) - return; - - cursor_visible_ = false; - work_area_->removeCursor(); -} - - -void FrontendCursor::toggle(BufferView & bv) -{ - if (cursor_visible_) - hide(); - else - show(bv); -} - - -void FrontendCursor::prepare() -{ - cursor_visible_ = false; -} - -} // namespace frontend -} // namespace lyx - Index: frontends/FrontendCursor.h =================================================================== --- frontends/FrontendCursor.h (revision 14030) +++ frontends/FrontendCursor.h (working copy) @@ -1,73 +0,0 @@ -// -*- C++ -*- -/** - * \file FrontendCursor.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author unknown - * \author John Levon - * \author Abdelrazak Younes - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef FRONTEND_CURSOR_H -#define FRONTEND_CURSOR_H - - -class LyXText; -class CursorSlice; -class BufferView; -class ViewMetricsInfo; - -namespace lyx { -namespace frontend { - -class BaseWorkArea; - -/** - * FrontendCursor - document rendering management - * - * The blinking cursor is handled here. - */ -class FrontendCursor { -public: - FrontendCursor(); - - virtual ~FrontendCursor(); - - void connect(BaseWorkArea * work_area); - - /// hide the visible cursor, if it is visible - void hide(); - - /// show the cursor if it is not visible - void show(BufferView & bv); - - /// toggle the cursor's visibility - void toggle(BufferView & bv); - - /// set cursor_visible_ to false in prep for re-display - void prepare(); - - /// types of cursor in work area - enum Cursor_Shape { - /// normal I-beam - BAR_SHAPE, - /// L-shape for locked insets of a different language - L_SHAPE, - /// reverse L-shape for RTL text - REVERSED_L_SHAPE - }; - -private: - /// is the cursor currently displayed - bool cursor_visible_; - - BaseWorkArea * work_area_; -}; - -} // namespace frontend -} // namespace lyx - -#endif // FRONTEND_CURSOR_H Index: frontends/Gui.h =================================================================== --- frontends/Gui.h (revision 14006) +++ frontends/Gui.h (working copy) @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file BaseFrontend.h + * \file Gui.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -11,41 +11,39 @@ * Full author contact details are available in file CREDITS. */ -#ifndef BASE_FRONTEND_H -#define BASE_FRONTEND_H +#ifndef BASE_GUI_H +#define BASE_GUI_H -#include "frontends/BaseClipboard.h" -#include "frontends/BaseWorkArea.h" -#include "frontends/FrontendCursor.h" +#include "frontends/Clipboard.h" +#include "frontends/WorkArea.h" +#include "frontends/GuiCursor.h" namespace lyx { -namespace frontend { /** - * A BaseFrontend class manages the different frontend elements. + * A Gui class manages the different frontend elements. */ -class BaseFrontend +class Gui { public: - virtual ~BaseFrontend() {} + virtual ~Gui() {} /// - virtual BaseClipboard& clipboard() = 0; + virtual Clipboard& clipboard() = 0; /// virtual size_t newWorkArea(int w, int h) = 0; /// - virtual BaseWorkArea& workArea(size_t id) = 0; + virtual WorkArea& workArea(size_t id) = 0; /// virtual void destroyWorkArea(size_t id) = 0; /// - FrontendCursor & cursor() {return cursor_;} + GuiCursor & cursor() {return cursor_;} private: - FrontendCursor cursor_; + GuiCursor cursor_; }; -} // namespace frontend } // namespace lyx -#endif // BASE_FRONTEND_H +#endif // BASE_GUI_H Index: frontends/GuiCursor.C =================================================================== --- frontends/GuiCursor.C (revision 14006) +++ frontends/GuiCursor.C (working copy) @@ -1,5 +1,5 @@ /** - * \file FrontendCursor.C + * \file GuiCursor.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -13,12 +13,12 @@ #include <config.h> -#include "frontends/FrontendCursor.h" +#include "frontends/GuiCursor.h" #include "font_metrics.h" #include "lyx_gui.h" #include "Painter.h" -#include "BaseWorkArea.h" +#include "WorkArea.h" #include "BufferView.h" #include "buffer.h" @@ -54,25 +54,24 @@ using std::string; namespace lyx { -namespace frontend { -FrontendCursor::FrontendCursor() +GuiCursor::GuiCursor() : cursor_visible_(false), work_area_(NULL) { } -FrontendCursor::~FrontendCursor() +GuiCursor::~GuiCursor() { } -void FrontendCursor::connect(BaseWorkArea * work_area) +void GuiCursor::connect(WorkArea * work_area) { work_area_ = work_area; } -void FrontendCursor::show(BufferView & bv) +void GuiCursor::show(BufferView & bv) { if (cursor_visible_) return; @@ -109,7 +108,7 @@ //lyxerr << "Cursor::show x: " << x << " y: " << y << endl; // if it doesn't touch the screen, don't try to show it - if (y + h < 0 || y >= work_area_->workHeight()) + if (y + h < 0 || y >= work_area_->height()) return; cursor_visible_ = true; @@ -117,7 +116,7 @@ } -void FrontendCursor::hide() +void GuiCursor::hide() { if (!cursor_visible_) return; @@ -127,7 +126,7 @@ } -void FrontendCursor::toggle(BufferView & bv) +void GuiCursor::toggle(BufferView & bv) { if (cursor_visible_) hide(); @@ -136,11 +135,10 @@ } -void FrontendCursor::prepare() +void GuiCursor::prepare() { cursor_visible_ = false; } -} // namespace frontend } // namespace lyx Index: frontends/GuiCursor.h =================================================================== --- frontends/GuiCursor.h (revision 14006) +++ frontends/GuiCursor.h (working copy) @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file FrontendCursor.h + * \file GuiCursor.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -11,8 +11,8 @@ * Full author contact details are available in file CREDITS. */ -#ifndef FRONTEND_CURSOR_H -#define FRONTEND_CURSOR_H +#ifndef GUI_CURSOR_H +#define GUI_CURSOR_H class LyXText; @@ -21,22 +21,21 @@ class ViewMetricsInfo; namespace lyx { -namespace frontend { -class BaseWorkArea; +class WorkArea; /** - * FrontendCursor - document rendering management + * GuiCursor - document rendering management * * The blinking cursor is handled here. */ -class FrontendCursor { +class GuiCursor { public: - FrontendCursor(); + GuiCursor(); - virtual ~FrontendCursor(); + virtual ~GuiCursor(); - void connect(BaseWorkArea * work_area); + void connect(WorkArea * work_area); /// hide the visible cursor, if it is visible void hide(); @@ -64,10 +63,9 @@ /// is the cursor currently displayed bool cursor_visible_; - BaseWorkArea * work_area_; + WorkArea * work_area_; }; -} // namespace frontend } // namespace lyx -#endif // FRONTEND_CURSOR_H +#endif // GUI_CURSOR_H Index: frontends/LyXView.h =================================================================== --- frontends/LyXView.h (revision 14026) +++ frontends/LyXView.h (working copy) @@ -33,9 +33,9 @@ class FuncRequest; namespace lyx { +class Gui; namespace frontend { class ControlCommandBuffer; -class BaseFrontend; } // namespace frontend } // namespace lyx @@ -146,7 +146,7 @@ // returns true if this view has the focus. virtual bool hasFocus() const = 0; - virtual lyx::frontend::BaseFrontend & frontend() = 0; + virtual lyx::Gui & gui() = 0; protected: /// view of a buffer. Eventually there will be several. Index: frontends/qt4/Application.C =================================================================== --- frontends/qt4/Application.C (revision 14026) +++ frontends/qt4/Application.C (working copy) @@ -12,7 +12,7 @@ #include "Application.h" -#include "frontends/BaseWorkArea.h" +#include "frontends/WorkArea.h" #include "qt_helpers.h" #include "BufferView.h" @@ -60,7 +60,7 @@ #endif } -void Application::connect(BaseWorkArea * work_area) +void Application::connect(WorkArea * work_area) { work_area_ = work_area; } Index: frontends/qt4/Application.h =================================================================== --- frontends/qt4/Application.h (revision 14026) +++ frontends/qt4/Application.h (working copy) @@ -26,7 +26,7 @@ namespace lyx { namespace frontend { -class BaseWorkArea; +class WorkArea; /// The Qt main application class /** @@ -41,11 +41,11 @@ public: Application(int & argc, char ** argv); - void connect(BaseWorkArea * work_area); + void connect(WorkArea * work_area); private: /// - BaseWorkArea * work_area_; + WorkArea * work_area_; #ifdef Q_WS_X11 public: Index: frontends/qt4/Clipboard.C =================================================================== --- frontends/qt4/Clipboard.C (revision 14026) +++ frontends/qt4/Clipboard.C (working copy) @@ -54,7 +54,7 @@ } -string const Clipboard::getClipboard() const +string const Clipboard::get() const { QString str = qApp->clipboard()->text(CLIPBOARD_MODE); lyxerr[Debug::ACTION] << "getClipboard: " << (const char*) str << endl; @@ -65,7 +65,7 @@ } -void Clipboard::putClipboard(string const & str) +void Clipboard::put(string const & str) { lyxerr[Debug::ACTION] << "putClipboard: " << str << endl; Index: frontends/qt4/Clipboard.h =================================================================== --- frontends/qt4/Clipboard.h (revision 14026) +++ frontends/qt4/Clipboard.h (working copy) @@ -14,7 +14,7 @@ #ifndef CLIPBOARD_H #define CLIPBOARD_H -#include "frontends/BaseClipboard.h" +#include "frontends/Clipboard.h" namespace lyx { namespace frontend { @@ -22,7 +22,7 @@ /** * The Qt4 version of the Clipboard. */ -class Clipboard: public BaseClipboard +class Clipboard: public lyx::Clipboard { public: Clipboard() {} @@ -33,8 +33,8 @@ */ //@{ void haveSelection(bool own); - std::string const getClipboard() const; - void putClipboard(std::string const & str); + std::string const get() const; + void put(std::string const & str); //@} }; Index: frontends/qt4/Frontend.C =================================================================== --- frontends/qt4/Frontend.C (revision 14031) +++ frontends/qt4/Frontend.C (working copy) @@ -1,57 +0,0 @@ -// -*- C++ -*- -/** - * \file Frontend.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author unknown - * \author John Levon - * - * Full author contact details are available in file CREDITS. - */ - -#include "Frontend.h" -#include "WorkArea.h" -#include "QtView.h" - -using boost::shared_ptr; - -namespace lyx { -namespace frontend { - -Frontend::Frontend(QtView & owner): owner_(owner), max_id_(0) -{ -} - - -BaseClipboard& Frontend::clipboard() -{ - return clipboard_; -} - - -size_t Frontend::newWorkArea(int w, int h) -{ - size_t const id = max_id_; - ++max_id_; - work_areas_[id].reset(new WorkArea(owner_, w, h)); - return id; -} - -BaseWorkArea& Frontend::workArea(size_t id) -{ - BOOST_ASSERT(work_areas_.find(id) != work_areas_.end()); - - cursor().connect(work_areas_[id].get()); - - return *work_areas_[id].get(); -} - - -void Frontend::destroyWorkArea(size_t id) -{ - work_areas_.erase(id); -} - -} // namespace frontend -} // namespace lyx Index: frontends/qt4/Frontend.h =================================================================== --- frontends/qt4/Frontend.h (revision 14026) +++ frontends/qt4/Frontend.h (working copy) @@ -1,58 +0,0 @@ -// -*- C++ -*- -/** - * \file Frontend.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author unknown - * \author John Levon - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef FRONTEND_H -#define FRONTEND_H - -#include "frontends/BaseFrontend.h" -#include "Clipboard.h" - -#include <boost/shared_ptr.hpp> - -#include <map> - -namespace lyx { -namespace frontend { - -class WorkArea; -class QtView; - -/** - * The Frontend class is the interface to all Qt4 components. - */ -class Frontend: public BaseFrontend -{ -public: - Frontend(QtView & owner); - virtual ~Frontend() {} - - BaseClipboard& clipboard(); - - size_t newWorkArea(int w, int h); - BaseWorkArea& workArea(size_t id); - void destroyWorkArea(size_t id); - -private: - /// - Clipboard clipboard_; - /// - std::map<size_t, boost::shared_ptr<WorkArea> > work_areas_; - /// - QtView & owner_; - /// - size_t max_id_; -}; - -} // namespace frontend -} // namespace lyx - -#endif // FRONTEND_H Index: frontends/qt4/Gui.C =================================================================== --- frontends/qt4/Gui.C (revision 14006) +++ frontends/qt4/Gui.C (working copy) @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file Frontend.C + * \file Gui.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -10,7 +10,7 @@ * Full author contact details are available in file CREDITS. */ -#include "Frontend.h" +#include "Gui.h" #include "WorkArea.h" #include "QtView.h" @@ -19,18 +19,18 @@ namespace lyx { namespace frontend { -Frontend::Frontend(QtView & owner): owner_(owner), max_id_(0) +Gui::Gui(QtView & owner): owner_(owner), max_id_(0) { } -BaseClipboard& Frontend::clipboard() +lyx::Clipboard& Gui::clipboard() { return clipboard_; } -size_t Frontend::newWorkArea(int w, int h) +size_t Gui::newWorkArea(int w, int h) { size_t const id = max_id_; ++max_id_; @@ -38,7 +38,7 @@ return id; } -BaseWorkArea& Frontend::workArea(size_t id) +lyx::WorkArea& Gui::workArea(size_t id) { BOOST_ASSERT(work_areas_.find(id) != work_areas_.end()); @@ -48,7 +48,7 @@ } -void Frontend::destroyWorkArea(size_t id) +void Gui::destroyWorkArea(size_t id) { work_areas_.erase(id); } Index: frontends/qt4/Gui.h =================================================================== --- frontends/qt4/Gui.h (revision 14006) +++ frontends/qt4/Gui.h (working copy) @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file Frontend.h + * \file Gui.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -10,10 +10,10 @@ * Full author contact details are available in file CREDITS. */ -#ifndef FRONTEND_H -#define FRONTEND_H +#ifndef GUI_H +#define GUI_H -#include "frontends/BaseFrontend.h" +#include "frontends/Gui.h" #include "Clipboard.h" #include <boost/shared_ptr.hpp> @@ -27,18 +27,18 @@ class QtView; /** - * The Frontend class is the interface to all Qt4 components. + * The Gui class is the interface to all Qt4 components. */ -class Frontend: public BaseFrontend +class Gui: public lyx::Gui { public: - Frontend(QtView & owner); - virtual ~Frontend() {} + Gui(QtView & owner); + virtual ~Gui() {} - BaseClipboard& clipboard(); + lyx::Clipboard& clipboard(); size_t newWorkArea(int w, int h); - BaseWorkArea& workArea(size_t id); + lyx::WorkArea& workArea(size_t id); void destroyWorkArea(size_t id); private: @@ -55,4 +55,4 @@ } // namespace frontend } // namespace lyx -#endif // FRONTEND_H +#endif // GUI_H Index: frontends/qt4/QtView.h =================================================================== --- frontends/qt4/QtView.h (revision 14026) +++ frontends/qt4/QtView.h (working copy) @@ -17,7 +17,8 @@ // Must be here because of moc. #include <config.h> -#include "Frontend.h" +#include "Gui.h" + #include "frontends/LyXView.h" #include "funcrequest.h" @@ -74,7 +75,7 @@ virtual bool hasFocus() const; // - BaseFrontend & frontend() { return frontend_; } + lyx::Gui & gui() { return frontend_; } static QMainWindow* mainWidget(); @@ -110,7 +111,7 @@ /// static QMainWindow* mainWidget_; - Frontend frontend_; + Gui frontend_; }; } // namespace frontend Index: frontends/qt4/WorkArea.C =================================================================== --- frontends/qt4/WorkArea.C (revision 14060) +++ frontends/qt4/WorkArea.C (working copy) @@ -112,7 +112,7 @@ WorkArea::WorkArea(LyXView & owner, int w, int h) - : QAbstractScrollArea(lyx::frontend::QtView::mainWidget()), BaseWorkArea(owner, w, h), view_(owner), painter_(this) +: QAbstractScrollArea(lyx::frontend::QtView::mainWidget()), lyx::WorkArea(owner, w, h), view_(owner), painter_(this) { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -519,7 +519,7 @@ } -void WorkArea::showCursor(int x, int y, int h, FrontendCursor::Cursor_Shape shape) +void WorkArea::showCursor(int x, int y, int h, GuiCursor::Cursor_Shape shape) { if (!qApp->focusWidget()) return; @@ -544,16 +544,16 @@ cursor_shape_ = shape; switch (cursor_shape_) { - case FrontendCursor::BAR_SHAPE: + case GuiCursor::BAR_SHAPE: // FIXME the cursor width shouldn't be hard-coded! cursor_w_ = 2; lshape_cursor_ = false; break; - case FrontendCursor::L_SHAPE: + case GuiCursor::L_SHAPE: cursor_w_ = cursor_h_ / 3; lshape_cursor_ = true; break; - case FrontendCursor::REVERSED_L_SHAPE: + case GuiCursor::REVERSED_L_SHAPE: cursor_w_ = cursor_h_ / 3; cursor_x_ -= cursor_w_ - 1; lshape_cursor_ = true; Index: frontends/qt4/WorkArea.h =================================================================== --- frontends/qt4/WorkArea.h (revision 14026) +++ frontends/qt4/WorkArea.h (working copy) @@ -23,7 +23,7 @@ #endif #include "frontends/LyXView.h" -#include "frontends/BaseWorkArea.h" +#include "frontends/WorkArea.h" #include "QLPainter.h" @@ -98,7 +98,7 @@ * Qt-specific implementation of the work area * (buffer view GUI) */ -class WorkArea: public QAbstractScrollArea, public BaseWorkArea { +class WorkArea: public QAbstractScrollArea, public lyx::WorkArea { Q_OBJECT @@ -108,10 +108,10 @@ virtual ~WorkArea(); /// return the width of the content pane - virtual int workWidth() const { return workWidth_; } + virtual int width() const { return workWidth_; } /// return the height of the content pane - virtual int workHeight() const { return workHeight_; } + virtual int height() const { return workHeight_; } /// virtual void setScrollbarParams(int height, int pos, int line_height); @@ -150,7 +150,7 @@ virtual void expose(int x, int y, int exp_width, int exp_height); /// paint the cursor and store the background - virtual void showCursor(int x, int y, int h, FrontendCursor::Cursor_Shape shape); + virtual void showCursor(int x, int y, int h, GuiCursor::Cursor_Shape shape); /// hide the cursor virtual void removeCursor(); @@ -249,7 +249,7 @@ /// QColor cursor_color_; /// - FrontendCursor::Cursor_Shape cursor_shape_; + GuiCursor::Cursor_Shape cursor_shape_; }; } // namespace frontend Index: frontends/WorkArea.C =================================================================== --- frontends/WorkArea.C (revision 14006) +++ frontends/WorkArea.C (working copy) @@ -1,5 +1,5 @@ /** - * \file BaseWorkArea.C + * \file WorkArea.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -13,7 +13,7 @@ #include <config.h> -#include "BaseWorkArea.h" +#include "WorkArea.h" #include "font_metrics.h" #include "lyx_gui.h" @@ -54,7 +54,6 @@ namespace lyx { -namespace frontend { class SplashScreen : boost::noncopyable, boost::signals::trackable { public: @@ -118,26 +117,26 @@ loader_.reset(file); } -BaseWorkArea::BaseWorkArea(LyXView & owner, int w, int h) +WorkArea::WorkArea(LyXView & owner, int w, int h) : greyed_out_(true) { // Start loading the pixmap as soon as possible if (lyxrc.show_banner) { SplashScreen const & splash = SplashScreen::get(); - splash.connect(boost::bind(&BaseWorkArea::checkAndGreyOut, this)); + splash.connect(boost::bind(&WorkArea::checkAndGreyOut, this)); splash.startLoading(); } } -void BaseWorkArea::checkAndGreyOut() +void WorkArea::checkAndGreyOut() { if (greyed_out_) greyOut(); } -void BaseWorkArea::redraw(BufferView & bv, ViewMetricsInfo const & vi) +void WorkArea::redraw(BufferView & bv, ViewMetricsInfo const & vi) { greyed_out_ = false; getPainter().start(); @@ -145,21 +144,21 @@ lyxerr[Debug::DEBUG] << "Redraw screen" << endl; int const ymin = std::max(vi.y1, 0); int const ymax = - ( vi.p2 < vi.size - 1 ? vi.y2 : workHeight() ); - expose(0, ymin, workWidth(), ymax - ymin); + ( vi.p2 < vi.size - 1 ? vi.y2 : height() ); + expose(0, ymin, width(), ymax - ymin); getPainter().end(); theCoords.doneUpdating(); } -void BaseWorkArea::greyOut() +void WorkArea::greyOut() { greyed_out_ = true; getPainter().start(); getPainter().fillRectangle(0, 0, - workWidth(), - workHeight(), + width(), + height(), LColor::bottomarea); // Add a splash screen to the centre of the work area @@ -169,8 +168,8 @@ int const w = splash_image->getWidth(); int const h = splash_image->getHeight(); - int x = (workWidth() - w) / 2; - int y = (workHeight() - h) / 2; + int x = (width() - w) / 2; + int y = (height() - h) / 2; getPainter().image(x, y, w, h, *splash_image); @@ -179,9 +178,8 @@ getPainter().text(x, y, splash.text(), splash.font()); } - expose(0, 0, workWidth(), workHeight()); + expose(0, 0, width(), height()); getPainter().end(); } -} // namespace frontend } // namespace lyx Index: frontends/WorkArea.h =================================================================== --- frontends/WorkArea.h (revision 14026) +++ frontends/WorkArea.h (working copy) @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file BaseWorkArea.h + * \file WorkArea.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -14,7 +14,7 @@ #ifndef BASE_WORKAREA_H #define BASE_WORKAREA_H -#include "frontends/FrontendCursor.h" +#include "frontends/GuiCursor.h" #include "frontends/key_state.h" #include "frontends/LyXKeySym.h" @@ -26,7 +26,6 @@ class ViewMetricsInfo; namespace lyx { -namespace frontend { /** * The work area class represents the widget that provides the @@ -35,20 +34,20 @@ * It works in concert with the BaseScreen class to update the * widget view of a document. */ -class BaseWorkArea { +class WorkArea { public: - BaseWorkArea(LyXView & owner, int w, int h); + WorkArea(LyXView & owner, int w, int h); - virtual ~BaseWorkArea() {} + virtual ~WorkArea() {} /// return the painter object for this work area virtual Painter & getPainter() = 0; /// return the width of the work area in pixels - virtual int workWidth() const = 0; + virtual int width() const = 0; /// return the height of the work area in pixels - virtual int workHeight() const = 0; + virtual int height() const = 0; /** * Update the scrollbar. @@ -65,7 +64,7 @@ void greyOut(); /// paint the cursor and store the background - virtual void showCursor(int x, int y, int h, FrontendCursor::Cursor_Shape shape) = 0; + virtual void showCursor(int x, int y, int h, GuiCursor::Cursor_Shape shape) = 0; /// hide the cursor virtual void removeCursor() = 0; @@ -82,7 +81,6 @@ bool greyed_out_; }; -} // namespace frontend } // namespace lyx #endif // BASE_WORKAREA_H