#undef emit
#endif
-#include "funcrequest.h"
-#include "frontends/Timeout.h"
-
#include "WorkArea.h"
#include "QLPainter.h"
#include "LyXView.h"
+#include "funcrequest.h"
+#include "frontends/Timeout.h"
+
#include <QAbstractScrollArea>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QKeyEvent>
#include <QPaintEvent>
#include <QTimer>
-
-#include <boost/scoped_ptr.hpp>
+#include <QImage>
+#include <QPixmap>
#include <queue>
/**
* Qt-specific implementation of the work area
* (buffer view GUI)
- *
- * It consists of a content pane widget, and a scrollbar.
- * Hopefully soon we can just use QScrollView ...
- */
+*/
class QWorkArea : public QAbstractScrollArea, public WorkArea {
Q_OBJECT
virtual ~QWorkArea();
/// return the width of the content pane
- virtual int workWidth() const { return viewport()->width(); }
+ virtual int workWidth() const { return workWidth_; }
+
/// return the height of the content pane
- virtual int workHeight() const { return viewport()->height(); }
+ virtual int workHeight() const { return workHeight_; }
///
virtual void setScrollbarParams(int height, int pos, int line_height);
/// a selection exists
virtual void haveSelection(bool) const;
+
///
virtual std::string const getClipboard() const;
+
///
virtual void putClipboard(std::string const &) const;
+
///
virtual void dragEnterEvent(QDragEnterEvent * event);
+
///
virtual void dropEvent(QDropEvent* event);
-
+
/// return the widget's painter
- virtual Painter & getPainter();
+ virtual Painter & getPainter() { return (Painter &) painter_; }
- //virtual QPaintDevice & paintDevice() { return content_->pixmap(); }
/// return the backing pixmap
- QPixmap * pixmap() const { return pixmap_.get(); }
-
- /// return the widget's painter
-// virtual QLPainter & getQLPainter();
+ QPaintDevice * paintDevice() { return &paint_device_; }
- /// get the content pane widget
- QWidget * getContent() const;
+ /// update the passed area.
+ void update(int x, int y, int w, int h);
+ /// return a screen copy of the defined area.
+ QPixmap copyScreen(int x, int y, int w, int h) const;
+ /// Draw a pixmap onto the backing pixmap.
+ /**
+ QPixmap is implicitely shared so no need to pass by reference.
+ */
+ void drawScreen(int x, int y, QPixmap pixmap);
+ LyXView & view()
+ {
+ return view_;
+ }
protected:
-
-// void scrollContentsBy(int dx, int dy);
/// repaint part of the widget
void paintEvent(QPaintEvent * e);
-
/// widget has been resized
void resizeEvent(QResizeEvent * e);
-
/// mouse button press
void mousePressEvent(QMouseEvent * e);
/// mouse button release
void keyPressEvent(QKeyEvent * e);
#if USE_INPUT_METHODS
+protected:
/// IM events
- void QWorkArea::inputMethodEvent(QInputMethodEvent * e)
+ void QWorkArea::inputMethodEvent(QInputMethodEvent * e)
#endif
public slots:
+ /// Timeout event Slot for keyboard bufferring.
+ /// \todo This is not used currently in the code, remove?
void keyeventTimeout();
- void adjustViewWithScrollBar(int action);
-
-protected:
+ /// Adjust the LyX buffer view with the position of the scrollbar.
+ /**
+ * The action argument is not used in the the code, it is there
+ * only for the connection to the vertical srollbar signal which
+ * emits an 'int' action.
+ */
+ void adjustViewWithScrollBar(int action = 0);
private:
+ ///
+ LyXView & view_;
+
+ /// Buffer view width.
+ int workWidth_;
+
+ /// Buffer view height.
+ int workHeight_;
- /// our painter
+ /// Our painter.
QLPainter painter_;
/// The slot connected to SyntheticMouseEvent::timeout.
void generateSyntheticMouseEvent();
+ ///
SyntheticMouseEvent synthetic_mouse_event_;
- /// the double buffered pixmap
- boost::scoped_ptr<QPixmap> pixmap_;
+ /// Our client side painting device.
+ QImage paint_device_;
+ /// Our server side painting device.
+ QPixmap screen_device_;
+
+ /// \todo remove
QTimer step_timer_;
+
+ /// \todo remove
std::queue<boost::shared_ptr<QKeyEvent> > keyeventQueue_;
double_click dc_event_;
-
- bool scrolled_with_mouse_;
- bool scrolled_with_keyboard_;
};
#endif // QWORKAREA_H