#include "lcolorcache.h"
#include "qt_helpers.h"
-
+#include "BufferView.h"
#include "debug.h"
#include "funcrequest.h"
#include "LColor.h"
using lyx::support::subst;
#endif
-// You can find other qt-immodule, X11 and MACX specific stuff
+// You can find other qt-immodule, X11 and MACX specific stuff
// at the end of this file...
///////////////////////////////////////////////////////////////
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);
synthetic_mouse_event_.timeout.timeout.connect(
boost::bind(&QWorkArea::generateSyntheticMouseEvent,
this));
-
+
// Initialize the vertical Scroll Bar
QObject::connect(verticalScrollBar(), SIGNAL(actionTriggered(int)),
this, SLOT(adjustViewWithScrollBar(int)));
// PageStep only depends on the viewport height.
- verticalScrollBar()->setPageStep(workHeight_);
+ verticalScrollBar()->setPageStep(workHeight_);
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
<< "\n Area width\t" << width()
<< " linestep=" << verticalScrollBar()->lineStep()
<< endl;
- this->scrollDocView(verticalScrollBar()->sliderPosition());
+ view_.view()->scrollDocView(verticalScrollBar()->sliderPosition());
}
void QWorkArea::haveSelection(bool own) const
{
- wa_ptr = this;
+ /// \todo ask X11 and MAC devels why this wa_ptr is useful.
+ wa_ptr = const_cast<QWorkArea*>(this);
if (!QApplication::clipboard()->supportsSelection())
return;
#ifdef Q_WS_MACX
// The MAC clipboard uses \r for lineendings, and we use \n
QApplication::clipboard()->setText(toqstr(subst(str, '\n', '\r')),
- QClipboard::Selection);
+ QClipboard::Selection);
#else
- QApplication::clipboard()->setText(toqstr(str), QClipboard::Selection);
+ QApplication::clipboard()->setText(toqstr(str), QClipboard::Selection);
#endif
lyxerr[Debug::ACTION] << "putClipboard: " << str << endl;
}
/// \todo Ask lyx-devel is this is enough:
/// if (event->mimeData()->hasFormat("text/plain"))
- /// event->acceptProposedAction();
+ /// event->acceptProposedAction();
}
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()));
+
}
// This is not used for now...
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);
}
verticalScrollBar()->setPageStep(viewport()->height());
screen_device_ = QPixmap(viewport()->width(), viewport()->height());
- paint_device_ = QImage(viewport()->width(), viewport()->height(), QImage::Format_RGB32);\r
+ paint_device_ = QImage(viewport()->width(), viewport()->height(), QImage::Format_RGB32);
+
+ view_.view()->workAreaResize();
- this->workAreaResize();
-\r
/*
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
<< "\n QWidget width\t" << this->QWidget::width()
<< "\n viewport height\t" << viewport()->height()
<< "\n QResizeEvent rect left\t" << rect().left()
<< "\n QResizeEvent rect right\t" << rect().right()
- << endl;\r
+ << endl;
*/
}
-void QWorkArea::update(int x, int y, int w, int h)\r
-{\r
- //screen_device_.fromImage(paint_device_);\r
- QPainter q(&screen_device_);\r
- q.drawImage(x, y, paint_device_.copy(x, y, w, h));\r
- \r
- viewport()->update(x, y, w, h);\r
-}\r
-\r
+void QWorkArea::update(int x, int y, int w, int h)
+{
+ //screen_device_.fromImage(paint_device_);
+ QPainter q(&screen_device_);
+ q.drawImage(x, y, paint_device_.copy(x, y, w, h));
+
+ viewport()->update(x, y, w, h);
+}
+
void QWorkArea::paintEvent(QPaintEvent * e)
-{\r
+{
/*
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
<< "\n QWidget width\t" << this->width()
<< "\n QPaintEvent y\t" << e->rect().y()
<< "\n QPaintEvent w\t" << e->rect().width()
<< "\n QPaintEvent h\t" << e->rect().height()
- << endl;\r
+ << endl;
*/
QPainter q(viewport());
q.drawPixmap(e->rect(), screen_device_, e->rect());
}
-\r
-QPixmap QWorkArea::copyScreen(int x, int y, int w, int h) const\r
-{\r
- return screen_device_.copy(x, y, w, h);\r
-}\r
-\r
-void QWorkArea::drawScreen(int x, int y, QPixmap pixmap)\r
-{\r
- QPainter q(&screen_device_);\r
- q.drawPixmap(x, y, pixmap);\r
- viewport()->update(x, y, pixmap.width(), pixmap.height());\r
-}\r
+
+
+QPixmap QWorkArea::copyScreen(int x, int y, int w, int h) const
+{
+ return screen_device_.copy(x, y, w, h);
+}
+
+void QWorkArea::drawScreen(int x, int y, QPixmap pixmap)
+{
+ QPainter q(&screen_device_);
+ q.drawPixmap(x, y, pixmap);
+ viewport()->update(x, y, pixmap.width(), pixmap.height());
+}
///////////////////////////////////////////////////////////////
#if USE_INPUT_METHODS
// to make qt-immodule work
-void QWorkArea::inputMethodEvent(QInputMethodEvent * e)
+void QWorkArea::inputMethodEvent(QInputMethodEvent * e)
{
QString const text = e->text();
if (!text.isEmpty()) {
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;