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"
27 #include <boost/shared_ptr.hpp>
38 virtual ~LayoutBox() {}
39 /// Select the correct layout in the combox.
40 virtual void set(std::string const & layout) = 0;
41 /// Populate the layout combox.
42 virtual void update() = 0;
43 /// Erase the layout list.
44 virtual void clear() = 0;
45 /// Display the layout list.
46 virtual void open() = 0;
47 /// Set the activation status of the combox.
48 virtual void setEnabled(bool) = 0;
55 /// Add a button to the bar.
56 virtual void add(ToolbarItem const & item) = 0;
59 * \param update_metrics is a hint to the layout engine that the
60 * metrics should be updated.
62 virtual void hide(bool update_metrics) = 0;
64 * \param update_metrics is a hint to the layout engine that the
65 * metrics should be updated.
67 virtual void show(bool update_metrics) = 0;
68 /** update toolbar information
69 * ToolbarInfo will then be saved by session
71 virtual void saveInfo(ToolbarSection::ToolbarInfo & tbinfo) = 0;
73 /// whether toolbar is visible
74 virtual bool isVisible() const = 0;
75 /// Refresh the contents of the bar.
76 virtual void update() = 0;
77 /// Accessor to the layout combox, if any.
78 virtual LayoutBox * layout() const = 0;
85 Toolbars(LyXView & owner);
87 /// Initialize the toolbars using the backend database.
90 /// Show/hide the named toolbar.
91 void display(std::string const & name, bool show);
93 /// get toolbar state (on/off/auto)
94 ToolbarInfo::Flags getToolbarState(std::string const & name);
96 /// toggle the state of toolbars (on/off/auto)
97 void toggleToolbarState(std::string const & name);
99 /// Update the state of the toolbars.
100 void update(bool in_math, bool in_table, bool review);
102 /// Is the Toolbar currently visible?
103 bool visible(std::string const & name) const;
105 /// save toolbar information
106 void saveToolbarInfo();
108 /// Select the right layout in the combox.
109 void setLayout(std::string const & layout);
111 /** Populate the layout combox - returns whether we did a full
114 bool updateLayoutList(int textclass);
116 /// Drop down the layout list.
117 void openLayoutList();
118 /// Erase the layout list.
119 void clearLayoutList();
122 typedef boost::shared_ptr<Toolbar> ToolbarPtr;
125 /// Add a new toolbar. if newline==true, start from a new line
126 void add(ToolbarInfo const & tbinfo, bool newline);
127 /// Show or hide a toolbar.
128 void displayToolbar(ToolbarInfo const & tbinfo, bool show);
129 /// Update the state of the icons
132 /// The parent window.
135 /** The layout box is actually owned by whichever toolbar
136 * contains it. All the Toolbars class needs is a means of
139 * We don't need to use boost::weak_ptr here because the toolbars
140 * are also stored here. There are, therefore, no lifetime issues.
144 /// Toolbar store providing access to individual toolbars by name.
145 typedef std::map<std::string, ToolbarPtr> ToolbarsMap;
146 ToolbarsMap toolbars_;
148 /// The last textclass layout list in the layout choice selector
151 // load flags with saved values
152 void initFlags(ToolbarInfo & tbinfo);
155 /// Set the layout in the kernel when an entry has been selected
156 void layoutSelected(LyXView & lv, std::string const & name);
161 #endif // NOT TOOLBARS_H