]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/Toolbar_pimpl.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / Toolbar_pimpl.C
index 501531d7e2f19132060272125328fc8d39c67e2b..eb74e515fdc13730b2d22d2bcdd74fbea738cc38 100644 (file)
@@ -1,11 +1,13 @@
 /**
  * \file Toolbar_pimpl.C
  * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
  * Copyright 1996-1998 Lars Gullik Bjønnes
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Lars Gullik Bjønnes, larsbj@lyx.org
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 //  Added pseudo-action handling, asierra 180296
 #include "XFormsView.h"
 #include "lyxfunc.h"
 #include "FuncStatus.h"
-#include "BufferView.h"
 #include "buffer.h"
 #include "funcrequest.h"
-#include "MathsSymbols.h"
 #include "gettext.h"
 #include "Tooltips.h"
 #include FORMS_H_LOCATION
@@ -36,8 +36,6 @@
 #include "support/filetools.h"
 #include "support/lstrings.h"
 
-#include <boost/tuple/tuple.hpp>
 using std::endl;
 
 // some constants
@@ -48,8 +46,7 @@ const int height = 30; // the height of all items in the toolbar
 
 Toolbar::Pimpl::toolbarItem::toolbarItem()
        : action(LFUN_NOACTION), icon(0)
-{
-}
+{}
 
 
 Toolbar::Pimpl::toolbarItem::~toolbarItem()
@@ -89,11 +86,11 @@ Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & ti)
 
 
 
-Toolbar::Pimpl::Pimpl(LyXView * o, Dialogs & d, int x, int y)
+Toolbar::Pimpl::Pimpl(LyXView * o, int x, int y)
        : owner_(static_cast<XFormsView *>(o)), xpos(x), ypos(y)
 {
        combox_ = 0;
-       tooltip_ = new Tooltips(d);
+       tooltip_ = new Tooltips();
 }
 
 
@@ -118,7 +115,7 @@ void Toolbar::Pimpl::update()
        ToolbarList::const_iterator end = toollist_.end();
        for (; p != end; ++p) {
                if (p->action == ToolbarDefaults::LAYOUTS && combox_) {
-                       if (owner_->getLyXFunc()->getStatus(LFUN_LAYOUT).disabled())
+                       if (owner_->getLyXFunc().getStatus(LFUN_LAYOUT).disabled())
                                combox_->deactivate();
                        else
                                combox_->activate();
@@ -128,7 +125,7 @@ void Toolbar::Pimpl::update()
                if (!p->icon)
                        continue;
  
-               FuncStatus const status = owner_->getLyXFunc()->getStatus(p->action);
+               FuncStatus const status = owner_->getLyXFunc().getStatus(p->action);
                if (status.onoff(true)) {
                        // I'd like to use a different color
                        // here, but then the problem is to
@@ -170,7 +167,7 @@ void Toolbar::Pimpl::layoutSelected()
        for (LyXTextClass::const_iterator cit = tc.begin();
             cit != end; ++cit) {
                if (_((*cit)->name()) == layoutguiname) {
-                       owner_->getLyXFunc()->dispatch(FuncRequest(LFUN_LAYOUT, (*cit)->name()));
+                       owner_->getLyXFunc().dispatch(FuncRequest(LFUN_LAYOUT, (*cit)->name()));
                        return;
                }
        }
@@ -234,7 +231,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac)
 {
        XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata);
 
-       owner->getLyXFunc()->dispatch(int(ac), true);
+       owner->getLyXFunc().dispatch(int(ac), true);
 }
 
 
@@ -249,22 +246,24 @@ extern "C" {
 }
 
 
-void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height)
+void setPixmap(FL_OBJECT * obj, int action)
 {
        string xpm_name;
-
-       kb_action act;
-       string arg;
-       boost::tie(act, arg) = lyxaction.retrieveActionArg(action);
+       FuncRequest ev = lyxaction.retrieveActionArg(action);
  
-       string const name = lyxaction.getActionName(act);
-       if (!arg.empty())
-               xpm_name = subst(name + ' ' + arg, ' ','_');
+       string const name = lyxaction.getActionName(ev.action);
+       if (!ev.argument.empty())
+               xpm_name = subst(name + ' ' + ev.argument, ' ','_');
        else
                xpm_name = name;
 
        string fullname = LibFileSearch("images", xpm_name, "xpm");
 
+       if (ev.action == LFUN_INSERT_MATH && !ev.argument.empty()) {
+               string arg = ev.argument.substr(1);
+               fullname = LibFileSearch("images/math/", arg, "xpm");
+       }
        if (!fullname.empty()) {
                lyxerr[Debug::GUI] << "Full icon name is `"
                                   << fullname << "'" << endl;
@@ -272,19 +271,6 @@ void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height)
                return;
        }
 
-       if (act == LFUN_INSERT_MATH && !arg.empty()) {
-               char const ** pixmap = get_pixmap_from_symbol(arg.c_str(),
-                                                             buttonwidth,
-                                                             height);
-               if (pixmap) {
-                       lyxerr[Debug::GUI] << "Using mathed-provided icon"
-                                          << endl;
-                       fl_set_pixmapbutton_data(obj,
-                                                const_cast<char **>(pixmap));
-                       return;
-               }
-       }
-
        lyxerr << "Unable to find icon `" << xpm_name << "'" << endl;
        fullname = LibFileSearch("images", "unknown", "xpm");
        if (!fullname.empty()) {
@@ -344,7 +330,7 @@ void Toolbar::Pimpl::add(int action)
                // The view that this object belongs to.
                obj->u_vdata = owner_;
 
-               setPixmap(obj, action, buttonwidth, height);
+               setPixmap(obj, action);
                // we must remember to update the positions
                xpos += buttonwidth;
                // ypos is constant