X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FToolbarBackend.h;h=7d9fc9f6b914729081bd8c95f033a996287efb0a;hb=e7f4618bcce770369cf46335c2c7f0164b4b8857;hp=7e609ac8c4ecbf941c3e990138321f6b13bc7378;hpb=1423bdb7a7615b0af878188c9a36b07cbd2421e6;p=lyx.git diff --git a/src/ToolbarBackend.h b/src/ToolbarBackend.h index 7e609ac8c4..7d9fc9f6b9 100644 --- a/src/ToolbarBackend.h +++ b/src/ToolbarBackend.h @@ -4,70 +4,112 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author unknown + * \author Jean-Marc Lasgouttes + * \author John Levon * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ #ifndef TOOLBAR_BACKEND_H #define TOOLBAR_BACKEND_H +#include "funcrequest.h" + #include -#include "LString.h" + +namespace lyx { + class LyXLex; + /// class ToolbarBackend { public: /// The special toolbar actions - enum ItemType { + enum ItemType { + /// the command buffer + MINIBUFFER = -3, /// adds space between buttons in the toolbar - SEPARATOR = -3, + SEPARATOR = -2, /// a special combox insead of a button - LAYOUTS = -2, - /// begin a new line of button (not working) - NEWLINE = -1 + LAYOUTS = -1, + }; + + /// action, tooltip + typedef std::pair Item; + + /// the toolbar items + typedef std::vector Items; + + /// 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 + REVIEW = 256, //< shown when change tracking is enabled + AUTO = 512 //< only if AUTO is set, will MATH, TABLE and REIVEW is used + }; + + /// a toolbar + struct Toolbar { + /// toolbar name + std::string name; + /// toolbar GUI name + std::string gui_name; + /// toolbar contents + Items items; + /// flags + Flags flags; }; - /// - typedef std::vector Items; - /// - typedef Items::iterator iterator; - /// - typedef Items::const_iterator const_iterator; - /// + typedef std::vector Toolbars; + + typedef Items::const_iterator item_iterator; + ToolbarBackend(); - /// - iterator begin() { - return items.begin(); - } - /// - const_iterator begin() const { - return items.begin(); - } - /// - iterator end() { - return items.end(); - } - /// - const_iterator end() const { - return items.end(); - } - /// + + /// iterator for all toolbars + Toolbars::const_iterator begin() const { return usedtoolbars.begin(); } + + Toolbars::const_iterator end() const { return usedtoolbars.end(); } + + Toolbars::iterator begin() { return usedtoolbars.begin(); } + + Toolbars::iterator end() { return usedtoolbars.end(); } + + /// read a toolbar from the file void read(LyXLex &); + + /// read the used toolbars + void readToolbars(LyXLex &); + + /// return a full path of an XPM for the given action + static std::string const getIcon(FuncRequest const &); + private: - /// This func is just to make it easy for me... - void add(int); - /// - void add(string const &); - /// - Items items; + /// add the given lfun with tooltip if relevant + void add(Toolbar & tb, FuncRequest const &, + docstring const & tooltip = docstring()); + + /// all the toolbars + Toolbars toolbars; + + /// toolbars listed + Toolbars usedtoolbars; }; /// The global instance extern ToolbarBackend toolbarbackend; + +} // namespace lyx + #endif // TOOLBAR_BACKEND_H