]> git.lyx.org Git - lyx.git/blobdiff - src/ToolbarBackend.h
Alfredo's second patch
[lyx.git] / src / ToolbarBackend.h
index 7e609ac8c4ecbf941c3e990138321f6b13bc7378..bbc3498f5ebd6c01e287fe3744940318948502d7 100644 (file)
@@ -13,6 +13,7 @@
 #define TOOLBAR_BACKEND_H
 
 #include <vector>
+#include <algorithm>
 
 #include "LString.h"
 
@@ -22,48 +23,73 @@ 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,
        };
 
-       ///
-       typedef std::vector<int> Items;
-       ///
-       typedef Items::iterator iterator;
-       ///
-       typedef Items::const_iterator const_iterator;
-       ///
+       /// action, tooltip
+       typedef std::pair<int, string> Item;
+
+       /// the toolbar items
+       typedef std::vector<std::pair<int, string> > 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
+       };
+
+       /// a toolbar
+       struct Toolbar {
+               /// toolbar UI name
+               string name;
+               /// toolbar contents
+               Items items;
+               /// flags
+               Flags flags;
+       };
+
+       typedef std::vector<Toolbar> 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();
+
+       /// iterator for all toolbars
+       Toolbars::const_iterator begin() const {
+               return toolbars.begin();
        }
-       ///
-       const_iterator end() const {
-               return items.end();
+
+       Toolbars::const_iterator end() const {
+               return toolbars.end();
        }
-       ///
+
+       /// read a toolbar from the file
        void read(LyXLex &);
+
+       /// return a full path of an XPM for the given action
+       static string const getIcon(int action);
+
 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, int, string const & tooltip = string());
+
+       /// add the given lfun with tooltip if relevant
+       void add(Toolbar & tb, string const &, string const & tooltip);
+
+       /// all the toolbars
+       Toolbars toolbars;
 };
 
 /// The global instance