#include "GuiWorkArea.h"
#include "GuiApplication.h"
-#include "QLPainter.h"
-#include "QKeySymbol.h"
+#include "GuiPainter.h"
+#include "GuiKeySymbol.h"
#include "qt_helpers.h"
#include "frontends/LyXView.h"
#include "debug.h"
#include "FuncRequest.h"
#include "LyXRC.h"
-#include "rowpainter.h"
#include "version.h"
#include "support/filetools.h" // LibFileSearch
-#include "support/convert.h"
#include "graphics/GraphicsImage.h"
#include "graphics/GraphicsLoader.h"
int const CursorWidth = 1;
#endif
+#undef KeyPress
+#undef NoModifier
using std::endl;
using std::string;
using support::FileName;
-/// return the LyX key state from Qt's
-static key_modifier::state q_key_state(Qt::KeyboardModifiers state)
-{
- key_modifier::state k = key_modifier::none;
- if (state & Qt::ControlModifier)
- k |= key_modifier::ctrl;
- if (state & Qt::ShiftModifier)
- k |= key_modifier::shift;
- if (state & Qt::AltModifier || state & Qt::MetaModifier)
- k |= key_modifier::alt;
- return k;
-}
-
-
/// return the LyX mouse button state from Qt's
static mouse_button::state q_button_state(Qt::MouseButton button)
{
{}
-GuiWorkArea::GuiWorkArea(int w, int h, int id, LyXView & lyx_view)
- : WorkArea(id, lyx_view), need_resize_(false), schedule_redraw_(false),
+GuiWorkArea::GuiWorkArea(Buffer & buf, LyXView & lv)
+ : WorkArea(buf, lv), need_resize_(false), schedule_redraw_(false),
preedit_lines_(1)
{
screen_ = QPixmap(viewport()->width(), viewport()->height());
viewport()->setCursor(Qt::IBeamCursor);
- resize(w, h);
-
synthetic_mouse_event_.timeout.timeout.connect(
boost::bind(&GuiWorkArea::generateSyntheticMouseEvent,
this));
}
-void GuiWorkArea::adjustViewWithScrollBar(int)
+void GuiWorkArea::adjustViewWithScrollBar(int action)
{
- scrollBufferView(verticalScrollBar()->sliderPosition());
+ stopBlinkingCursor();
+ if (action == QAbstractSlider::SliderPageStepAdd)
+ buffer_view_->scrollDown(viewport()->height());
+ else if (action == QAbstractSlider::SliderPageStepSub)
+ buffer_view_->scrollUp(viewport()->height());
+ else
+ buffer_view_->scrollDocView(verticalScrollBar()->sliderPosition());
+
+ if (lyxrc.cursor_follows_scrollbar) {
+ buffer_view_->setCursorFromScrollbar();
+ lyx_view_->updateLayoutChoice();
+ }
+ // Show the cursor immediately after any operation.
+ startBlinkingCursor();
QApplication::syncX();
}
// if (theApp() == 0 || &lyx_view_ == theApp()->currentView())
// return;
- theApp()->setCurrentView(lyx_view_);
+ theApp()->setCurrentView(*lyx_view_);
// Repaint the whole screen.
// Note: this is different from redraw() as only the backing pixmap
// will be redrawn, which is cheap.
viewport()->repaint();
- // FIXME: it would be better to send a signal "newBuffer()"
- // in BufferList that could be connected to the different tabbars.
- lyx_view_.updateTab();
-
startBlinkingCursor();
}
<< " key=" << e->key()
<< endl;
- boost::shared_ptr<QKeySymbol> sym(new QKeySymbol);
+ boost::shared_ptr<GuiKeySymbol> sym(new GuiKeySymbol);
sym->set(e);
processKeySym(sym, q_key_state(e->modifiers()));
}
-void GuiWorkArea::doubleClickTimeout() {
+
+void GuiWorkArea::doubleClickTimeout()
+{
dc_event_.active = false;
}
+
void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
{
dc_event_ = double_click(e);
}
-void GuiWorkArea::doGreyOut(QLPainter & pain)
-{
- pain.fillRectangle(0, 0, width(), height(),
- Color::bottomarea);
-
- //if (!lyxrc.show_banner)
- // return;
- LYXERR(Debug::GUI) << "show banner: " << lyxrc.show_banner << endl;
- /// The text to be written on top of the pixmap
- QString const text = lyx_version ? QString(lyx_version) : qt_("unknown version");
- FileName const file = support::libFileSearch("images", "banner", "png");
- if (file.empty())
- return;
-
- QPixmap pm(toqstr(file.absFilename()));
- if (!pm) {
- lyxerr << "could not load splash screen: '" << file << "'" << endl;
- return;
- }
-
- QFont font;
- // The font used to display the version info
- font.setStyleHint(QFont::SansSerif);
- font.setWeight(QFont::Bold);
- font.setPointSize(convert<int>(lyxrc.font_sizes[Font::SIZE_LARGE]));
-
- int const w = pm.width();
- int const h = pm.height();
-
- int x = (width() - w) / 2;
- int y = (height() - h) / 2;
-
- pain.drawPixmap(x, y, pm);
-
- x += 260;
- y += 270;
-
- pain.setPen(QColor(255, 255, 0));
- pain.setFont(font);
- pain.drawText(x, y, text);
-}
-
-
void GuiWorkArea::paintEvent(QPaintEvent * ev)
{
QRect const rc = ev->rect();
void GuiWorkArea::updateScreen()
{
- QLPainter pain(&screen_);
-
- if (greyed_out_) {
- LYXERR(Debug::GUI) << "splash screen requested" << endl;
- verticalScrollBar()->hide();
- doGreyOut(pain);
- return;
- }
-
+ GuiPainter pain(&screen_);
verticalScrollBar()->show();
- paintText(*buffer_view_, pain);
+ buffer_view_->draw(pain);
}
void GuiWorkArea::showCursor(int x, int y, int h, CursorShape shape)
{
if (schedule_redraw_) {
- if (buffer_view_ && buffer_view_->buffer()) {
- buffer_view_->update(Update::Force);
- updateScreen();
- viewport()->update(QRect(0, 0, viewport()->width(), viewport()->height()));
- }
+ buffer_view_->update(Update::Force);
+ updateScreen();
+ viewport()->update(QRect(0, 0, viewport()->width(), viewport()->height()));
schedule_redraw_ = false;
// Show the cursor immediately after the update.
hideCursor();
docstring const & preedit_string
= qstring_to_ucs4(e->preeditString());
- if(greyed_out_) {
- e->ignore();
- return;
- }
-
if (!commit_string.isEmpty()) {
LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
return;
}
- QLPainter pain(&screen_);
+ GuiPainter pain(&screen_);
buffer_view_->updateMetrics(false);
- paintText(*buffer_view_, pain);
+ buffer_view_->draw(pain);
Font font = buffer_view_->cursor().getFont();
FontMetrics const & fm = theFontMetrics(font);
int height = fm.maxHeight();