]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/Toolbar_pimpl.C
layout as string
[lyx.git] / src / frontends / xforms / Toolbar_pimpl.C
index 67ca360a182cb5cb7134e2c299984416749975af..3785955688390797f3d61a79d8b39733fa9d6b6a 100644 (file)
@@ -23,7 +23,7 @@
 #include "debug.h"
 #include "XFormsView.h"
 #include "lyxfunc.h"
-#include "func_status.h"
+#include "FuncStatus.h"
 #include "BufferView.h"
 #include "buffer.h"
 #include "lyxtextclasslist.h"
@@ -130,13 +130,13 @@ int BubblePost(FL_OBJECT *ob, int event,
        FL_OBJECT * bubble_timer = reinterpret_cast<FL_OBJECT *>(ob->u_cdata);
        
        // We do not test for empty help here, since this can never happen
-       if (event == FL_ENTER){
+       if (event == FL_ENTER) {
                fl_set_object_callback(bubble_timer,
                                       C_Toolbar_BubbleTimerCB,
                                       reinterpret_cast<long>(ob));
                fl_set_timer(bubble_timer, 1);
        }
-       else if (event != FL_MOTION){
+       else if (event != FL_MOTION) {
                fl_set_timer(bubble_timer, 0);
                fl_hide_oneliner();
        }
@@ -190,8 +190,8 @@ void Toolbar::Pimpl::update()
        ToolbarList::const_iterator end = toollist.end();
        for (; p != end; ++p) {
                if (p->icon) {
-                       int status = owner->getLyXFunc()->getStatus(p->action);
-                       if (status & func_status::ToggleOn) {
+                       FuncStatus 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
                                // know how to use transparency with
@@ -203,8 +203,7 @@ void Toolbar::Pimpl::update()
                                fl_set_object_color(p->icon, FL_MCOL, FL_BLUE);
                                fl_set_object_boxtype(p->icon, FL_UP_BOX);
                        }
-
-                       if (status & func_status::Disabled) {
+                       if (status.disabled()) {
                                // Is there a way here to specify a
                                // mask in order to show that the
                                // button is disabled? (JMarc)
@@ -212,6 +211,11 @@ void Toolbar::Pimpl::update()
                        }
                        else
                                fl_activate_object(p->icon);
+               } else if (p->action == ToolbarDefaults::LAYOUTS && combox) {
+                       if (owner->getLyXFunc()->getStatus(LFUN_LAYOUT).disabled())
+                               combox->deactivate();
+                       else
+                               combox->activate();
                }
        }
 }
@@ -230,8 +234,7 @@ void Toolbar::Pimpl::layoutSelected()
 {
        string const & layoutguiname = combox->getline();
        LyXTextClass const & tc =
-               textclasslist.TextClass(owner->buffer()->
-                                       params.textclass);
+               textclasslist[owner->buffer()->params.textclass];
        
        LyXTextClass::const_iterator end = tc.end();
        for (LyXTextClass::const_iterator cit = tc.begin();
@@ -246,12 +249,11 @@ void Toolbar::Pimpl::layoutSelected()
 }
  
 
-void Toolbar::Pimpl::setLayout(int layout)
+void Toolbar::Pimpl::setLayout(string const & layout)
 {
        if (combox) {
                LyXTextClass const & tc =
-                       textclasslist.TextClass(owner->buffer()->
-                                               params.textclass);
+                       textclasslist[owner->buffer()->params.textclass];
                combox->select(_(tc[layout].name()));
        }
 }
@@ -266,8 +268,7 @@ void Toolbar::Pimpl::updateLayoutList(bool force)
        if (combox->empty() || force) {
                combox->clear();
                LyXTextClass const & tc =
-                       textclasslist.TextClass(owner->buffer()->
-                                               params.textclass);
+                       textclasslist[owner->buffer()->params.textclass];
                LyXTextClass::const_iterator end = tc.end();
                for (LyXTextClass::const_iterator cit = tc.begin();
                     cit != end; ++cit) {
@@ -303,10 +304,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac)
 {
        XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata);
        
-       string res = owner->getLyXFunc()->dispatch(int(ac));
-       if (!res.empty())
-               lyxerr[Debug::GUI] << "ToolbarCB: Function returned: " 
-                                  << res << endl;
+       owner->getLyXFunc()->verboseDispatch(int(ac), true);
 }
 
 
@@ -323,20 +321,15 @@ extern "C" {
 
 void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height)
 {
-       string name;
        string arg;
        string xpm_name;
-       kb_action act;
 
-       if (lyxaction.isPseudoAction(action)) {
-               act = lyxaction.retrieveActionArg(action, arg);
-               name = lyxaction.getActionName(act);
+       const kb_action act = lyxaction.retrieveActionArg(action, arg);
+       string const name = lyxaction.getActionName(act);
+       if (!arg.empty())
                xpm_name = subst(name + ' ' + arg, ' ','_');
-       } else {
-               act = (kb_action)action;
-               name = lyxaction.getActionName(action);
+       else 
                xpm_name = name;
-       }
 
        string fullname = LibFileSearch("images", xpm_name, "xpm");
 
@@ -394,7 +387,7 @@ void Toolbar::Pimpl::set(bool doingmain)
        ToolbarList::iterator item = toollist.begin();
        ToolbarList::iterator end = toollist.end();
        for (; item != end; ++item) {
-               switch (item->action){
+               switch (item->action) {
                case ToolbarDefaults::SEPARATOR:
                        xpos += sepspace;
                        break;