#include "Buffer.h"
#include "BufferParams.h"
-#include "debug.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
-#include "gettext.h"
#include "Layout.h"
#include "LyX.h"
#include "LyXFunc.h"
#include "TextClass.h"
#include "ToolbarBackend.h"
+#include "support/debug.h"
+#include "support/gettext.h"
-using std::endl;
-using std::string;
+#include "support/assert.h"
+
+
+using namespace std;
namespace lyx {
namespace frontend {
#define TurnOnFlag(x) flags |= ToolbarInfo::x
#define TurnOffFlag(x) flags &= ~ToolbarInfo::x
-GuiToolbars::GuiToolbars(GuiViewBase & owner)
- : owner_(owner),
- layout_(0),
- last_textclass_(TextClassPtr())
-{}
+GuiToolbars::GuiToolbars(GuiView & owner)
+ : owner_(owner)
+{
+ init();
+}
void GuiToolbars::initFlags(ToolbarInfo & tbinfo)
TurnOnFlag(AUTO);
}
/*
- std::cout << "State " << info.state << " FLAGS: " << flags
+ cout << "State " << info.state << " FLAGS: " << flags
<< " ON:" << (flags & ToolbarBackend::ON)
<< " OFF:" << (flags & ToolbarBackend::OFF)
<< " L:" << (flags & ToolbarBackend::LEFT)
<< " RE:" << (flags & ToolbarBackend::REVIEW)
<< " TB:" << (flags & ToolbarBackend::TABLE)
<< " AU:" << (flags & ToolbarBackend::AUTO)
- << std::endl;
+ << endl;
*/
// now set the flags
tbinfo.flags = static_cast<lyx::ToolbarInfo::Flags>(flags);
void GuiToolbars::init()
{
+ ToolbarsMap::const_iterator it = toolbars_.begin();
+ for (; it != toolbars_.end(); ++it)
+ delete it->second;
+ toolbars_.clear();
+
// extracts the toolbars from the backend
ToolbarBackend::Toolbars::iterator cit = toolbarbackend.begin();
ToolbarBackend::Toolbars::iterator end = toolbarbackend.end();
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;
}
} else if (allowauto
&& ((flags & ToolbarInfo::MATH)
|| (flags & ToolbarInfo::TABLE)
- || (flags & ToolbarInfo::REVIEW))) {
+ || (flags & ToolbarInfo::REVIEW)
+ || (flags & ToolbarInfo::MATHMACROTEMPLATE))) {
// for math etc, toggle from on -> auto
TurnOffFlag(ON);
TurnOnFlag(AUTO);
}
tbi->flags = static_cast<ToolbarInfo::Flags>(flags);
}
+
+
+void GuiToolbars::toggleFullScreen(bool start_full_screen)
+{
+ // we need to know number of fullscreens until every
+ // LyXView has its own toolbar configuration
+ toolbarbackend.fullScreenWindows += start_full_screen ? 1 : -1;
+
+ // extracts the toolbars from the backend
+ ToolbarBackend::Toolbars::iterator cit = toolbarbackend.begin();
+ ToolbarBackend::Toolbars::iterator end = toolbarbackend.end();
+ int flags = 0;
+
+ for (; cit != end; ++cit) {
+
+ if (start_full_screen) {
+ if (toolbarbackend.fullScreenWindows == 1)
+ flags = cit->before_fullscreen = cit->flags;
+ TurnOffFlag(ON);
+ TurnOffFlag(AUTO);
+ TurnOnFlag(OFF);
+ } else
+ flags = cit->before_fullscreen;
+
+ cit->flags = static_cast<ToolbarInfo::Flags>(flags);
+ }
+}
#undef TurnOnFlag
#undef TurnOffFlag
-void GuiToolbars::update(bool in_math, bool in_table, bool review)
+void GuiToolbars::update(bool in_math, bool in_table, bool review,
+ bool in_mathmacrotemplate)
{
updateIcons();
else if ((cit->flags & ToolbarInfo::AUTO) && (cit->flags & ToolbarInfo::TABLE))
displayToolbar(*cit, in_table);
else if ((cit->flags & ToolbarInfo::AUTO) && (cit->flags & ToolbarInfo::REVIEW))
- displayToolbar(*cit, review);
+ displayToolbar(*cit, review);
+ else if ((cit->flags & ToolbarInfo::AUTO) && (cit->flags & ToolbarInfo::MATHMACROTEMPLATE))
+ displayToolbar(*cit, in_mathmacrotemplate);
}
}
bool GuiToolbars::visible(string const & name) const
{
- std::map<string, GuiToolbar *>::const_iterator it =
+ map<string, GuiToolbar *>::const_iterator it =
toolbars_.find(name);
if (it == toolbars_.end())
return false;
for (ToolbarBackend::Toolbars::iterator cit = toolbarbackend.begin();
cit != toolbarbackend.end(); ++cit) {
ToolbarsMap::iterator it = toolbars_.find(cit->name);
- BOOST_ASSERT(it != toolbars_.end());
+ LASSERT(it != toolbars_.end(), /**/);
// get toolbar info from session.
ToolbarSection::ToolbarInfo & info = tb.load(cit->name);
if (cit->flags & ToolbarInfo::ON)
}
-void GuiToolbars::setLayout(docstring const & layout)
-{
- if (layout_)
- layout_->set(layout);
-}
-
-
-bool GuiToolbars::updateLayoutList(TextClassPtr textclass)
-{
- // update the layout display
- if (last_textclass_ != textclass) {
- if (layout_)
- layout_->updateContents();
- last_textclass_ = textclass;
- return true;
- } else
- return false;
-}
-
-
-void GuiToolbars::openLayoutList()
-{
- if (layout_)
- layout_->showPopup();
-}
-
-
-void GuiToolbars::clearLayoutList()
-{
- last_textclass_ = TextClassPtr();
- if (layout_)
- layout_->clear();
-}
-
-
void GuiToolbars::add(ToolbarInfo const & tbinfo, bool newline)
{
GuiToolbar * tb_ptr = owner_.makeToolbar(tbinfo, newline);
tb_ptr->show();
else
tb_ptr->hide();
-
- if (tb_ptr->layout())
- layout_ = tb_ptr->layout();
}
bool show_it)
{
ToolbarsMap::iterator it = toolbars_.find(tbinfo.name);
- BOOST_ASSERT(it != toolbars_.end());
+ LASSERT(it != toolbars_.end(), /**/);
if (show_it) {
if (it->second->isVisible())
ToolbarsMap::const_iterator const end = toolbars_.end();
for (; it != end; ++it)
it->second->updateContents();
-
- bool const enable =
- lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled();
-
- if (layout_)
- layout_->setEnabled(enable);
}
if (!cb)
continue;
if (!show_it) {
- it->second->hide();
+ // FIXME: this is a hack, "minibuffer" should not be
+ // hardcoded.
+ display("minibuffer", false);
return;
}
if (!it->second->isVisible())
- it->second->show();
+ display("minibuffer", true);
cb->setFocus();
return;
}