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
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pö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
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
#include "FuncCode.h"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2006-09-01 15:41:38 +00:00
|
|
|
#include "support/docstring.h"
|
|
|
|
|
2016-06-20 19:10:14 +00:00
|
|
|
#include "frontends/KeyModifier.h"
|
2008-03-15 01:20:36 +00:00
|
|
|
#include "frontends/mouse_state.h"
|
|
|
|
|
2004-02-03 11:49:05 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2012-06-07 15:19:04 +00:00
|
|
|
class LyXErr;
|
|
|
|
|
2018-03-12 13:34:24 +00:00
|
|
|
namespace frontend {
|
|
|
|
class GuiView;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2008-03-15 01:20:36 +00:00
|
|
|
class FuncRequest
|
|
|
|
{
|
2002-08-13 17:43:40 +00:00
|
|
|
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
|
2017-07-03 17:45:58 +00:00
|
|
|
COMMANDBUFFER,
|
2012-04-17 12:44:25 +00:00
|
|
|
LYXSERVER,
|
2009-04-08 21:06:58 +00:00
|
|
|
TOC
|
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
|
2008-03-15 01:20:36 +00:00
|
|
|
explicit FuncRequest(FuncCode act, Origin o = INTERNAL);
|
2002-08-28 08:30:27 +00:00
|
|
|
/// actions without extra argument
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode act, int x, int y, mouse_button::state button,
|
2016-06-20 19:10:14 +00:00
|
|
|
KeyModifier modifier, Origin o = INTERNAL);
|
2002-08-13 17:43:40 +00:00
|
|
|
/// actions with extra argument
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode act, docstring const & arg,
|
2006-09-01 15:41:38 +00:00
|
|
|
Origin o = INTERNAL);
|
|
|
|
/// actions with extra argument. FIXME: remove this
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode 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);
|
2017-07-03 17:45:58 +00:00
|
|
|
|
2010-04-09 19:00:42 +00:00
|
|
|
/// access the whole argument
|
|
|
|
docstring const & argument() const { return argument_; }
|
|
|
|
///
|
|
|
|
FuncCode action() const { return action_ ; }
|
|
|
|
///
|
|
|
|
void setAction(FuncCode act) { action_ = act; }
|
|
|
|
///
|
|
|
|
Origin origin() const { return origin_; }
|
|
|
|
///
|
|
|
|
void setOrigin(Origin o) { origin_ = o; }
|
|
|
|
///
|
2018-03-12 13:34:24 +00:00
|
|
|
frontend::GuiView* view_origin() const { return view_origin_; }
|
|
|
|
///
|
|
|
|
void setViewOrigin(frontend::GuiView* o) { view_origin_ = o; }
|
|
|
|
///
|
2010-04-09 19:00:42 +00:00
|
|
|
int x() const { return x_; }
|
|
|
|
///
|
|
|
|
int y() const { return y_; }
|
|
|
|
///
|
|
|
|
void set_y(int y) { y_ = y; }
|
2017-07-03 17:45:58 +00:00
|
|
|
///
|
2010-04-09 19:00:42 +00:00
|
|
|
mouse_button::state button() const { return button_; }
|
2016-06-20 19:10:14 +00:00
|
|
|
///
|
|
|
|
KeyModifier modifier() { return modifier_; }
|
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;
|
2009-12-02 09:39:39 +00:00
|
|
|
/// argument parsing, extract argument i as std::string,
|
|
|
|
/// eating all characters up to the end of the command line
|
|
|
|
std::string getLongArg(unsigned int i) const;
|
|
|
|
|
2017-07-03 17:45:58 +00:00
|
|
|
///
|
2007-10-20 23:27:03 +00:00
|
|
|
static FuncRequest const unknown;
|
2017-07-03 17:45:58 +00:00
|
|
|
///
|
2007-10-20 23:27:03 +00:00
|
|
|
static FuncRequest const noaction;
|
2018-04-19 03:03:24 +00:00
|
|
|
///
|
|
|
|
bool allowAsync() const { return allow_async_; }
|
|
|
|
///
|
|
|
|
void allowAsync(bool allow_async) { allow_async_ = allow_async; }
|
|
|
|
|
2006-09-01 15:41:38 +00:00
|
|
|
private:
|
2010-04-09 18:15:17 +00:00
|
|
|
/// the action
|
|
|
|
FuncCode action_;
|
2010-04-12 15:40:51 +00:00
|
|
|
/// the action's string argument
|
|
|
|
docstring argument_;
|
2004-11-08 10:54:29 +00:00
|
|
|
/// who initiated the action
|
2010-04-09 18:15:17 +00:00
|
|
|
Origin origin_;
|
2018-03-12 13:34:24 +00:00
|
|
|
/// to which view should be this command sent (see bug #11004)
|
|
|
|
/// NULL=current view
|
|
|
|
frontend::GuiView* view_origin_;
|
2002-08-12 09:53:04 +00:00
|
|
|
/// the x coordinate of a mouse press
|
2010-04-09 18:15:17 +00:00
|
|
|
int x_;
|
2002-08-12 09:53:04 +00:00
|
|
|
/// the y coordinate of a mouse press
|
2010-04-09 18:15:17 +00:00
|
|
|
int y_;
|
2002-08-12 09:53:04 +00:00
|
|
|
/// some extra information (like button number)
|
2002-08-19 10:11:13 +00:00
|
|
|
mouse_button::state button_;
|
2016-06-20 19:10:14 +00:00
|
|
|
///
|
|
|
|
KeyModifier modifier_;
|
2018-04-19 03:03:24 +00:00
|
|
|
///
|
|
|
|
bool allow_async_;
|
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
|
|
|
|
2012-06-07 15:19:04 +00:00
|
|
|
LyXErr & operator<<(LyXErr &, FuncRequest const &);
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2002-08-07 23:43:38 +00:00
|
|
|
#endif // FUNCREQUEST_H
|