2003-04-02 18:08:05 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2008-05-25 08:30:06 +00:00
|
|
|
* \file Toolbars.h
|
2003-04-02 18:08:05 +00:00
|
|
|
* 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
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2003-09-21 18:57:15 +00:00
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
#include <vector>
|
2008-05-27 11:47:50 +00:00
|
|
|
#include <map>
|
2003-04-02 18:08:05 +00:00
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
class Lexer;
|
2003-04-02 18:08:05 +00:00
|
|
|
|
2008-05-25 08:30:06 +00:00
|
|
|
namespace frontend {
|
|
|
|
|
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
|
2007-04-19 20:29:27 +00:00
|
|
|
TABLEINSERT,
|
2009-04-18 10:44:44 +00:00
|
|
|
/// a button that expands a menu
|
2007-04-19 20:29:27 +00:00
|
|
|
POPUPMENU,
|
2009-04-18 10:44:44 +00:00
|
|
|
/// a button that expands a menu but remembers the last choice
|
|
|
|
STICKYPOPUPMENU,
|
2007-04-19 20:29:27 +00:00
|
|
|
///
|
|
|
|
ICONPALETTE
|
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());
|
|
|
|
|
|
|
|
/// 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:
|
|
|
|
/// 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
|
2008-08-15 18:43:46 +00:00
|
|
|
docstring gui_name;
|
2007-04-19 19:43:15 +00:00
|
|
|
/// toolbar contents
|
|
|
|
Items items;
|
|
|
|
|
|
|
|
/// read a toolbar from the file
|
2007-04-26 11:30:54 +00:00
|
|
|
ToolbarInfo & read(Lexer &);
|
2007-04-19 19:43:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// add toolbar item
|
|
|
|
void add(ToolbarItem const &);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///
|
2008-05-25 08:30:06 +00:00
|
|
|
class Toolbars {
|
2007-04-19 19:43:15 +00:00
|
|
|
public:
|
2008-05-27 11:15:17 +00:00
|
|
|
/// toolbar visibility flags
|
|
|
|
enum Visibility {
|
|
|
|
ON = 1, //< show
|
|
|
|
OFF = 2, //< do not show
|
|
|
|
TOP = 4, //< show at top
|
|
|
|
BOTTOM = 8, //< show at bottom
|
|
|
|
LEFT = 16, //< show at left
|
|
|
|
RIGHT = 32, //< show at right
|
|
|
|
AUTO = 64, //< only if AUTO is set, when MATH, TABLE and REVIEW is used
|
|
|
|
MATH = 128, //< show when in math
|
|
|
|
TABLE = 256, //< show when in table
|
|
|
|
REVIEW = 512, //< show when change tracking is enabled
|
2010-01-27 17:19:14 +00:00
|
|
|
MATHMACROTEMPLATE = 1024, //< show in math macro template
|
2012-08-21 12:56:34 +00:00
|
|
|
SAMEROW = 2048, //place to the current row, no new line
|
|
|
|
IPA = 4096, //< show when in IPA inset
|
2015-04-18 17:10:33 +00:00
|
|
|
MINIBUFFER = 8192, //< show when command-execute has been invoked
|
|
|
|
ALLOWAUTO = MATH | TABLE | REVIEW | MATHMACROTEMPLATE | IPA | MINIBUFFER
|
2008-05-27 11:15:17 +00:00
|
|
|
};
|
|
|
|
|
2008-05-25 08:30:06 +00:00
|
|
|
typedef std::vector<ToolbarInfo> Infos;
|
2003-04-08 19:17:00 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
Toolbars() {}
|
2003-04-09 19:53:10 +00:00
|
|
|
|
2008-06-25 18:03:38 +00:00
|
|
|
///
|
|
|
|
void reset();
|
|
|
|
|
2003-04-09 19:53:10 +00:00
|
|
|
/// iterator for all toolbars
|
2008-05-27 11:15:17 +00:00
|
|
|
Infos::const_iterator begin() const { return toolbar_info_.begin(); }
|
2003-04-09 19:53:10 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
Infos::const_iterator end() const { return toolbar_info_.end(); }
|
2003-04-09 19:53:10 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
Infos::iterator begin() { return toolbar_info_.begin(); }
|
2006-11-02 16:01:36 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
Infos::iterator end() { return toolbar_info_.end(); }
|
2006-11-02 16:01:36 +00:00
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
/// read toolbars from the file
|
2007-04-26 11:30:54 +00:00
|
|
|
void readToolbars(Lexer &);
|
2003-06-11 19:21:46 +00:00
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
/// read ui toolbar settings
|
2007-04-26 11:30:54 +00:00
|
|
|
void readToolbarSettings(Lexer &);
|
2007-07-09 20:33:32 +00:00
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
///
|
2008-05-27 11:15:17 +00:00
|
|
|
ToolbarInfo const * info(std::string const & name) const;
|
2007-04-19 19:43:15 +00:00
|
|
|
///
|
2008-05-27 11:15:17 +00:00
|
|
|
int defaultVisibility(std::string const & name) const;
|
2008-06-02 12:51:36 +00:00
|
|
|
///
|
|
|
|
bool isMainToolbar(std::string const & name) const;
|
2008-02-28 11:19:19 +00:00
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
private:
|
2007-07-09 20:33:32 +00:00
|
|
|
/// all the defined toolbars
|
2008-05-27 11:15:17 +00:00
|
|
|
Infos toolbar_info_;
|
|
|
|
///
|
|
|
|
std::map<std::string, int> toolbar_visibility_;
|
2003-04-02 18:08:05 +00:00
|
|
|
};
|
|
|
|
|
2008-05-25 08:30:06 +00:00
|
|
|
} // namespace frontend
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2003-04-02 18:08:05 +00:00
|
|
|
#endif // TOOLBAR_BACKEND_H
|