// -*- C++ -*- /* This file is part of * ====================================================== * * LyX, The Document Processor * * Copyright 2000-2001 The LyX Team. * * ====================================================== * * \author Angus Leeming */ #ifndef FORMBASE_H #define FORMBASE_H #include #include FORMS_H_LOCATION // Can't forward-declare FL_FORM #ifdef __GNUG__ #pragma interface #endif #include "ViewBase.h" #include "LString.h" #include "ButtonPolicies.h" class xformsBC; /** This class is an XForms GUI base class. */ class FormBase : public ViewBC { public: /// FormBase(ControlButtons &, string const &); /// virtual ~FormBase() {} /// input callback function void InputCB(FL_OBJECT *, long); protected: /// Build the dialog virtual void build() = 0; /// Hide the dialog. void hide(); /// Create the dialog if necessary, update it and display it. void show(); private: /// Pointer to the actual instantiation of xform's form virtual FL_FORM * form() const = 0; /** Filter the inputs on callback from xforms Return true if inputs are valid. */ virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /** Redraw the form (on receipt of a Signal indicating, for example, that the xform colors have been re-mapped). */ virtual void redraw(); protected: /// Overcome a dumb xforms sizing bug mutable int minw_; /// mutable int minh_; private: /// dialog title, displayed by WM. string title_; }; template class FormDB: public FormBase { protected: /// FormDB(ControlButtons &, string const &); /// Pointer to the actual instantiation of xform's form virtual FL_FORM * form() const; /// Real GUI implementation. boost::scoped_ptr dialog_; }; template FormDB::FormDB(ControlButtons & c, string const & t) : FormBase(c, t) {} template FL_FORM * FormDB::form() const { if (dialog_.get()) return dialog_->form; return 0; } template class FormCB: public Base { protected: /// FormCB(ControlButtons &, string const &); /// The parent controller Controller & controller() const; }; template FormCB::FormCB(ControlButtons & c, string const & t) : Base(c, t) {} template Controller & FormCB::controller() const { return static_cast(controller_); //return dynamic_cast(controller_); } #endif // FORMBASE_H