]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiWorkArea.cpp
reduce line noise
[features.git] / src / frontends / qt4 / GuiWorkArea.cpp
index 0449643c09dd0ca011d1a0b48973af0325923bc1..66654b45ba07b714aac39edcd86902d52578a35b 100644 (file)
@@ -247,12 +247,9 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & lv)
        // PageStep only depends on the viewport height.
        verticalScrollBar()->setPageStep(viewport()->height());
 
-       LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION
-               << "\n Area width\t" << width()
-               << "\n Area height\t" << height()
+       LYXERR(Debug::GUI, BOOST_CURRENT_FUNCTION
                << "\n viewport width\t" << viewport()->width()
-               << "\n viewport height\t" << viewport()->height()
-               << endl;
+               << "\n viewport height\t" << viewport()->height());
 
        // Enables input methods for asian languages.
        // Must be set when creating custom text editing widgets.
@@ -325,16 +322,16 @@ void GuiWorkArea::redraw()
        
        ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
 
-       LYXERR(Debug::WORKAREA) << "WorkArea::redraw screen" << endl;
+       LYXERR(Debug::WORKAREA, "WorkArea::redraw screen");
 
        int const ymin = std::max(vi.y1, 0);
-       int const ymax = vi.p2 < vi.size - 1 ? vi.y2 : height();
+       int const ymax = vi.p2 < vi.size - 1 ? vi.y2 : viewport()->height();
 
-       expose(0, ymin, width(), ymax - ymin);
+       updateScreen();
+       update(0, ymin, viewport()->width(), ymax - ymin);
 
-       //LYXERR(Debug::WORKAREA)
-       //<< "  ymin = " << ymin << "  width() = " << width()
-//             << "  ymax-ymin = " << ymax-ymin << std::endl;
+       //LYXERR(Debug::WORKAREA, "  ymin = " << ymin << "  width() = " << width()
+       //              << "  ymax-ymin = " << ymax-ymin);
 
        if (lyxerr.debugging(Debug::WORKAREA))
                buffer_view_->coordCache().dump();
@@ -408,21 +405,12 @@ void GuiWorkArea::resizeBufferView()
        // WARNING: Please don't put any code that will trigger a repaint here!
        // We are already inside a paint event.
        lyx_view_->setBusy(true);
-       buffer_view_->resize(width(), height());
+       buffer_view_->resize(viewport()->width(), viewport()->height());
        lyx_view_->updateLayoutChoice(false);
        lyx_view_->setBusy(false);
 }
 
 
-void GuiWorkArea::updateScrollbar()
-{
-       buffer_view_->updateScrollbar();
-       ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
-       setScrollbarParams(scroll_.height, scroll_.position,
-               scroll_.lineScrollHeight);
-}
-
-
 void GuiWorkArea::showCursor()
 {
        if (cursor_visible_)
@@ -456,7 +444,7 @@ void GuiWorkArea::showCursor()
        y -= asc;
 
        // if it doesn't touch the screen, don't try to show it
-       if (y + h < 0 || y >= height())
+       if (y + h < 0 || y >= viewport()->height())
                return;
 
        cursor_visible_ = true;
@@ -491,21 +479,23 @@ void GuiWorkArea::toggleCursor()
 }
 
 
-void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step)
+void GuiWorkArea::updateScrollbar()
 {
        if (verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOn)
                setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-
        verticalScrollBar()->setTracking(false);
 
+       buffer_view_->updateScrollbar();
+       ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
+
        // do what cursor movement does (some grey)
-       h += height() / 4;
-       int scroll_max_ = std::max(0, h - height());
+       int const h = scroll_.height + viewport()->height() / 4;
+       int scroll_max_ = std::max(0, h - viewport()->height());
 
        verticalScrollBar()->setRange(0, scroll_max_);
-       verticalScrollBar()->setSliderPosition(scroll_pos);
-       verticalScrollBar()->setSingleStep(scroll_line_step);
-       verticalScrollBar()->setValue(scroll_pos);
+       verticalScrollBar()->setSliderPosition(scroll_.position);
+       verticalScrollBar()->setSingleStep(scroll_.lineScrollHeight);
+       verticalScrollBar()->setValue(scroll_.position);
 
        verticalScrollBar()->setTracking(true);
 }
@@ -678,20 +668,18 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * ev)
 #ifdef Q_WS_X11
        if (XEventsQueued(QX11Info::display(), 0) > 1 && ev->isAutoRepeat() 
                        && (Qt::Key_PageDown || Qt::Key_PageUp)) {
-               LYXERR(Debug::KEY)      
-                       << BOOST_CURRENT_FUNCTION << endl
-                       << "system is busy: scroll key event ignored" << endl;
+               LYXERR(Debug::KEY, BOOST_CURRENT_FUNCTION
+                       << "\nsystem is busy: scroll key event ignored");
                ev->ignore();
                return;
        }
 #endif
 
-       LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
+       LYXERR(Debug::KEY, BOOST_CURRENT_FUNCTION
                << " count=" << ev->count()
                << " text=" << fromqstr(ev->text())
                << " isAutoRepeat=" << ev->isAutoRepeat()
-               << " key=" << ev->key()
-               << endl;
+               << " key=" << ev->key());
 
        KeySymbol sym;
        setKeySymbol(&sym, ev);
@@ -756,13 +744,6 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
 }
 
 
-void GuiWorkArea::expose(int x, int y, int w, int h)
-{
-       updateScreen();
-       update(x, y, w, h);
-}
-
-
 void GuiWorkArea::updateScreen()
 {
        GuiPainter pain(&screen_);
@@ -806,10 +787,9 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
 
        if (!commit_string.isEmpty()) {
 
-               LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
+               LYXERR(Debug::KEY, BOOST_CURRENT_FUNCTION
                        << " preeditString =" << fromqstr(e->preeditString())
-                       << " commitString  =" << fromqstr(e->commitString())
-                       << endl;
+                       << " commitString  =" << fromqstr(e->commitString()));
 
                int key = 0;
 
@@ -844,7 +824,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
        int cur_y = cursor_->rect().bottom();
 
        // redraw area of preedit string.
-       update(0, cur_y - height, GuiWorkArea::width(),
+       update(0, cur_y - height, viewport()->width(),
                (height + 1) * preedit_lines_);
 
        if (preedit_string.empty()) {
@@ -907,7 +887,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
                ps = Painter::preedit_default;
 
                // if we reached the right extremity of the screen, go to next line.
-               if (cur_x + fm.width(typed_char) > GuiWorkArea::width() - right_margin) {
+               if (cur_x + fm.width(typed_char) > viewport()->width() - right_margin) {
                        cur_x = right_margin;
                        cur_y += height + 1;
                        ++preedit_lines_;
@@ -931,7 +911,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
        }
 
        // update the preedit string screen area.
-       update(0, cur_y - preedit_lines_*height, GuiWorkArea::width(),
+       update(0, cur_y - preedit_lines_*height, viewport()->width(),
                (height + 1) * preedit_lines_);
 
        // Don't forget to accept the event!
@@ -1025,9 +1005,7 @@ TabWorkArea::TabWorkArea(QWidget * parent) : QTabWidget(parent)
                this, SLOT(closeCurrentTab()));
 
        setCornerWidget(closeTabButton);
-#if QT_VERSION >= 0x040200
        setUsesScrollButtons(true);
-#endif
 }
 
 
@@ -1124,8 +1102,8 @@ void TabWorkArea::on_currentTabChanged(int i)
        ///
        currentWorkAreaChanged(wa);
 
-       LYXERR(Debug::GUI) << "currentTabChanged " << i
-               << "File" << bv.buffer().absFileName() << endl;
+       LYXERR(Debug::GUI, "currentTabChanged " << i
+               << "File" << bv.buffer().absFileName());
 }