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 Return true if inputs are valid. */
56 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
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();
62 /// Overcome a dumb xforms sizing bug
66 /// Can the dialog be resized after it has been created?
69 /// dialog title, displayed by WM.
74 template <class Dialog>
75 class FormDB: public FormBase
79 FormDB(ControlButtons &, string const &, bool allowResize=true);
80 /// Pointer to the actual instantiation of xform's form
81 virtual FL_FORM * form() const;
82 /// Real GUI implementation.
83 boost::scoped_ptr<Dialog> dialog_;
87 template <class Dialog>
88 FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
89 : FormBase(c, t, allowResize)
93 template <class Dialog>
94 FL_FORM * FormDB<Dialog>::form() const
96 if (dialog_.get()) return dialog_->form;
101 template <class Controller, class Base>
102 class FormCB: public Base
106 FormCB(ControlButtons &, string const &, bool allowResize=true);
107 /// The parent controller
108 Controller & controller() const;
112 template <class Controller, class Base>
113 FormCB<Controller, Base>::FormCB(ControlButtons & c, string const & t,
115 : Base(c, t, allowResize)
119 template <class Controller, class Base>
120 Controller & FormCB<Controller, Base>::controller() const
122 return static_cast<Controller &>(controller_);
123 //return dynamic_cast<Controller &>(controller_);