#include "GuiToolbars.h"
+#include "GuiCommandBuffer.h"
#include "GuiToolbar.h"
#include "GuiView.h"
#include "LyX.h"
#include "LyXFunc.h"
#include "TextClass.h"
+#include "ToolbarBackend.h"
using std::endl;
#define TurnOnFlag(x) flags |= ToolbarInfo::x
#define TurnOffFlag(x) flags &= ~ToolbarInfo::x
-GuiToolbars::GuiToolbars(GuiViewBase & owner)
+GuiToolbars::GuiToolbars(GuiView & owner)
: owner_(owner),
layout_(0),
last_textclass_(TextClassPtr())
initFlags(*cit);
// add toolbars according the order in session
- ToolbarSection::ToolbarList::const_iterator tb = LyX::ref().session().toolbars().begin();
- ToolbarSection::ToolbarList::const_iterator te = LyX::ref().session().toolbars().end();
- ToolbarSection::ToolbarInfo::Location last_loc = ToolbarSection::ToolbarInfo::NOTSET;
+ ToolbarSection::ToolbarList::const_iterator tb =
+ LyX::ref().session().toolbars().begin();
+ ToolbarSection::ToolbarList::const_iterator te =
+ LyX::ref().session().toolbars().end();
+ ToolbarSection::ToolbarInfo::Location last_loc =
+ ToolbarSection::ToolbarInfo::NOTSET;
int last_posx = 0;
int last_posy = 0;
for (; tb != te; ++tb) {
- LYXERR(Debug::INIT) << "Adding " << tb->get<0>() << " at position " << tb->get<1>().posx << " " << tb->get<1>().posy << endl;
+ LYXERR(Debug::INIT, "Adding " << tb->key << " at position "
+ << tb->info.posx << " " << tb->info.posy);
// add toolbar break if posx or posy changes
- bool newline = tb->get<1>().location == last_loc && (
+ bool newline = tb->info.location == last_loc && (
// if two toolbars at the same location, assume uninitialized and add toolbar break
- (tb->get<1>().posx == last_posx && tb->get<1>().posy == last_posy) ||
- (last_loc == ToolbarSection::ToolbarInfo::TOP && tb->get<1>().posy != last_posy) ||
- (last_loc == ToolbarSection::ToolbarInfo::BOTTOM && tb->get<1>().posy != last_posy) ||
- (last_loc == ToolbarSection::ToolbarInfo::LEFT && tb->get<1>().posx != last_posx) ||
- (last_loc == ToolbarSection::ToolbarInfo::RIGHT && tb->get<1>().posx != last_posx) );
+ (tb->info.posx == last_posx && tb->info.posy == last_posy) ||
+ (last_loc == ToolbarSection::ToolbarInfo::TOP && tb->info.posy != last_posy) ||
+ (last_loc == ToolbarSection::ToolbarInfo::BOTTOM && tb->info.posy != last_posy) ||
+ (last_loc == ToolbarSection::ToolbarInfo::LEFT && tb->info.posx != last_posx) ||
+ (last_loc == ToolbarSection::ToolbarInfo::RIGHT && tb->info.posx != last_posx) );
// find the backend item and add
for (cit = toolbarbackend.begin(); cit != end; ++cit)
- if (cit->name == tb->get<0>()) {
+ if (cit->name == tb->key) {
add(*cit, newline);
- last_loc = tb->get<1>().location;
- last_posx = tb->get<1>().posx;
- last_posy = tb->get<1>().posy;
+ last_loc = tb->info.location;
+ last_posx = tb->info.posx;
+ last_posy = tb->info.posy;
break;
}
}
}
}
- LYXERR(Debug::GUI) << "Toolbar::display: no toolbar named "
- << name << endl;
+ LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
}
ToolbarInfo * tbi = toolbarbackend.getUsedToolbarInfo(name);
if (!tbi) {
- LYXERR(Debug::GUI) << "Toolbar::display: no toolbar named "
- << name << endl;
+ LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
return;
}
}
-bool GuiToolbars::updateLayoutList(TextClassPtr textclass)
+bool GuiToolbars::updateLayoutList(TextClassPtr textclass, bool force)
{
// update the layout display
- if (last_textclass_ != textclass) {
+ if (last_textclass_ != textclass || force) {
if (layout_)
layout_->updateContents();
last_textclass_ = textclass;
layout_->setEnabled(enable);
}
+
+void GuiToolbars::showCommandBuffer(bool show_it)
+{
+ ToolbarsMap::const_iterator it = toolbars_.begin();
+ ToolbarsMap::const_iterator const end = toolbars_.end();
+ for (; it != end; ++it) {
+ GuiCommandBuffer * cb = it->second->commandBuffer();
+ if (!cb)
+ continue;
+ if (!show_it) {
+ // FIXME: this is a hack, "minibuffer" should not be
+ // hardcoded.
+ display("minibuffer", false);
+ return;
+ }
+ if (!it->second->isVisible())
+ display("minibuffer", true);
+ cb->setFocus();
+ return;
+ }
+}
+
} // namespace frontend
} // namespace lyx