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 "TextClass_ptr.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;
88 Toolbars(LyXView & owner);
90 /// Initialize the toolbars using the backend database.
93 /// Show/hide the named toolbar.
94 void display(std::string const & name, bool show);
97 ToolbarInfo * getToolbarInfo(std::string const & name);
99 /** toggle the state of toolbars (on/off/auto). Skip "auto"
100 * when allowauto is false.
102 void toggleToolbarState(std::string const & name, bool allowauto);
104 /// Update the state of the toolbars.
105 void update(bool in_math, bool in_table, bool review);
107 /// Is the Toolbar currently visible?
108 bool visible(std::string const & name) const;
110 /// save toolbar information
111 void saveToolbarInfo();
113 /// Select the right layout in the combox.
114 void setLayout(docstring const & layout);
116 /** Populate the layout combox - returns whether we did a full
119 bool updateLayoutList(TextClass_ptr textclass);
121 /// Drop down the layout list.
122 void openLayoutList();
123 /// Erase the layout list.
124 void clearLayoutList();
127 typedef boost::shared_ptr<Toolbar> ToolbarPtr;
130 /// Add a new toolbar. if newline==true, start from a new line
131 void add(ToolbarInfo const & tbinfo, bool newline);
132 /// Show or hide a toolbar.
133 void displayToolbar(ToolbarInfo const & tbinfo, bool show);
134 /// Update the state of the icons
137 /// The parent window.
140 /** The layout box is actually owned by whichever toolbar
141 * contains it. All the Toolbars class needs is a means of
144 * We don't need to use boost::weak_ptr here because the toolbars
145 * are also stored here. There are, therefore, no lifetime issues.
149 /// Toolbar store providing access to individual toolbars by name.
150 typedef std::map<std::string, ToolbarPtr> ToolbarsMap;
151 ToolbarsMap toolbars_;
153 /// The last textclass layout list in the layout choice selector
154 TextClass_ptr last_textclass_;
156 // load flags with saved values
157 void initFlags(ToolbarInfo & tbinfo);
160 /// Set the layout in the kernel when an entry has been selected
161 void layoutSelected(LyXView & lv, docstring const & name);
164 } // namespace frontend
167 #endif // NOT TOOLBARS_H