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"
|
|
|
|
|
|
2006-09-29 22:06:28 +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; }
|
|
|
|
|
|
2001-07-03 15:19:04 +00:00
|
|
|
|
class Buffer;
|
2004-04-13 13:10:33 +00:00
|
|
|
|
class InsetBase;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
class Menubar;
|
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
class BufferView;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
class Dialogs;
|
2001-07-03 15:19:04 +00:00
|
|
|
|
class LyXFunc;
|
2002-06-12 02:54:19 +00:00
|
|
|
|
class LyXFont;
|
2002-02-18 19:13:48 +00:00
|
|
|
|
class Timeout;
|
2002-08-13 17:43:40 +00:00
|
|
|
|
class FuncRequest;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
|
namespace frontend {
|
2006-07-03 22:31:51 +00:00
|
|
|
|
class WorkArea;
|
2004-05-19 15:11:37 +00:00
|
|
|
|
class ControlCommandBuffer;
|
|
|
|
|
} // namespace frontend
|
2006-06-20 08:39:16 +00:00
|
|
|
|
|
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()
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void setWorkArea(frontend::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).
|
|
|
|
|
frontend::WorkArea const * currentWorkArea() const;
|
|
|
|
|
/// FIXME: This non-const access is needed because of
|
|
|
|
|
/// a mis-designed \c ControlSpellchecker.
|
|
|
|
|
frontend::WorkArea * currentWorkArea();
|
|
|
|
|
|
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
|
|
|
|
//@}
|
|
|
|
|
|
2006-07-13 16:37:55 +00:00
|
|
|
|
/// load a buffer into the current workarea
|
2006-12-02 16:07:15 +00:00
|
|
|
|
bool loadLyXFile(support::FileName const & name, bool tolastfiles = true);
|
2006-07-13 16:37:55 +00:00
|
|
|
|
|
|
|
|
|
/// set a buffer to the current workarea
|
|
|
|
|
void setBuffer(Buffer * b);
|
|
|
|
|
|
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();
|
2006-11-02 18:59:33 +00:00
|
|
|
|
/// get toolbar state
|
2007-04-19 19:43:15 +00:00
|
|
|
|
ToolbarInfo::Flags getToolbarState(std::string const & name);
|
2006-11-02 16:01:36 +00:00
|
|
|
|
/// toggle toolbar state
|
|
|
|
|
void toggleToolbarState(std::string const & name);
|
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.
|
|
|
|
|
*/
|
2004-04-13 13:10:33 +00:00
|
|
|
|
Buffer const * const updateInset(InsetBase 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
|
|
|
|
|
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,
|
|
|
|
|
std::string const & data, InsetBase * inset);
|
|
|
|
|
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!
|
2006-10-21 00:16:43 +00:00
|
|
|
|
typedef boost::scoped_ptr<frontend::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
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-06-12 02:54:19 +00:00
|
|
|
|
#endif // LYXVIEW_H
|