2003-09-02 10:29:05 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file GViewBase.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Huang Ying
|
|
|
|
*
|
2003-09-02 17:02:32 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-09-02 10:29:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GVIEWBASE_H
|
|
|
|
#define GVIEWBASE_H
|
|
|
|
|
|
|
|
#include "Dialog.h"
|
|
|
|
#include "ButtonPolicies.h"
|
|
|
|
#include "GBC.h"
|
|
|
|
|
2004-09-26 18:36:07 +00:00
|
|
|
#include <gtkmm.h>
|
|
|
|
#include <libglademm.h>
|
|
|
|
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2004-09-26 16:48:30 +00:00
|
|
|
class GViewBase : public Dialog::View, public sigc::trackable {
|
2003-09-02 10:29:05 +00:00
|
|
|
public:
|
2003-10-06 15:43:21 +00:00
|
|
|
GViewBase(Dialog &, std::string const &, bool allowResize);
|
2003-09-02 10:29:05 +00:00
|
|
|
virtual ~GViewBase();
|
2004-02-23 00:21:04 +00:00
|
|
|
void setCancel(Gtk::Button * cancel);
|
|
|
|
void setApply(Gtk::Button * apply);
|
|
|
|
void setOK(Gtk::Button * ok);
|
|
|
|
void setRestore(Gtk::Button * restore);
|
2003-09-02 10:29:05 +00:00
|
|
|
protected:
|
|
|
|
// Build the dialog
|
|
|
|
virtual void build();
|
|
|
|
virtual void doBuild() = 0;
|
|
|
|
// Hide the dialog
|
|
|
|
virtual void hide();
|
|
|
|
// Create the dialog if necessary, update it and display it.
|
|
|
|
virtual void show();
|
|
|
|
//
|
|
|
|
virtual bool isVisible() const;
|
|
|
|
GBC & bcview();
|
|
|
|
void onApply();
|
|
|
|
void onOK();
|
|
|
|
void onCancel();
|
|
|
|
void onRestore();
|
|
|
|
bool onDeleteEvent(GdkEventAny *);
|
|
|
|
private:
|
|
|
|
virtual Gtk::Window * window() = 0;
|
|
|
|
virtual Gtk::Window const * window() const = 0;
|
|
|
|
bool allowResize_;
|
|
|
|
};
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
template <class Dialog>
|
2004-09-26 13:18:29 +00:00
|
|
|
class GViewDB : public GViewBase {
|
2003-09-02 10:29:05 +00:00
|
|
|
protected:
|
2003-10-06 15:43:21 +00:00
|
|
|
GViewDB(Dialog &, std::string const &, bool allowResize);
|
2004-09-26 18:36:07 +00:00
|
|
|
virtual Gtk::Window const * window() const;
|
2003-09-02 10:29:05 +00:00
|
|
|
virtual Gtk::Window * window();
|
|
|
|
boost::scoped_ptr<Dialog> dialog_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Dialog>
|
2003-10-06 15:43:21 +00:00
|
|
|
GViewDB<Dialog>::GViewDB(Dialog & parent, std::string const & t, bool allowResize) :
|
2003-09-02 10:29:05 +00:00
|
|
|
GViewBase(parent, t, allowResize)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Dialog>
|
|
|
|
Gtk::Window * GViewDB<Dialog>::window()
|
|
|
|
{
|
|
|
|
return dialog_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Dialog>
|
|
|
|
const Gtk::Window * GViewDB<Dialog>::window() const
|
|
|
|
{
|
|
|
|
return dialog_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-26 16:48:30 +00:00
|
|
|
class GViewGladeB : public GViewBase {
|
2003-09-02 10:29:05 +00:00
|
|
|
protected:
|
2003-10-06 15:43:21 +00:00
|
|
|
GViewGladeB(Dialog & parent, std::string const & t, bool allowResize);
|
2004-09-26 13:18:29 +00:00
|
|
|
virtual Gtk::Window const * window() const;
|
2003-09-02 10:29:05 +00:00
|
|
|
virtual Gtk::Window * window();
|
|
|
|
Glib::RefPtr<Gnome::Glade::Xml> xml_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
2004-09-26 13:18:29 +00:00
|
|
|
class GViewCB : public Base {
|
2003-09-02 10:29:05 +00:00
|
|
|
public:
|
|
|
|
Controller & controller();
|
|
|
|
Controller const & controller() const;
|
|
|
|
protected:
|
2003-10-06 15:43:21 +00:00
|
|
|
GViewCB(Dialog & parent, std::string const & t, bool allowResize = false);
|
2003-09-02 10:29:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
2003-10-06 15:43:21 +00:00
|
|
|
GViewCB<Controller, Base>::GViewCB(Dialog & parent, std::string const & t,
|
2003-09-02 10:29:05 +00:00
|
|
|
bool allowResize) :
|
|
|
|
Base(parent, t, allowResize)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
|
|
|
Controller & GViewCB<Controller, Base>::controller()
|
|
|
|
{
|
|
|
|
return static_cast<Controller &>(getController());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
|
|
|
Controller const & GViewCB<Controller, Base>::controller() const
|
|
|
|
{
|
|
|
|
return static_cast<Controller const &>(getController());
|
|
|
|
}
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
#endif
|