]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiToolbars.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiToolbars.cpp
index fbd189e42c7320fba416269a1be24660674066c9..13544e458c947e7f3d0472d79e56a4b20b145386 100644 (file)
 
 #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 {
@@ -41,9 +43,7 @@ namespace frontend {
 #define TurnOffFlag(x)  flags &= ~ToolbarInfo::x
 
 GuiToolbars::GuiToolbars(GuiView & owner)
-       : owner_(owner),
-         layout_(0),
-         last_textclass_(TextClassPtr())
+       : owner_(owner)
 {
        init();
 }
@@ -94,7 +94,7 @@ 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)
@@ -105,7 +105,7 @@ void GuiToolbars::initFlags(ToolbarInfo & tbinfo)
                << " 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);
@@ -114,6 +114,11 @@ void GuiToolbars::initFlags(ToolbarInfo & tbinfo)
 
 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();
@@ -207,7 +212,8 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto)
        } 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);
@@ -218,11 +224,39 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto)
        }
        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();
 
@@ -240,14 +274,16 @@ void GuiToolbars::update(bool in_math, bool in_table, bool review)
                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;
@@ -262,7 +298,7 @@ void GuiToolbars::saveToolbarInfo()
        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)
@@ -288,41 +324,6 @@ void GuiToolbars::saveToolbarInfo()
 }
 
 
-void GuiToolbars::setLayout(docstring const & layout)
-{
-       if (layout_)
-               layout_->set(layout);
-}
-
-
-bool GuiToolbars::updateLayoutList(TextClassPtr textclass, bool force)
-{
-       // update the layout display
-       if (last_textclass_ != textclass || force) {
-               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);
@@ -332,9 +333,6 @@ void GuiToolbars::add(ToolbarInfo const & tbinfo, bool newline)
                tb_ptr->show();
        else
                tb_ptr->hide();
-
-       if (tb_ptr->layout())
-               layout_ = tb_ptr->layout();
 }
 
 
@@ -342,7 +340,7 @@ void GuiToolbars::displayToolbar(ToolbarInfo const & tbinfo,
                              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())
@@ -360,12 +358,6 @@ void GuiToolbars::updateIcons()
        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);
 }