3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
11 * Splash screen code added by Angus Leeming
16 #include "frontends/GuiCursor.h"
18 #include "font_metrics.h"
20 #include "frontends/Painter.h"
21 #include "frontends/WorkArea.h"
23 #include "BufferView.h"
25 #include "bufferparams.h"
26 #include "coordcache.h"
35 #include "metricsinfo.h"
36 #include "paragraph.h"
37 #include "rowpainter.h"
40 #include "graphics/GraphicsImage.h"
41 #include "graphics/GraphicsLoader.h"
43 #include "support/filetools.h" // LibFileSearch
45 #include <boost/utility.hpp>
46 #include <boost/bind.hpp>
47 #include <boost/signals/trackable.hpp>
49 using lyx::support::libFileSearch;
59 GuiCursor::GuiCursor()
60 : cursor_visible_(false), work_area_(NULL)
65 GuiCursor::~GuiCursor()
69 void GuiCursor::connect(WorkArea * work_area)
71 work_area_ = work_area;
75 void GuiCursor::show(BufferView & bv)
83 Cursor_Shape shape = BAR_SHAPE;
85 LyXText const & text = *bv.getLyXText();
86 LyXFont const & realfont = text.real_current_font;
87 BufferParams const & bp = bv.buffer()->params();
88 bool const samelang = realfont.language() == bp.language;
89 bool const isrtl = realfont.isVisibleRightToLeft();
91 if (!samelang || isrtl != bp.language->rightToLeft()) {
94 shape = REVERSED_L_SHAPE;
97 // The ERT language hack needs fixing up
98 if (realfont.language() == latex_language)
101 LyXFont const font = bv.cursor().getFont();
102 int const asc = font_metrics::maxAscent(font);
103 int const des = font_metrics::maxDescent(font);
107 bv.cursor().getPos(x, y);
109 //lyxerr << "Cursor::show x: " << x << " y: " << y << endl;
111 BOOST_ASSERT(work_area_);
113 // if it doesn't touch the screen, don't try to show it
114 if (y + h < 0 || y >= work_area_->height())
117 cursor_visible_ = true;
118 work_area_->showCursor(x, y, h, shape);
122 void GuiCursor::hide()
124 if (!cursor_visible_)
127 cursor_visible_ = false;
128 BOOST_ASSERT(work_area_);
129 work_area_->removeCursor();
133 void GuiCursor::toggle(BufferView & bv)
142 void GuiCursor::prepare()
144 cursor_visible_ = false;
147 } // namespace frontend