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:
Abdelrazak Younes 2006-08-15 21:57:23 +00:00
parent d147703f9b
commit f475b7bde6
14 changed files with 61 additions and 80 deletions

View File

@ -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) bool BufferView::workAreaDispatch(FuncRequest const & ev)
{ {
return pimpl_->workAreaDispatch(ev); return pimpl_->workAreaDispatch(ev);

View File

@ -182,9 +182,6 @@ public:
/// ///
void workAreaResize(int width, int height); 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 /// a function should be executed from the workarea
bool workAreaDispatch(FuncRequest const & ev); bool workAreaDispatch(FuncRequest const & ev);

View File

@ -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 int BufferView::Pimpl::width() const
{ {
return width_; return width_;
@ -470,7 +464,6 @@ void BufferView::Pimpl::scrollDocView(int value)
t.setCursorFromCoordinates(cur, 0, newy); 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() void BufferView::Pimpl::selectionRequested()
{ {
static string sel; static string sel;
@ -556,8 +542,6 @@ void BufferView::Pimpl::workAreaResize(int width, int height)
if (widthChange || heightChange) if (widthChange || heightChange)
update(); update();
owner_->updateLayoutChoice();
} }
@ -845,12 +829,6 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
// LFUN_FILE_OPEN generated by drag-and-drop. // LFUN_FILE_OPEN generated by drag-and-drop.
FuncRequest cmd = cmd0; FuncRequest cmd = cmd0;
// Handle drag&drop
if (cmd.action == LFUN_FILE_OPEN) {
owner_->dispatch(cmd);
return true;
}
if (!buffer_) if (!buffer_)
return false; return false;
@ -899,16 +877,6 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
update(Update::FitCursor | Update::MultiParSel); 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; return true;
} }

View File

@ -69,8 +69,6 @@ public:
/// Wheel mouse scroll, move by multiples of text->defaultRowHeight(). /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
void scroll(int lines); void scroll(int lines);
/// ///
void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
///
void selectionRequested(); void selectionRequested();
/// ///
void selectionLost(); void selectionLost();
@ -97,9 +95,6 @@ public:
/// a function should be executed /// a function should be executed
bool dispatch(FuncRequest const & ev); bool dispatch(FuncRequest const & ev);
/// the frontend
lyx::frontend::Gui & gui() const;
/// Width and height of the BufferView in Pixels /// Width and height of the BufferView in Pixels
/** /**
This is set externally by the workAreaResize method. This is set externally by the workAreaResize method.

View File

@ -16,7 +16,9 @@
#include "WorkArea.h" #include "WorkArea.h"
#include "font_metrics.h" #include "font_metrics.h"
#include "funcrequest.h"
#include "lyx_gui.h" #include "lyx_gui.h"
#include "lyxfunc.h"
#include "Painter.h" #include "Painter.h"
#include "BufferView.h" #include "BufferView.h"
@ -31,6 +33,7 @@
#include "lyxrc.h" #include "lyxrc.h"
#include "lyxrow.h" #include "lyxrow.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "LyXView.h"
#include "metricsinfo.h" #include "metricsinfo.h"
#include "paragraph.h" #include "paragraph.h"
#include "rowpainter.h" #include "rowpainter.h"
@ -135,8 +138,8 @@ boost::signals::connection timecon;
} // anon namespace } // anon namespace
WorkArea::WorkArea(BufferView * buffer_view) WorkArea::WorkArea(LyXView & lyx_view)
: buffer_view_(buffer_view), greyed_out_(true), : buffer_view_(0), lyx_view_(lyx_view), greyed_out_(true),
cursor_visible_(false), cursor_timeout_(400) cursor_visible_(false), cursor_timeout_(400)
{ {
// Start loading the pixmap as soon as possible // Start loading the pixmap as soon as possible
@ -211,7 +214,7 @@ void WorkArea::processKeySym(LyXKeySymPtr key,
key_modifier::state state) key_modifier::state state)
{ {
hideCursor(); hideCursor();
buffer_view_->workAreaKeyPress(key, state); lyx_view_.getLyXFunc().processKeySym(key, state);
/* This is perhaps a bit of a hack. When we move /* This is perhaps a bit of a hack. When we move
* around, or type, it's nice to be able to see * around, or type, it's nice to be able to see
@ -232,7 +235,25 @@ void WorkArea::processKeySym(LyXKeySymPtr key,
void WorkArea::dispatch(FuncRequest const & cmd0) void WorkArea::dispatch(FuncRequest const & cmd0)
{ {
// Handle drag&drop
if (cmd0.action == LFUN_FILE_OPEN) {
lyx_view_.dispatch(cmd0);
return;
}
buffer_view_->workAreaDispatch(cmd0); 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(); redraw();
} }
@ -240,6 +261,15 @@ void WorkArea::dispatch(FuncRequest const & cmd0)
void WorkArea::resizeBufferView() void WorkArea::resizeBufferView()
{ {
buffer_view_->workAreaResize(width(), height()); buffer_view_->workAreaResize(width(), height());
lyx_view_.updateLayoutChoice();
redraw();
}
void WorkArea::scrollBufferView(int position)
{
buffer_view_->scrollDocView(position);
lyx_view_.updateLayoutChoice();
redraw(); redraw();
} }

View File

@ -37,6 +37,7 @@ int const CursorShape = CursorShape;
class BufferView; class BufferView;
class FuncRequest; class FuncRequest;
class LyXView;
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
@ -62,7 +63,7 @@ enum CursorShape {
*/ */
class WorkArea { class WorkArea {
public: public:
WorkArea(BufferView * buffer_view = 0); WorkArea(LyXView & lyx_view);
virtual ~WorkArea() {} virtual ~WorkArea() {}
@ -109,11 +110,13 @@ public:
/// FIXME: This is public because of qt3 and gtk, should be protected /// FIXME: This is public because of qt3 and gtk, should be protected
void dispatch(FuncRequest const & cmd0); void dispatch(FuncRequest const & cmd0);
protected: /// FIXME: This is public because of qt3 and gtk, should be protected
///
void resizeBufferView(); 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 /// hide the visible cursor, if it is visible
void hideCursor(); void hideCursor();
@ -132,6 +135,9 @@ protected:
/// ///
BufferView * buffer_view_; BufferView * buffer_view_;
///
LyXView & lyx_view_;
private: private:
/// ///
void checkAndGreyOut(); void checkAndGreyOut();

View File

@ -376,8 +376,7 @@ void GWorkArea::onScroll()
adjusting_ = true; adjusting_ = true;
double val = vscrollbar_.get_adjustment()->get_value(); double val = vscrollbar_.get_adjustment()->get_value();
view_.view()->scrollDocView(static_cast<int>(val)); view_.workArea()->scrollBufferView(static_cast<int>(val));
view_.workArea()->redraw();
adjusting_ = false; adjusting_ = false;
} }

View File

@ -82,6 +82,12 @@ public:
/// a selection exists /// a selection exists
virtual void haveSelection(bool); virtual void haveSelection(bool);
void inputCommit(gchar * str); void inputCommit(gchar * str);
LyXView & view()
{
return view_;
}
private: private:
bool onExpose(GdkEventExpose * event); bool onExpose(GdkEventExpose * event);
bool onConfigure(GdkEventConfigure * event); bool onConfigure(GdkEventConfigure * event);

View File

@ -27,7 +27,7 @@ namespace frontend {
class GuiWorkArea: public lyx::frontend::WorkArea { class GuiWorkArea: public lyx::frontend::WorkArea {
public: public:
GuiWorkArea(GScreen * screen, GWorkArea * work_area) 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)
{ {
} }

View File

@ -30,7 +30,7 @@ typedef QWorkArea FWorkArea;
class GuiWorkArea: public lyx::frontend::WorkArea { class GuiWorkArea: public lyx::frontend::WorkArea {
public: public:
GuiWorkArea(FScreen * screen, FWorkArea * work_area) 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)
{ {
} }

View File

@ -169,10 +169,8 @@ void QContentPane::generateSyntheticMouseEvent()
void QContentPane::scrollBarChanged(int val) void QContentPane::scrollBarChanged(int val)
{ {
if (track_scrollbar_) { if (track_scrollbar_)
wa_->view().view()->scrollDocView(val); wa_->view().workArea()->scrollBufferView(val);
wa_->view().workArea()->redraw();
}
} }
@ -340,7 +338,7 @@ void QContentPane::resizeEvent(QResizeEvent *)
} }
pixmap_->resize(width(), height()); 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()) { if (!pixmap_.get()) {
pixmap_.reset(new QPixmap(width(), height())); pixmap_.reset(new QPixmap(width(), height()));
buffer_view_->workAreaResize(width(), height()); wa_->view().workArea()->resizeBufferView();
return; return;
} }

View File

@ -75,7 +75,7 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int view_id)
GuiView * view = views_[view_id].get(); 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 // FIXME BufferView creation should be independant of WorkArea creation
buffer_views_[id].reset(new BufferView(view)); buffer_views_[id].reset(new BufferView(view));

View File

@ -117,8 +117,8 @@ SyntheticMouseEvent::SyntheticMouseEvent()
{} {}
GuiWorkArea::GuiWorkArea(int w, int h, QWidget * parent, BufferView * buffer_view) GuiWorkArea::GuiWorkArea(int w, int h, LyXView & lyx_view)
: QAbstractScrollArea(parent), WorkArea(buffer_view), painter_(this) : WorkArea(lyx_view), painter_(this)
{ {
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -137,7 +137,6 @@ GuiWorkArea::GuiWorkArea(int w, int h, QWidget * parent, BufferView * buffer_vie
viewport()->setCursor(Qt::IBeamCursor); viewport()->setCursor(Qt::IBeamCursor);
resize(w, h); resize(w, h);
show();
workWidth_ = w; workWidth_ = w;
workHeight_ = h; workHeight_ = h;
@ -197,18 +196,7 @@ void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step
void GuiWorkArea::adjustViewWithScrollBar(int) void GuiWorkArea::adjustViewWithScrollBar(int)
{ {
/* scrollBufferView(verticalScrollBar()->sliderPosition());
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();
} }

View File

@ -101,7 +101,7 @@ class GuiWorkArea: public QAbstractScrollArea, public WorkArea {
public: public:
GuiWorkArea(int width, int height, QWidget * parent, BufferView * buffer_view = 0); GuiWorkArea(int width, int height, LyXView & lyx_view);
virtual ~GuiWorkArea(); virtual ~GuiWorkArea();
/// return the width of the content pane /// return the width of the content pane