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>
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
class LyXLex;
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
class ToolbarItem {
|
2003-04-02 18:08:05 +00:00
|
|
|
public:
|
2007-04-19 19:43:15 +00:00
|
|
|
enum Type {
|
|
|
|
/// command/action
|
|
|
|
COMMAND,
|
2003-04-15 01:06:13 +00:00
|
|
|
/// the command buffer
|
2007-04-19 19:43:15 +00:00
|
|
|
MINIBUFFER,
|
2003-04-02 18:08:05 +00:00
|
|
|
/// adds space between buttons in the toolbar
|
2007-04-19 19:43:15 +00:00
|
|
|
SEPARATOR,
|
2003-04-02 18:08:05 +00:00
|
|
|
/// a special combox insead of a button
|
2007-04-19 19:43:15 +00:00
|
|
|
LAYOUTS,
|
|
|
|
/// a special widget to insert tabulars
|
|
|
|
TABLEINSERT
|
2003-04-02 18:08:05 +00:00
|
|
|
};
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
ToolbarItem(Type type,
|
|
|
|
FuncRequest const & func,
|
|
|
|
docstring const & label = docstring());
|
2003-04-08 19:17:00 +00:00
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
ToolbarItem(Type type,
|
|
|
|
std::string const & name = std::string(),
|
|
|
|
docstring const & label = docstring());
|
|
|
|
|
|
|
|
~ToolbarItem();
|
|
|
|
|
|
|
|
/// item type
|
|
|
|
Type type_;
|
|
|
|
/// action
|
|
|
|
FuncRequest func_;
|
|
|
|
/// label/tooltip
|
|
|
|
docstring label_;
|
|
|
|
/// name
|
|
|
|
std::string name_;
|
|
|
|
};
|
2003-04-08 19:17:00 +00:00
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
class ToolbarInfo {
|
|
|
|
public:
|
2003-04-15 01:06:13 +00:00
|
|
|
/// toolbar flags
|
|
|
|
enum Flags {
|
2007-04-19 19:43:15 +00:00
|
|
|
ON = 1, //< show
|
|
|
|
OFF = 2, //< do not show
|
|
|
|
MATH = 4, //< show when in math
|
|
|
|
TABLE = 8, //< show when in table
|
2003-04-15 01:06:13 +00:00
|
|
|
TOP = 16, //< show at top
|
|
|
|
BOTTOM = 32, //< show at bottom
|
|
|
|
LEFT = 64, //< show at left
|
2006-10-29 11:13:46 +00:00
|
|
|
RIGHT = 128, //< show at right
|
2007-04-19 19:43:15 +00:00
|
|
|
REVIEW = 256, //< show when change tracking is enabled
|
|
|
|
AUTO = 512 //< only if AUTO is set, when MATH, TABLE and REVIEW is used
|
2003-04-10 14:08:06 +00:00
|
|
|
};
|
2007-04-19 19:43:15 +00:00
|
|
|
/// the toolbar items
|
|
|
|
typedef std::vector<ToolbarItem> Items;
|
2003-04-10 14:08:06 +00:00
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
typedef Items::const_iterator item_iterator;
|
2003-04-09 19:53:10 +00:00
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
explicit ToolbarInfo(std::string const & name = std::string())
|
|
|
|
: name(name) {}
|
2003-04-09 19:53:10 +00:00
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
/// toolbar name
|
|
|
|
std::string name;
|
|
|
|
/// toolbar GUI name
|
|
|
|
std::string gui_name;
|
|
|
|
/// toolbar contents
|
|
|
|
Items items;
|
|
|
|
/// flags
|
|
|
|
Flags flags;
|
|
|
|
|
|
|
|
/// read a toolbar from the file
|
|
|
|
ToolbarInfo & read(LyXLex &);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// add toolbar item
|
|
|
|
void add(ToolbarItem const &);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
class ToolbarBackend {
|
|
|
|
public:
|
|
|
|
typedef std::vector<ToolbarInfo> Toolbars;
|
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
|
2006-10-21 00:16:43 +00:00
|
|
|
Toolbars::const_iterator begin() const { return usedtoolbars.begin(); }
|
2003-04-09 19:53:10 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
Toolbars::const_iterator end() const { return usedtoolbars.end(); }
|
2003-04-09 19:53:10 +00:00
|
|
|
|
2006-11-02 16:01:36 +00:00
|
|
|
Toolbars::iterator begin() { return usedtoolbars.begin(); }
|
|
|
|
|
|
|
|
Toolbars::iterator end() { return usedtoolbars.end(); }
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
/// read toolbars from the file
|
2003-06-11 19:21:46 +00:00
|
|
|
void readToolbars(LyXLex &);
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
/// read ui toolbar settings
|
|
|
|
void readToolbarSettings(LyXLex &);
|
|
|
|
///
|
|
|
|
ToolbarInfo const & getToolbar(std::string const & name) const;
|
|
|
|
///
|
|
|
|
ToolbarInfo & getToolbar(std::string const & name);
|
2003-04-08 19:17:00 +00:00
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
private:
|
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;
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
#endif // TOOLBAR_BACKEND_H
|