4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
12 * The Toolbars class is a container of toolbars.
13 * It provides accessors to each Toolbar and to the LayoutBox.
15 * Each GUI frontend should provide toolbar and layout boxes by derivation
16 * from the LayoutBox and Toolbar pure abstract classes.
18 * The Toolbars class has no knowledge at all of the details of each
19 * frontend's implementation, which requires that each frontend should
20 * provide a 'make_toolbar' function, signature below.
26 #include "ToolbarBackend.h"
29 #include <boost/shared_ptr.hpp>
40 virtual ~LayoutBox() {}
41 /// Select the correct layout in the combox.
42 virtual void set(docstring const & layout) = 0;
43 /// Populate the layout combox.
44 virtual void update() = 0;
45 /// Erase the layout list.
46 virtual void clear() = 0;
47 /// Display the layout list.
48 virtual void open() = 0;
49 /// Set the activation status of the combox.
50 virtual void setEnabled(bool) = 0;
57 /// Add a button to the bar.
58 virtual void add(ToolbarItem const & item) = 0;
61 * \param update_metrics is a hint to the layout engine that the
62 * metrics should be updated.
64 virtual void hide(bool update_metrics) = 0;
66 * \param update_metrics is a hint to the layout engine that the
67 * metrics should be updated.
69 virtual void show(bool update_metrics) = 0;
70 /** update toolbar information
71 * ToolbarInfo will then be saved by session
73 virtual void saveInfo(ToolbarSection::ToolbarInfo & tbinfo) = 0;
75 /// whether toolbar is visible
76 virtual bool isVisible() const = 0;
77 /// Refresh the contents of the bar.
78 virtual void update() = 0;
79 /// Accessor to the layout combox, if any.
80 virtual LayoutBox * layout() const = 0;
87 Toolbars(LyXView & owner);
89 /// Initialize the toolbars using the backend database.
92 /// Show/hide the named toolbar.
93 void display(std::string const & name, bool show);
96 ToolbarInfo * getToolbarInfo(std::string const & name);
98 /** toggle the state of toolbars (on/off/auto). Skip "auto"
99 * when allowauto is false.
101 void toggleToolbarState(std::string const & name, bool allowauto);
103 /// Update the state of the toolbars.
104 void update(bool in_math, bool in_table, bool review);
106 /// Is the Toolbar currently visible?
107 bool visible(std::string const & name) const;
109 /// save toolbar information
110 void saveToolbarInfo();
112 /// Select the right layout in the combox.
113 void setLayout(docstring const & layout);
115 /** Populate the layout combox - returns whether we did a full
118 bool updateLayoutList(int textclass);
120 /// Drop down the layout list.
121 void openLayoutList();
122 /// Erase the layout list.
123 void clearLayoutList();
126 typedef boost::shared_ptr<Toolbar> ToolbarPtr;
129 /// Add a new toolbar. if newline==true, start from a new line
130 void add(ToolbarInfo const & tbinfo, bool newline);
131 /// Show or hide a toolbar.
132 void displayToolbar(ToolbarInfo const & tbinfo, bool show);
133 /// Update the state of the icons
136 /// The parent window.
139 /** The layout box is actually owned by whichever toolbar
140 * contains it. All the Toolbars class needs is a means of
143 * We don't need to use boost::weak_ptr here because the toolbars
144 * are also stored here. There are, therefore, no lifetime issues.
148 /// Toolbar store providing access to individual toolbars by name.
149 typedef std::map<std::string, ToolbarPtr> ToolbarsMap;
150 ToolbarsMap toolbars_;
152 /// The last textclass layout list in the layout choice selector
155 // load flags with saved values
156 void initFlags(ToolbarInfo & tbinfo);
159 /// Set the layout in the kernel when an entry has been selected
160 void layoutSelected(LyXView & lv, docstring const & name);
163 } // namespace frontend
166 #endif // NOT TOOLBARS_H