- p->viewport()->update(x, y, w, h);
-}
-
-
-void GuiWorkArea::paintEvent(QPaintEvent * ev)
-{
- QRectF const rc = ev->rect();
- // LYXERR(Debug::PAINTING, "paintEvent begin: x: " << rc.x()
- // << " y: " << rc.y() << " w: " << rc.width() << " h: " << rc.height());
-
- if (d->needResize()) {
- d->resetScreen();
- d->resizeBufferView();
- if (d->cursor_visible_) {
- d->hideCursor();
- d->showCursor();
- }
- }
-
- QPainter pain(viewport());
- double const pr = pixelRatio();
- QRectF const rcs = QRectF(rc.x() * pr, rc.y() * pr, rc.width() * pr, rc.height() * pr);
-
- if (lyxrc.use_qimage) {
- QImage const & image = static_cast<QImage const &>(*d->screen_);
- pain.drawImage(rc, image, rcs);
- } else {
- QPixmap const & pixmap = static_cast<QPixmap const &>(*d->screen_);
- pain.drawPixmap(rc, pixmap, rcs);
- }
- d->cursor_->draw(pain);
- ev->accept();
-}
-
-
-void GuiWorkArea::Private::updateScreen()
-{
- GuiPainter pain(screen_, p->pixelRatio());
- buffer_view_->draw(pain);
-}
-
-
-void GuiWorkArea::Private::showCursor(int x, int y, int h,
- bool l_shape, bool rtl, bool completable)
-{
- if (schedule_redraw_) {
- // This happens when a graphic conversion is finished. As we don't know
- // the size of the new graphics, it's better the update everything.
- // We can't use redraw() here because this would trigger a infinite
- // recursive loop with showCursor().
- buffer_view_->resize(p->viewport()->width(), p->viewport()->height());
- updateScreen();
- updateScrollbar();
- p->viewport()->update(QRect(0, 0, p->viewport()->width(), p->viewport()->height()));
- schedule_redraw_ = false;
- // Show the cursor immediately after the update.
- hideCursor();
- p->toggleCursor();
- return;
- }
-
- cursor_->update(x, y, h, l_shape, rtl, completable);
- cursor_->show();
- p->viewport()->update(cursor_->rect());
-}
-
-
-void GuiWorkArea::Private::removeCursor()
-{
- cursor_->hide();
- //if (!qApp->focusWidget())
- p->viewport()->update(cursor_->rect());
-}
-
-
-void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
-{
- QString const & commit_string = e->commitString();
- docstring const & preedit_string
- = qstring_to_ucs4(e->preeditString());
-
- if (!commit_string.isEmpty()) {
-
- LYXERR(Debug::KEY, "preeditString: " << e->preeditString()
- << " commitString: " << e->commitString());
-
- int key = 0;
-
- // FIXME Iwami 04/01/07: we should take care also of UTF16 surrogates here.
- for (int i = 0; i != commit_string.size(); ++i) {
- QKeyEvent ev(QEvent::KeyPress, key, Qt::NoModifier, commit_string[i]);
- keyPressEvent(&ev);
- }
- }
-
- // Hide the cursor during the kana-kanji transformation.
- if (preedit_string.empty())
- startBlinkingCursor();
- else
- stopBlinkingCursor();
-
- // last_width : for checking if last preedit string was/wasn't empty.
- // FIXME THREAD && FIXME
- // We could have more than one work area, right?
- static bool last_width = false;
- if (!last_width && preedit_string.empty()) {
- // if last_width is last length of preedit string.
- e->accept();