}
+void BufferView::selectionRequested()
+{
+ pimpl_->selectionRequested();
+}
+
+
+void BufferView::selectionLost()
+{
+ pimpl_->selectionLost();
+}
+
+
+void BufferView::workAreaResize()
+{
+ pimpl_->workAreaResize();
+}
+
+
+void BufferView::workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state)
+{
+ pimpl_->workAreaKeyPress(key, state);
+}
+
+
+bool BufferView::workAreaDispatch(FuncRequest const & ev)
+{
+ return pimpl_->workAreaDispatch(ev);
+}
+
+
void BufferView::scroll(int lines)
{
pimpl_->scroll(lines);
#ifndef BUFFER_VIEW_H
#define BUFFER_VIEW_H
+#include "frontends/LyXKeySym.h"
+
#include "support/types.h"
#include <boost/utility.hpp>
/// execute the given function
bool dispatch(FuncRequest const & argument);
+ ///
+ void selectionRequested();
+ ///
+ void selectionLost();
+
+ ///
+ void workAreaResize();
+
+ /// Receive a keypress
+ void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
+
+ /// a function should be executed from the workarea
+ bool workAreaDispatch(FuncRequest const & ev);
+
/// clear the X selection
void unsetXSel();
// to these connections we avoid a segfault upon startup, and also at exit.
// (Lgb)
-boost::signals::connection dispatchcon;
boost::signals::connection timecon;
-boost::signals::connection doccon;
-boost::signals::connection resizecon;
-boost::signals::connection kpresscon;
-boost::signals::connection selectioncon;
-boost::signals::connection lostcon;
-
/// Return an inset of this class if it exists at the current cursor position
template <class T>
screen_.reset(LyXScreenFactory::create(workarea()));
// Setup the signals
- doccon = workarea().scrollDocView
- .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
- resizecon = workarea().workAreaResize
- .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
- dispatchcon = workarea().dispatch
- .connect(boost::bind(&BufferView::Pimpl::workAreaDispatch, this, _1));
- kpresscon = workarea().workAreaKeyPress
- .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
- selectioncon = workarea().selectionRequested
- .connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
- lostcon = workarea().selectionLost
- .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
-
timecon = cursor_timeout.timeout
.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
+
cursor_timeout.start();
+
saved_positions.resize(saved_positions_num);
// load saved bookmarks
lyx::Session::BookmarkList & bmList = LyX::ref().session().loadBookmarks();
virtual std::string const getClipboard() const = 0;
/// fill the clipboard
virtual void putClipboard(std::string const &) const = 0;
-
- /// work area dimensions have changed
- boost::signal<void()> workAreaResize;
- /// the scrollbar has changed
- boost::signal<void(int)> scrollDocView;
- /// a key combination has been pressed
- boost::signal<void(LyXKeySymPtr, key_modifier::state)> workAreaKeyPress;
- /// some mouse event
- boost::signal<void(FuncRequest)> dispatch;
- /// emitted when an X client has requested our selection
- boost::signal<void()> selectionRequested;
- /// emitted when another X client has stolen our selection
- boost::signal<void()> selectionLost;
};
#endif // WORKAREA_H
#include "GtkmmX.h"
#include "GLyXKeySym.h"
+#include "BufferView.h"
#include "debug.h"
#include "funcrequest.h"
#include "LColor.h"
GWorkArea::GWorkArea(LyXView & owner, int width, int height)
- : workAreaPixmap_(0), painter_(*this), draw_(0), colorHandler_(*this),
+ : view_(owner), workAreaPixmap_(0), painter_(*this), draw_(0), colorHandler_(*this),
adjusting_(false)
{
workArea_.set_size_request(width, height);
gtk_im_context_set_client_window(
imContext_, workArea_.get_window()->gobj());
}
- workAreaResize();
+ view_.view()->workAreaResize();
return true;
}
adjusting_ = true;
double val = vscrollbar_.get_adjustment()->get_value();
- scrollDocView(static_cast<int>(val));
+ view_.view()->scrollDocView(static_cast<int>(val));
adjusting_ = false;
}
default:
break;
}
- dispatch(FuncRequest(ka,
+ view_.view()->workAreaDispatch(FuncRequest(ka,
static_cast<int>(event->x),
static_cast<int>(event->y),
gButtonToLyx(event->button)));
bool GWorkArea::onButtonRelease(GdkEventButton * event)
{
- dispatch(FuncRequest(LFUN_MOUSE_RELEASE,
+ view_.view()->workAreaDispatch(FuncRequest(LFUN_MOUSE_RELEASE,
static_cast<int>(event->x),
static_cast<int>(event->y),
gButtonToLyx(event->button)));
}
timeBefore = event->time;
}
- dispatch(FuncRequest(LFUN_MOUSE_MOTION,
+ view_.view()->workAreaDispatch(FuncRequest(LFUN_MOUSE_MOTION,
static_cast<int>(event->x),
static_cast<int>(event->y),
gtkButtonState(event->state)));
!inputGet) {
#endif
GLyXKeySym *glk = new GLyXKeySym(event->keyval);
- workAreaKeyPress(LyXKeySymPtr(glk),
+ view_.view()->workAreaKeyPress(LyXKeySymPtr(glk),
gtkKeyState(event->state));
#ifdef I18N
} else if (!inputCache_.empty())
void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
guint /*info*/)
{
- selectionRequested();
+ view_.view()->selectionRequested();
}
}
-// ENCODING: Gtk::Clipboard returns UTF-8, we assume that the backend
+// ENCODING: Gtk::Clipboard returns UTF-8, we assume that the backend
// wants ISO-8859-1 and convert it to that.
string const GWorkArea::getClipboard() const
{
}
-// ENCODING: we assume that the backend passes us ISO-8859-1 and
+// ENCODING: we assume that the backend passes us ISO-8859-1 and
// convert from that to UTF-8 before passing to GTK
void GWorkArea::putClipboard(string const & str) const
{
bool onKeyPress(GdkEventKey * event);
void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
void onClipboardClear();
+ LyXView & view_;
Gtk::HBox hbox_;
Gtk::DrawingArea workArea_;
Gtk::VScrollbar vscrollbar_;
#include <config.h>
+#include "BufferView.h"
+#include "frontends/LyXView.h"
+
// Qt defines a macro 'signals' that clashes with a boost namespace.
// All is well if the namespace is visible first.
#include "QWorkArea.h"
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
// ... and dispatch the event to the LyX core.
- wa_->dispatch(synthetic_mouse_event_.cmd);
+ wa_->view().view()->workAreaDispatch(synthetic_mouse_event_.cmd);
}
}
void QContentPane::scrollBarChanged(int val)
{
if (track_scrollbar_)
- wa_->scrollDocView(val);
+ wa_->view().view()->scrollDocView(val);
}
FuncRequest cmd(LFUN_MOUSE_TRIPLE,
dc_event_.x, dc_event_.y,
q_button_state(dc_event_.state));
- wa_->dispatch(cmd);
+ wa_->view().view()->workAreaDispatch(cmd);
return;
}
FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
q_button_state(e->button()));
- wa_->dispatch(cmd);
+ wa_->view().view()->workAreaDispatch(cmd);
}
FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
q_button_state(e->button()));
- wa_->dispatch(cmd);
+ wa_->view().view()->workAreaDispatch(cmd);
}
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
// ... and dispatch the event to the LyX core.
- wa_->dispatch(cmd);
+ wa_->view().view()->workAreaDispatch(cmd);
}
}
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
sym->set(ev.get());
- wa_->workAreaKeyPress(sym, q_key_state(ev->state()));
+ wa_->view().view()->workAreaKeyPress(sym, q_key_state(ev->state()));
keyeventQueue_.pop();
handle_autos = false;
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
dc_event_.x, dc_event_.y,
q_button_state(dc_event_.state));
- wa_->dispatch(cmd);
+ wa_->view().view()->workAreaDispatch(cmd);
}
}
pixmap_->resize(width(), height());
- wa_->workAreaResize();
+ wa_->view().view()->workAreaResize();
}
{
if (!pixmap_.get()) {
pixmap_.reset(new QPixmap(width(), height()));
- wa_->workAreaResize();
+ wa_->view().view()->workAreaResize();
return;
}
#include <config.h>
+#include "frontends/LyXView.h"
+#include "BufferView.h"
+
#include "QWorkArea.h"
#include "lcolorcache.h"
namespace os = lyx::support::os;
namespace {
-QWorkArea const * wa_ptr = 0;
+QWorkArea * wa_ptr = 0;
}
-QWorkArea::QWorkArea(LyXView &, int, int)
- : WorkArea(), QWidget(qApp->mainWidget()), painter_(*this)
+QWorkArea::QWorkArea(LyXView & owner, int, int)
+ : WorkArea(), QWidget(qApp->mainWidget()), owner_(owner), painter_(*this)
{
scrollbar_ = new QScrollBar(QScrollBar::Vertical, this);
content_ = new QContentPane(this);
case SelectionRequest:
lyxerr[Debug::GUI] << "X requested selection." << endl;
if (wa_ptr)
- wa_ptr->selectionRequested();
+ wa_ptr->view().view()->selectionRequested();
break;
case SelectionClear:
lyxerr[Debug::GUI] << "Lost selection." << endl;
if (wa_ptr)
- wa_ptr->selectionLost();
+ wa_ptr->view().view()->selectionLost();
break;
}
return false;
void QWorkArea::haveSelection(bool own) const
{
- wa_ptr = this;
+ wa_ptr = const_cast<QWorkArea*>(this);
if (!QApplication::clipboard()->supportsSelection())
return;
}
-void QWorkArea::dropEvent(QDropEvent* event)
+void QWorkArea::dropEvent(QDropEvent * event)
{
QStringList files;
lyxerr[Debug::GUI] << "QWorkArea::dropEvent: got URIs!"
<< endl;
for (QStringList::Iterator i = files.begin();
- i!=files.end(); ++i) {
+ i != files.end(); ++i) {
string const file = os::internal_path(fromqstr(*i));
- dispatch(FuncRequest(LFUN_FILE_OPEN, file));
+ view().view()->workAreaDispatch(FuncRequest(LFUN_FILE_OPEN, file));
}
}
}
/// get the content pane widget
QWidget * getContent() const { return content_; }
+ ///
+ LyXView & view()
+ {
+ return owner_;
+ }
private:
+ /// The owning LyXView
+ LyXView & owner_;
+
/// scroll bar
QScrollBar * scrollbar_;
/// content
namespace {
-QWorkArea const * wa_ptr = 0;
+QWorkArea * wa_ptr = 0;
/// return the LyX key state from Qt's
key_modifier::state q_key_state(Qt::ButtonState state)
{}
-QWorkArea::QWorkArea(LyXView &, int w, int h)
- : QAbstractScrollArea(qApp->mainWidget()), WorkArea(), painter_(this)
+QWorkArea::QWorkArea(LyXView & owner, int w, int h)
+ : QAbstractScrollArea(qApp->mainWidget()), WorkArea(), view_(owner), painter_(this)
{
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
<< " linestep=" << verticalScrollBar()->lineStep()
<< endl;
- this->scrollDocView(verticalScrollBar()->sliderPosition());
+ view_.view()->scrollDocView(verticalScrollBar()->sliderPosition());
}
for (QStringList::Iterator i = files.begin();
i!=files.end(); ++i) {
string const file = os::internal_path(fromqstr(*i));
- dispatch(FuncRequest(LFUN_FILE_OPEN, file));
+ view_.view()->workAreaDispatch(FuncRequest(LFUN_FILE_OPEN, file));
}
}
}
FuncRequest cmd(LFUN_MOUSE_TRIPLE,
dc_event_.x, dc_event_.y,
q_button_state(dc_event_.state));
- this->dispatch(cmd);
+ view_.view()->workAreaDispatch(cmd);
return;
}
FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
q_button_state(e->button()));
- this->dispatch(cmd);
+ view_.view()->workAreaDispatch(cmd);
}
FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
q_button_state(e->button()));
- this->dispatch(cmd);
+ view_.view()->workAreaDispatch(cmd);
}
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
// ... and dispatch the event to the LyX core.
- this->dispatch(cmd);
+ view_.view()->workAreaDispatch(cmd);
}
}
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
// ... and dispatch the event to the LyX core.
- this->dispatch(synthetic_mouse_event_.cmd);
+ view_.view()->workAreaDispatch(synthetic_mouse_event_.cmd);
}
}
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
sym->set(e);
- this->workAreaKeyPress(sym, q_key_state(e->state()));
+ view_.view()->workAreaKeyPress(sym, q_key_state(e->state()));
}
continue;
}
- boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
+ boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
sym->set(ev.get());
- lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
- << " count=" << ev->count()
- << " text=" << (const char *) ev->text()
- << " isAutoRepeat=" << ev->isAutoRepeat()
- << " key=" << ev->key()
- << endl;
+ lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
+ << " count=" << ev->count()
+ << " text=" << (const char *) ev->text()
+ << " isAutoRepeat=" << ev->isAutoRepeat()
+ << " key=" << ev->key()
+ << endl;
- this->workAreaKeyPress(sym, q_key_state(ev->state()));
+ view_.view()->workAreaKeyPress(sym, q_key_state(ev->state()));
keyeventQueue_.pop();
handle_autos = false;
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
dc_event_.x, dc_event_.y,
q_button_state(dc_event_.state));
- this->dispatch(cmd);
+ view_.view()->workAreaDispatch(cmd);
}
screen_device_ = QPixmap(viewport()->width(), viewport()->height());
paint_device_ = QImage(viewport()->width(), viewport()->height(), QImage::Format_RGB32);
- this->workAreaResize();
+ view_.view()->workAreaResize();
/*
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
q.drawPixmap(e->rect(), screen_device_, e->rect());
}
+
QPixmap QWorkArea::copyScreen(int x, int y, int w, int h) const
{
return screen_device_.copy(x, y, w, h);
case SelectionRequest:
lyxerr[Debug::GUI] << "X requested selection." << endl;
if (wa_ptr)
- wa_ptr->selectionRequested();
+ wa_ptr->view().view()->selectionRequested();
break;
case SelectionClear:
lyxerr[Debug::GUI] << "Lost selection." << endl;
if (wa_ptr)
- wa_ptr->selectionLost();
+ wa_ptr->view().view()->selectionLost();
break;
}
return false;
FSRefMakePath(&ref, (UInt8*)qstr_buf,
1024);
s_arg=QString::fromUtf8(qstr_buf);
- wa_ptr->dispatch(
+ wa_ptr->view().view()->workAreaDispatch(
FuncRequest(LFUN_FILE_OPEN,
fromqstr(s_arg)));
break;
*/
void drawScreen(int x, int y, QPixmap pixmap);
+ LyXView & view()
+ {
+ return view_;
+ }
protected:
/// repaint part of the widget
void adjustViewWithScrollBar(int action = 0);
private:
-
+ ///
+ LyXView & view_;
+
/// Buffer view width.
int workWidth_;
#include <config.h>
#include "XWorkArea.h"
+#include "BufferView.h"
#include "Color.h"
#include "XFormsView.h"
XWorkArea::XWorkArea(LyXView & owner, int w, int h)
- : workareapixmap(0), painter_(*this)
+ : view_(owner), workareapixmap(0), painter_(*this)
{
fl_freeze_all_forms();
height,
fl_get_visual_depth());
- workAreaResize();
+ view_.view()->workAreaResize();
}
<< "scroll: docheight: " << doc_height_ << endl;
}
- scrollDocView(int(val));
+ view_.view()->scrollDocView(int(val));
waitForX(false);
}
// Should really have used xbutton.state
lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl;
- area->dispatch(
+ area->view_.view()->workAreaDispatch(
FuncRequest(LFUN_MOUSE_PRESS,
ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl;
- area->dispatch(
+ area->view_.view()->workAreaDispatch(
FuncRequest(LFUN_MOUSE_RELEASE,
ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
x_button_state(key));
- area->dispatch(cmd);
+ area->view_.view()->workAreaDispatch(cmd);
}
break;
}
XLyXKeySym * xlk = new XLyXKeySym;
xlk->initFromKeySym(ret_key);
- area->workAreaKeyPress(LyXKeySymPtr(xlk),
+ area->view_.view()->workAreaKeyPress(LyXKeySymPtr(xlk),
x_key_state(ret_state));
break;
}
ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
x_button_state(key));
- area->dispatch(cmd);
+ area->view_.view()->workAreaDispatch(cmd);
}
break;
ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
x_button_state(key));
- area->dispatch(cmd);
+ area->view_.view()->workAreaDispatch(cmd);
}
break;
switch (xev->type) {
case SelectionRequest:
lyxerr[Debug::GUI] << "X requested selection." << endl;
- selectionRequested();
+ view_.view()->selectionRequested();
break;
case SelectionClear:
lyxerr[Debug::GUI] << "Lost selection." << endl;
- selectionLost();
+ view_.view()->selectionLost();
break;
}
return 0;
/// handles SelectionRequest X Event, to fill the clipboard
int event_cb(XEvent * xev);
private:
+ LyXView & view_;
+
/// generate the pixmap, and copy backing pixmap to it,
/// and send resize event if needed
void redraw(int, int);