2003-08-23 00:17:00 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file FuncRequest.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-08-07 23:43:38 +00:00
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
2003-08-23 00:17:00 +00:00
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-08-07 23:43:38 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
|
#ifndef FUNCREQUEST_H
|
|
|
|
|
#define FUNCREQUEST_H
|
|
|
|
|
|
2003-03-19 17:15:32 +00:00
|
|
|
|
#include "lfuns.h"
|
2002-08-19 10:11:13 +00:00
|
|
|
|
#include "frontends/mouse_state.h"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2006-09-01 15:41:38 +00:00
|
|
|
|
#include "support/docstring.h"
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
#include <iosfwd>
|
2002-08-07 08:11:41 +00:00
|
|
|
|
|
2004-02-03 11:49:05 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
|
2002-12-01 22:59:25 +00:00
|
|
|
|
/**
|
2002-08-07 23:43:38 +00:00
|
|
|
|
* This class encapsulates a LyX action and its argument
|
|
|
|
|
* in order to pass it around easily.
|
2002-08-07 08:11:41 +00:00
|
|
|
|
*/
|
2002-08-13 17:43:40 +00:00
|
|
|
|
class FuncRequest {
|
|
|
|
|
public:
|
2004-11-08 10:54:29 +00:00
|
|
|
|
/// Where the request came from
|
|
|
|
|
enum Origin {
|
2004-11-26 14:52:54 +00:00
|
|
|
|
INTERNAL,
|
2006-11-09 14:56:57 +00:00
|
|
|
|
MENU, // A menu entry
|
|
|
|
|
TOOLBAR, // A toolbar icon
|
2004-11-08 10:54:29 +00:00
|
|
|
|
KEYBOARD, // a keyboard binding
|
2004-11-26 14:52:54 +00:00
|
|
|
|
COMMANDBUFFER
|
2004-11-08 10:54:29 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// just for putting these things in std::container
|
|
|
|
|
explicit FuncRequest(Origin o = INTERNAL);
|
2002-08-13 17:43:40 +00:00
|
|
|
|
/// actions without extra argument
|
2004-11-08 10:54:29 +00:00
|
|
|
|
explicit FuncRequest(kb_action act, Origin o = INTERNAL);
|
2002-08-28 08:30:27 +00:00
|
|
|
|
/// actions without extra argument
|
2004-11-26 14:52:54 +00:00
|
|
|
|
FuncRequest(kb_action act, int x, int y, mouse_button::state button,
|
|
|
|
|
Origin o = INTERNAL);
|
2002-08-13 17:43:40 +00:00
|
|
|
|
/// actions with extra argument
|
2006-10-21 00:16:43 +00:00
|
|
|
|
FuncRequest(kb_action act, docstring const & arg,
|
2006-09-01 15:41:38 +00:00
|
|
|
|
Origin o = INTERNAL);
|
|
|
|
|
/// actions with extra argument. FIXME: remove this
|
2004-11-26 14:52:54 +00:00
|
|
|
|
FuncRequest(kb_action act, std::string const & arg,
|
2004-11-08 10:54:29 +00:00
|
|
|
|
Origin o = INTERNAL);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
/// for changing requests a bit
|
2006-10-21 00:16:43 +00:00
|
|
|
|
FuncRequest(FuncRequest const & cmd, docstring const & arg,
|
2006-09-01 15:41:38 +00:00
|
|
|
|
Origin o = INTERNAL);
|
|
|
|
|
/// for changing requests a bit. FIXME: remove this
|
2004-11-26 14:52:54 +00:00
|
|
|
|
FuncRequest(FuncRequest const & cmd, std::string const & arg,
|
2004-11-08 10:54:29 +00:00
|
|
|
|
Origin o = INTERNAL);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2002-08-19 10:11:13 +00:00
|
|
|
|
/// access to button
|
|
|
|
|
mouse_button::state button() const;
|
2002-08-13 17:43:40 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
/// argument parsing, extract argument i as std::string
|
|
|
|
|
std::string getArg(unsigned int i) const;
|
2003-02-26 18:03:48 +00:00
|
|
|
|
|
2006-09-01 15:41:38 +00:00
|
|
|
|
/// access the whole argument
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring const & argument() const { return argument_; }
|
2006-09-01 15:41:38 +00:00
|
|
|
|
|
2004-01-15 17:34:44 +00:00
|
|
|
|
public: // should be private
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/// the action
|
2002-08-07 08:11:41 +00:00
|
|
|
|
kb_action action;
|
2006-09-01 15:41:38 +00:00
|
|
|
|
private:
|
|
|
|
|
/// the action's string argument
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring argument_;
|
2006-09-01 15:41:38 +00:00
|
|
|
|
public: // should be private
|
2004-11-08 10:54:29 +00:00
|
|
|
|
/// who initiated the action
|
|
|
|
|
Origin origin;
|
2002-08-12 09:53:04 +00:00
|
|
|
|
/// the x coordinate of a mouse press
|
|
|
|
|
int x;
|
|
|
|
|
/// the y coordinate of a mouse press
|
|
|
|
|
int y;
|
|
|
|
|
/// some extra information (like button number)
|
2002-08-19 10:11:13 +00:00
|
|
|
|
mouse_button::state button_;
|
2002-08-07 08:11:41 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-09-21 23:00:47 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
|
|
|
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream &, FuncRequest const &);
|
2003-09-21 23:00:47 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-08-07 23:43:38 +00:00
|
|
|
|
#endif // FUNCREQUEST_H
|