#include "BufferView.h"
#include "CoordCache.h"
#include "Cursor.h"
-#include "debug.h"
#include "Font.h"
#include "FuncRequest.h"
-#include "gettext.h"
#include "GuiApplication.h"
#include "GuiKeySymbol.h"
#include "GuiPainter.h"
#include "graphics/GraphicsImage.h"
#include "graphics/GraphicsLoader.h"
+#include "support/debug.h"
+#include "support/gettext.h"
#include "support/FileName.h"
-#include "support/ForkedcallsController.h"
+#include "support/ForkedCalls.h"
#include "frontends/Application.h"
-#include "frontends/Dialogs.h" // only used in setReadOnly
#include "frontends/FontMetrics.h"
#include "frontends/WorkAreaManager.h"
#include <QTimer>
#include <boost/bind.hpp>
-#include <boost/current_function.hpp>
#ifdef Q_WS_X11
#include <QX11Info>
namespace lyx {
using support::FileName;
-using support::ForkedcallsController;
/// return the LyX mouse button state from Qt's
-// All the below connection objects are needed because of a bug in some
-// versions of GCC (<=2.96 are on the suspects list.) By having and assigning
-// to these connections we avoid a segfault upon startup, and also at exit.
-// (Lgb)
-
-static boost::signals::connection timecon;
-
-
GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & lv)
: buffer_view_(new BufferView(buffer)), lyx_view_(&lv),
- cursor_visible_(false), cursor_timeout_(400),
+ cursor_visible_(false),
need_resize_(false), schedule_redraw_(false),
preedit_lines_(1)
{
buffer.workAreaManager().add(this);
// Setup the signals
- timecon = cursor_timeout_.timeout
- .connect(boost::bind(&GuiWorkArea::toggleCursor, this));
+ cursor_timeout_.setInterval(400);
+ connect(&cursor_timeout_, SIGNAL(timeout()),
+ this, SLOT(toggleCursor()));
cursor_timeout_.start();
cursor_ = new frontend::CursorWidget();
cursor_->hide();
- setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setAcceptDrops(true);
setMouseTracking(true);
// PageStep only depends on the viewport height.
verticalScrollBar()->setPageStep(viewport()->height());
- LYXERR(Debug::GUI, BOOST_CURRENT_FUNCTION
- << "\n viewport width\t" << viewport()->width()
- << "\n viewport height\t" << viewport()->height());
+ LYXERR(Debug::GUI, "viewport width: " << viewport()->width()
+ << " viewport height: " << viewport()->height());
// Enables input methods for asian languages.
// Must be set when creating custom text editing widgets.
{
buffer_view_->buffer().workAreaManager().remove(this);
delete buffer_view_;
+ delete cursor_;
}
void GuiWorkArea::startBlinkingCursor()
{
showCursor();
- cursor_timeout_.restart();
+ cursor_timeout_.start();
}
// No need to do anything if this is the current view. The BufferView
// metrics are already up to date.
- if (lyx_view_ != theApp()->currentView()) {
+ if (lyx_view_ != guiApp->currentView()) {
// FIXME: it would be nice to optimize for the off-screen case.
buffer_view_->updateMetrics();
buffer_view_->cursor().fixIfBroken();
showCursor();
}
- ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
-
LYXERR(Debug::WORKAREA, "WorkArea::redraw screen");
-
- int const ymin = std::max(vi.y1, 0);
- int const ymax = vi.p2 < vi.size - 1 ? vi.y2 : viewport()->height();
-
updateScreen();
- update(0, ymin, viewport()->width(), ymax - ymin);
+ update(0, 0, viewport()->width(), viewport()->height());
- //LYXERR(Debug::WORKAREA, " ymin = " << ymin << " width() = " << width()
- // << " ymax-ymin = " << ymax-ymin);
+ lyx_view_->updateStatusBar();
if (lyxerr.debugging(Debug::WORKAREA))
buffer_view_->coordCache().dump();
// Skip these when selecting
if (cmd.action != LFUN_MOUSE_MOTION) {
- lyx_view_->updateLayoutChoice(false);
+ lyx_view_->updateLayoutList();
lyx_view_->updateToolbars();
}
// We are already inside a paint event.
lyx_view_->setBusy(true);
buffer_view_->resize(viewport()->width(), viewport()->height());
- lyx_view_->updateLayoutChoice(false);
+ lyx_view_->updateLayoutList();
lyx_view_->setBusy(false);
+ need_resize_ = false;
}
// Use this opportunity to deal with any child processes that
// have finished but are waiting to communicate this fact
// to the rest of LyX.
- ForkedcallsController & fcc = ForkedcallsController::get();
- fcc.handleCompletedProcesses();
-
- cursor_timeout_.restart();
+ support::ForkedCallsController::handleCompletedProcesses();
}
void GuiWorkArea::updateScrollbar()
{
- if (verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOn)
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
verticalScrollBar()->setTracking(false);
buffer_view_->updateScrollbar();
if (lyxrc.cursor_follows_scrollbar) {
buffer_view_->setCursorFromScrollbar();
- lyx_view_->updateLayoutChoice(false);
+ lyx_view_->updateLayoutList();
}
// Show the cursor immediately after any operation.
startBlinkingCursor();
#ifdef Q_WS_X11
if (XEventsQueued(QX11Info::display(), 0) > 1 && ev->isAutoRepeat()
&& (Qt::Key_PageDown || Qt::Key_PageUp)) {
- LYXERR(Debug::KEY, BOOST_CURRENT_FUNCTION
- << "\nsystem is busy: scroll key event ignored");
+ LYXERR(Debug::KEY, "system is busy: scroll key event ignored");
ev->ignore();
return;
}
#endif
- LYXERR(Debug::KEY, BOOST_CURRENT_FUNCTION
- << " count=" << ev->count()
- << " text=" << fromqstr(ev->text())
- << " isAutoRepeat=" << ev->isAutoRepeat()
- << " key=" << ev->key());
+ LYXERR(Debug::KEY, " count: " << ev->count()
+ << " text: " << fromqstr(ev->text())
+ << " isAutoRepeat: " << ev->isAutoRepeat() << " key: " << ev->key());
KeySymbol sym;
setKeySymbol(&sym, ev);
void GuiWorkArea::paintEvent(QPaintEvent * ev)
{
QRect const rc = ev->rect();
- /*
- LYXERR(Debug::PAINTING) << "paintEvent begin: x: " << rc.x()
- << " y: " << rc.y()
- << " w: " << rc.width()
- << " h: " << rc.height() << endl;
- */
+ // LYXERR(Debug::PAINTING, "paintEvent begin: x: " << rc.x()
+ // << " y: " << rc.y() << " w: " << rc.width() << " h: " << rc.height());
if (need_resize_) {
verticalScrollBar()->setPageStep(viewport()->height());
updateScreen();
hideCursor();
showCursor();
- need_resize_ = false;
}
QPainter pain(viewport());
void GuiWorkArea::updateScreen()
{
GuiPainter pain(&screen_);
- verticalScrollBar()->show();
buffer_view_->draw(pain);
}
if (!commit_string.isEmpty()) {
- LYXERR(Debug::KEY, BOOST_CURRENT_FUNCTION
- << " preeditString =" << fromqstr(e->preeditString())
- << " commitString =" << fromqstr(e->commitString()));
+ LYXERR(Debug::KEY, "preeditString: " << fromqstr(e->preeditString())
+ << " commitString: " << fromqstr(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) {
+ for (int i = 0; i != commit_string.size(); ++i) {
QKeyEvent ev(QEvent::KeyPress, key, Qt::NoModifier, commit_string[i]);
keyPressEvent(&ev);
}
// cursor_pos : cursor position in preedit string.
size_t cursor_pos = 0;
bool cursor_is_visible = false;
- for (int i = 0; i < att.size(); ++i) {
+ for (int i = 0; i != att.size(); ++i) {
if (att.at(i).type == QInputMethodEvent::Cursor) {
cursor_pos = att.at(i).start;
cursor_is_visible = att.at(i).length != 0;
// rLength : selected string length in IM.
size_t rLength = 0;
if (cursor_pos < preedit_length) {
- for (int i = 0; i < att.size(); ++i) {
+ for (int i = 0; i != att.size(); ++i) {
if (att.at(i).type == QInputMethodEvent::TextFormat) {
if (att.at(i).start <= int(cursor_pos)
&& int(cursor_pos) < att.at(i).start + att.at(i).length) {
{
updateWindowTitle();
if (this == lyx_view_->currentWorkArea())
- lyx_view_->getDialogs().updateBufferDependent(false);
+ lyx_view_->updateBufferDependent(false);
}
void TabWorkArea::showBar(bool show)
{
+ tabBar()->setEnabled(show);
tabBar()->setVisible(show);
}
}
+GuiWorkArea * TabWorkArea::addWorkArea(Buffer & buffer, GuiView & view)
+{
+ GuiWorkArea * wa = new GuiWorkArea(buffer, view);
+ wa->setUpdatesEnabled(false);
+ // Hide tabbar if there's no tab (avoid a resize and a flashing tabbar
+ // when hiding it again below).
+ showBar(count() > 0);
+ addTab(wa, wa->windowTitle());
+ QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
+ this, SLOT(updateTabText(GuiWorkArea *)));
+ // Hide tabbar if there's only one tab.
+ showBar(count() > 1);
+ return wa;
+}
+
+
bool TabWorkArea::removeWorkArea(GuiWorkArea * work_area)
{
BOOST_ASSERT(work_area);
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(i));
BOOST_ASSERT(wa);
BufferView & bv = wa->bufferView();
- bv.updateMetrics();
bv.cursor().fixIfBroken();
+ bv.updateMetrics();
wa->setUpdatesEnabled(true);
wa->redraw();
wa->setFocus();