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 <gtkmm.h>
|
|
|
|
#include <libglademm.h>
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
#include "Dialog.h"
|
|
|
|
#include "ButtonPolicies.h"
|
|
|
|
#include "GBC.h"
|
|
|
|
|
|
|
|
class GViewBase : public Dialog::View, public SigC::Object
|
|
|
|
{
|
|
|
|
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_;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Dialog>
|
|
|
|
class GViewDB : public GViewBase
|
|
|
|
{
|
|
|
|
protected:
|
2003-10-06 15:43:21 +00:00
|
|
|
GViewDB(Dialog &, std::string const &, bool allowResize);
|
2003-09-02 10:29:05 +00:00
|
|
|
virtual const Gtk::Window * window() const;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class GViewGladeB : public GViewBase
|
|
|
|
{
|
|
|
|
protected:
|
2003-10-06 15:43:21 +00:00
|
|
|
GViewGladeB(Dialog & parent, std::string const & t, bool allowResize);
|
2003-09-02 10:29:05 +00:00
|
|
|
virtual const Gtk::Window * window() const;
|
|
|
|
virtual Gtk::Window * window();
|
|
|
|
Glib::RefPtr<Gnome::Glade::Xml> xml_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
|
|
|
class GViewCB : public Base
|
|
|
|
{
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|