mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-26 18:07:18 +00:00
* frontends/WorkArea.h(workAreaResize, scrollDocView, workAreaKeyPress,
dispatch, selectionReuqested, selectionLost): remove signals * BufferView.[Ch] (selectionRequested, selectionLost, workAreaResize, workAreaKeyPress, workAreaDispatch): add forwarding functions to the pimpl * BufferView_pimpl.C (Pimpl): Remove the setup of the now deleted signals, also remove corresponding connection objects. * frontends/xforms/XWorkArea.h: * frontends/qt2/QWorkArea.h: * frontends/qt4/QWorkArea.h: * frontends/gtk/GWorkArea.h: add LyXView as class variable view_ (qt classes also get view() medthod) * frontends/qt2/QWorkArea.C: * frontends/qt2/QContentPane.C: * frontends/qt4/QWorkArea.C: * frontends/xforms/XWorkArea.C: * frontends/gtk/GWorkArea.C: Change from calling signals to call the functions directly through view_.view() git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13671 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b5cdc90ef9
commit
67d576f75e
@ -235,6 +235,36 @@ bool BufferView::dispatch(FuncRequest const & ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
void BufferView::scroll(int lines)
|
||||||
{
|
{
|
||||||
pimpl_->scroll(lines);
|
pimpl_->scroll(lines);
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#ifndef BUFFER_VIEW_H
|
#ifndef BUFFER_VIEW_H
|
||||||
#define BUFFER_VIEW_H
|
#define BUFFER_VIEW_H
|
||||||
|
|
||||||
|
#include "frontends/LyXKeySym.h"
|
||||||
|
|
||||||
#include "support/types.h"
|
#include "support/types.h"
|
||||||
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
@ -175,6 +177,20 @@ public:
|
|||||||
/// execute the given function
|
/// execute the given function
|
||||||
bool dispatch(FuncRequest const & argument);
|
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
|
/// clear the X selection
|
||||||
void unsetXSel();
|
void unsetXSel();
|
||||||
|
|
||||||
|
@ -116,14 +116,7 @@ unsigned int const saved_positions_num = 20;
|
|||||||
// to these connections we avoid a segfault upon startup, and also at exit.
|
// to these connections we avoid a segfault upon startup, and also at exit.
|
||||||
// (Lgb)
|
// (Lgb)
|
||||||
|
|
||||||
boost::signals::connection dispatchcon;
|
|
||||||
boost::signals::connection timecon;
|
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
|
/// Return an inset of this class if it exists at the current cursor position
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -153,22 +146,11 @@ BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
|
|||||||
screen_.reset(LyXScreenFactory::create(workarea()));
|
screen_.reset(LyXScreenFactory::create(workarea()));
|
||||||
|
|
||||||
// Setup the signals
|
// 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
|
timecon = cursor_timeout.timeout
|
||||||
.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
|
.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
|
||||||
|
|
||||||
cursor_timeout.start();
|
cursor_timeout.start();
|
||||||
|
|
||||||
saved_positions.resize(saved_positions_num);
|
saved_positions.resize(saved_positions_num);
|
||||||
// load saved bookmarks
|
// load saved bookmarks
|
||||||
lyx::Session::BookmarkList & bmList = LyX::ref().session().loadBookmarks();
|
lyx::Session::BookmarkList & bmList = LyX::ref().session().loadBookmarks();
|
||||||
|
@ -58,19 +58,6 @@ public:
|
|||||||
virtual std::string const getClipboard() const = 0;
|
virtual std::string const getClipboard() const = 0;
|
||||||
/// fill the clipboard
|
/// fill the clipboard
|
||||||
virtual void putClipboard(std::string const &) const = 0;
|
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
|
#endif // WORKAREA_H
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "GtkmmX.h"
|
#include "GtkmmX.h"
|
||||||
#include "GLyXKeySym.h"
|
#include "GLyXKeySym.h"
|
||||||
|
|
||||||
|
#include "BufferView.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
@ -172,7 +173,7 @@ void inputCommitRelay(GtkIMContext */*imcontext*/, gchar * str, GWorkArea * area
|
|||||||
|
|
||||||
|
|
||||||
GWorkArea::GWorkArea(LyXView & owner, int width, int height)
|
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)
|
adjusting_(false)
|
||||||
{
|
{
|
||||||
workArea_.set_size_request(width, height);
|
workArea_.set_size_request(width, height);
|
||||||
@ -331,7 +332,7 @@ bool GWorkArea::onConfigure(GdkEventConfigure * /*event*/)
|
|||||||
gtk_im_context_set_client_window(
|
gtk_im_context_set_client_window(
|
||||||
imContext_, workArea_.get_window()->gobj());
|
imContext_, workArea_.get_window()->gobj());
|
||||||
}
|
}
|
||||||
workAreaResize();
|
view_.view()->workAreaResize();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +375,7 @@ void GWorkArea::onScroll()
|
|||||||
adjusting_ = true;
|
adjusting_ = true;
|
||||||
|
|
||||||
double val = vscrollbar_.get_adjustment()->get_value();
|
double val = vscrollbar_.get_adjustment()->get_value();
|
||||||
scrollDocView(static_cast<int>(val));
|
view_.view()->scrollDocView(static_cast<int>(val));
|
||||||
adjusting_ = false;
|
adjusting_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +421,7 @@ bool GWorkArea::onButtonPress(GdkEventButton * event)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dispatch(FuncRequest(ka,
|
view_.view()->workAreaDispatch(FuncRequest(ka,
|
||||||
static_cast<int>(event->x),
|
static_cast<int>(event->x),
|
||||||
static_cast<int>(event->y),
|
static_cast<int>(event->y),
|
||||||
gButtonToLyx(event->button)));
|
gButtonToLyx(event->button)));
|
||||||
@ -431,7 +432,7 @@ bool GWorkArea::onButtonPress(GdkEventButton * event)
|
|||||||
|
|
||||||
bool GWorkArea::onButtonRelease(GdkEventButton * event)
|
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->x),
|
||||||
static_cast<int>(event->y),
|
static_cast<int>(event->y),
|
||||||
gButtonToLyx(event->button)));
|
gButtonToLyx(event->button)));
|
||||||
@ -456,7 +457,7 @@ bool GWorkArea::onMotionNotify(GdkEventMotion * event)
|
|||||||
}
|
}
|
||||||
timeBefore = event->time;
|
timeBefore = event->time;
|
||||||
}
|
}
|
||||||
dispatch(FuncRequest(LFUN_MOUSE_MOTION,
|
view_.view()->workAreaDispatch(FuncRequest(LFUN_MOUSE_MOTION,
|
||||||
static_cast<int>(event->x),
|
static_cast<int>(event->x),
|
||||||
static_cast<int>(event->y),
|
static_cast<int>(event->y),
|
||||||
gtkButtonState(event->state)));
|
gtkButtonState(event->state)));
|
||||||
@ -480,7 +481,7 @@ bool GWorkArea::onKeyPress(GdkEventKey * event)
|
|||||||
!inputGet) {
|
!inputGet) {
|
||||||
#endif
|
#endif
|
||||||
GLyXKeySym *glk = new GLyXKeySym(event->keyval);
|
GLyXKeySym *glk = new GLyXKeySym(event->keyval);
|
||||||
workAreaKeyPress(LyXKeySymPtr(glk),
|
view_.view()->workAreaKeyPress(LyXKeySymPtr(glk),
|
||||||
gtkKeyState(event->state));
|
gtkKeyState(event->state));
|
||||||
#ifdef I18N
|
#ifdef I18N
|
||||||
} else if (!inputCache_.empty())
|
} else if (!inputCache_.empty())
|
||||||
@ -493,7 +494,7 @@ bool GWorkArea::onKeyPress(GdkEventKey * event)
|
|||||||
void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
|
void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
|
||||||
guint /*info*/)
|
guint /*info*/)
|
||||||
{
|
{
|
||||||
selectionRequested();
|
view_.view()->selectionRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ private:
|
|||||||
bool onKeyPress(GdkEventKey * event);
|
bool onKeyPress(GdkEventKey * event);
|
||||||
void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
|
void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
|
||||||
void onClipboardClear();
|
void onClipboardClear();
|
||||||
|
LyXView & view_;
|
||||||
Gtk::HBox hbox_;
|
Gtk::HBox hbox_;
|
||||||
Gtk::DrawingArea workArea_;
|
Gtk::DrawingArea workArea_;
|
||||||
Gtk::VScrollbar vscrollbar_;
|
Gtk::VScrollbar vscrollbar_;
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "BufferView.h"
|
||||||
|
#include "frontends/LyXView.h"
|
||||||
|
|
||||||
// Qt defines a macro 'signals' that clashes with a boost namespace.
|
// Qt defines a macro 'signals' that clashes with a boost namespace.
|
||||||
// All is well if the namespace is visible first.
|
// All is well if the namespace is visible first.
|
||||||
#include "QWorkArea.h"
|
#include "QWorkArea.h"
|
||||||
@ -155,7 +158,7 @@ void QContentPane::generateSyntheticMouseEvent()
|
|||||||
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
|
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
|
||||||
|
|
||||||
// ... and dispatch the event to the LyX core.
|
// ... and dispatch the event to the LyX core.
|
||||||
wa_->dispatch(synthetic_mouse_event_.cmd);
|
wa_->view().view()->workAreaDispatch(synthetic_mouse_event_.cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +166,7 @@ void QContentPane::generateSyntheticMouseEvent()
|
|||||||
void QContentPane::scrollBarChanged(int val)
|
void QContentPane::scrollBarChanged(int val)
|
||||||
{
|
{
|
||||||
if (track_scrollbar_)
|
if (track_scrollbar_)
|
||||||
wa_->scrollDocView(val);
|
wa_->view().view()->scrollDocView(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -174,13 +177,13 @@ void QContentPane::mousePressEvent(QMouseEvent * e)
|
|||||||
FuncRequest cmd(LFUN_MOUSE_TRIPLE,
|
FuncRequest cmd(LFUN_MOUSE_TRIPLE,
|
||||||
dc_event_.x, dc_event_.y,
|
dc_event_.x, dc_event_.y,
|
||||||
q_button_state(dc_event_.state));
|
q_button_state(dc_event_.state));
|
||||||
wa_->dispatch(cmd);
|
wa_->view().view()->workAreaDispatch(cmd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
|
FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
|
||||||
q_button_state(e->button()));
|
q_button_state(e->button()));
|
||||||
wa_->dispatch(cmd);
|
wa_->view().view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -191,7 +194,7 @@ void QContentPane::mouseReleaseEvent(QMouseEvent * e)
|
|||||||
|
|
||||||
FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
|
FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
|
||||||
q_button_state(e->button()));
|
q_button_state(e->button()));
|
||||||
wa_->dispatch(cmd);
|
wa_->view().view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -251,7 +254,7 @@ void QContentPane::mouseMoveEvent(QMouseEvent * e)
|
|||||||
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
|
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
|
||||||
|
|
||||||
// ... and dispatch the event to the LyX core.
|
// ... and dispatch the event to the LyX core.
|
||||||
wa_->dispatch(cmd);
|
wa_->view().view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +292,7 @@ void QContentPane::keyeventTimeout()
|
|||||||
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
|
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
|
||||||
sym->set(ev.get());
|
sym->set(ev.get());
|
||||||
|
|
||||||
wa_->workAreaKeyPress(sym, q_key_state(ev->state()));
|
wa_->view().view()->workAreaKeyPress(sym, q_key_state(ev->state()));
|
||||||
keyeventQueue_.pop();
|
keyeventQueue_.pop();
|
||||||
|
|
||||||
handle_autos = false;
|
handle_autos = false;
|
||||||
@ -310,7 +313,7 @@ void QContentPane::doubleClickTimeout()
|
|||||||
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
|
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
|
||||||
dc_event_.x, dc_event_.y,
|
dc_event_.x, dc_event_.y,
|
||||||
q_button_state(dc_event_.state));
|
q_button_state(dc_event_.state));
|
||||||
wa_->dispatch(cmd);
|
wa_->view().view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -331,7 +334,7 @@ void QContentPane::resizeEvent(QResizeEvent *)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pixmap_->resize(width(), height());
|
pixmap_->resize(width(), height());
|
||||||
wa_->workAreaResize();
|
wa_->view().view()->workAreaResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -339,7 +342,7 @@ void QContentPane::paintEvent(QPaintEvent * e)
|
|||||||
{
|
{
|
||||||
if (!pixmap_.get()) {
|
if (!pixmap_.get()) {
|
||||||
pixmap_.reset(new QPixmap(width(), height()));
|
pixmap_.reset(new QPixmap(width(), height()));
|
||||||
wa_->workAreaResize();
|
wa_->view().view()->workAreaResize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "frontends/LyXView.h"
|
||||||
|
#include "BufferView.h"
|
||||||
|
|
||||||
#include "QWorkArea.h"
|
#include "QWorkArea.h"
|
||||||
|
|
||||||
#include "lcolorcache.h"
|
#include "lcolorcache.h"
|
||||||
@ -46,11 +49,11 @@ using std::string;
|
|||||||
namespace os = lyx::support::os;
|
namespace os = lyx::support::os;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
QWorkArea const * wa_ptr = 0;
|
QWorkArea * wa_ptr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWorkArea::QWorkArea(LyXView &, int, int)
|
QWorkArea::QWorkArea(LyXView & owner, int, int)
|
||||||
: WorkArea(), QWidget(qApp->mainWidget()), painter_(*this)
|
: WorkArea(), QWidget(qApp->mainWidget()), owner_(owner), painter_(*this)
|
||||||
{
|
{
|
||||||
scrollbar_ = new QScrollBar(QScrollBar::Vertical, this);
|
scrollbar_ = new QScrollBar(QScrollBar::Vertical, this);
|
||||||
content_ = new QContentPane(this);
|
content_ = new QContentPane(this);
|
||||||
@ -103,12 +106,12 @@ bool lyxX11EventFilter(XEvent * xev)
|
|||||||
case SelectionRequest:
|
case SelectionRequest:
|
||||||
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
||||||
if (wa_ptr)
|
if (wa_ptr)
|
||||||
wa_ptr->selectionRequested();
|
wa_ptr->view().view()->selectionRequested();
|
||||||
break;
|
break;
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
||||||
if (wa_ptr)
|
if (wa_ptr)
|
||||||
wa_ptr->selectionLost();
|
wa_ptr->view().view()->selectionLost();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -183,7 +186,7 @@ pascal OSErr handleOpenDocuments(const AppleEvent* inEvent,
|
|||||||
|
|
||||||
void QWorkArea::haveSelection(bool own) const
|
void QWorkArea::haveSelection(bool own) const
|
||||||
{
|
{
|
||||||
wa_ptr = this;
|
wa_ptr = const_cast<QWorkArea*>(this);
|
||||||
|
|
||||||
if (!QApplication::clipboard()->supportsSelection())
|
if (!QApplication::clipboard()->supportsSelection())
|
||||||
return;
|
return;
|
||||||
@ -230,7 +233,7 @@ void QWorkArea::dragEnterEvent(QDragEnterEvent * event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::dropEvent(QDropEvent* event)
|
void QWorkArea::dropEvent(QDropEvent * event)
|
||||||
{
|
{
|
||||||
QStringList files;
|
QStringList files;
|
||||||
|
|
||||||
@ -238,9 +241,9 @@ void QWorkArea::dropEvent(QDropEvent* event)
|
|||||||
lyxerr[Debug::GUI] << "QWorkArea::dropEvent: got URIs!"
|
lyxerr[Debug::GUI] << "QWorkArea::dropEvent: got URIs!"
|
||||||
<< endl;
|
<< endl;
|
||||||
for (QStringList::Iterator i = files.begin();
|
for (QStringList::Iterator i = files.begin();
|
||||||
i!=files.end(); ++i) {
|
i != files.end(); ++i) {
|
||||||
string const file = os::internal_path(fromqstr(*i));
|
string const file = os::internal_path(fromqstr(*i));
|
||||||
dispatch(FuncRequest(LFUN_FILE_OPEN, file));
|
view().view()->workAreaDispatch(FuncRequest(LFUN_FILE_OPEN, file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,15 @@ public:
|
|||||||
|
|
||||||
/// get the content pane widget
|
/// get the content pane widget
|
||||||
QWidget * getContent() const { return content_; }
|
QWidget * getContent() const { return content_; }
|
||||||
|
///
|
||||||
|
LyXView & view()
|
||||||
|
{
|
||||||
|
return owner_;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
|
/// The owning LyXView
|
||||||
|
LyXView & owner_;
|
||||||
|
|
||||||
/// scroll bar
|
/// scroll bar
|
||||||
QScrollBar * scrollbar_;
|
QScrollBar * scrollbar_;
|
||||||
/// content
|
/// content
|
||||||
|
@ -60,7 +60,7 @@ namespace os = lyx::support::os;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
QWorkArea const * wa_ptr = 0;
|
QWorkArea * wa_ptr = 0;
|
||||||
|
|
||||||
/// return the LyX key state from Qt's
|
/// return the LyX key state from Qt's
|
||||||
key_modifier::state q_key_state(Qt::ButtonState state)
|
key_modifier::state q_key_state(Qt::ButtonState state)
|
||||||
@ -120,8 +120,8 @@ SyntheticMouseEvent::SyntheticMouseEvent()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
QWorkArea::QWorkArea(LyXView &, int w, int h)
|
QWorkArea::QWorkArea(LyXView & owner, int w, int h)
|
||||||
: QAbstractScrollArea(qApp->mainWidget()), WorkArea(), painter_(this)
|
: QAbstractScrollArea(qApp->mainWidget()), WorkArea(), view_(owner), painter_(this)
|
||||||
{
|
{
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
@ -224,7 +224,7 @@ void QWorkArea::adjustViewWithScrollBar(int action)
|
|||||||
<< " linestep=" << verticalScrollBar()->lineStep()
|
<< " linestep=" << verticalScrollBar()->lineStep()
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
this->scrollDocView(verticalScrollBar()->sliderPosition());
|
view_.view()->scrollDocView(verticalScrollBar()->sliderPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ void QWorkArea::dropEvent(QDropEvent* event)
|
|||||||
for (QStringList::Iterator i = files.begin();
|
for (QStringList::Iterator i = files.begin();
|
||||||
i!=files.end(); ++i) {
|
i!=files.end(); ++i) {
|
||||||
string const file = os::internal_path(fromqstr(*i));
|
string const file = os::internal_path(fromqstr(*i));
|
||||||
dispatch(FuncRequest(LFUN_FILE_OPEN, file));
|
view_.view()->workAreaDispatch(FuncRequest(LFUN_FILE_OPEN, file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,13 +305,13 @@ void QWorkArea::mousePressEvent(QMouseEvent * e)
|
|||||||
FuncRequest cmd(LFUN_MOUSE_TRIPLE,
|
FuncRequest cmd(LFUN_MOUSE_TRIPLE,
|
||||||
dc_event_.x, dc_event_.y,
|
dc_event_.x, dc_event_.y,
|
||||||
q_button_state(dc_event_.state));
|
q_button_state(dc_event_.state));
|
||||||
this->dispatch(cmd);
|
view_.view()->workAreaDispatch(cmd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
|
FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
|
||||||
q_button_state(e->button()));
|
q_button_state(e->button()));
|
||||||
this->dispatch(cmd);
|
view_.view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ void QWorkArea::mouseReleaseEvent(QMouseEvent * e)
|
|||||||
|
|
||||||
FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
|
FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
|
||||||
q_button_state(e->button()));
|
q_button_state(e->button()));
|
||||||
this->dispatch(cmd);
|
view_.view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ void QWorkArea::mouseMoveEvent(QMouseEvent * e)
|
|||||||
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
|
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
|
||||||
|
|
||||||
// ... and dispatch the event to the LyX core.
|
// ... and dispatch the event to the LyX core.
|
||||||
this->dispatch(cmd);
|
view_.view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,7 +412,7 @@ void QWorkArea::generateSyntheticMouseEvent()
|
|||||||
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
|
synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
|
||||||
|
|
||||||
// ... and dispatch the event to the LyX core.
|
// ... and dispatch the event to the LyX core.
|
||||||
this->dispatch(synthetic_mouse_event_.cmd);
|
view_.view()->workAreaDispatch(synthetic_mouse_event_.cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ void QWorkArea::keyPressEvent(QKeyEvent * e)
|
|||||||
|
|
||||||
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
|
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
|
||||||
sym->set(e);
|
sym->set(e);
|
||||||
this->workAreaKeyPress(sym, q_key_state(e->state()));
|
view_.view()->workAreaKeyPress(sym, q_key_state(e->state()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +458,7 @@ void QWorkArea::keyeventTimeout()
|
|||||||
<< " key=" << ev->key()
|
<< " key=" << ev->key()
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
this->workAreaKeyPress(sym, q_key_state(ev->state()));
|
view_.view()->workAreaKeyPress(sym, q_key_state(ev->state()));
|
||||||
keyeventQueue_.pop();
|
keyeventQueue_.pop();
|
||||||
|
|
||||||
handle_autos = false;
|
handle_autos = false;
|
||||||
@ -481,7 +481,7 @@ void QWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
|
|||||||
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
|
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
|
||||||
dc_event_.x, dc_event_.y,
|
dc_event_.x, dc_event_.y,
|
||||||
q_button_state(dc_event_.state));
|
q_button_state(dc_event_.state));
|
||||||
this->dispatch(cmd);
|
view_.view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -495,7 +495,7 @@ void QWorkArea::resizeEvent(QResizeEvent * resizeEvent)
|
|||||||
screen_device_ = QPixmap(viewport()->width(), viewport()->height());
|
screen_device_ = QPixmap(viewport()->width(), viewport()->height());
|
||||||
paint_device_ = QImage(viewport()->width(), viewport()->height(), QImage::Format_RGB32);
|
paint_device_ = QImage(viewport()->width(), viewport()->height(), QImage::Format_RGB32);
|
||||||
|
|
||||||
this->workAreaResize();
|
view_.view()->workAreaResize();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
||||||
@ -538,6 +538,7 @@ void QWorkArea::paintEvent(QPaintEvent * e)
|
|||||||
q.drawPixmap(e->rect(), screen_device_, e->rect());
|
q.drawPixmap(e->rect(), screen_device_, e->rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap QWorkArea::copyScreen(int x, int y, int w, int h) const
|
QPixmap QWorkArea::copyScreen(int x, int y, int w, int h) const
|
||||||
{
|
{
|
||||||
return screen_device_.copy(x, y, w, h);
|
return screen_device_.copy(x, y, w, h);
|
||||||
@ -588,12 +589,12 @@ bool lyxX11EventFilter(XEvent * xev)
|
|||||||
case SelectionRequest:
|
case SelectionRequest:
|
||||||
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
||||||
if (wa_ptr)
|
if (wa_ptr)
|
||||||
wa_ptr->selectionRequested();
|
wa_ptr->view().view()->selectionRequested();
|
||||||
break;
|
break;
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
||||||
if (wa_ptr)
|
if (wa_ptr)
|
||||||
wa_ptr->selectionLost();
|
wa_ptr->view().view()->selectionLost();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -657,7 +658,7 @@ pascal OSErr handleOpenDocuments(const AppleEvent* inEvent,
|
|||||||
FSRefMakePath(&ref, (UInt8*)qstr_buf,
|
FSRefMakePath(&ref, (UInt8*)qstr_buf,
|
||||||
1024);
|
1024);
|
||||||
s_arg=QString::fromUtf8(qstr_buf);
|
s_arg=QString::fromUtf8(qstr_buf);
|
||||||
wa_ptr->dispatch(
|
wa_ptr->view().view()->workAreaDispatch(
|
||||||
FuncRequest(LFUN_FILE_OPEN,
|
FuncRequest(LFUN_FILE_OPEN,
|
||||||
fromqstr(s_arg)));
|
fromqstr(s_arg)));
|
||||||
break;
|
break;
|
||||||
|
@ -145,6 +145,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
void drawScreen(int x, int y, QPixmap pixmap);
|
void drawScreen(int x, int y, QPixmap pixmap);
|
||||||
|
|
||||||
|
LyXView & view()
|
||||||
|
{
|
||||||
|
return view_;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// repaint part of the widget
|
/// repaint part of the widget
|
||||||
@ -185,6 +189,8 @@ public slots:
|
|||||||
void adjustViewWithScrollBar(int action = 0);
|
void adjustViewWithScrollBar(int action = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
///
|
||||||
|
LyXView & view_;
|
||||||
|
|
||||||
/// Buffer view width.
|
/// Buffer view width.
|
||||||
int workWidth_;
|
int workWidth_;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "XWorkArea.h"
|
#include "XWorkArea.h"
|
||||||
|
#include "BufferView.h"
|
||||||
|
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "XFormsView.h"
|
#include "XFormsView.h"
|
||||||
@ -108,7 +109,7 @@ int C_event_cb(FL_FORM * form, void * xev)
|
|||||||
|
|
||||||
|
|
||||||
XWorkArea::XWorkArea(LyXView & owner, int w, int h)
|
XWorkArea::XWorkArea(LyXView & owner, int w, int h)
|
||||||
: workareapixmap(0), painter_(*this)
|
: view_(owner), workareapixmap(0), painter_(*this)
|
||||||
{
|
{
|
||||||
fl_freeze_all_forms();
|
fl_freeze_all_forms();
|
||||||
|
|
||||||
@ -219,7 +220,7 @@ void XWorkArea::redraw(int width, int height)
|
|||||||
height,
|
height,
|
||||||
fl_get_visual_depth());
|
fl_get_visual_depth());
|
||||||
|
|
||||||
workAreaResize();
|
view_.view()->workAreaResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -276,7 +277,7 @@ void XWorkArea::scroll_cb()
|
|||||||
<< "scroll: docheight: " << doc_height_ << endl;
|
<< "scroll: docheight: " << doc_height_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollDocView(int(val));
|
view_.view()->scrollDocView(int(val));
|
||||||
waitForX(false);
|
waitForX(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +332,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
|||||||
|
|
||||||
// Should really have used xbutton.state
|
// Should really have used xbutton.state
|
||||||
lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl;
|
lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl;
|
||||||
area->dispatch(
|
area->view_.view()->workAreaDispatch(
|
||||||
FuncRequest(LFUN_MOUSE_PRESS,
|
FuncRequest(LFUN_MOUSE_PRESS,
|
||||||
ev->xbutton.x - ob->x,
|
ev->xbutton.x - ob->x,
|
||||||
ev->xbutton.y - ob->y,
|
ev->xbutton.y - ob->y,
|
||||||
@ -349,7 +350,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
|||||||
|
|
||||||
lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl;
|
lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl;
|
||||||
|
|
||||||
area->dispatch(
|
area->view_.view()->workAreaDispatch(
|
||||||
FuncRequest(LFUN_MOUSE_RELEASE,
|
FuncRequest(LFUN_MOUSE_RELEASE,
|
||||||
ev->xbutton.x - ob->x,
|
ev->xbutton.x - ob->x,
|
||||||
ev->xbutton.y - ob->y,
|
ev->xbutton.y - ob->y,
|
||||||
@ -418,7 +419,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
|||||||
ev->xbutton.x - ob->x,
|
ev->xbutton.x - ob->x,
|
||||||
ev->xbutton.y - ob->y,
|
ev->xbutton.y - ob->y,
|
||||||
x_button_state(key));
|
x_button_state(key));
|
||||||
area->dispatch(cmd);
|
area->view_.view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -509,7 +510,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
|||||||
XLyXKeySym * xlk = new XLyXKeySym;
|
XLyXKeySym * xlk = new XLyXKeySym;
|
||||||
xlk->initFromKeySym(ret_key);
|
xlk->initFromKeySym(ret_key);
|
||||||
|
|
||||||
area->workAreaKeyPress(LyXKeySymPtr(xlk),
|
area->view_.view()->workAreaKeyPress(LyXKeySymPtr(xlk),
|
||||||
x_key_state(ret_state));
|
x_key_state(ret_state));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -542,7 +543,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
|||||||
ev->xbutton.x - ob->x,
|
ev->xbutton.x - ob->x,
|
||||||
ev->xbutton.y - ob->y,
|
ev->xbutton.y - ob->y,
|
||||||
x_button_state(key));
|
x_button_state(key));
|
||||||
area->dispatch(cmd);
|
area->view_.view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -558,7 +559,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
|||||||
ev->xbutton.x - ob->x,
|
ev->xbutton.x - ob->x,
|
||||||
ev->xbutton.y - ob->y,
|
ev->xbutton.y - ob->y,
|
||||||
x_button_state(key));
|
x_button_state(key));
|
||||||
area->dispatch(cmd);
|
area->view_.view()->workAreaDispatch(cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -601,11 +602,11 @@ int XWorkArea::event_cb(XEvent * xev)
|
|||||||
switch (xev->type) {
|
switch (xev->type) {
|
||||||
case SelectionRequest:
|
case SelectionRequest:
|
||||||
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
||||||
selectionRequested();
|
view_.view()->selectionRequested();
|
||||||
break;
|
break;
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
||||||
selectionLost();
|
view_.view()->selectionLost();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -65,6 +65,8 @@ public:
|
|||||||
/// handles SelectionRequest X Event, to fill the clipboard
|
/// handles SelectionRequest X Event, to fill the clipboard
|
||||||
int event_cb(XEvent * xev);
|
int event_cb(XEvent * xev);
|
||||||
private:
|
private:
|
||||||
|
LyXView & view_;
|
||||||
|
|
||||||
/// generate the pixmap, and copy backing pixmap to it,
|
/// generate the pixmap, and copy backing pixmap to it,
|
||||||
/// and send resize event if needed
|
/// and send resize event if needed
|
||||||
void redraw(int, int);
|
void redraw(int, int);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user