2001-06-13 13:44:23 +00:00
|
|
|
// -*- C++ -*-
|
2001-03-22 11:24:36 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file ControlDialogs.h
|
|
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
|
|
*
|
2001-04-03 14:30:58 +00:00
|
|
|
* ControlDialog is to be used as a parent class for dialogs that are not
|
|
|
|
* views onto parameters of insets. (An ugly description I know, but I hope
|
|
|
|
* the meaning is clear! * Can anyone do any better?) Examples would be the
|
|
|
|
* Document and Paragraph dialogs.
|
2001-03-22 11:24:36 +00:00
|
|
|
*/
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
#ifndef CONTROLDIALOGS_H
|
|
|
|
#define CONTROLDIALOGS_H
|
2001-03-22 11:24:36 +00:00
|
|
|
|
|
|
|
#include "ControlConnections.h"
|
2001-08-28 12:24:03 +00:00
|
|
|
#include "debug.h"
|
2001-03-22 11:24:36 +00:00
|
|
|
|
|
|
|
/** Base class to control connection/disconnection of signals with the LyX
|
|
|
|
kernel for dialogs NOT used with insets.
|
|
|
|
The Base class will be either ControlConnectBI or ControlConnectBD.
|
|
|
|
*/
|
|
|
|
template <class Base>
|
|
|
|
class ControlDialog : public Base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
ControlDialog(LyXView &, Dialogs &);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Show the dialog.
|
|
|
|
virtual void show();
|
|
|
|
/// Hide the dialog.
|
|
|
|
virtual void hide();
|
|
|
|
/// Update the dialog.
|
|
|
|
virtual void update();
|
|
|
|
|
|
|
|
/// clean-up on hide.
|
|
|
|
virtual void clearParams() {}
|
2001-03-23 17:09:34 +00:00
|
|
|
/// set the params before show or update
|
|
|
|
virtual void setParams() {}
|
2001-08-28 12:24:03 +00:00
|
|
|
|
2001-09-12 09:35:25 +00:00
|
|
|
private:
|
2001-08-28 12:24:03 +00:00
|
|
|
/// is the dialog built ?
|
|
|
|
bool dialog_built_;
|
2001-03-22 11:24:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
#include "LyXView.h"
|
2001-03-22 11:24:36 +00:00
|
|
|
|
|
|
|
template <class Base>
|
|
|
|
ControlDialog<Base>::ControlDialog(LyXView & lv, Dialogs & d)
|
2001-08-28 12:24:03 +00:00
|
|
|
: Base(lv, d), dialog_built_(false)
|
2001-03-22 11:24:36 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Base>
|
|
|
|
void ControlDialog<Base>::show()
|
|
|
|
{
|
|
|
|
if (isBufferDependent() && !lv_.view()->available())
|
|
|
|
return;
|
|
|
|
|
2001-09-12 09:35:25 +00:00
|
|
|
connect();
|
|
|
|
|
2001-03-22 11:24:36 +00:00
|
|
|
setParams();
|
|
|
|
|
2001-08-28 12:24:03 +00:00
|
|
|
if (!dialog_built_) {
|
2001-08-24 14:57:27 +00:00
|
|
|
view().build();
|
2001-08-28 12:24:03 +00:00
|
|
|
dialog_built_ = true;
|
2001-08-24 14:57:27 +00:00
|
|
|
}
|
|
|
|
|
2001-03-22 11:24:36 +00:00
|
|
|
bc().readOnly(isReadonly());
|
|
|
|
view().show();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Base>
|
|
|
|
void ControlDialog<Base>::update()
|
|
|
|
{
|
|
|
|
if (isBufferDependent() && !lv_.view()->available())
|
|
|
|
return;
|
|
|
|
|
|
|
|
setParams();
|
2001-08-24 14:57:27 +00:00
|
|
|
|
2001-03-22 11:24:36 +00:00
|
|
|
bc().readOnly(isReadonly());
|
|
|
|
view().update();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Base>
|
|
|
|
void ControlDialog<Base>::hide()
|
|
|
|
{
|
|
|
|
clearParams();
|
|
|
|
|
|
|
|
disconnect();
|
|
|
|
view().hide();
|
|
|
|
}
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
#endif // CONTROLDIALOGS_H
|