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 "TextClassPtr.h"
27 #include "ToolbarBackend.h"
30 #include <boost/shared_ptr.hpp>
41 virtual ~LayoutBox() {}
42 /// Select the correct layout in the combox.
43 virtual void set(docstring const & layout) = 0;
44 /// Populate the layout combox.
45 virtual void update() = 0;
46 /// Erase the layout list.
47 virtual void clear() = 0;
48 /// Display the layout list.
49 virtual void open() = 0;
50 /// Set the activation status of the combox.
51 virtual void setEnabled(bool) = 0;
58 /// Add a button to the bar.
59 virtual void add(ToolbarItem const & item) = 0;
62 * \param update_metrics is a hint to the layout engine that the
63 * metrics should be updated.
65 virtual void hide(bool update_metrics) = 0;
67 * \param update_metrics is a hint to the layout engine that the
68 * metrics should be updated.
70 virtual void show(bool update_metrics) = 0;
71 /** update toolbar information
72 * ToolbarInfo will then be saved by session
74 virtual void saveInfo(ToolbarSection::ToolbarInfo & tbinfo) = 0;
76 /// whether toolbar is visible
77 virtual bool isVisible() const = 0;
78 /// Refresh the contents of the bar.
79 virtual void update() = 0;
80 /// Accessor to the layout combox, if any.
81 virtual LayoutBox * layout() const = 0;
83 /// Set the focus on the command buffer, if any.
84 virtual void focusCommandBuffer() = 0;
91 Toolbars(LyXView & owner);
93 /// Initialize the toolbars using the backend database.
96 /// Show/hide the named toolbar.
97 Toolbar * display(std::string const & name, bool show);
100 ToolbarInfo * getToolbarInfo(std::string const & name);
102 /** toggle the state of toolbars (on/off/auto). Skip "auto"
103 * when allowauto is false.
105 void toggleToolbarState(std::string const & name, bool allowauto);
107 /// Update the state of the toolbars.
108 void update(bool in_math, bool in_table, bool review);
110 /// Is the Toolbar currently visible?
111 bool visible(std::string const & name) const;
113 /// save toolbar information
114 void saveToolbarInfo();
116 /// Select the right layout in the combox.
117 void setLayout(docstring const & layout);
119 /** Populate the layout combox - returns whether we did a full
122 bool updateLayoutList(TextClassPtr textclass);
124 /// Drop down the layout list.
125 void openLayoutList();
126 /// Erase the layout list.
127 void clearLayoutList();
130 typedef boost::shared_ptr<Toolbar> ToolbarPtr;
133 /// Add a new toolbar. if newline==true, start from a new line
134 void add(ToolbarInfo const & tbinfo, bool newline);
135 /// Show or hide a toolbar.
136 Toolbar * displayToolbar(ToolbarInfo const & tbinfo, bool show);
137 /// Update the state of the icons
140 /// The parent window.
143 /** The layout box is actually owned by whichever toolbar
144 * contains it. All the Toolbars class needs is a means of
147 * We don't need to use boost::weak_ptr here because the toolbars
148 * are also stored here. There are, therefore, no lifetime issues.
152 /// Toolbar store providing access to individual toolbars by name.
153 typedef std::map<std::string, ToolbarPtr> ToolbarsMap;
154 ToolbarsMap toolbars_;
156 /// The last textclass layout list in the layout choice selector
157 TextClassPtr last_textclass_;
159 // load flags with saved values
160 void initFlags(ToolbarInfo & tbinfo);
163 /// Set the layout in the kernel when an entry has been selected
164 void layoutSelected(LyXView & lv, docstring const & name);
167 } // namespace frontend
170 #endif // NOT TOOLBARS_H