2000-09-22 15:09:51 +00:00
|
|
|
// -*- C++ -*-
|
2002-03-11 17:00:41 +00:00
|
|
|
/**
|
|
|
|
* \file FormBase.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-09-22 15:09:51 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-03-11 17:00:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* A base class for the MCV-ed xforms dialogs.
|
2000-09-22 15:09:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FORMBASE_H
|
|
|
|
#define FORMBASE_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
#include "ViewBase.h"
|
|
|
|
#include "ButtonPolicies.h"
|
2002-09-30 20:00:42 +00:00
|
|
|
#include "forms_fwd.h"
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2002-09-30 20:00:42 +00:00
|
|
|
#include "LString.h"
|
2002-05-22 01:16:37 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2002-09-30 20:00:42 +00:00
|
|
|
#include <X11/Xlib.h> // for Pixmap
|
2002-05-22 01:16:37 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
class xformsBC;
|
2002-02-06 17:15:28 +00:00
|
|
|
class Tooltips;
|
2002-08-12 14:28:43 +00:00
|
|
|
|
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
|
|
|
*/
|
2002-11-25 18:58:15 +00:00
|
|
|
class FormBase : public ViewBase
|
2001-03-15 13:37:04 +00:00
|
|
|
{
|
2000-09-22 15:09:51 +00:00
|
|
|
public:
|
|
|
|
///
|
2002-08-12 14:28:43 +00:00
|
|
|
FormBase(string const &, bool allowResize);
|
2000-09-22 15:09:51 +00:00
|
|
|
///
|
2002-02-06 17:15:28 +00:00
|
|
|
virtual ~FormBase();
|
2000-09-22 15:09:51 +00:00
|
|
|
|
2002-11-25 18:58:15 +00:00
|
|
|
/** Input callback function.
|
|
|
|
* Invoked only by the xforms callback interface
|
2002-03-21 16:59:12 +00:00
|
|
|
*/
|
2001-03-15 13:37:04 +00:00
|
|
|
void InputCB(FL_OBJECT *, long);
|
2002-02-05 14:59:26 +00:00
|
|
|
|
2002-11-25 18:58:15 +00:00
|
|
|
/** Message callback function.
|
|
|
|
* Invoked only by the xforms callback interface
|
|
|
|
*/
|
|
|
|
void MessageCB(FL_OBJECT *, int event);
|
|
|
|
|
|
|
|
/** Prehandler callback function.
|
|
|
|
* Invoked only by the xforms callback interface
|
|
|
|
*/
|
|
|
|
void PrehandlerCB(FL_OBJECT * ob, int event, int key);
|
|
|
|
|
|
|
|
///
|
2002-03-11 09:54:42 +00:00
|
|
|
Tooltips & tooltips();
|
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.
|
2002-11-15 02:50:55 +00:00
|
|
|
virtual void hide();
|
2001-03-15 13:37:04 +00:00
|
|
|
/// Create the dialog if necessary, update it and display it.
|
2002-11-19 19:18:11 +00:00
|
|
|
virtual void show();
|
2002-02-05 17:25:16 +00:00
|
|
|
|
|
|
|
/** Prepare the way to:
|
2002-03-21 16:59:12 +00:00
|
|
|
* 1. display feedback as the mouse moves over ob. This feedback will
|
|
|
|
* typically be rather more verbose than just a tooltip.
|
|
|
|
* 2. activate the button controller after a paste with the middle
|
|
|
|
* mouse button.
|
|
|
|
*/
|
2002-03-11 09:54:42 +00:00
|
|
|
static void setPrehandler(FL_OBJECT * ob);
|
2002-02-05 14:59:26 +00:00
|
|
|
|
2002-11-25 18:58:15 +00:00
|
|
|
/** Pass the class a pointer to the message_widget so that it can
|
|
|
|
post the message */
|
|
|
|
void setMessageWidget(FL_OBJECT * message_widget);
|
|
|
|
|
|
|
|
/** Send the warning message from the daughter class to the
|
|
|
|
message_widget direct. The message will persist till the mouse
|
|
|
|
movesto a new object. */
|
|
|
|
void postWarning(string const & warning);
|
|
|
|
/// Reset the message_widget_
|
|
|
|
void clearMessage();
|
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
///
|
|
|
|
xformsBC & bc();
|
|
|
|
|
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;
|
2002-03-21 21:21:28 +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,
|
2002-03-21 16:59:12 +00:00
|
|
|
* that the xform colors have been re-mapped).
|
|
|
|
*/
|
2001-03-15 13:37:04 +00:00
|
|
|
virtual void redraw();
|
|
|
|
|
2002-09-30 20:00:42 +00:00
|
|
|
/** Called on the first show() request, initialising various bits and
|
|
|
|
* pieces.
|
|
|
|
*/
|
|
|
|
void prepare_to_show();
|
|
|
|
|
2002-11-25 18:58:15 +00:00
|
|
|
/** Get the feedback message for ob.
|
|
|
|
Called if warning_posted_ == false. */
|
|
|
|
virtual string const getFeedback(FL_OBJECT * /* ob */)
|
|
|
|
{ return string(); }
|
|
|
|
|
|
|
|
/// Post the feedback message for ob to message_widget_
|
|
|
|
void postMessage(string const & message);
|
|
|
|
|
|
|
|
/** Variable used to decide whether to remove the existing feedback
|
|
|
|
message or not (if it is in fact a warning) */
|
|
|
|
bool warning_posted_;
|
|
|
|
/// The widget to display the feedback
|
|
|
|
FL_OBJECT * message_widget_;
|
|
|
|
|
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_;
|
2002-09-30 20:00:42 +00:00
|
|
|
/// dialog title, displayed by the window manager.
|
2002-03-21 21:21:28 +00:00
|
|
|
string title_;
|
2002-09-30 20:00:42 +00:00
|
|
|
/// Passed to the window manager to give a pretty little symbol ;-)
|
|
|
|
Pixmap icon_pixmap_;
|
|
|
|
///
|
|
|
|
Pixmap icon_mask_;
|
2002-02-06 17:15:28 +00:00
|
|
|
///
|
2002-03-11 09:54:42 +00:00
|
|
|
Tooltips * tooltips_;
|
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
|
|
|
///
|
2002-08-12 14:28:43 +00:00
|
|
|
FormDB(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>
|
2002-08-12 14:28:43 +00:00
|
|
|
FormDB<Dialog>::FormDB(string const & t, bool allowResize)
|
|
|
|
: FormBase(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
|
|
|
{
|
2002-11-25 18:58:15 +00:00
|
|
|
public:
|
2001-03-20 10:14:03 +00:00
|
|
|
/// The parent controller
|
2002-08-12 14:28:43 +00:00
|
|
|
Controller & controller();
|
|
|
|
///
|
|
|
|
Controller const & controller() const;
|
2002-11-25 18:58:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
///
|
|
|
|
FormCB(string const &, bool allowResize = true);
|
2001-03-20 10:14:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
2002-08-12 14:28:43 +00:00
|
|
|
FormCB<Controller, Base>::FormCB(string const & t, bool allowResize)
|
|
|
|
: Base(t, allowResize)
|
2001-03-20 10:14:03 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
2002-08-12 14:28:43 +00:00
|
|
|
Controller & FormCB<Controller, Base>::controller()
|
|
|
|
{
|
|
|
|
return static_cast<Controller &>(getController());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
|
|
|
Controller const & FormCB<Controller, Base>::controller() const
|
2001-03-20 10:14:03 +00:00
|
|
|
{
|
2002-08-12 14:28:43 +00:00
|
|
|
return static_cast<Controller const &>(getController());
|
2001-03-15 13:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // FORMBASE_H
|