2006-03-05 17:24:44 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
2006-06-20 09:33:01 +00:00
|
|
|
|
* \file GuiView.h
|
2006-03-05 17:24:44 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bjornes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Abdelrazak Younes
|
2006-11-29 10:04:35 +00:00
|
|
|
|
* \author Peter K<EFBFBD>mmel
|
2006-03-05 17:24:44 +00:00
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
|
#ifndef GUI_VIEW_H
|
|
|
|
|
#define GUI_VIEW_H
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
|
2007-11-22 23:29:53 +00:00
|
|
|
|
#include "support/strfwd.h"
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
2007-08-14 13:20:16 +00:00
|
|
|
|
#include <QMainWindow>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
|
class QCloseEvent;
|
2007-08-14 13:20:16 +00:00
|
|
|
|
class QDragEnterEvent;
|
|
|
|
|
class QDropEvent;
|
2006-11-08 23:10:46 +00:00
|
|
|
|
class QMenu;
|
2007-11-15 12:58:44 +00:00
|
|
|
|
class QShowEvent;
|
2007-11-12 23:23:19 +00:00
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2007-11-12 23:23:19 +00:00
|
|
|
|
|
2007-11-13 14:49:50 +00:00
|
|
|
|
class ToolbarInfo;
|
2007-11-12 23:23:19 +00:00
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2007-11-18 23:49:52 +00:00
|
|
|
|
class Dialog;
|
2007-11-20 22:03:56 +00:00
|
|
|
|
class GuiLayoutBox;
|
2007-10-01 20:45:50 +00:00
|
|
|
|
class GuiToolbar;
|
2007-10-06 15:48:58 +00:00
|
|
|
|
class GuiWorkArea;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2006-06-20 09:33:01 +00:00
|
|
|
|
* GuiView - Qt4 implementation of LyXView
|
2006-03-05 17:24:44 +00:00
|
|
|
|
*
|
2006-06-26 16:55:35 +00:00
|
|
|
|
* qt4-private implementation of the main LyX window.
|
2006-10-24 15:01:07 +00:00
|
|
|
|
*
|
2007-08-31 05:53:55 +00:00
|
|
|
|
* Note: a QObject emits a destroyed(QObject *) Qt signal when it
|
|
|
|
|
* is deleted. This might be useful for closing other dialogs
|
|
|
|
|
* depending on a given GuiView.
|
2006-03-05 17:24:44 +00:00
|
|
|
|
*/
|
2007-11-21 22:48:13 +00:00
|
|
|
|
class GuiView : public QMainWindow, public LyXView, public GuiBufferViewDelegate,
|
|
|
|
|
public GuiBufferDelegate
|
2007-09-05 20:33:29 +00:00
|
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2006-06-26 16:55:35 +00:00
|
|
|
|
/// create a main window of the given dimensions
|
2007-11-05 13:52:37 +00:00
|
|
|
|
GuiView(int id);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
|
~GuiView();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-11-18 23:30:41 +00:00
|
|
|
|
///
|
|
|
|
|
int id() const { return id_; }
|
|
|
|
|
void close();
|
|
|
|
|
void setFocus();
|
|
|
|
|
void setBusy(bool);
|
2007-11-20 22:03:56 +00:00
|
|
|
|
/// returns true if this view has the focus.
|
|
|
|
|
bool hasFocus() const;
|
2007-11-15 12:58:44 +00:00
|
|
|
|
|
2007-01-31 02:39:46 +00:00
|
|
|
|
/// add toolbar, if newline==true, add a toolbar break before the toolbar
|
2007-10-01 20:45:50 +00:00
|
|
|
|
GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
|
2006-10-23 16:29:24 +00:00
|
|
|
|
virtual void updateStatusBar();
|
2007-04-25 16:39:21 +00:00
|
|
|
|
virtual void message(docstring const & str);
|
2007-11-20 22:03:56 +00:00
|
|
|
|
|
|
|
|
|
/// updates the possible layouts selectable
|
|
|
|
|
void updateLayoutList();
|
2007-10-01 20:45:50 +00:00
|
|
|
|
void updateToolbars();
|
2007-11-12 23:23:19 +00:00
|
|
|
|
QMenu * createPopupMenu();
|
2007-11-19 20:56:05 +00:00
|
|
|
|
FuncStatus getStatus(FuncRequest const & cmd);
|
2007-11-12 23:23:19 +00:00
|
|
|
|
void dispatch(FuncRequest const & cmd);
|
|
|
|
|
|
2007-11-20 22:03:56 +00:00
|
|
|
|
///
|
|
|
|
|
void setLayoutDialog(GuiLayoutBox *);
|
|
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
|
/// \return the buffer currently shown in this window
|
|
|
|
|
Buffer * buffer();
|
|
|
|
|
Buffer const * buffer() const;
|
|
|
|
|
/// set a buffer to the current workarea.
|
|
|
|
|
void setBuffer(Buffer * b); ///< \c Buffer to set.
|
|
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
|
/// GuiBufferDelegate.
|
|
|
|
|
///@{
|
|
|
|
|
void resetAutosaveTimers();
|
|
|
|
|
void errors(std::string const &);
|
|
|
|
|
void structureChanged() { updateToc(); }
|
|
|
|
|
///@}
|
|
|
|
|
|
|
|
|
|
/// called on timeout
|
|
|
|
|
void autoSave();
|
2007-11-11 22:30:21 +00:00
|
|
|
|
///
|
2007-11-13 14:04:32 +00:00
|
|
|
|
void updateEmbeddedFiles();
|
2007-11-11 22:30:21 +00:00
|
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
|
/// \return the current buffer view.
|
|
|
|
|
BufferView * view();
|
2006-10-31 14:12:46 +00:00
|
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
|
/** redraw \c inset in all the BufferViews in which it is currently
|
|
|
|
|
* visible. If successful return a pointer to the owning Buffer.
|
|
|
|
|
*/
|
|
|
|
|
Buffer const * updateInset(Inset const *);
|
2006-06-21 10:30:32 +00:00
|
|
|
|
///
|
2007-11-13 14:04:32 +00:00
|
|
|
|
void restartCursor();
|
2006-06-21 10:30:32 +00:00
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
/// \return the \c Workarea associated to \p Buffer
|
|
|
|
|
/// \retval 0 if no \c WorkArea is found.
|
2007-11-13 09:52:28 +00:00
|
|
|
|
GuiWorkArea * workArea(Buffer & buffer);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
|
|
|
|
|
/// Add a \c WorkArea
|
|
|
|
|
/// \return the \c Workarea associated to \p Buffer
|
|
|
|
|
/// \retval 0 if no \c WorkArea is found.
|
2007-11-13 09:52:28 +00:00
|
|
|
|
GuiWorkArea * addWorkArea(Buffer & buffer);
|
2007-11-12 23:23:19 +00:00
|
|
|
|
///
|
2007-11-13 09:52:28 +00:00
|
|
|
|
void setCurrentWorkArea(GuiWorkArea * work_area);
|
2007-11-12 23:23:19 +00:00
|
|
|
|
///
|
2007-11-13 09:52:28 +00:00
|
|
|
|
void removeWorkArea(GuiWorkArea * work_area);
|
|
|
|
|
/// return the current WorkArea (the one that has the focus).
|
|
|
|
|
GuiWorkArea const * currentWorkArea() const;
|
|
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void closing(int);
|
2007-11-13 09:52:28 +00:00
|
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
|
public Q_SLOTS:
|
|
|
|
|
/// idle timeout.
|
|
|
|
|
/// clear any temporary message and replace with current status.
|
|
|
|
|
void clearMessage();
|
|
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
|
///
|
|
|
|
|
void updateWindowTitle(GuiWorkArea * wa);
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
void on_currentWorkAreaChanged(GuiWorkArea *);
|
|
|
|
|
|
|
|
|
|
/// slots to change the icon size
|
|
|
|
|
void smallSizedIcons();
|
|
|
|
|
void normalSizedIcons();
|
|
|
|
|
void bigSizedIcons();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
///
|
|
|
|
|
void addTabWorkArea();
|
2007-11-13 09:52:28 +00:00
|
|
|
|
|
|
|
|
|
/// connect to signals in the given BufferView
|
2007-11-12 23:23:19 +00:00
|
|
|
|
void connectBufferView(BufferView & bv);
|
2007-11-13 09:52:28 +00:00
|
|
|
|
/// disconnect from signals in the given BufferView
|
2007-11-12 23:23:19 +00:00
|
|
|
|
void disconnectBufferView();
|
2007-11-13 09:52:28 +00:00
|
|
|
|
/// connect to signals in the given buffer
|
|
|
|
|
void connectBuffer(Buffer & buf);
|
|
|
|
|
/// disconnect from signals in the given buffer
|
|
|
|
|
void disconnectBuffer();
|
2007-11-12 23:23:19 +00:00
|
|
|
|
///
|
|
|
|
|
void updateToc();
|
2007-08-14 13:14:47 +00:00
|
|
|
|
///
|
|
|
|
|
void dragEnterEvent(QDragEnterEvent * ev);
|
|
|
|
|
///
|
|
|
|
|
void dropEvent(QDropEvent * ev);
|
2007-11-13 14:04:32 +00:00
|
|
|
|
/// make sure we quit cleanly
|
2007-11-15 12:58:44 +00:00
|
|
|
|
void closeEvent(QCloseEvent * e);
|
2007-11-13 14:04:32 +00:00
|
|
|
|
///
|
2007-11-15 12:58:44 +00:00
|
|
|
|
void showEvent(QShowEvent *);
|
2007-08-14 13:14:47 +00:00
|
|
|
|
|
2006-12-20 21:28:05 +00:00
|
|
|
|
/// in order to catch Tab key press.
|
|
|
|
|
bool event(QEvent * e);
|
2006-12-22 16:13:19 +00:00
|
|
|
|
bool focusNextPrevChild(bool);
|
2007-11-12 22:15:51 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
struct GuiViewPrivate;
|
|
|
|
|
GuiViewPrivate & d;
|
2006-12-20 21:28:05 +00:00
|
|
|
|
|
2007-11-18 00:01:14 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
2007-11-12 23:23:19 +00:00
|
|
|
|
/// dialogs for this view
|
2007-11-18 00:01:14 +00:00
|
|
|
|
///
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-11-21 15:12:47 +00:00
|
|
|
|
///
|
|
|
|
|
void resetDialogs();
|
|
|
|
|
|
2007-11-18 00:01:14 +00:00
|
|
|
|
/** Check the status of all visible dialogs and disable or reenable
|
|
|
|
|
* them as appropriate.
|
|
|
|
|
*
|
|
|
|
|
* Disabling is needed for example when a dialog is open and the
|
|
|
|
|
* cursor moves to a position where the corresponding inset is not
|
|
|
|
|
* allowed.
|
|
|
|
|
*/
|
|
|
|
|
void checkStatus();
|
|
|
|
|
|
|
|
|
|
/// Hide all visible dialogs
|
|
|
|
|
void hideAll() const;
|
|
|
|
|
/// Hide any dialogs that require a buffer for them to operate
|
|
|
|
|
void hideBufferDependent() const;
|
|
|
|
|
/** Update visible, buffer-dependent dialogs
|
|
|
|
|
If the bool is true then a buffer change has occurred
|
|
|
|
|
else it is still the same buffer.
|
|
|
|
|
*/
|
|
|
|
|
void updateBufferDependent(bool) const;
|
|
|
|
|
|
|
|
|
|
/** \param name == "bibtex", "citation" etc; an identifier used to
|
|
|
|
|
launch a particular dialog.
|
|
|
|
|
\param data is a string representation of the Inset contents.
|
|
|
|
|
It is often little more than the output from Inset::write.
|
|
|
|
|
It is passed to, and parsed by, the frontend dialog.
|
|
|
|
|
Several of these dialogs do not need any data,
|
|
|
|
|
so it defaults to string().
|
|
|
|
|
\param inset ownership is _not_ passed to the frontend dialog.
|
|
|
|
|
It is stored internally and used by the kernel to ascertain
|
|
|
|
|
what to do with the FuncRequest dispatched from the frontend
|
|
|
|
|
dialog on 'Apply'; should it be used to create a new inset at
|
|
|
|
|
the current cursor position or modify an existing, 'open' inset?
|
|
|
|
|
*/
|
|
|
|
|
void showDialog(std::string const & name,
|
2007-11-18 00:39:15 +00:00
|
|
|
|
std::string const & data, Inset * inset = 0);
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
|
|
|
|
/** \param name == "citation", "bibtex" etc; an identifier used
|
|
|
|
|
to update the contents of a particular dialog with \param data.
|
|
|
|
|
See the comments to 'show', above.
|
|
|
|
|
*/
|
|
|
|
|
void updateDialog(std::string const & name, std::string const & data);
|
|
|
|
|
|
|
|
|
|
/** All Dialogs of the given \param name will be closed if they are
|
|
|
|
|
connected to the given \param inset.
|
|
|
|
|
*/
|
|
|
|
|
void hideDialog(std::string const & name, Inset * inset);
|
|
|
|
|
///
|
|
|
|
|
void disconnectDialog(std::string const & name);
|
2007-11-23 09:44:02 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2007-11-18 00:01:14 +00:00
|
|
|
|
///
|
|
|
|
|
Inset * getOpenInset(std::string const & name) const;
|
|
|
|
|
|
2007-11-19 20:56:05 +00:00
|
|
|
|
/// Is the dialog currently visible?
|
|
|
|
|
bool isDialogVisible(std::string const & name) const;
|
2007-11-18 00:01:14 +00:00
|
|
|
|
///
|
|
|
|
|
Dialog * find_or_build(std::string const & name);
|
|
|
|
|
///
|
|
|
|
|
Dialog * build(std::string const & name);
|
|
|
|
|
|
2007-11-18 23:30:41 +00:00
|
|
|
|
/// This view ID.
|
|
|
|
|
int id_;
|
2007-11-18 00:01:14 +00:00
|
|
|
|
};
|
2007-10-06 15:48:58 +00:00
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2006-06-20 09:33:01 +00:00
|
|
|
|
#endif // GUIVIEW_H
|