1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-06-12 02:54:19 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file LyXView.h
|
2002-09-05 15:14:23 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-12 02:54:19 +00:00
|
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-12 02:54:19 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef LYXVIEW_H
|
|
|
|
|
#define LYXVIEW_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-09-22 09:47:39 +00:00
|
|
|
|
#include "frontends/Application.h"
|
2006-09-10 11:03:21 +00:00
|
|
|
|
#include "frontends/Toolbars.h"
|
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXFunc.h"
|
2002-06-12 02:54:19 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2002-08-02 09:21:50 +00:00
|
|
|
|
#include <boost/shared_ptr.hpp>
|
2004-09-26 14:19:47 +00:00
|
|
|
|
#include <boost/signal.hpp>
|
2002-05-29 16:21:03 +00:00
|
|
|
|
#include <boost/signals/trackable.hpp>
|
2004-09-26 14:19:47 +00:00
|
|
|
|
#include <boost/utility.hpp>
|
2002-05-29 16:21:03 +00:00
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
namespace support { class FileName; }
|
|
|
|
|
|
2007-08-14 09:54:59 +00:00
|
|
|
|
class Font;
|
2001-07-03 15:19:04 +00:00
|
|
|
|
class Buffer;
|
2000-04-08 17:02:02 +00:00
|
|
|
|
class BufferView;
|
2007-08-14 09:54:59 +00:00
|
|
|
|
class FuncRequest;
|
|
|
|
|
class Inset;
|
2001-07-03 15:19:04 +00:00
|
|
|
|
class LyXFunc;
|
2002-02-18 19:13:48 +00:00
|
|
|
|
class Timeout;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2007-08-14 09:54:59 +00:00
|
|
|
|
class ControlCommandBuffer;
|
|
|
|
|
class Dialogs;
|
|
|
|
|
class Menubar;
|
|
|
|
|
class WorkArea;
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
2002-06-12 02:54:19 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2002-05-29 16:21:03 +00:00
|
|
|
|
class LyXView : public boost::signals::trackable, boost::noncopyable {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2002-06-12 11:34:13 +00:00
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
LyXView(int id);
|
2002-06-12 11:34:13 +00:00
|
|
|
|
|
2001-07-03 15:19:04 +00:00
|
|
|
|
virtual ~LyXView();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
int const id() const { return id_; }
|
|
|
|
|
|
|
|
|
|
virtual void close() = 0;
|
|
|
|
|
|
2006-12-23 17:09:50 +00:00
|
|
|
|
virtual void setFocus() = 0;
|
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
std::vector<int> const & workAreaIds() const { return work_area_ids_; }
|
|
|
|
|
|
2007-01-05 13:31:34 +00:00
|
|
|
|
/// FIXME: rename to setCurrentWorkArea()
|
2007-08-14 09:54:59 +00:00
|
|
|
|
void setWorkArea(WorkArea * work_area);
|
2006-07-13 16:37:55 +00:00
|
|
|
|
|
2007-01-05 13:31:34 +00:00
|
|
|
|
/// return the current WorkArea (the one that has the focus).
|
2007-08-14 09:54:59 +00:00
|
|
|
|
WorkArea const * currentWorkArea() const;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
/// FIXME: This non-const access is needed because of
|
2007-01-05 13:31:34 +00:00
|
|
|
|
/// a mis-designed \c ControlSpellchecker.
|
2007-08-14 09:54:59 +00:00
|
|
|
|
WorkArea * currentWorkArea();
|
2007-01-05 13:31:34 +00:00
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
/**
|
2002-06-18 15:44:30 +00:00
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2006-09-29 23:10:17 +00:00
|
|
|
|
virtual void init() = 0;
|
|
|
|
|
|
2007-03-17 12:28:26 +00:00
|
|
|
|
enum Maximized {
|
|
|
|
|
NotMaximized,
|
|
|
|
|
VerticallyMaximized,
|
|
|
|
|
HorizontallyMaximized,
|
|
|
|
|
CompletelyMaximized
|
|
|
|
|
};
|
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
///
|
2006-09-29 23:10:17 +00:00
|
|
|
|
virtual void setGeometry(
|
|
|
|
|
unsigned int width,
|
|
|
|
|
unsigned int height,
|
|
|
|
|
int posx, int posy,
|
2007-03-17 12:28:26 +00:00
|
|
|
|
int maximize,
|
2006-11-29 16:45:38 +00:00
|
|
|
|
unsigned int iconSizeXY,
|
|
|
|
|
const std::string & geometryArg) = 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
/// save the geometry state in the session manager.
|
|
|
|
|
virtual void saveGeometry() = 0;
|
|
|
|
|
|
2003-02-14 14:49:51 +00:00
|
|
|
|
/// show busy cursor
|
2006-10-26 13:29:10 +00:00
|
|
|
|
virtual void busy(bool) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-04-21 17:38:43 +00:00
|
|
|
|
virtual Toolbars::ToolbarPtr makeToolbar(ToolbarInfo const & tbinfo, bool newline) = 0;
|
2006-09-10 11:03:21 +00:00
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
//@{ generic accessor functions
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-08-02 09:21:50 +00:00
|
|
|
|
/** 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.
|
|
|
|
|
*/
|
2006-06-26 16:55:35 +00:00
|
|
|
|
BufferView * view() const;
|
2000-07-25 10:46:18 +00:00
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
/// return the buffer currently shown in this window
|
|
|
|
|
Buffer * buffer() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
/// return the toolbar for this view
|
2004-04-29 09:54:59 +00:00
|
|
|
|
Toolbars & getToolbars() { return *toolbars_.get(); }
|
2002-08-13 14:40:38 +00:00
|
|
|
|
///
|
2004-09-27 20:52:39 +00:00
|
|
|
|
Toolbars const & getToolbars() const { return *toolbars_.get(); }
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-06-12 02:54:19 +00:00
|
|
|
|
/// return the menubar for this view
|
2002-08-13 14:40:38 +00:00
|
|
|
|
Menubar & getMenubar() { return *menubar_.get(); }
|
|
|
|
|
///
|
|
|
|
|
Menubar const & getMenubar() const { return *menubar_.get(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-06-12 02:54:19 +00:00
|
|
|
|
/// get access to the dialogs
|
2002-08-13 14:40:38 +00:00
|
|
|
|
Dialogs & getDialogs() { return *dialogs_.get(); }
|
|
|
|
|
///
|
|
|
|
|
Dialogs const & getDialogs() const { return *dialogs_.get(); }
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
//@}
|
|
|
|
|
|
2007-06-19 14:56:52 +00:00
|
|
|
|
/// load a buffer into the current workarea.
|
|
|
|
|
bool loadLyXFile(support::FileName const & name, ///< File to load.
|
|
|
|
|
bool tolastfiles = true, ///< append to the "Open recent" menu?
|
|
|
|
|
bool child_document = false, ///< Is this a child document?
|
|
|
|
|
bool auto_open = false); ///< Is this being opened by LyX itself?
|
|
|
|
|
|
|
|
|
|
/// set a buffer to the current workarea.
|
|
|
|
|
void setBuffer(Buffer * b, ///< \c Buffer to set.
|
|
|
|
|
bool child_document = false); ///< Is this a child document?
|
2006-07-13 16:37:55 +00:00
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
/// updates the possible layouts selectable
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void updateLayoutChoice();
|
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
/// update the toolbar
|
2004-04-29 09:54:59 +00:00
|
|
|
|
void updateToolbars();
|
2007-07-09 20:33:32 +00:00
|
|
|
|
/// get toolbar info
|
|
|
|
|
ToolbarInfo * getToolbarInfo(std::string const & name);
|
2006-11-02 16:01:36 +00:00
|
|
|
|
/// toggle toolbar state
|
2007-06-06 13:52:31 +00:00
|
|
|
|
void toggleToolbarState(std::string const & name, bool allowauto);
|
2002-06-12 11:34:13 +00:00
|
|
|
|
/// update the menubar
|
|
|
|
|
void updateMenubar();
|
2006-07-13 16:37:55 +00:00
|
|
|
|
/// update the status bar
|
|
|
|
|
virtual void updateStatusBar() = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-07-19 20:56:31 +00:00
|
|
|
|
/// focus the command buffer (minibuffer)
|
2004-09-26 14:19:47 +00:00
|
|
|
|
boost::signal<void()> focus_command_buffer;
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
/// display a message in the view
|
2006-10-21 00:16:43 +00:00
|
|
|
|
virtual void message(docstring const &) = 0;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
2003-04-07 16:57:38 +00:00
|
|
|
|
/// clear any temporary message and replace with current status
|
|
|
|
|
virtual void clearMessage() = 0;
|
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
/// updates the title of the window
|
|
|
|
|
void updateWindowTitle();
|
2000-07-20 11:39:14 +00:00
|
|
|
|
|
2006-10-31 14:12:46 +00:00
|
|
|
|
/// updates the tab view
|
|
|
|
|
virtual void updateTab() = 0;
|
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
/// reset autosave timer
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void resetAutosaveTimer();
|
2002-06-12 11:34:13 +00:00
|
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
|
/// dispatch to current BufferView
|
2004-01-15 17:34:44 +00:00
|
|
|
|
void dispatch(FuncRequest const & cmd);
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2003-10-14 21:30:23 +00:00
|
|
|
|
/** redraw \c inset in all the BufferViews in which it is currently
|
|
|
|
|
* visible. If successful return a pointer to the owning Buffer.
|
|
|
|
|
*/
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Buffer const * const updateInset(Inset const *) const;
|
2003-10-14 21:30:23 +00:00
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
|
/// returns true if this view has the focus.
|
2004-11-16 10:46:23 +00:00
|
|
|
|
virtual bool hasFocus() const = 0;
|
|
|
|
|
|
2006-07-14 21:47:48 +00:00
|
|
|
|
/// show the error list to the user
|
|
|
|
|
void showErrorList(std::string const &);
|
|
|
|
|
|
2006-09-19 13:36:20 +00:00
|
|
|
|
/// connect to signals in the given BufferView
|
|
|
|
|
void connectBufferView(BufferView & bv);
|
|
|
|
|
/// disconnect from signals in the given BufferView
|
|
|
|
|
void disconnectBufferView();
|
|
|
|
|
|
2001-07-03 15:19:04 +00:00
|
|
|
|
protected:
|
2006-07-03 22:31:51 +00:00
|
|
|
|
/// current work area (screen view of a BufferView).
|
2006-06-26 16:55:35 +00:00
|
|
|
|
/**
|
2006-07-03 22:31:51 +00:00
|
|
|
|
\todo FIXME: there is only one workArea per LyXView for now.
|
2006-06-26 16:55:35 +00:00
|
|
|
|
*/
|
2006-10-21 00:16:43 +00:00
|
|
|
|
frontend::WorkArea * work_area_;
|
2002-06-12 02:54:19 +00:00
|
|
|
|
|
|
|
|
|
/// view's menubar
|
|
|
|
|
boost::scoped_ptr<Menubar> menubar_;
|
|
|
|
|
|
1999-10-25 14:18:30 +00:00
|
|
|
|
private:
|
2002-06-12 02:54:19 +00:00
|
|
|
|
/**
|
|
|
|
|
* setWindowTitle - set title of window
|
|
|
|
|
* @param t main window title
|
|
|
|
|
* @param it iconified (short) title
|
|
|
|
|
*/
|
2006-10-21 00:16:43 +00:00
|
|
|
|
virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
|
2002-06-12 02:54:19 +00:00
|
|
|
|
|
2002-08-13 14:40:38 +00:00
|
|
|
|
/// called on timeout
|
|
|
|
|
void autoSave();
|
|
|
|
|
|
2004-04-29 09:54:59 +00:00
|
|
|
|
/// view's toolbar
|
|
|
|
|
boost::scoped_ptr<Toolbars> toolbars_;
|
2002-08-13 14:40:38 +00:00
|
|
|
|
/// auto-saving of buffers
|
|
|
|
|
boost::scoped_ptr<Timeout> const autosave_timeout_;
|
2002-06-12 02:54:19 +00:00
|
|
|
|
/// our function handler
|
|
|
|
|
boost::scoped_ptr<LyXFunc> lyxfunc_;
|
|
|
|
|
/// dialogs for this view
|
|
|
|
|
boost::scoped_ptr<Dialogs> dialogs_;
|
2002-08-14 09:52:30 +00:00
|
|
|
|
|
2006-10-22 10:51:59 +00:00
|
|
|
|
/// buffer changed signal connection
|
|
|
|
|
boost::signals::connection bufferChangedConnection_;
|
2007-03-12 11:23:41 +00:00
|
|
|
|
/// buffer structure changed signal connection
|
|
|
|
|
boost::signals::connection bufferStructureChangedConnection_;
|
2006-07-14 21:47:48 +00:00
|
|
|
|
/// buffer errors signal connection
|
2006-07-15 22:43:37 +00:00
|
|
|
|
boost::signals::connection errorsConnection_;
|
2006-07-14 21:47:48 +00:00
|
|
|
|
/// 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
|
2007-08-03 14:07:39 +00:00
|
|
|
|
/// NOTE: Do not call this unless you really want no buffer
|
|
|
|
|
/// to be connected---for example, when closing the last open
|
|
|
|
|
/// buffer. If you are switching buffers, just call
|
|
|
|
|
/// connectBuffer(), and the old buffer will be disconnected
|
|
|
|
|
/// automatically. This ensures that we do not leave LyX in a
|
|
|
|
|
/// state in which no buffer is connected.
|
2006-07-14 21:47:48 +00:00
|
|
|
|
void disconnectBuffer();
|
2006-09-19 13:36:20 +00:00
|
|
|
|
|
|
|
|
|
/// 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_;
|
2006-09-26 10:06:46 +00:00
|
|
|
|
boost::signals::connection layout_changed_connection_;
|
2006-09-19 13:36:20 +00:00
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/// 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,
|
2007-04-29 13:39:47 +00:00
|
|
|
|
std::string const & data, Inset * inset);
|
2006-09-19 13:36:20 +00:00
|
|
|
|
void updateDialog(std::string const & name,
|
|
|
|
|
std::string const & data);
|
|
|
|
|
//@}
|
|
|
|
|
|
2006-07-14 21:47:48 +00:00
|
|
|
|
/// notify readonly status
|
|
|
|
|
void showReadonly(bool);
|
|
|
|
|
|
2002-08-14 09:52:30 +00:00
|
|
|
|
protected:
|
2007-03-12 11:23:41 +00:00
|
|
|
|
///
|
|
|
|
|
void updateToc();
|
|
|
|
|
|
2002-08-14 09:52:30 +00:00
|
|
|
|
/// view's command buffer controller
|
|
|
|
|
// this has to be declared _after_ lyxfunc_ as its initialization depends
|
|
|
|
|
// on it!
|
2007-08-14 09:54:59 +00:00
|
|
|
|
typedef boost::scoped_ptr<ControlCommandBuffer>
|
2004-05-19 15:11:37 +00:00
|
|
|
|
CommandBufferPtr;
|
|
|
|
|
|
|
|
|
|
CommandBufferPtr const controlcommand_;
|
2006-10-23 16:29:24 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int id_;
|
|
|
|
|
std::vector<int> work_area_ids_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
2002-06-12 02:54:19 +00:00
|
|
|
|
|
2007-08-14 09:54:59 +00:00
|
|
|
|
} // namespace frontend
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-06-12 02:54:19 +00:00
|
|
|
|
#endif // LYXVIEW_H
|