2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
11 * Author: Angus Leeming <a.leeming@ic.ac.uk>
17 #include <boost/smart_ptr.hpp>
18 #include FORMS_H_LOCATION // Can't forward-declare FL_FORM
26 #include "ButtonPolicies.h"
30 /** This class is an XForms GUI base class.
32 class FormBase : public ViewBC<xformsBC>
36 FormBase(ControlBase &, string const &);
38 virtual ~FormBase() {}
40 /// input callback function
41 void InputCB(FL_OBJECT *, long);
45 virtual void build() = 0;
48 /// Create the dialog if necessary, update it and display it.
52 /// Pointer to the actual instantiation of xform's form
53 virtual FL_FORM * form() const = 0;
54 /** Filter the inputs on callback from xforms
55 Return true if inputs are valid. */
56 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long) = 0;
58 /** Redraw the form (on receipt of a Signal indicating, for example,
59 that the xform colors have been re-mapped). */
60 virtual void redraw();
63 /// Overcome a dumb xforms sizing bug
69 /// dialog title, displayed by WM.
74 template <class Controller, class Dialog>
75 class FormBase2: public FormBase
79 FormBase2(ControlBase &, string const &);
80 /// The parent controller
81 Controller & controller() const;
82 /// Pointer to the actual instantiation of xform's form
83 virtual FL_FORM * form() const;
84 /// Real GUI implementation.
85 boost::scoped_ptr<Dialog> dialog_;
89 template <class Controller, class Dialog>
90 FormBase2<Controller, Dialog>::FormBase2(ControlBase & c, string const & t)
95 template <class Controller, class Dialog>
96 Controller & FormBase2<Controller, Dialog>::controller() const
98 return static_cast<Controller &>(controller_);
99 //return dynamic_cast<Controller &>(controller_);
103 template <class Controller, class Dialog>
104 FL_FORM * FormBase2<Controller, Dialog>::form() const
106 if (dialog_.get()) return dialog_->form;