2000-09-22 15:09:51 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 2000-2001 The LyX Team.
|
2000-09-22 15:09:51 +00:00
|
|
|
*
|
|
|
|
* ======================================================
|
2001-03-15 13:37:04 +00:00
|
|
|
*
|
2001-03-20 10:14:03 +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>
|
2001-03-19 16:37:01 +00:00
|
|
|
#include FORMS_H_LOCATION // Can't forward-declare FL_FORM
|
2000-09-22 15:09:51 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
#include "ViewBase.h"
|
|
|
|
#include "LString.h"
|
|
|
|
#include "ButtonPolicies.h"
|
|
|
|
|
|
|
|
class xformsBC;
|
|
|
|
|
2002-02-05 17:25:16 +00:00
|
|
|
|
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:
|
2002-02-06 12:12:04 +00:00
|
|
|
///
|
|
|
|
enum TooltipLevel {
|
|
|
|
NO_TOOLTIP,
|
|
|
|
MINIMAL_TOOLTIP,
|
|
|
|
VERBOSE_TOOLTIP
|
|
|
|
};
|
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
///
|
2001-08-28 13:48:40 +00:00
|
|
|
FormBase(ControlButtons &, string const &, bool allowResize);
|
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
|
|
|
|
2002-02-05 17:25:16 +00:00
|
|
|
/** input callback function.
|
|
|
|
Invoked only by C_FormBaseInputCB and by C_FormBasePrehandler */
|
2001-03-15 13:37:04 +00:00
|
|
|
void InputCB(FL_OBJECT *, long);
|
2002-02-05 17:25:16 +00:00
|
|
|
/// feedback callback function, invoked only by C_FormBasePrehandler
|
2002-02-05 14:59:26 +00:00
|
|
|
void FeedbackCB(FL_OBJECT *, int event);
|
|
|
|
|
2002-02-06 12:12:04 +00:00
|
|
|
/** Return the tooltip dependent on the value of tooltip_level_
|
|
|
|
Invoked only by setTooltipHandler and by TooltipTimerCB */
|
|
|
|
string const getTooltip(FL_OBJECT *) const;
|
2002-02-05 17:25:16 +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();
|
2002-02-05 17:25:16 +00:00
|
|
|
|
2002-02-06 12:12:04 +00:00
|
|
|
/// Set's how verbose the tooltips are going to be
|
|
|
|
void setTooltipLevel(TooltipLevel level);
|
|
|
|
|
2002-02-05 17:25:16 +00:00
|
|
|
/// Prepare the way to produce a tooltip when the mouse is over ob.
|
|
|
|
void setTooltipHandler(FL_OBJECT * ob);
|
|
|
|
|
|
|
|
/** Prepare the way to:
|
|
|
|
1. display feedback as the mouse moves over ob. This feedback will
|
|
|
|
typically be rather more verbose than just a tooltip.
|
2002-02-05 14:59:26 +00:00
|
|
|
2. activate the button controller after a paste with the middle
|
|
|
|
mouse button */
|
|
|
|
void setPrehandler(FL_OBJECT * ob);
|
|
|
|
|
|
|
|
/** Flag that the message is a warning and should not be removed
|
2002-02-05 17:25:16 +00:00
|
|
|
when the mouse is no longer over the object.
|
|
|
|
Used in conjunction with setPrehandler(ob) and with feedback(ob),
|
|
|
|
clear_feedback(). */
|
2002-02-05 14:59:26 +00:00
|
|
|
void setWarningPosted(bool);
|
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;
|
2001-09-07 10:11:02 +00:00
|
|
|
/// Filter the inputs on callback from xforms
|
2001-03-20 10:14:03 +00:00
|
|
|
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
2001-03-15 13:37:04 +00:00
|
|
|
|
|
|
|
/** Redraw the form (on receipt of a Signal indicating, for example,
|
|
|
|
that the xform colors have been re-mapped). */
|
|
|
|
virtual void redraw();
|
|
|
|
|
2002-02-06 12:12:04 +00:00
|
|
|
/// These methods can be overridden in the daughter classes.
|
|
|
|
virtual string const getMinimalTooltip(FL_OBJECT *) const
|
|
|
|
{ return string(); }
|
|
|
|
virtual string const getVerboseTooltip(FL_OBJECT *) const
|
|
|
|
{ return string(); }
|
2002-02-05 17:25:16 +00:00
|
|
|
|
2002-02-06 12:12:04 +00:00
|
|
|
/// Post feedback for ob. Defaults to nothing
|
2002-02-05 17:25:16 +00:00
|
|
|
virtual void feedback(FL_OBJECT * /* ob */) {}
|
|
|
|
/// clear the feedback message
|
|
|
|
virtual void clear_feedback() {}
|
|
|
|
|
2001-09-07 10:11:02 +00:00
|
|
|
/// The dialog's minimum allowable dimensions.
|
|
|
|
int minw_;
|
2000-10-20 09:50:09 +00:00
|
|
|
///
|
2001-09-07 10:11:02 +00:00
|
|
|
int minh_;
|
2001-08-28 13:48:40 +00:00
|
|
|
/// Can the dialog be resized after it has been created?
|
|
|
|
bool allow_resize_;
|
2001-03-15 13:37:04 +00:00
|
|
|
/// dialog title, displayed by WM.
|
|
|
|
string title_;
|
2002-02-05 14:59:26 +00:00
|
|
|
/** Variable used to decide whether to remove the existing feedback
|
|
|
|
message or not (if it is infact a warning) */
|
|
|
|
bool warning_posted_;
|
2002-02-05 17:25:16 +00:00
|
|
|
/// Enables tooltips for crappy GUI libraries...
|
|
|
|
#if FL_REVISION < 89
|
|
|
|
FL_OBJECT * tooltip_timer_;
|
|
|
|
#endif
|
2002-02-06 12:12:04 +00:00
|
|
|
/// How verbose are the tooltips?
|
|
|
|
TooltipLevel tooltip_level_;
|
2000-09-22 15:09:51 +00:00
|
|
|
};
|
|
|
|
|
2000-10-13 05:57:05 +00:00
|
|
|
|
2001-03-20 10:14:03 +00:00
|
|
|
template <class Dialog>
|
|
|
|
class FormDB: public FormBase
|
2001-03-15 13:37:04 +00:00
|
|
|
{
|
2000-10-20 09:50:09 +00:00
|
|
|
protected:
|
2001-03-15 13:37:04 +00:00
|
|
|
///
|
2001-08-28 13:48:40 +00:00
|
|
|
FormDB(ControlButtons &, string const &, bool allowResize=true);
|
2001-03-15 13:37:04 +00:00
|
|
|
/// 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-20 10:14:03 +00:00
|
|
|
template <class Dialog>
|
2001-08-28 13:48:40 +00:00
|
|
|
FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
|
|
|
|
: FormBase(c, t, allowResize)
|
2001-03-15 13:37:04 +00:00
|
|
|
{}
|
2000-10-13 05:57:05 +00:00
|
|
|
|
|
|
|
|
2001-03-20 10:14:03 +00:00
|
|
|
template <class Dialog>
|
|
|
|
FL_FORM * FormDB<Dialog>::form() const
|
2001-03-15 13:37:04 +00:00
|
|
|
{
|
2001-03-20 10:14:03 +00:00
|
|
|
if (dialog_.get()) return dialog_->form;
|
|
|
|
return 0;
|
2001-03-15 13:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-20 10:14:03 +00:00
|
|
|
template <class Controller, class Base>
|
|
|
|
class FormCB: public Base
|
2001-03-15 13:37:04 +00:00
|
|
|
{
|
2001-03-20 10:14:03 +00:00
|
|
|
protected:
|
|
|
|
///
|
2001-08-28 13:48:40 +00:00
|
|
|
FormCB(ControlButtons &, string const &, bool allowResize=true);
|
2001-03-20 10:14:03 +00:00
|
|
|
/// The parent controller
|
|
|
|
Controller & controller() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
2001-08-28 13:48:40 +00:00
|
|
|
FormCB<Controller, Base>::FormCB(ControlButtons & c, string const & t,
|
|
|
|
bool allowResize)
|
|
|
|
: Base(c, t, allowResize)
|
2001-03-20 10:14:03 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
|
|
|
Controller & FormCB<Controller, Base>::controller() const
|
|
|
|
{
|
|
|
|
return static_cast<Controller &>(controller_);
|
|
|
|
//return dynamic_cast<Controller &>(controller_);
|
2001-03-15 13:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // FORMBASE_H
|