X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FToolbar_pimpl.C;h=6bf013398c537dc34623149f3a9dac17b5c5e320;hb=2c3af1475e2a408f725b5eea93583ee13e3d09cc;hp=655fa2a98e808e2865291bed56609b1448e0524d;hpb=271f8d7eec31175f53d012147af164cb27b043ce;p=lyx.git diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index 655fa2a98e..6bf013398c 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -23,14 +23,16 @@ #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" #include "LyXAction.h" #include "MathsSymbols.h" +#include "gettext.h" + #include "support/filetools.h" #include "support/lstrings.h" -#include "gettext.h" using std::endl; @@ -42,18 +44,21 @@ const int sepspace = 6; // extra space const int buttonwidth = 30; // the standard button width const int height = 30; // the height of all items in the toolbar -Toolbar::Pimpl::toolbarItem::toolbarItem() { +Toolbar::Pimpl::toolbarItem::toolbarItem() +{ action = LFUN_NOACTION; icon = 0; } -Toolbar::Pimpl::toolbarItem::~toolbarItem() { +Toolbar::Pimpl::toolbarItem::~toolbarItem() +{ clean(); } -void Toolbar::Pimpl::toolbarItem::clean() { +void Toolbar::Pimpl::toolbarItem::clean() +{ if (icon) { fl_delete_object(icon); fl_free_object(icon); @@ -63,7 +68,8 @@ void Toolbar::Pimpl::toolbarItem::clean() { Toolbar::Pimpl::toolbarItem & -Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & ti) { +Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & ti) +{ // Are we assigning the object onto itself? if (this == &ti) return *this; @@ -106,13 +112,15 @@ void BubbleTimerCB(FL_OBJECT *, long data) } -extern "C" +extern "C" { + static void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data) { BubbleTimerCB(ob, data); } +} // post_handler for bubble-help (Matthias) int BubblePost(FL_OBJECT *ob, int event, @@ -122,13 +130,13 @@ int BubblePost(FL_OBJECT *ob, int event, FL_OBJECT * bubble_timer = reinterpret_cast(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(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(); } @@ -136,7 +144,8 @@ int BubblePost(FL_OBJECT *ob, int event, } -extern "C" +extern "C" { + static int C_Toolbar_BubblePost(FL_OBJECT * ob, int event, FL_Coord /*mx*/, FL_Coord /*my*/, @@ -144,6 +153,8 @@ int C_Toolbar_BubblePost(FL_OBJECT * ob, int event, { return BubblePost(ob, event, 0, 0, key, xev); } + +} #endif } // namespace anon @@ -172,14 +183,15 @@ void Toolbar::Pimpl::deactivate() } } + void Toolbar::Pimpl::update() { ToolbarList::const_iterator p = toollist.begin(); 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 @@ -191,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) @@ -200,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(); } } } @@ -234,7 +250,8 @@ void Toolbar::Pimpl::layoutSelected() } -void Toolbar::Pimpl::setLayout(int layout) { +void Toolbar::Pimpl::setLayout(int layout) +{ if (combox) { LyXTextClass const & tc = textclasslist.TextClass(owner->buffer()-> @@ -290,10 +307,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac) { XFormsView * owner = static_cast(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); } @@ -308,19 +322,17 @@ extern "C" { } -void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) { - string name, arg, xpm_name; - kb_action act; +void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) +{ + string arg; + string xpm_name; - 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"); @@ -378,7 +390,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;