2000-09-22 15:09:51 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
2001-03-15 13:37:04 +00:00
|
|
|
*
|
|
|
|
* Author: Angus Leeming <a.leeming@ic.ac.uk>
|
2000-09-22 15:09:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FORMBASE_H
|
|
|
|
#define FORMBASE_H
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
#include <boost/smart_ptr.hpp>
|
2000-09-22 15:09:51 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
#include FORMS_H_LOCATION // Can't forward-declare FL_FORM
|
|
|
|
#include "ViewBase.h"
|
|
|
|
#include "LString.h"
|
|
|
|
#include "ButtonPolicies.h"
|
|
|
|
|
|
|
|
class xformsBC;
|
|
|
|
|
2000-10-13 05:57:05 +00:00
|
|
|
/** This class is an XForms GUI base class.
|
2000-09-22 15:09:51 +00:00
|
|
|
*/
|
2001-03-15 13:37:04 +00:00
|
|
|
class FormBase : public ViewBC<xformsBC>
|
|
|
|
{
|
2000-09-22 15:09:51 +00:00
|
|
|
public:
|
|
|
|
///
|
2001-03-15 13:37:04 +00:00
|
|
|
FormBase(ControlBase &, string const &);
|
2000-09-22 15:09:51 +00:00
|
|
|
///
|
2001-03-15 13:37:04 +00:00
|
|
|
virtual ~FormBase() {}
|
2000-09-22 15:09:51 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
/// input callback function
|
|
|
|
void InputCB(FL_OBJECT *, long);
|
2000-10-20 09:50:09 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
protected:
|
2000-09-22 15:09:51 +00:00
|
|
|
/// Build the dialog
|
|
|
|
virtual void build() = 0;
|
2001-03-15 13:37:04 +00:00
|
|
|
/// Hide the dialog.
|
|
|
|
void hide();
|
|
|
|
/// Create the dialog if necessary, update it and display it.
|
|
|
|
void show();
|
2000-09-22 15:09:51 +00:00
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
private:
|
2001-03-15 13:37:04 +00:00
|
|
|
/// 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) = 0;
|
|
|
|
|
|
|
|
/** Redraw the form (on receipt of a Signal indicating, for example,
|
|
|
|
that the xform colors have been re-mapped). */
|
|
|
|
virtual void redraw();
|
|
|
|
|
|
|
|
protected:
|
2000-10-20 09:50:09 +00:00
|
|
|
/// Overcome a dumb xforms sizing bug
|
|
|
|
mutable int minw_;
|
|
|
|
///
|
|
|
|
mutable int minh_;
|
2001-03-15 13:37:04 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// dialog title, displayed by WM.
|
|
|
|
string title_;
|
2000-09-22 15:09:51 +00:00
|
|
|
};
|
|
|
|
|
2000-10-13 05:57:05 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
template <class Controller, class Dialog>
|
|
|
|
class FormBase2: public FormBase
|
|
|
|
{
|
2000-10-20 09:50:09 +00:00
|
|
|
protected:
|
2001-03-15 13:37:04 +00:00
|
|
|
///
|
|
|
|
FormBase2(ControlBase &, string const &);
|
|
|
|
/// The parent controller
|
|
|
|
Controller & controller() const;
|
|
|
|
/// Pointer to the actual instantiation of xform's form
|
|
|
|
virtual FL_FORM * form() const;
|
|
|
|
/// Real GUI implementation.
|
|
|
|
boost::scoped_ptr<Dialog> dialog_;
|
2000-10-13 05:57:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
template <class Controller, class Dialog>
|
|
|
|
FormBase2<Controller, Dialog>::FormBase2(ControlBase & c, string const & t)
|
|
|
|
: FormBase(c, t)
|
|
|
|
{}
|
2000-10-13 05:57:05 +00:00
|
|
|
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
template <class Controller, class Dialog>
|
|
|
|
Controller & FormBase2<Controller, Dialog>::controller() const
|
|
|
|
{
|
|
|
|
return static_cast<Controller &>(controller_);
|
|
|
|
//return dynamic_cast<Controller &>(controller_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Dialog>
|
|
|
|
FL_FORM * FormBase2<Controller, Dialog>::form() const
|
|
|
|
{
|
|
|
|
if (dialog_.get()) return dialog_->form;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // FORMBASE_H
|