* 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 <vector>
-#include "LString.h"
+
+namespace lyx {
+
class LyXLex;
-///
-class ToolbarBackend {
+class ToolbarItem {
public:
- /// The special toolbar actions
- enum ItemType {
+ enum Type {
+ /// command/action
+ COMMAND,
+ /// the command buffer
+ MINIBUFFER,
/// adds space between buttons in the toolbar
- SEPARATOR = -3,
+ SEPARATOR,
/// a special combox insead of a button
- LAYOUTS = -2,
- /// begin a new line of button (not working)
- NEWLINE = -1
+ LAYOUTS,
+ /// a special widget to insert tabulars
+ TABLEINSERT,
+ ///
+ POPUPMENU,
+ ///
+ ICONPALETTE
};
- ///
- typedef std::vector<int> Items;
- ///
- typedef Items::iterator iterator;
- ///
- typedef Items::const_iterator const_iterator;
- ///
+ ToolbarItem(Type type,
+ FuncRequest const & func,
+ docstring const & label = docstring());
+
+ 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_;
+};
+
+
+///
+class ToolbarInfo {
+public:
+ /// toolbar flags
+ enum Flags {
+ ON = 1, //< show
+ OFF = 2, //< do not show
+ MATH = 4, //< show when in math
+ TABLE = 8, //< show 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, //< show when change tracking is enabled
+ AUTO = 512 //< only if AUTO is set, when MATH, TABLE and REVIEW is used
+ };
+ /// the toolbar items
+ typedef std::vector<ToolbarItem> Items;
+
+ typedef Items::const_iterator item_iterator;
+
+ explicit ToolbarInfo(std::string const & name = std::string())
+ : name(name) {}
+
+ /// 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;
+
ToolbarBackend();
+
+ /// 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 toolbars from the file
+ void readToolbars(LyXLex &);
+
+ /// read ui toolbar settings
+ void readToolbarSettings(LyXLex &);
///
- iterator begin() {
- return items.begin();
- }
- ///
- const_iterator begin() const {
- return items.begin();
- }
- ///
- iterator end() {
- return items.end();
- }
- ///
- const_iterator end() const {
- return items.end();
- }
+ ToolbarInfo const & getToolbar(std::string const & name) const;
///
- void read(LyXLex &);
+ ToolbarInfo & getToolbar(std::string const & name);
+
private:
- /// This func is just to make it easy for me...
- void add(int);
- ///
- void add(string const &);
- ///
- Items items;
+ /// all the toolbars
+ Toolbars toolbars;
+
+ /// toolbars listed
+ Toolbars usedtoolbars;
};
/// The global instance
extern ToolbarBackend toolbarbackend;
+
+} // namespace lyx
+
#endif // TOOLBAR_BACKEND_H