2003-04-02 18:08:05 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file ToolbarBackend.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author John Levon
|
2003-04-02 18:08:05 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-04-02 18:08:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TOOLBAR_BACKEND_H
|
|
|
|
#define TOOLBAR_BACKEND_H
|
|
|
|
|
2003-09-21 18:57:15 +00:00
|
|
|
#include "funcrequest.h"
|
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
class LyXLex;
|
|
|
|
|
2003-09-21 18:57:15 +00:00
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
///
|
|
|
|
class ToolbarBackend {
|
|
|
|
public:
|
|
|
|
/// The special toolbar actions
|
2003-04-10 14:08:06 +00:00
|
|
|
enum ItemType {
|
2003-04-15 01:06:13 +00:00
|
|
|
/// the command buffer
|
|
|
|
MINIBUFFER = -3,
|
2003-04-02 18:08:05 +00:00
|
|
|
/// adds space between buttons in the toolbar
|
2003-04-15 01:06:13 +00:00
|
|
|
SEPARATOR = -2,
|
2003-04-02 18:08:05 +00:00
|
|
|
/// a special combox insead of a button
|
2003-04-15 01:06:13 +00:00
|
|
|
LAYOUTS = -1,
|
2003-04-02 18:08:05 +00:00
|
|
|
};
|
|
|
|
|
2003-04-08 19:17:00 +00:00
|
|
|
/// action, tooltip
|
2003-10-06 15:43:21 +00:00
|
|
|
typedef std::pair<FuncRequest, std::string> Item;
|
2003-04-08 19:17:00 +00:00
|
|
|
|
|
|
|
/// the toolbar items
|
2003-09-21 18:57:15 +00:00
|
|
|
typedef std::vector<Item> Items;
|
2003-04-08 19:17:00 +00:00
|
|
|
|
2003-04-15 01:06:13 +00:00
|
|
|
/// toolbar flags
|
|
|
|
enum Flags {
|
|
|
|
ON = 1, //< always shown
|
|
|
|
OFF = 2, //< never shown
|
|
|
|
MATH = 4, //< shown when in math
|
|
|
|
TABLE = 8, //< shown when in table
|
|
|
|
TOP = 16, //< show at top
|
|
|
|
BOTTOM = 32, //< show at bottom
|
|
|
|
LEFT = 64, //< show at left
|
|
|
|
RIGHT = 128 //< show at right
|
2003-04-10 14:08:06 +00:00
|
|
|
};
|
|
|
|
|
2003-04-09 19:53:10 +00:00
|
|
|
/// a toolbar
|
|
|
|
struct Toolbar {
|
2004-04-21 00:19:27 +00:00
|
|
|
/// toolbar name
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string name;
|
2004-04-21 00:19:27 +00:00
|
|
|
/// toolbar GUI name
|
|
|
|
std::string gui_name;
|
2003-04-09 19:53:10 +00:00
|
|
|
/// toolbar contents
|
|
|
|
Items items;
|
2003-04-15 01:06:13 +00:00
|
|
|
/// flags
|
|
|
|
Flags flags;
|
2003-04-09 19:53:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<Toolbar> Toolbars;
|
|
|
|
|
|
|
|
typedef Items::const_iterator item_iterator;
|
2003-04-08 19:17:00 +00:00
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
ToolbarBackend();
|
2003-04-09 19:53:10 +00:00
|
|
|
|
|
|
|
/// iterator for all toolbars
|
|
|
|
Toolbars::const_iterator begin() const {
|
2003-06-11 19:21:46 +00:00
|
|
|
return usedtoolbars.begin();
|
2003-04-02 18:08:05 +00:00
|
|
|
}
|
2003-04-09 19:53:10 +00:00
|
|
|
|
|
|
|
Toolbars::const_iterator end() const {
|
2003-06-11 19:21:46 +00:00
|
|
|
return usedtoolbars.end();
|
2003-04-02 18:08:05 +00:00
|
|
|
}
|
2003-04-09 19:53:10 +00:00
|
|
|
|
|
|
|
/// read a toolbar from the file
|
2003-04-02 18:08:05 +00:00
|
|
|
void read(LyXLex &);
|
2003-04-08 19:17:00 +00:00
|
|
|
|
2003-06-11 19:21:46 +00:00
|
|
|
/// read the used toolbars
|
|
|
|
void readToolbars(LyXLex &);
|
|
|
|
|
2003-04-08 19:17:00 +00:00
|
|
|
/// return a full path of an XPM for the given action
|
2003-10-06 15:43:21 +00:00
|
|
|
static std::string const getIcon(FuncRequest const &);
|
2003-04-08 19:17:00 +00:00
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
private:
|
2003-04-08 19:17:00 +00:00
|
|
|
/// add the given lfun with tooltip if relevant
|
2003-09-21 18:57:15 +00:00
|
|
|
void add(Toolbar & tb, FuncRequest const &,
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & tooltip = std::string());
|
2003-04-09 19:53:10 +00:00
|
|
|
|
|
|
|
/// all the toolbars
|
|
|
|
Toolbars toolbars;
|
2003-06-11 19:21:46 +00:00
|
|
|
|
|
|
|
/// toolbars listed
|
|
|
|
Toolbars usedtoolbars;
|
2003-04-02 18:08:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// The global instance
|
|
|
|
extern ToolbarBackend toolbarbackend;
|
|
|
|
|
|
|
|
|
|
|
|
#endif // TOOLBAR_BACKEND_H
|