mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 11:08:41 +00:00
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
This commit is contained in:
parent
7dcf1bdb26
commit
e7b69c030e
@ -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();
|
||||
|
@ -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
|
||||
|
@ -14,13 +14,12 @@
|
||||
#ifndef BASE_GUI_H
|
||||
#define BASE_GUI_H
|
||||
|
||||
#include "frontends/GuiCursor.h"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
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<int, boost::shared_ptr<BufferView> > buffer_views_;
|
||||
|
||||
private:
|
||||
///
|
||||
GuiCursor cursor_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -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 <config.h>
|
||||
|
||||
#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
|
@ -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
|
@ -32,8 +32,6 @@ libfrontends_la_SOURCES = \
|
||||
Toolbars.h \
|
||||
Clipboard.h \
|
||||
Gui.h \
|
||||
GuiCursor.C \
|
||||
GuiCursor.h \
|
||||
WorkArea.C \
|
||||
WorkArea.h \
|
||||
font_metrics.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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef GSCREEN_H
|
||||
#define GSCREEN_H
|
||||
|
||||
#include "frontends/GuiCursor.h"
|
||||
#include "frontends/WorkArea.h"
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
|
@ -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<GView*>(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<GView *>(this)->get_window()->set_cursor(cursor);
|
||||
const_cast<GView *>(this)->set_sensitive(false);
|
||||
|
@ -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()));
|
||||
|
@ -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()));
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user