// -*- C++ -*-
+/**
+ * \file LyXView.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
-#ifndef LYXVIEW_BASE_H
-#define LYXVIEW_BASE_H
+#ifndef LYXVIEW_H
+#define LYXVIEW_H
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include "frontends/Application.h"
+#include "frontends/Toolbars.h"
+#include "LyXFunc.h"
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/signal.hpp>
+#include <boost/signals/trackable.hpp>
#include <boost/utility.hpp>
-#include <sigc++/signal_system.h>
-#include "LString.h"
-#include "support/types.h"
+#include <vector>
+
+namespace lyx {
+
+namespace support { class FileName; }
class Buffer;
-class Toolbar;
-class MiniBuffer;
-class Intl;
+class Inset;
class Menubar;
class BufferView;
class Dialogs;
class LyXFunc;
+class Font;
class Timeout;
+class FuncRequest;
+
+namespace frontend {
+class WorkArea;
+class ControlCommandBuffer;
+} // namespace frontend
-///
-class LyXView : public SigC::Object, boost::noncopyable {
+
+/**
+ * LyXView - main LyX window
+ *
+ * This class represents the main LyX window and provides
+ * accessor functions to its content.
+ *
+ * The eventual intention is that LyX will support a number
+ * of containing LyXViews. Currently a lot of code still
+ * relies on there being a single top-level view.
+ *
+ * Additionally we would like to support multiple views
+ * in a single LyXView.
+ */
+class LyXView : public boost::signals::trackable, boost::noncopyable {
public:
- ///
- LyXView();
- ///
+
+ LyXView(int id);
+
virtual ~LyXView();
- ///
- virtual void init() = 0;
- ///
- virtual void setPosition(int, int) = 0;
- ///
- virtual void show(int, int, string const &) = 0;
- /// Redraw the main form.
- virtual void redraw() = 0;
- /// Resize all BufferViews in this LyXView (because the width changed)
- void resize();
+ int const id() const { return id_; }
- /// returns the buffer currently shown in the main form.
- Buffer * buffer() const;
+ virtual void close() = 0;
- ///
- BufferView * view() const;
+ virtual void setFocus() = 0;
- /// return a pointer to the toolbar
- Toolbar * getToolbar() const;
+ std::vector<int> const & workAreaIds() const { return work_area_ids_; }
- /// sets the layout in the toolbar layout combox
- void setLayout(string const & layout);
- /// update the toolbar
- void updateToolbar();
+ /// FIXME: rename to setCurrentWorkArea()
+ void setWorkArea(frontend::WorkArea * work_area);
- /// return a pointer to the lyxfunc
- LyXFunc * getLyXFunc() const;
+ /// return the current WorkArea (the one that has the focus).
+ frontend::WorkArea const * currentWorkArea() const;
+ /// FIXME: This non-const access is needed because of
+ /// a mis-designed \c ControlSpellchecker.
+ frontend::WorkArea * currentWorkArea();
- /// return a pointer to the minibuffer
- MiniBuffer * getMiniBuffer() const;
+ /**
+ * This is called after the concrete view has been created.
+ * We have to have the toolbar and the other stuff created
+ * before we can populate it with this call.
+ */
+ virtual void init() = 0;
- ///
- void message(string const &);
- ///
- void messagePush(string const & str);
- ///
- void messagePop();
+ enum Maximized {
+ NotMaximized,
+ VerticallyMaximized,
+ HorizontallyMaximized,
+ CompletelyMaximized
+ };
///
- Menubar * getMenubar() const;
+ virtual void setGeometry(
+ unsigned int width,
+ unsigned int height,
+ int posx, int posy,
+ int maximize,
+ unsigned int iconSizeXY,
+ const std::string & geometryArg) = 0;
- ///
- void updateMenubar();
+ /// save the geometry state in the session manager.
+ virtual void saveGeometry() = 0;
+
+ /// show busy cursor
+ virtual void busy(bool) = 0;
+
+ virtual Toolbars::ToolbarPtr makeToolbar(ToolbarInfo const & tbinfo, bool newline) = 0;
+
+ //@{ generic accessor functions
+
+ /** return the current buffer view
+ Returned as a shared_ptr so that anything wanting to cache the
+ buffer view can do so safely using a boost::weak_ptr.
+ */
+ BufferView * view() const;
+ /// return the buffer currently shown in this window
+ Buffer * buffer() const;
+
+ /// return the toolbar for this view
+ Toolbars & getToolbars() { return *toolbars_.get(); }
///
- Intl * getIntl() const;
+ Toolbars const & getToolbars() const { return *toolbars_.get(); }
+ /// return the menubar for this view
+ Menubar & getMenubar() { return *menubar_.get(); }
///
- Dialogs * getDialogs() { return dialogs_; }
+ Menubar const & getMenubar() const { return *menubar_.get(); }
+ /// get access to the dialogs
+ Dialogs & getDialogs() { return *dialogs_.get(); }
///
+ Dialogs const & getDialogs() const { return *dialogs_.get(); }
+
+ //@}
+
+ /// load a buffer into the current workarea
+ bool loadLyXFile(support::FileName const & name, bool tolastfiles = true);
+
+ /// set a buffer to the current workarea
+ void setBuffer(Buffer * b);
+
+ /// updates the possible layouts selectable
void updateLayoutChoice();
- /// Updates the title of the window
+ /// update the toolbar
+ void updateToolbars();
+ /// get toolbar state
+ ToolbarInfo::Flags getToolbarState(std::string const & name);
+ /// toggle toolbar state
+ void toggleToolbarState(std::string const & name);
+ /// update the menubar
+ void updateMenubar();
+ /// update the status bar
+ virtual void updateStatusBar() = 0;
+
+ /// focus the command buffer (minibuffer)
+ boost::signal<void()> focus_command_buffer;
+
+ /// display a message in the view
+ virtual void message(docstring const &) = 0;
+
+ /// clear any temporary message and replace with current status
+ virtual void clearMessage() = 0;
+
+ /// updates the title of the window
void updateWindowTitle();
- /// Show state (toolbar and font in minibuffer)
- void showState();
+ /// updates the tab view
+ virtual void updateTab() = 0;
- /// Reset autosave timer
+ /// reset autosave timer
void resetAutosaveTimer();
- ///
- virtual void prohibitInput() const = 0;
- ///
- virtual void allowInput() const = 0;
+
+ /// dispatch to current BufferView
+ void dispatch(FuncRequest const & cmd);
+
+ /** redraw \c inset in all the BufferViews in which it is currently
+ * visible. If successful return a pointer to the owning Buffer.
+ */
+ Buffer const * const updateInset(Inset const *) const;
+
+ /// returns true if this view has the focus.
+ virtual bool hasFocus() const = 0;
+
+ /// show the error list to the user
+ void showErrorList(std::string const &);
+
+ /// connect to signals in the given BufferView
+ void connectBufferView(BufferView & bv);
+ /// disconnect from signals in the given BufferView
+ void disconnectBufferView();
+
protected:
- ///
- Menubar * menubar;
- ///
- Toolbar * toolbar;
- /** This is supposed to be a pointer or a list of pointers to the
- BufferViews currently being shown in the LyXView. So far
- this is not used, but that should change pretty soon. (Lgb) */
- BufferView * bufferview;
- ///
- MiniBuffer * minibuffer;
- ///
- Intl * intl;
- ///
- Timeout * autosave_timeout;
- /// A callback
- void AutoSave();
- ///
- void invalidateLayoutChoice();
+ /// current work area (screen view of a BufferView).
+ /**
+ \todo FIXME: there is only one workArea per LyXView for now.
+ */
+ frontend::WorkArea * work_area_;
+
+ /// view's menubar
+ boost::scoped_ptr<Menubar> menubar_;
+
private:
+ /**
+ * setWindowTitle - set title of window
+ * @param t main window title
+ * @param it iconified (short) title
+ */
+ virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
+
+ /// called on timeout
+ void autoSave();
+
+ /// view's toolbar
+ boost::scoped_ptr<Toolbars> toolbars_;
+ /// auto-saving of buffers
+ boost::scoped_ptr<Timeout> const autosave_timeout_;
+ /// our function handler
+ boost::scoped_ptr<LyXFunc> lyxfunc_;
+ /// dialogs for this view
+ boost::scoped_ptr<Dialogs> dialogs_;
+
+ /// buffer changed signal connection
+ boost::signals::connection bufferChangedConnection_;
+ /// buffer structure changed signal connection
+ boost::signals::connection bufferStructureChangedConnection_;
+ /// buffer errors signal connection
+ boost::signals::connection errorsConnection_;
+ /// buffer messages signal connection
+ boost::signals::connection messageConnection_;
+ /// buffer busy status signal connection
+ boost::signals::connection busyConnection_;
+ /// buffer title changed signal connection
+ boost::signals::connection titleConnection_;
+ /// buffer reset timers signal connection
+ boost::signals::connection timerConnection_;
+ /// buffer readonly status changed signal connection
+ boost::signals::connection readonlyConnection_;
+ /// buffer closing signal connection
+ boost::signals::connection closingConnection_;
+ /// connect to signals in the given buffer
+ void connectBuffer(Buffer & buf);
+ /// disconnect from signals in the given buffer
+ void disconnectBuffer();
+
+ /// BufferView messages signal connection
+ //@{
+ boost::signals::connection message_connection_;
+ boost::signals::connection show_dialog_connection_;
+ boost::signals::connection show_dialog_with_data_connection_;
+ boost::signals::connection show_inset_dialog_connection_;
+ boost::signals::connection update_dialog_connection_;
+ boost::signals::connection layout_changed_connection_;
+ //@}
+
+ /// Bind methods for BufferView messages signal connection
+ //@{
+ void showDialog(std::string const & name);
+ void showDialogWithData(std::string const & name,
+ std::string const & data);
+ void showInsetDialog(std::string const & name,
+ std::string const & data, Inset * inset);
+ void updateDialog(std::string const & name,
+ std::string const & data);
+ //@}
+
+ /// notify readonly status
+ void showReadonly(bool);
+
+protected:
///
- LyXFunc * lyxfunc;
- ///
- Dialogs * dialogs_;
- ///
- virtual void setWindowTitle(string const &, string const &) = 0;
- /** The last textclass layout list in the layout choice selector
- This should probably be moved to the toolbar, but for now it's
- here. (Asger) */
- int last_textclass;
+ void updateToc();
+
+ /// view's command buffer controller
+ // this has to be declared _after_ lyxfunc_ as its initialization depends
+ // on it!
+ typedef boost::scoped_ptr<frontend::ControlCommandBuffer>
+ CommandBufferPtr;
+
+ CommandBufferPtr const controlcommand_;
+
+private:
+ int id_;
+ std::vector<int> work_area_ids_;
};
-#endif
+
+} // namespace lyx
+
+#endif // LYXVIEW_H