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 using lyx::support::libFileSearch;
55 GuiCursor::GuiCursor()
56 : cursor_visible_(false), work_area_(0)
61 GuiCursor::~GuiCursor()
65 void GuiCursor::connect(WorkArea * work_area)
67 work_area_ = work_area;
71 void GuiCursor::show(BufferView & bv)
79 CursorShape shape = BAR_SHAPE;
81 LyXText const & text = *bv.getLyXText();
82 LyXFont const & realfont = text.real_current_font;
83 BufferParams const & bp = bv.buffer()->params();
84 bool const samelang = realfont.language() == bp.language;
85 bool const isrtl = realfont.isVisibleRightToLeft();
87 if (!samelang || isrtl != bp.language->rightToLeft()) {
90 shape = REVERSED_L_SHAPE;
93 // The ERT language hack needs fixing up
94 if (realfont.language() == latex_language)
97 LyXFont const font = bv.cursor().getFont();
98 int const asc = font_metrics::maxAscent(font);
99 int const des = font_metrics::maxDescent(font);
103 bv.cursor().getPos(x, y);
105 //lyxerr << "Cursor::show x: " << x << " y: " << y << endl;
107 BOOST_ASSERT(work_area_);
109 // if it doesn't touch the screen, don't try to show it
110 if (y + h < 0 || y >= work_area_->height())
113 cursor_visible_ = true;
114 work_area_->showCursor(x, y, h, shape);
118 void GuiCursor::hide()
120 if (!cursor_visible_)
123 cursor_visible_ = false;
124 BOOST_ASSERT(work_area_);
125 work_area_->removeCursor();
129 void GuiCursor::toggle(BufferView & bv)
138 void GuiCursor::prepare()
140 cursor_visible_ = false;
143 } // namespace frontend