2001-06-13 14:33:31 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-05 14:10:50 +00:00
|
|
|
/**
|
|
|
|
* \file ControlConnections.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.
|
2001-03-15 13:37:04 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Angus Leeming
|
2001-03-15 13:37:04 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-22 11:24:36 +00:00
|
|
|
*
|
|
|
|
* ControlConnections.h contains the definition of three controller classes,
|
|
|
|
* ControlConnectBase, ControlConnectBI and ControlConnectBD.
|
|
|
|
*
|
|
|
|
* Together they control the connection/disconnection of signals with the LyX
|
2001-04-03 14:30:58 +00:00
|
|
|
* kernel. Controllers of individual dialogs interacting with the kernel through
|
2001-03-22 11:24:36 +00:00
|
|
|
* signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
|
|
|
|
*
|
2001-04-03 14:30:58 +00:00
|
|
|
* A dialog is classed as "Buffer Dependent" if its contents change with the
|
|
|
|
* buffer (document). An example would be the Citation dialog. Such a dialog
|
2001-03-22 11:24:36 +00:00
|
|
|
* would be derived, therefore, from ControlConnectBD.
|
|
|
|
*
|
2001-04-03 14:30:58 +00:00
|
|
|
* Conversely, a dialog is "Buffer Independent" if its contents do not change
|
|
|
|
* when the buffer changes. An example would be the Copyright dialog. Such a
|
|
|
|
* dialog is therefore derived from ControlConnectBI.
|
2001-03-22 11:24:36 +00:00
|
|
|
*
|
2001-03-15 13:37:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONTROLCONNECTIONS_H
|
|
|
|
#define CONTROLCONNECTIONS_H
|
|
|
|
|
|
|
|
|
2001-04-03 14:30:58 +00:00
|
|
|
#include "ControlButtons.h"
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include <boost/signals/connection.hpp>
|
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
class Buffer;
|
|
|
|
class BufferView;
|
2001-03-22 11:24:36 +00:00
|
|
|
class Dialogs;
|
|
|
|
class LyXView;
|
2002-08-12 20:17:41 +00:00
|
|
|
class LyXFunc;
|
2001-03-22 11:24:36 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
/** Base class to control connection/disconnection of signals with the LyX
|
|
|
|
kernel. It is meant to be used solely as the parent class to
|
|
|
|
ControlConnectBI and ControlConnectBD.
|
|
|
|
*/
|
2002-10-21 17:38:09 +00:00
|
|
|
class ControlConnectBase : public ControlButtons {
|
2001-03-15 13:37:04 +00:00
|
|
|
public:
|
2001-03-26 13:16:57 +00:00
|
|
|
///
|
|
|
|
enum DocTypes {
|
|
|
|
///
|
|
|
|
LATEX,
|
|
|
|
///
|
|
|
|
LITERATE,
|
|
|
|
///
|
|
|
|
LINUXDOC,
|
|
|
|
///
|
|
|
|
DOCBOOK
|
|
|
|
};
|
2001-03-15 13:37:04 +00:00
|
|
|
///
|
|
|
|
ControlConnectBase(LyXView &, Dialogs &);
|
2001-03-22 11:24:36 +00:00
|
|
|
/// The View may need to know if the buffer is read-only.
|
2002-08-12 20:17:41 +00:00
|
|
|
bool bufferIsReadonly() const;
|
2002-03-21 21:21:28 +00:00
|
|
|
///
|
2001-03-26 13:16:57 +00:00
|
|
|
DocTypes docType() const;
|
2001-03-15 13:37:04 +00:00
|
|
|
protected:
|
2001-03-22 11:24:36 +00:00
|
|
|
/// True if the dialog depends on the buffer, else false.
|
|
|
|
virtual bool isBufferDependent() const = 0;
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
/// Connect signals
|
|
|
|
virtual void connect();
|
|
|
|
/// Disconnect signals
|
|
|
|
virtual void disconnect();
|
|
|
|
|
|
|
|
/** Redraw the dialog (on receipt of a Signal indicating, for example,
|
|
|
|
its colors have been re-mapped).
|
|
|
|
*/
|
|
|
|
void redraw();
|
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
/// a wrapper for BufferView::avaliable()
|
|
|
|
bool bufferIsAvailable() const;
|
|
|
|
/// a wrapper for LyXView::view()
|
|
|
|
BufferView * bufferview();
|
|
|
|
///
|
|
|
|
BufferView const * bufferview() const;
|
|
|
|
/// a wrapper for LyXView::buffer()
|
|
|
|
Buffer * buffer();
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
Buffer const & buffer() const;
|
2002-08-12 20:17:41 +00:00
|
|
|
/// a wrapper for LyXView::getLyXFunc()
|
|
|
|
LyXFunc & lyxfunc();
|
|
|
|
///
|
|
|
|
LyXFunc const & lyxfunc() const;
|
2002-09-24 12:43:01 +00:00
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
///
|
2001-03-22 11:24:36 +00:00
|
|
|
LyXView & lv_;
|
2001-03-15 13:37:04 +00:00
|
|
|
/// Contains the signals we have to connect to.
|
|
|
|
Dialogs & d_;
|
|
|
|
/// Hide connection.
|
2002-05-29 16:21:03 +00:00
|
|
|
boost::signals::connection h_;
|
2001-03-15 13:37:04 +00:00
|
|
|
/// Redraw connection.
|
2002-05-29 16:21:03 +00:00
|
|
|
boost::signals::connection r_;
|
2001-03-15 13:37:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** Base class to control connection/disconnection of signals with the LyX
|
|
|
|
kernel for Buffer Independent dialogs.
|
|
|
|
Such dialogs do not require an update Connection although they may use
|
|
|
|
an update() function which is also supported by the Restore button.
|
|
|
|
*/
|
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
class ControlConnectBI : public ControlConnectBase {
|
2001-03-15 13:37:04 +00:00
|
|
|
public:
|
2002-03-21 21:21:28 +00:00
|
|
|
///
|
|
|
|
ControlConnectBI(LyXView &, Dialogs &);
|
2001-03-15 13:37:04 +00:00
|
|
|
protected:
|
2001-03-22 11:24:36 +00:00
|
|
|
///
|
|
|
|
virtual bool isBufferDependent() const { return false; }
|
2001-03-15 13:37:04 +00:00
|
|
|
/// Connect signals
|
|
|
|
virtual void connect();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** Base class to control connection/disconnection of signals with the LyX
|
|
|
|
kernel for Buffer Dependent dialogs.
|
|
|
|
*/
|
2002-10-21 17:38:09 +00:00
|
|
|
class ControlConnectBD : public ControlConnectBase {
|
2001-03-15 13:37:04 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
ControlConnectBD(LyXView &, Dialogs &);
|
|
|
|
protected:
|
2001-03-22 11:24:36 +00:00
|
|
|
///
|
|
|
|
virtual bool isBufferDependent() const { return true; }
|
2001-03-15 13:37:04 +00:00
|
|
|
/// Connect signals
|
|
|
|
virtual void connect();
|
|
|
|
/// Disconnect signals
|
|
|
|
virtual void disconnect();
|
|
|
|
private:
|
2001-03-23 17:09:34 +00:00
|
|
|
/** Slot connected to update signal.
|
|
|
|
Bool indicates if a buffer switch took place.
|
|
|
|
Default behaviour is to ignore this and simply update().
|
|
|
|
*/
|
|
|
|
virtual void updateSlot(bool) { update(); }
|
2001-03-15 13:37:04 +00:00
|
|
|
/// Update connection.
|
2002-05-29 16:21:03 +00:00
|
|
|
boost::signals::connection u_;
|
2001-03-15 13:37:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONTROLCONNECTIONS_H
|