]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiToolbars.cpp
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / GuiToolbars.cpp
index e3ab5e8a899fc7c0f3e39ffd7c55072ebc853cae..dda0b7873b9cbf16369e0b74ec2ba7d3fbb52d41 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;
+using namespace std;
 
 namespace lyx {
 namespace frontend {
@@ -41,10 +40,10 @@ namespace frontend {
 #define TurnOffFlag(x)  flags &= ~ToolbarInfo::x
 
 GuiToolbars::GuiToolbars(GuiView & owner)
-       : owner_(owner),
-         layout_(0),
-         last_textclass_(TextClassPtr())
-{}
+       : owner_(owner)
+{
+       init();
+}
 
 
 void GuiToolbars::initFlags(ToolbarInfo & tbinfo)
@@ -92,7 +91,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)
@@ -103,7 +102,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);
@@ -112,6 +111,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();
@@ -131,8 +135,8 @@ void GuiToolbars::init()
        int last_posx = 0;
        int last_posy = 0;
        for (; tb != te; ++tb) {
-               LYXERR(Debug::INIT) << "Adding " << tb->key << " at position "
-                       << tb->info.posx << " " << tb->info.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->info.location == last_loc && (
                        // if two toolbars at the same location, assume uninitialized and add toolbar break
@@ -174,8 +178,7 @@ void GuiToolbars::display(string const & name, bool show)
                }
        }
 
-       LYXERR(Debug::GUI) << "Toolbar::display: no toolbar named "
-               << name << endl;
+       LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
 }
 
 
@@ -190,8 +193,7 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto)
        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;
        }
 
@@ -207,7 +209,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 +221,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 +271,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;
@@ -288,41 +321,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 +330,6 @@ void GuiToolbars::add(ToolbarInfo const & tbinfo, bool newline)
                tb_ptr->show();
        else
                tb_ptr->hide();
-
-       if (tb_ptr->layout())
-               layout_ = tb_ptr->layout();
 }
 
 
@@ -360,12 +355,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);
 }