From e7b69c030ed487a862cad6da9e605b138bae5852 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Sat, 8 Jul 2006 22:55:22 +0000 Subject: [PATCH] Extracted from r14281 * BufferView: - hideCursor(): deleted (for real) * frontends/GuiCursor: - deleted. Functionality transfered to WorkArea. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14389 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 6 -- src/BufferView.h | 3 - src/frontends/Gui.h | 10 +- src/frontends/GuiCursor.C | 144 -------------------------- src/frontends/GuiCursor.h | 89 ---------------- src/frontends/Makefile.am | 2 - src/frontends/WorkArea.h | 29 +++++- src/frontends/gtk/GScreen.C | 4 +- src/frontends/gtk/GScreen.h | 2 +- src/frontends/gtk/GView.C | 5 +- src/frontends/gtk/GuiImplementation.C | 1 - src/frontends/qt3/GuiImplementation.h | 1 - src/frontends/qt4/GuiImplementation.C | 2 - 13 files changed, 35 insertions(+), 263 deletions(-) delete mode 100644 src/frontends/GuiCursor.C delete mode 100644 src/frontends/GuiCursor.h diff --git a/src/BufferView.C b/src/BufferView.C index aba9142877..8da4777884 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -43,7 +43,6 @@ #include "frontends/Clipboard.h" #include "frontends/Dialogs.h" #include "frontends/LyXView.h" -#include "frontends/Gui.h" #include "insets/insetcommand.h" // ChangeRefs #include "insets/insettext.h" @@ -299,11 +298,6 @@ void BufferView::gotoLabel(string const & label) } -void BufferView::hideCursor() -{ - pimpl_->gui().guiCursor().hide(); -} - LyXText * BufferView::getLyXText() { LyXText * text = cursor().innerText(); diff --git a/src/BufferView.h b/src/BufferView.h index a967a2fed4..a05c38e84c 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -160,9 +160,6 @@ public: /// set the cursor based on the given TeX source row void setCursorFromRow(int row); - /// hide the cursor if it is visible - void hideCursor(); - /// center the document view around the cursor void center(); /// scroll document by the given number of lines of default height diff --git a/src/frontends/Gui.h b/src/frontends/Gui.h index 9676e62f49..7632177048 100644 --- a/src/frontends/Gui.h +++ b/src/frontends/Gui.h @@ -14,13 +14,12 @@ #ifndef BASE_GUI_H #define BASE_GUI_H -#include "frontends/GuiCursor.h" - #include #include class LyXView; +class BufferView; namespace lyx { namespace frontend { @@ -54,16 +53,9 @@ public: /// virtual void destroyWorkArea(int id) = 0; - /// - GuiCursor & guiCursor() {return cursor_;} - protected: /// view of a buffer. Eventually there will be several. std::map > buffer_views_; - -private: - /// - GuiCursor cursor_; }; } // namespace frontend diff --git a/src/frontends/GuiCursor.C b/src/frontends/GuiCursor.C deleted file mode 100644 index 77f6eaed08..0000000000 --- a/src/frontends/GuiCursor.C +++ /dev/null @@ -1,144 +0,0 @@ -/** - * \file GuiCursor.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 - -#include "frontends/GuiCursor.h" - -#include "font_metrics.h" -#include "lyx_gui.h" -#include "frontends/Painter.h" -#include "frontends/WorkArea.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 - -using lyx::support::libFileSearch; - -using std::endl; -using std::min; -using std::max; -using std::string; - -namespace lyx { -namespace frontend { - -GuiCursor::GuiCursor() - : cursor_visible_(false), work_area_(0) -{ -} - - -GuiCursor::~GuiCursor() -{ -} - -void GuiCursor::connect(WorkArea * work_area) -{ - work_area_ = work_area; -} - - -void GuiCursor::show(BufferView & bv) -{ - if (cursor_visible_) - return; - - if (!bv.available()) - return; - - CursorShape 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; - - BOOST_ASSERT(work_area_); - - // if it doesn't touch the screen, don't try to show it - if (y + h < 0 || y >= work_area_->height()) - return; - - cursor_visible_ = true; - work_area_->showCursor(x, y, h, shape); -} - - -void GuiCursor::hide() -{ - if (!cursor_visible_) - return; - - cursor_visible_ = false; - BOOST_ASSERT(work_area_); - work_area_->removeCursor(); -} - - -void GuiCursor::toggle(BufferView & bv) -{ - if (cursor_visible_) - hide(); - else - show(bv); -} - - -void GuiCursor::prepare() -{ - cursor_visible_ = false; -} - -} // namespace frontend -} // namespace lyx diff --git a/src/frontends/GuiCursor.h b/src/frontends/GuiCursor.h deleted file mode 100644 index e6ee467414..0000000000 --- a/src/frontends/GuiCursor.h +++ /dev/null @@ -1,89 +0,0 @@ -// -*- C++ -*- -/** - * \file GuiCursor.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. - */ - -// X11 use a define called CursorShape, and we really want to use -// that name our selves. Therefore we do something similar to what is done -// in kde/fixx11h.h: -namespace X { -#ifdef CursorShape -#ifndef FIXX11H_CursorShape -#define FIXX11H_CursorShape -int const XCursorShape = CursorShape; -#undef CursorShape -int const CursorShape = CursorShape; -#endif -#undef CursorShape -#endif - -} // namespace X - -#ifndef GUI_CURSOR_H -#define GUI_CURSOR_H - - -class LyXText; -class CursorSlice; -class BufferView; -class ViewMetricsInfo; - -namespace lyx { -namespace frontend { - -class WorkArea; - -/// types of cursor in work area -enum CursorShape { - /// 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 -}; - -/** - * GuiCursor - document rendering management - * - * The blinking cursor is handled here. - */ -class GuiCursor { -public: - GuiCursor(); - - virtual ~GuiCursor(); - - void connect(WorkArea * 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(); - -private: - /// is the cursor currently displayed - bool cursor_visible_; - - WorkArea * work_area_; -}; - -} // namespace frontend -} // namespace lyx - -#endif // GUI_CURSOR_H diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index 69d2f0623b..2e6d5c5a6d 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -32,8 +32,6 @@ libfrontends_la_SOURCES = \ Toolbars.h \ Clipboard.h \ Gui.h \ - GuiCursor.C \ - GuiCursor.h \ WorkArea.C \ WorkArea.h \ font_metrics.h \ diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index c8a846c9f5..ffa8b2bc42 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -11,11 +11,25 @@ * Full author contact details are available in file CREDITS. */ +// X11 use a define called CursorShape, and we really want to use +// that name our selves. Therefore we do something similar to what is done +// in kde/fixx11h.h: +namespace X { +#ifdef CursorShape +#ifndef FIXX11H_CursorShape +#define FIXX11H_CursorShape +int const XCursorShape = CursorShape; +#undef CursorShape +int const CursorShape = CursorShape; +#endif +#undef CursorShape +#endif +} // namespace X + + #ifndef BASE_WORKAREA_H #define BASE_WORKAREA_H -#include "frontends/GuiCursor.h" - #include "frontends/key_state.h" #include "frontends/LyXKeySym.h" #include "frontends/Timeout.h" @@ -27,6 +41,17 @@ namespace frontend { class Painter; +/// types of cursor in work area +enum CursorShape { + /// 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 +}; + + /** * The work area class represents the widget that provides the * view onto a document. It is owned by the BufferView, and diff --git a/src/frontends/gtk/GScreen.C b/src/frontends/gtk/GScreen.C index b5a48bab06..702b5bb44d 100644 --- a/src/frontends/gtk/GScreen.C +++ b/src/frontends/gtk/GScreen.C @@ -32,7 +32,7 @@ #include "frontends/font_metrics.h" #include "frontends/Painter.h" -#include "frontends/GuiCursor.h" +#include "frontends/WorkArea.h" #include "insets/insettext.h" @@ -41,6 +41,8 @@ namespace lyx { namespace frontend { +using lyx::frontend::CursorShape; + GScreen::GScreen(GWorkArea & o) : owner_(o) { diff --git a/src/frontends/gtk/GScreen.h b/src/frontends/gtk/GScreen.h index 1aae24e9cb..fc717ae71e 100644 --- a/src/frontends/gtk/GScreen.h +++ b/src/frontends/gtk/GScreen.h @@ -12,7 +12,7 @@ #ifndef GSCREEN_H #define GSCREEN_H -#include "frontends/GuiCursor.h" +#include "frontends/WorkArea.h" #include diff --git a/src/frontends/gtk/GView.C b/src/frontends/gtk/GView.C index edaa95f853..6765f2197e 100644 --- a/src/frontends/gtk/GView.C +++ b/src/frontends/gtk/GView.C @@ -32,6 +32,7 @@ #include "funcrequest.h" #include "frontends/Toolbars.h" +#include "frontends/WorkArea.h" #include "support/filetools.h" #include "support/convert.h" @@ -159,7 +160,7 @@ bool GView::onFocusIn(GdkEventFocus * /*event*/) void GView::prohibitInput() const { - view()->hideCursor(); + workArea()->hideCursor(); const_cast(this)->set_sensitive(false); } @@ -191,7 +192,7 @@ void GView::setWindowTitle(string const & t, string const & /*it*/) void GView::busy(bool yes) const { if (yes ) { - view()->hideCursor(); + workArea()->hideCursor(); Gdk::Cursor cursor(Gdk::WATCH); const_cast(this)->get_window()->set_cursor(cursor); const_cast(this)->set_sensitive(false); diff --git a/src/frontends/gtk/GuiImplementation.C b/src/frontends/gtk/GuiImplementation.C index c61aa6aa9a..27123c79d4 100644 --- a/src/frontends/gtk/GuiImplementation.C +++ b/src/frontends/gtk/GuiImplementation.C @@ -32,7 +32,6 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int /*view_id old_screen_.reset(new GScreen(*old_work_area_.get())); work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get())); clipboard_.reset(new GuiClipboard(old_work_area_.get())); - guiCursor().connect(work_area_.get()); // FIXME BufferView creation should be independant of WorkArea creation buffer_views_[0].reset(new BufferView(view_.get())); diff --git a/src/frontends/qt3/GuiImplementation.h b/src/frontends/qt3/GuiImplementation.h index 55a4e34f79..28aa612ec6 100644 --- a/src/frontends/qt3/GuiImplementation.h +++ b/src/frontends/qt3/GuiImplementation.h @@ -75,7 +75,6 @@ public: old_screen_.reset(new FScreen(*old_work_area_.get())); work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get())); clipboard_.reset(new GuiClipboard(old_work_area_.get())); - guiCursor().connect(work_area_.get()); // FIXME BufferView creation should be independant of WorkArea creation buffer_views_[0].reset(new BufferView(view_.get())); diff --git a/src/frontends/qt4/GuiImplementation.C b/src/frontends/qt4/GuiImplementation.C index d85fa83512..ee720bf659 100644 --- a/src/frontends/qt4/GuiImplementation.C +++ b/src/frontends/qt4/GuiImplementation.C @@ -78,8 +78,6 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int view_id) view->mainWidget()->setCentralWidget(work_areas_[id].get()); - guiCursor().connect(work_areas_[id].get()); - return id; } -- 2.39.5