#include "frontends/KeySymbol.h"
#include "frontends/LyXView.h"
#include "frontends/Selection.h"
-#include "frontends/WorkArea.h"
#include "support/environment.h"
#include "support/FileFilterList.h"
}
updateLabels(*buf);
lv->setBuffer(buf);
- lv->showErrorList("Parse");
+ lv->errors("Parse");
} else {
Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
if (b)
}
-namespace {
-void restartCursor(LyXView * lv)
-{
- /* When we move around, or type, it's nice to be able to see
- * the cursor immediately after the keypress.
- */
- if (lv && lv->currentWorkArea())
- lv->currentWorkArea()->startBlinkingCursor();
-}
-}
-
void LyXFunc::processKeySym(KeySymbol const & keysym, KeyModifier state)
{
LYXERR(Debug::KEY) << "KeySym is " << keysym.getSymbolName() << endl;
if (!keysym.isOK()) {
LYXERR(Debug::KEY) << "Empty kbd action (probably composing)"
<< endl;
- restartCursor(lyx_view_);
+ lyx_view_->restartCursor();
return;
}
if (keysym.isModifier()) {
LYXERR(Debug::KEY) << "isModifier true" << endl;
- restartCursor(lyx_view_);
+ lyx_view_->restartCursor();
return;
}
} else {
LYXERR(Debug::KEY) << "Unknown, !isText() - giving up" << endl;
lyx_view_->message(_("Unknown function."));
- restartCursor(lyx_view_);
+ lyx_view_->restartCursor();
return;
}
}
dispatch(func);
}
- restartCursor(lyx_view_);
+ lyx_view_->restartCursor();
}
if (buf) {
updateLabels(*buf);
lyx_view_->setBuffer(buf);
- lyx_view_->showErrorList("Parse");
+ lyx_view_->errors("Parse");
}
updateFlags = Update::None;
break;
lyx_view_->setBuffer(buf);
view()->setCursorFromRow(row);
if (loaded)
- lyx_view_->showErrorList("Parse");
+ lyx_view_->errors("Parse");
updateFlags = Update::FitCursor;
break;
}
updateLabels(*child->masterBuffer());
lyx_view_->setBuffer(child);
if (parsed)
- lyx_view_->showErrorList("Parse");
+ lyx_view_->errors("Parse");
}
// If a screen update is required (in case where auto_open is false),
if (buf) {
updateLabels(*buf);
lyx_view_->setBuffer(buf);
- lyx_view_->showErrorList("Parse");
+ lyx_view_->errors("Parse");
str2 = bformat(_("Document %1$s opened."), disp_fn);
} else {
str2 = bformat(_("Could not open document %1$s"), disp_fn);
if (buf) {
updateLabels(*buf);
lyx_view_->setBuffer(buf);
- lyx_view_->showErrorList("Parse");
+ lyx_view_->errors("Parse");
str = bformat(_("Document %1$s reloaded."), disp_fn);
} else {
str = bformat(_("Could not reload document %1$s"), disp_fn);
#include "frontends/FontMetrics.h"
#include "frontends/Gui.h"
#include "frontends/LyXView.h"
-#include "frontends/WorkArea.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
namespace frontend {
class Dialogs;
-class WorkArea;
/**
* LyXView - main LyX window
///
LyXView(int id) : id_(id) {}
///
- virtual ~LyXView();
+ virtual ~LyXView() {}
///
int id() const { return id_; }
///
///
virtual void setFocus() = 0;
- ///
- virtual WorkArea * workArea(Buffer & buffer) = 0;
- ///
- virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
- ///
- virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
- ///
- virtual void removeWorkArea(WorkArea * work_area) = 0;
- /// return the current WorkArea (the one that has the focus).
- virtual WorkArea const * currentWorkArea() const = 0;
- /// FIXME: This non-const access is needed because of
- /// a mis-designed \c ControlSpellchecker.
- virtual WorkArea * currentWorkArea() = 0;
-
/**
* This is called after the concrete view has been created.
* We have to have the toolbar and the other stuff created
unsigned int iconSizeXY,
const std::string & geometryArg) = 0;
- /// save the geometry state in the session manager.
- virtual void saveGeometry() = 0;
-
/// show busy cursor
virtual void setBusy(bool) = 0;
/// clear any temporary message and replace with current status
virtual void clearMessage() = 0;
- /// reset autosave timer
- virtual void resetAutosaveTimer() = 0;
-
/// dispatch to current BufferView
virtual void dispatch(FuncRequest const & cmd) = 0;
/// returns true if this view has the focus.
virtual bool hasFocus() const = 0;
- /// show the error list to the user
- virtual void showErrorList(std::string const &) = 0;
+ ///
+ virtual void restartCursor() = 0;
//
// GuiBufferDelegate
//
- /// This function is called when the buffer structure is changed.
- virtual void structureChanged() = 0;
- /// This function is called when some parsing error shows up.
- void errors(std::string const & err) { showErrorList(err); }
- /// Reset autosave timers for all users.
- void resetAutosaveTimers() { resetAutosaveTimer(); }
-
- /// connect to signals in the given BufferView
- virtual void connectBufferView(BufferView & bv) = 0;
- /// disconnect from signals in the given BufferView
- virtual void disconnectBufferView() = 0;
- /// connect to signals in the given buffer
- virtual void connectBuffer(Buffer & buf) = 0;
- /// disconnect from signals in the given buffer
- virtual void disconnectBuffer() = 0;
+ virtual void errors(std::string const &) = 0;
private:
/// noncopyable
///
WorkArea() {}
///
- virtual ~WorkArea();
-
- ///
- virtual BufferView & bufferView() = 0;
- ///
- virtual BufferView const & bufferView() const = 0;
-
- /// return true if has the keyboard input focus.
- virtual bool hasFocus() const = 0;
-
- /// return true if has this WorkArea is visible.
- virtual bool isVisible() const = 0;
-
- /// return the width of the work area in pixels
- virtual int width() const = 0;
-
- /// return the height of the work area in pixels
- virtual int height() const = 0;
-
- /**
- * Update the scrollbar.
- * @param height the total document height in pixels
- * @param pos the current position in the document, in pixels
- * @param line_height the line-scroll amount, in pixels
- */
- virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
-
- ///
- virtual void scheduleRedraw() = 0;
+ virtual ~WorkArea() {}
/// redraw the screen, without using existing pixmap
virtual void redraw() = 0;
- ///
- virtual void stopBlinkingCursor() = 0;
- virtual void startBlinkingCursor() = 0;
/// Process Key pressed event.
/// This needs to be public because it is accessed externally by GuiView.
#include "TextClassList.h"
#include "Validator.h"
-
-// FIXME: those two headers are needed because of the
-// WorkArea::redraw() call below.
-#include "frontends/LyXView.h"
-#include "frontends/WorkArea.h"
-
#include "insets/InsetListingsParams.h"
#include "support/lstrings.h"
#include "qt_helpers.h"
-// FIXME: those two headers are needed because of the
-// WorkArea::redraw() call below.
-#include "frontends/LyXView.h"
-#include "frontends/WorkArea.h"
-
#include "support/lstrings.h"
#include <QListWidget>
#endif
#include "frontends/alert.h"
-// FIXME: those two headers are needed because of the
-// WorkArea::redraw() call below.
-#include "frontends/LyXView.h"
-#include "frontends/WorkArea.h"
using std::advance;
using std::distance;
#include "GuiToolbar.h"
#include "GuiToolbars.h"
#include "Dialogs.h"
-#include "WorkArea.h"
#include "Gui.h"
#include "qt_helpers.h"
#include "frontends/Application.h"
#include "frontends/Dialogs.h"
#include "frontends/Gui.h"
-#include "frontends/WorkArea.h"
#include "support/filetools.h"
#include "support/convert.h"
unsigned int GuiView::GuiViewPrivate::lastIconSize = 0;
-/// FIXME
-LyXView::~LyXView() {}
-
-
GuiView::GuiView(int id)
: QMainWindow(), LyXView(id),
d(*new GuiViewPrivate),
}
-WorkArea * GuiView::workArea(Buffer & buffer)
+GuiWorkArea * GuiView::workArea(Buffer & buffer)
{
for (int i = 0; i != d.splitter_->count(); ++i) {
GuiWorkArea * wa = d.tabWorkArea(i)->workArea(buffer);
}
-WorkArea * GuiView::addWorkArea(Buffer & buffer)
+GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
{
GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
wa->setUpdatesEnabled(false);
}
-WorkArea * GuiView::currentWorkArea()
+GuiWorkArea * GuiView::currentWorkArea()
{
return d.current_work_area_;
}
-WorkArea const * GuiView::currentWorkArea() const
+GuiWorkArea const * GuiView::currentWorkArea() const
{
return d.current_work_area_;
}
-void GuiView::setCurrentWorkArea(WorkArea * work_area)
+void GuiView::setCurrentWorkArea(GuiWorkArea * work_area)
{
BOOST_ASSERT(work_area);
}
-void GuiView::removeWorkArea(WorkArea * work_area)
+void GuiView::removeWorkArea(GuiWorkArea * work_area)
{
BOOST_ASSERT(work_area);
GuiWorkArea * gwa = static_cast<GuiWorkArea *>(work_area);
// Not found in this tab group.
continue;
- // We found and removed the WorkArea.
+ // We found and removed the GuiWorkArea.
if (twa->count()) {
// No more WorkAreas in this tab group, so delete it.
delete twa;
}
if (d.current_work_area_)
- // This means that we are not closing the current WorkArea;
+ // This means that we are not closing the current GuiWorkArea;
break;
- // Switch to the next WorkArea in the found TabWorkArea.
+ // Switch to the next GuiWorkArea in the found TabWorkArea.
d.current_work_area_ = twa->currentWorkArea();
break;
}
Buffer * GuiView::buffer()
{
- WorkArea * work_area = currentWorkArea();
- if (work_area)
- return &work_area->bufferView().buffer();
+ if (d.current_work_area_)
+ return &d.current_work_area_->bufferView().buffer();
return 0;
}
Buffer const * GuiView::buffer() const
{
- WorkArea const * work_area = currentWorkArea();
- if (work_area)
- return &work_area->bufferView().buffer();
+ if (d.current_work_area_)
+ return &d.current_work_area_->bufferView().buffer();
return 0;
}
BOOST_ASSERT(newBuffer);
setBusy(true);
- WorkArea * wa = workArea(*newBuffer);
+ GuiWorkArea * wa = workArea(*newBuffer);
if (wa == 0) {
updateLabels(*newBuffer->masterBuffer());
wa = addWorkArea(*newBuffer);
return 0;
}
- WorkArea * wa = workArea(*newBuffer);
+ GuiWorkArea * wa = workArea(*newBuffer);
if (wa == 0)
wa = addWorkArea(*newBuffer);
void GuiView::disconnectBuffer()
{
- if (WorkArea * work_area = currentWorkArea())
- work_area->bufferView().setGuiDelegate(0);
+ if (d.current_work_area_)
+ d.current_work_area_->bufferView().setGuiDelegate(0);
}
void GuiView::disconnectBufferView()
{
- if (WorkArea * work_area = currentWorkArea())
- work_area->bufferView().setGuiDelegate(0);
+ if (d.current_work_area_)
+ d.current_work_area_->bufferView().setGuiDelegate(0);
}
-void GuiView::showErrorList(string const & error_type)
+void GuiView::errors(string const & error_type)
{
ErrorList & el = buffer()->errorList(error_type);
if (!el.empty())
BufferView * GuiView::view()
{
- WorkArea * wa = currentWorkArea();
- return wa ? &wa->bufferView() : 0;
+ return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
}
}
-void GuiView::resetAutosaveTimer()
+void GuiView::resetAutosaveTimers()
{
if (lyxrc.autosave)
autosave_timeout_->restart();
Buffer const * GuiView::updateInset(Inset const * inset)
{
- WorkArea * work_area = currentWorkArea();
- if (!work_area)
+ if (!d.current_work_area_)
return 0;
- if (inset) {
- BOOST_ASSERT(work_area);
- work_area->scheduleRedraw();
- }
- return &work_area->bufferView().buffer();
+ if (inset)
+ d.current_work_area_->scheduleRedraw();
+
+ return &d.current_work_area_->bufferView().buffer();
+}
+
+
+void GuiView::restartCursor()
+{
+ /* When we move around, or type, it's nice to be able to see
+ * the cursor immediately after the keypress.
+ */
+ if (d.current_work_area_)
+ d.current_work_area_->startBlinkingCursor();
}
} // namespace frontend
int maximized,
unsigned int iconSizeXY,
const std::string & geometryArg);
+ /// save the geometry state in the session manager.
virtual void saveGeometry();
virtual void setBusy(bool);
/// add toolbar, if newline==true, add a toolbar break before the toolbar
void bigSizedIcons();
private:
+ friend GuiWorkArea;
+
/// make sure we quit cleanly
virtual void closeEvent(QCloseEvent * e);
///
/// \return the \c Workarea associated to \p Buffer
/// \retval 0 if no \c WorkArea is found.
- WorkArea * workArea(Buffer & buffer);
+ GuiWorkArea * workArea(Buffer & buffer);
/// Add a \c WorkArea
/// \return the \c Workarea associated to \p Buffer
/// \retval 0 if no \c WorkArea is found.
- WorkArea * addWorkArea(Buffer & buffer);
- void setCurrentWorkArea(WorkArea * work_area);
- void removeWorkArea(WorkArea * work_area);
- WorkArea const * currentWorkArea() const;
- WorkArea * currentWorkArea();
-
+ GuiWorkArea * addWorkArea(Buffer & buffer);
///
- void resetAutosaveTimer();
- ///
- void showErrorList(std::string const & error_type);
+ void setCurrentWorkArea(GuiWorkArea * work_area);
///
+ void removeWorkArea(GuiWorkArea * work_area);
+ /// return the current WorkArea (the one that has the focus).
+ GuiWorkArea const * currentWorkArea() const;
+ /// FIXME: This non-const access is needed because of
+ /// a mis-designed \c ControlSpellchecker.
+ GuiWorkArea * currentWorkArea();
+
+ /// GuiBufferDelegate.
+ ///@{
+ void resetAutosaveTimers();
+ void errors(std::string const &);
void structureChanged() { updateToc(); }
- ///
- void connectBuffer(Buffer & buf);
- ///
- void disconnectBuffer();
- ///
+ ///@}
+
+
+ /// connect to signals in the given BufferView
void connectBufferView(BufferView & bv);
- ///
+ /// disconnect from signals in the given BufferView
void disconnectBufferView();
+ /// connect to signals in the given buffer
+ void connectBuffer(Buffer & buf);
+ /// disconnect from signals in the given buffer
+ void disconnectBuffer();
+
////
void showDialog(std::string const & name);
void showDialogWithData(std::string const & name,
* visible. If successful return a pointer to the owning Buffer.
*/
Buffer const * updateInset(Inset const *);
+ ///
+ void restartCursor();
private:
#include "GuiApplication.h"
#include "GuiKeySymbol.h"
#include "GuiPainter.h"
+#include "GuiView.h"
#include "KeySymbol.h"
#include "Language.h"
#include "LyXFunc.h"
#include "frontends/Application.h"
#include "frontends/Dialogs.h" // only used in setReadOnly
#include "frontends/FontMetrics.h"
-#include "frontends/LyXView.h"
#include "frontends/WorkAreaManager.h"
#include <QInputContext>
static boost::signals::connection timecon;
-// HACK: FIXME
-WorkArea::~WorkArea() {}
-
-GuiWorkArea::GuiWorkArea(Buffer & buffer, LyXView & lv)
+GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & lv)
: buffer_view_(new BufferView(buffer)), lyx_view_(&lv),
cursor_visible_(false), cursor_timeout_(400),
need_resize_(false), schedule_redraw_(false),
namespace frontend {
-class LyXView;
+class GuiView;
/// types of cursor in work area
enum CursorShape {
public:
///
- GuiWorkArea(Buffer & buffer, LyXView & lv);
+ GuiWorkArea(Buffer & buffer, GuiView & lv);
///
~GuiWorkArea();
+ /**
+ * Update the scrollbar.
+ * @param height the total document height in pixels
+ * @param pos the current position in the document, in pixels
+ * @param line_height the line-scroll amount, in pixels
+ */
+ void setScrollbarParams(int height, int pos, int line_height);
///
- bool hasFocus() const { return QAbstractScrollArea::hasFocus(); }
- bool isVisible() const { return QAbstractScrollArea::isVisible(); }
-
- /// return the width of the content pane
- virtual int width() const { return viewport()->width(); }
- /// return the height of the content pane
- virtual int height() const { return viewport()->height(); }
- ///
- virtual void setScrollbarParams(int height, int pos, int line_height);
- ///
- virtual void scheduleRedraw() { schedule_redraw_ = true; }
+ void scheduleRedraw() { schedule_redraw_ = true; }
/// update the passed area.
void update(int x, int y, int w, int h);
void stopBlinkingCursor();
///
void startBlinkingCursor();
- ///
+ /// Process Key pressed event.
+ /// This needs to be public because it is accessed externally by GuiView.
void processKeySym(KeySymbol const & key, KeyModifier mod);
public Q_SLOTS:
///
BufferView * buffer_view_;
///
- LyXView * lyx_view_;
+ GuiView * lyx_view_;
/// is the cursor currently displayed
bool cursor_visible_;