// -*- C++ -*- /* This file is part of * ====================================================== * * LyX, The Document Processor * * Copyright 2000 The LyX Team. * * ====================================================== * * \author Angus Leeming */ #ifndef QT2BASE_H #define QT2BASE_H class QDialog; #include #include #include #ifdef __GNUG__ #pragma interface #endif #include "ViewBase.h" #include "LString.h" #include "ButtonPolicies.h" #include "ControlButton.h" class qt2BC; /** This class is an Qt2 GUI base class. */ class Qt2Base : public QObject, public ViewBC { Q_OBJECT public: /// Qt2Base(::ControlButton &, const QString &); /// virtual ~Qt2Base() {} 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(); protected slots: // dialog closed from WM void slotWMHide(); // Apply button clicked void slotApply(); // OK button clicked void slotOK(); // Cancel button clicked void slotCancel(); // Restore button clicked void slotRestore(); private: /// Pointer to the actual instantiation of xform's form virtual QDialog* form() const = 0; /** Filter the inputs on callback from xforms Return true if inputs are valid. */ virtual ButtonPolicy::SMInput input(QWidget*, long); private: /// dialog title, displayed by WM. QString title_; }; template class Qt2DB: public Qt2Base { protected: /// Qt2DB(::ControlButton &, const QString&); /// Pointer to the actual instantiation of the Qt dialog virtual QDialog* form() const; /// Real GUI implementation. boost::scoped_ptr dialog_; }; template Qt2DB::Qt2DB(::ControlButton & c, const QString& t) : Qt2Base(c, t) {} template QDialog* Qt2DB::form() const { return dialog_.get(); } template class Qt2CB: public Base { protected: /// Qt2CB(::ControlButton &, const QString&); /// The parent controller Controller & controller() const; }; template Qt2CB::Qt2CB(::ControlButton & c, const QString& t) : Base(c, t) {} template Controller & Qt2CB::controller() const { return static_cast(controller_); //return dynamic_cast(controller_); } #endif // FORMBASE_H