2007-03-12 14:23:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file DockView.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DOCK_VIEW_H
|
|
|
|
#define DOCK_VIEW_H
|
|
|
|
|
2007-03-12 15:11:18 +00:00
|
|
|
#include "controllers/Dialog.h"
|
|
|
|
#include "qt_helpers.h"
|
2007-03-12 14:23:44 +00:00
|
|
|
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
/*
|
2007-03-12 14:23:44 +00:00
|
|
|
/// Dock Widget container for LyX dialogs.
|
|
|
|
/// This template class that encapsulates a given Widget inside a
|
|
|
|
/// DockWidget and presents a Dialog::View interface
|
|
|
|
template<class Controller, class Widget>
|
2007-05-28 22:27:45 +00:00
|
|
|
class DockView : public QDockWidget, public Dialog::View
|
2007-03-12 14:23:44 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DockView(
|
|
|
|
Dialog & dialog, ///< The (one) parent Dialog class.
|
|
|
|
Controller * form, ///< Associated model/controller
|
|
|
|
QMainWindow * parent, ///< the main window where to dock.
|
2007-03-25 01:25:29 +00:00
|
|
|
docstring const & title, ///< Window title (shown in the top title bar).
|
2007-05-29 11:38:28 +00:00
|
|
|
Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
|
|
|
|
Qt::WindowFlags flags = 0
|
2007-03-12 14:23:44 +00:00
|
|
|
)
|
2007-05-29 11:38:28 +00:00
|
|
|
: QDockWidget(toqstr(title), parent, flags),
|
|
|
|
Dialog::View(dialog, title)
|
2007-03-12 14:23:44 +00:00
|
|
|
{
|
2007-05-29 11:38:28 +00:00
|
|
|
if (flags & Qt::Drawer)
|
|
|
|
setFeatures(QDockWidget::NoDockWidgetFeatures);
|
2007-03-12 14:23:44 +00:00
|
|
|
widget_.reset(new Widget(form));
|
|
|
|
setWidget(widget_.get());
|
2007-03-25 01:25:29 +00:00
|
|
|
parent->addDockWidget(area, this);
|
2007-03-12 14:23:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Dialog::View inherited methods
|
|
|
|
//@{
|
2007-09-03 20:28:26 +00:00
|
|
|
void applyView() {}
|
|
|
|
void hideView() { QDockWidget::hide(); }
|
|
|
|
void showView() { QDockWidget::show(); }
|
|
|
|
bool isVisibleView() const { return QDockWidget::isVisible(); }
|
|
|
|
void redrawView() {}
|
|
|
|
void updateView()
|
2007-03-12 14:23:44 +00:00
|
|
|
{
|
|
|
|
widget_->update();
|
|
|
|
QDockWidget::update();
|
|
|
|
}
|
|
|
|
//@}
|
|
|
|
private:
|
|
|
|
/// The encapsulated widget.
|
|
|
|
boost::scoped_ptr<Widget> widget_;
|
|
|
|
};
|
2007-09-05 20:33:29 +00:00
|
|
|
*/
|
2007-03-12 14:23:44 +00:00
|
|
|
|
|
|
|
} // frontend
|
|
|
|
} // lyx
|
|
|
|
|
|
|
|
#endif // TOC_WIDGET_H
|