// -*- 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 * * Full author contact details are available in file CREDITS. */ #ifndef GVIEWBASE_H #define GVIEWBASE_H #include "Dialog.h" #include "ButtonPolicies.h" #include "GBC.h" #include #include #include namespace lyx { namespace frontend { class GViewBase : public Dialog::View, public sigc::trackable { public: GViewBase(Dialog &, std::string const &, bool allowResize); virtual ~GViewBase(); void setCancel(Gtk::Button * cancel); void setApply(Gtk::Button * apply); void setOK(Gtk::Button * ok); void setRestore(Gtk::Button * restore); void setTitle(std::string const &); bool readOnly() const; 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 GViewDB : public GViewBase { protected: GViewDB(Dialog &, std::string const &, bool allowResize); virtual Gtk::Window const * window() const; virtual Gtk::Window * window(); boost::scoped_ptr dialog_; }; template GViewDB::GViewDB(Dialog & parent, std::string const & t, bool allowResize) : GViewBase(parent, t, allowResize) { } template Gtk::Window * GViewDB::window() { return dialog_.get(); } template const Gtk::Window * GViewDB::window() const { return dialog_.get(); } class GViewGladeB : public GViewBase { protected: GViewGladeB(Dialog & parent, std::string const & t, bool allowResize); virtual Gtk::Window const * window() const; virtual Gtk::Window * window(); Glib::RefPtr xml_; }; template class GViewCB : public Base { public: Controller & controller(); Controller const & controller() const; protected: GViewCB(Dialog & parent, std::string const & t, bool allowResize = false); }; template GViewCB::GViewCB(Dialog & parent, std::string const & t, bool allowResize) : Base(parent, t, allowResize) { } template Controller & GViewCB::controller() { return static_cast(getController()); } template Controller const & GViewCB::controller() const { return static_cast(getController()); } } // namespace frontend } // namespace lyx #endif