mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
This commit transfers most of the LyXView use from BufferView to WorkArea, most notably:
LyXView::updateLayoutChoice(); LyXView::updateToolbars(); LyXView::getLyXFunc().processKeySym(key, state); LyXView::dispatch(cmd); * BufferView - workAreaKeyPress(): deleted * BufferView::pimpl - gui(): deleted - workAreaKeyPress(): deleted - workAreaDispatch(): special FuncRequest transfered to WorkArea::dispatch() * WorkArea - WorkArea(): now needs a LyXView - lyx_view: new member - scrollBufferView(): new method * qt4/GuiWorkArea: adapted to above changes * qt4/GuiImplementation: ditto * qt3/GuiWorkArea: ditto * qt3/QContentPane: ditto * gtk/GuiWorkArea: ditto * gtk/GWorkArea: ditto git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14695 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d147703f9b
commit
f475b7bde6
@ -232,12 +232,6 @@ void BufferView::workAreaResize(int width, int height)
|
||||
}
|
||||
|
||||
|
||||
void BufferView::workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state)
|
||||
{
|
||||
pimpl_->workAreaKeyPress(key, state);
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::workAreaDispatch(FuncRequest const & ev)
|
||||
{
|
||||
return pimpl_->workAreaDispatch(ev);
|
||||
|
@ -182,9 +182,6 @@ public:
|
||||
///
|
||||
void workAreaResize(int width, int height);
|
||||
|
||||
/// Receive a keypress
|
||||
void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
|
||||
|
||||
/// a function should be executed from the workarea
|
||||
bool workAreaDispatch(FuncRequest const & ev);
|
||||
|
||||
|
@ -231,12 +231,6 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
}
|
||||
|
||||
|
||||
lyx::frontend::Gui & BufferView::Pimpl::gui() const
|
||||
{
|
||||
return owner_->gui();
|
||||
}
|
||||
|
||||
|
||||
int BufferView::Pimpl::width() const
|
||||
{
|
||||
return width_;
|
||||
@ -470,7 +464,6 @@ void BufferView::Pimpl::scrollDocView(int value)
|
||||
t.setCursorFromCoordinates(cur, 0, newy);
|
||||
}
|
||||
}
|
||||
owner_->updateLayoutChoice();
|
||||
}
|
||||
|
||||
|
||||
@ -496,13 +489,6 @@ void BufferView::Pimpl::scroll(int /*lines*/)
|
||||
}
|
||||
|
||||
|
||||
void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
|
||||
key_modifier::state state)
|
||||
{
|
||||
owner_->getLyXFunc().processKeySym(key, state);
|
||||
}
|
||||
|
||||
|
||||
void BufferView::Pimpl::selectionRequested()
|
||||
{
|
||||
static string sel;
|
||||
@ -556,8 +542,6 @@ void BufferView::Pimpl::workAreaResize(int width, int height)
|
||||
|
||||
if (widthChange || heightChange)
|
||||
update();
|
||||
|
||||
owner_->updateLayoutChoice();
|
||||
}
|
||||
|
||||
|
||||
@ -845,12 +829,6 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
||||
// LFUN_FILE_OPEN generated by drag-and-drop.
|
||||
FuncRequest cmd = cmd0;
|
||||
|
||||
// Handle drag&drop
|
||||
if (cmd.action == LFUN_FILE_OPEN) {
|
||||
owner_->dispatch(cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!buffer_)
|
||||
return false;
|
||||
|
||||
@ -899,16 +877,6 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
||||
update(Update::FitCursor | Update::MultiParSel);
|
||||
}
|
||||
|
||||
// Skip these when selecting
|
||||
if (cmd.action != LFUN_MOUSE_MOTION) {
|
||||
owner_->updateLayoutChoice();
|
||||
owner_->updateToolbars();
|
||||
}
|
||||
|
||||
// Slight hack: this is only called currently when we
|
||||
// clicked somewhere, so we force through the display
|
||||
// of the new status here.
|
||||
owner_->clearMessage();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,6 @@ public:
|
||||
/// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
|
||||
void scroll(int lines);
|
||||
///
|
||||
void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
|
||||
///
|
||||
void selectionRequested();
|
||||
///
|
||||
void selectionLost();
|
||||
@ -97,9 +95,6 @@ public:
|
||||
/// a function should be executed
|
||||
bool dispatch(FuncRequest const & ev);
|
||||
|
||||
/// the frontend
|
||||
lyx::frontend::Gui & gui() const;
|
||||
|
||||
/// Width and height of the BufferView in Pixels
|
||||
/**
|
||||
This is set externally by the workAreaResize method.
|
||||
|
@ -16,7 +16,9 @@
|
||||
#include "WorkArea.h"
|
||||
|
||||
#include "font_metrics.h"
|
||||
#include "funcrequest.h"
|
||||
#include "lyx_gui.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "Painter.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
@ -31,6 +33,7 @@
|
||||
#include "lyxrc.h"
|
||||
#include "lyxrow.h"
|
||||
#include "lyxtext.h"
|
||||
#include "LyXView.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "paragraph.h"
|
||||
#include "rowpainter.h"
|
||||
@ -135,8 +138,8 @@ boost::signals::connection timecon;
|
||||
|
||||
} // anon namespace
|
||||
|
||||
WorkArea::WorkArea(BufferView * buffer_view)
|
||||
: buffer_view_(buffer_view), greyed_out_(true),
|
||||
WorkArea::WorkArea(LyXView & lyx_view)
|
||||
: buffer_view_(0), lyx_view_(lyx_view), greyed_out_(true),
|
||||
cursor_visible_(false), cursor_timeout_(400)
|
||||
{
|
||||
// Start loading the pixmap as soon as possible
|
||||
@ -211,7 +214,7 @@ void WorkArea::processKeySym(LyXKeySymPtr key,
|
||||
key_modifier::state state)
|
||||
{
|
||||
hideCursor();
|
||||
buffer_view_->workAreaKeyPress(key, state);
|
||||
lyx_view_.getLyXFunc().processKeySym(key, state);
|
||||
|
||||
/* This is perhaps a bit of a hack. When we move
|
||||
* around, or type, it's nice to be able to see
|
||||
@ -222,7 +225,7 @@ void WorkArea::processKeySym(LyXKeySymPtr key,
|
||||
*/
|
||||
// if (buffer_view_->available())
|
||||
toggleCursor();
|
||||
|
||||
|
||||
// uneeded "redraw()" call commented out for now.
|
||||
// When/if the call to LyXView::redrawWorkArea() in "lyxfunc.C:1610"
|
||||
// is not needed anymore, this line should be uncommented out
|
||||
@ -232,7 +235,25 @@ void WorkArea::processKeySym(LyXKeySymPtr key,
|
||||
|
||||
void WorkArea::dispatch(FuncRequest const & cmd0)
|
||||
{
|
||||
// Handle drag&drop
|
||||
if (cmd0.action == LFUN_FILE_OPEN) {
|
||||
lyx_view_.dispatch(cmd0);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer_view_->workAreaDispatch(cmd0);
|
||||
|
||||
// Skip these when selecting
|
||||
if (cmd0.action != LFUN_MOUSE_MOTION) {
|
||||
lyx_view_.updateLayoutChoice();
|
||||
lyx_view_.updateToolbars();
|
||||
}
|
||||
|
||||
// Slight hack: this is only called currently when we
|
||||
// clicked somewhere, so we force through the display
|
||||
// of the new status here.
|
||||
lyx_view_.clearMessage();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
@ -240,6 +261,15 @@ void WorkArea::dispatch(FuncRequest const & cmd0)
|
||||
void WorkArea::resizeBufferView()
|
||||
{
|
||||
buffer_view_->workAreaResize(width(), height());
|
||||
lyx_view_.updateLayoutChoice();
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
void WorkArea::scrollBufferView(int position)
|
||||
{
|
||||
buffer_view_->scrollDocView(position);
|
||||
lyx_view_.updateLayoutChoice();
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ int const CursorShape = CursorShape;
|
||||
|
||||
class BufferView;
|
||||
class FuncRequest;
|
||||
class LyXView;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
@ -62,7 +63,7 @@ enum CursorShape {
|
||||
*/
|
||||
class WorkArea {
|
||||
public:
|
||||
WorkArea(BufferView * buffer_view = 0);
|
||||
WorkArea(LyXView & lyx_view);
|
||||
|
||||
virtual ~WorkArea() {}
|
||||
|
||||
@ -109,11 +110,13 @@ public:
|
||||
/// FIXME: This is public because of qt3 and gtk, should be protected
|
||||
void dispatch(FuncRequest const & cmd0);
|
||||
|
||||
protected:
|
||||
///
|
||||
/// FIXME: This is public because of qt3 and gtk, should be protected
|
||||
void resizeBufferView();
|
||||
|
||||
/// FIXME: This is public because of qt3 and gtk, should be protected
|
||||
void scrollBufferView(int position);
|
||||
|
||||
protected:
|
||||
/// hide the visible cursor, if it is visible
|
||||
void hideCursor();
|
||||
|
||||
@ -132,6 +135,9 @@ protected:
|
||||
///
|
||||
BufferView * buffer_view_;
|
||||
|
||||
///
|
||||
LyXView & lyx_view_;
|
||||
|
||||
private:
|
||||
///
|
||||
void checkAndGreyOut();
|
||||
|
@ -376,8 +376,7 @@ void GWorkArea::onScroll()
|
||||
adjusting_ = true;
|
||||
|
||||
double val = vscrollbar_.get_adjustment()->get_value();
|
||||
view_.view()->scrollDocView(static_cast<int>(val));
|
||||
view_.workArea()->redraw();
|
||||
view_.workArea()->scrollBufferView(static_cast<int>(val));
|
||||
adjusting_ = false;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,12 @@ public:
|
||||
/// a selection exists
|
||||
virtual void haveSelection(bool);
|
||||
void inputCommit(gchar * str);
|
||||
|
||||
LyXView & view()
|
||||
{
|
||||
return view_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool onExpose(GdkEventExpose * event);
|
||||
bool onConfigure(GdkEventConfigure * event);
|
||||
|
@ -27,7 +27,7 @@ namespace frontend {
|
||||
class GuiWorkArea: public lyx::frontend::WorkArea {
|
||||
public:
|
||||
GuiWorkArea(GScreen * screen, GWorkArea * work_area)
|
||||
: old_screen_(screen), old_work_area_(work_area)
|
||||
: WorkArea(work_area->view()), old_screen_(screen), old_work_area_(work_area)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ typedef QWorkArea FWorkArea;
|
||||
class GuiWorkArea: public lyx::frontend::WorkArea {
|
||||
public:
|
||||
GuiWorkArea(FScreen * screen, FWorkArea * work_area)
|
||||
: old_screen_(screen), old_work_area_(work_area)
|
||||
: WorkArea(work_area->view()), old_screen_(screen), old_work_area_(work_area)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -169,10 +169,8 @@ void QContentPane::generateSyntheticMouseEvent()
|
||||
|
||||
void QContentPane::scrollBarChanged(int val)
|
||||
{
|
||||
if (track_scrollbar_) {
|
||||
wa_->view().view()->scrollDocView(val);
|
||||
wa_->view().workArea()->redraw();
|
||||
}
|
||||
if (track_scrollbar_)
|
||||
wa_->view().workArea()->scrollBufferView(val);
|
||||
}
|
||||
|
||||
|
||||
@ -340,7 +338,7 @@ void QContentPane::resizeEvent(QResizeEvent *)
|
||||
}
|
||||
|
||||
pixmap_->resize(width(), height());
|
||||
wa_->view().view()->workAreaResize(width(), height());
|
||||
wa_->view().workArea()->resizeBufferView();
|
||||
}
|
||||
|
||||
|
||||
@ -350,7 +348,7 @@ void QContentPane::paintEvent(QPaintEvent * e)
|
||||
|
||||
if (!pixmap_.get()) {
|
||||
pixmap_.reset(new QPixmap(width(), height()));
|
||||
buffer_view_->workAreaResize(width(), height());
|
||||
wa_->view().workArea()->resizeBufferView();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int view_id)
|
||||
|
||||
GuiView * view = views_[view_id].get();
|
||||
|
||||
work_areas_[id].reset(new GuiWorkArea(w, h, view));
|
||||
work_areas_[id].reset(new GuiWorkArea(w, h, *view));
|
||||
|
||||
// FIXME BufferView creation should be independant of WorkArea creation
|
||||
buffer_views_[id].reset(new BufferView(view));
|
||||
|
@ -117,8 +117,8 @@ SyntheticMouseEvent::SyntheticMouseEvent()
|
||||
{}
|
||||
|
||||
|
||||
GuiWorkArea::GuiWorkArea(int w, int h, QWidget * parent, BufferView * buffer_view)
|
||||
: QAbstractScrollArea(parent), WorkArea(buffer_view), painter_(this)
|
||||
GuiWorkArea::GuiWorkArea(int w, int h, LyXView & lyx_view)
|
||||
: WorkArea(lyx_view), painter_(this)
|
||||
{
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
@ -137,7 +137,6 @@ GuiWorkArea::GuiWorkArea(int w, int h, QWidget * parent, BufferView * buffer_vie
|
||||
viewport()->setCursor(Qt::IBeamCursor);
|
||||
|
||||
resize(w, h);
|
||||
show();
|
||||
workWidth_ = w;
|
||||
workHeight_ = h;
|
||||
|
||||
@ -197,18 +196,7 @@ void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step
|
||||
|
||||
void GuiWorkArea::adjustViewWithScrollBar(int)
|
||||
{
|
||||
/*
|
||||
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
||||
<< " verticalScrollBar val=" << verticalScrollBar()->value()
|
||||
<< " verticalScrollBar pos=" << verticalScrollBar()->sliderPosition()
|
||||
<< " min=" << verticalScrollBar()->minimum()
|
||||
<< " max=" << verticalScrollBar()->maximum()
|
||||
<< " pagestep=" << verticalScrollBar()->pageStep()
|
||||
<< " linestep=" << verticalScrollBar()->lineStep()
|
||||
<< endl;
|
||||
*/
|
||||
buffer_view_->scrollDocView(verticalScrollBar()->sliderPosition());
|
||||
redraw();
|
||||
scrollBufferView(verticalScrollBar()->sliderPosition());
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,7 +101,7 @@ class GuiWorkArea: public QAbstractScrollArea, public WorkArea {
|
||||
|
||||
public:
|
||||
|
||||
GuiWorkArea(int width, int height, QWidget * parent, BufferView * buffer_view = 0);
|
||||
GuiWorkArea(int width, int height, LyXView & lyx_view);
|
||||
|
||||
virtual ~GuiWorkArea();
|
||||
/// return the width of the content pane
|
||||
|
Loading…
Reference in New Issue
Block a user