2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000-2001 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(ControlButtons &, string const &, bool allowResize);
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 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
57 /** Redraw the form (on receipt of a Signal indicating, for example,
58 that the xform colors have been re-mapped). */
59 virtual void redraw();
61 /// The dialog's minimum allowable dimensions.
65 /// Can the dialog be resized after it has been created?
67 /// dialog title, displayed by WM.
72 template <class Dialog>
73 class FormDB: public FormBase
77 FormDB(ControlButtons &, string const &, bool allowResize=true);
78 /// Pointer to the actual instantiation of xform's form
79 virtual FL_FORM * form() const;
80 /// Real GUI implementation.
81 boost::scoped_ptr<Dialog> dialog_;
85 template <class Dialog>
86 FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
87 : FormBase(c, t, allowResize)
91 template <class Dialog>
92 FL_FORM * FormDB<Dialog>::form() const
94 if (dialog_.get()) return dialog_->form;
99 template <class Controller, class Base>
100 class FormCB: public Base
104 FormCB(ControlButtons &, string const &, bool allowResize=true);
105 /// The parent controller
106 Controller & controller() const;
110 template <class Controller, class Base>
111 FormCB<Controller, Base>::FormCB(ControlButtons & c, string const & t,
113 : Base(c, t, allowResize)
117 template <class Controller, class Base>
118 Controller & FormCB<Controller, Base>::controller() const
120 return static_cast<Controller &>(controller_);
121 //return dynamic_cast<Controller &>(controller_);