2002-02-06 17:15:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-03-11 17:00:41 +00:00
|
|
|
/**
|
2002-02-06 17:15:28 +00:00
|
|
|
* \file Tooltips.h
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author Angus Leeming, a.leeming@ic.ac.uk
|
2002-03-11 17:00:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Tooltips for xforms. xforms 0.89 supports them directly, but 0.88 needs
|
2002-02-06 17:15:28 +00:00
|
|
|
* a bit of jiggery pokery. This class wraps it all up in a neat interface.
|
|
|
|
* Based on code originally in Toolbar_pimpl.C that appears to have been
|
|
|
|
* written by Matthias Ettrich and Jean-Marc Lasgouttes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TOOLTIPS_H
|
|
|
|
#define TOOLTIPS_H
|
|
|
|
|
|
|
|
#include "LString.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2002-02-06 17:15:28 +00:00
|
|
|
#include <boost/utility.hpp>
|
2002-05-29 16:21:03 +00:00
|
|
|
#include <boost/signals/signal0.hpp>
|
|
|
|
#include <boost/signals/trackable.hpp>
|
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
#include "forms_fwd.h" // Can't forward-declare FL_OBJECT
|
2002-02-06 17:15:28 +00:00
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
2002-02-06 17:15:28 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
class Tooltips : boost::noncopyable, public boost::signals::trackable {
|
2002-02-06 17:15:28 +00:00
|
|
|
public:
|
2002-03-11 09:54:42 +00:00
|
|
|
Tooltips();
|
|
|
|
|
2002-03-11 17:00:41 +00:00
|
|
|
/// Initialise a tooltip for this ob.
|
2002-03-18 15:56:00 +00:00
|
|
|
void init(FL_OBJECT * ob, string const & tip);
|
2002-03-11 09:54:42 +00:00
|
|
|
|
|
|
|
/// Are the tooltips on or off?
|
|
|
|
static bool enabled() { return enabled_; }
|
|
|
|
|
2002-03-18 15:56:00 +00:00
|
|
|
/// This method is connected to the tooltipsToggled signal.
|
|
|
|
void set();
|
|
|
|
|
2002-06-02 18:58:19 +00:00
|
|
|
#if FL_VERSION < 1 && FL_REVISION < 89
|
2002-02-06 17:15:28 +00:00
|
|
|
|
2002-03-11 17:00:41 +00:00
|
|
|
/** Return the tooltip associated with this object.
|
|
|
|
* Required by an xforms callback routine.
|
|
|
|
*/
|
2002-03-18 15:56:00 +00:00
|
|
|
string const get(FL_OBJECT *) const;
|
2002-03-11 09:54:42 +00:00
|
|
|
|
|
|
|
#endif
|
2002-02-06 17:15:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2002-03-11 09:54:42 +00:00
|
|
|
/// Are the tooltips on or off?
|
|
|
|
static bool enabled_;
|
|
|
|
|
|
|
|
/** This method is connected to Dialogs::toggleTooltips and toggles
|
2002-03-11 17:00:41 +00:00
|
|
|
* the state of enabled_.
|
2002-03-11 09:54:42 +00:00
|
|
|
*/
|
|
|
|
static void toggleEnabled();
|
|
|
|
|
|
|
|
/** Once enabled_ is changed, then this signal is emitted to update
|
|
|
|
* all the tooltips.
|
|
|
|
*/
|
2002-05-29 16:21:03 +00:00
|
|
|
static boost::signal0<void> toggled;
|
2002-03-11 09:54:42 +00:00
|
|
|
|
2002-03-11 17:00:41 +00:00
|
|
|
/// The tooltips are stored so that they can be turned on and off.
|
2002-03-11 09:54:42 +00:00
|
|
|
typedef std::map<FL_OBJECT *, string> TooltipsMap;
|
|
|
|
|
|
|
|
TooltipsMap tooltipsMap;
|
|
|
|
|
2002-06-02 18:58:19 +00:00
|
|
|
#if FL_VERSION < 1 && FL_REVISION < 89
|
2002-03-11 09:54:42 +00:00
|
|
|
|
2002-03-11 17:00:41 +00:00
|
|
|
/** A timer is started once the mouse enters an object, so that the
|
|
|
|
* tip appears a short delay afterwards.
|
|
|
|
*/
|
2002-02-06 17:15:28 +00:00
|
|
|
FL_OBJECT * tooltip_timer_;
|
2002-03-11 09:54:42 +00:00
|
|
|
|
2002-03-11 17:00:41 +00:00
|
|
|
#endif
|
2002-02-06 17:15:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TOOLTIPS_H
|