X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffrontends%2Fxforms%2FToolbar_pimpl.C;h=dae43e651a1b96de5b3b063b6cec93d846436763;hb=8075064372c5361f2dfd91860003f0cb317b4e39;hp=07406dbc98c41d55857b7d626ee87b93d48bcfd5;hpb=f4b8943ebb264c92b86a9756f9ae02b76552b347;p=lyx.git diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index 07406dbc98..dae43e651a 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -4,7 +4,7 @@ * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich - * Copyright 1995-2000 The LyX Team. + * Copyright 1995-2001 The LyX Team. * * This file is Copyright 1996-1998 * Lars Gullik Bjønnes @@ -20,20 +20,20 @@ #endif #include "Toolbar_pimpl.h" -#include "lyxfunc.h" #include "debug.h" -#include "LyXView.h" +#include "XFormsView.h" +#include "lyxfunc.h" +#include "func_status.h" #include "BufferView.h" #include "buffer.h" #include "LyXAction.h" +#include "MathsSymbols.h" #include "support/filetools.h" +#include "support/lstrings.h" #include "gettext.h" using std::endl; -// this one is not "C" because combox callbacks are really C++ %-| -extern void LayoutsCB(int, void *); -extern char const ** get_pixmap_from_symbol(char const * arg, int, int); extern LyXAction lyxaction; // some constants @@ -63,7 +63,7 @@ void Toolbar::Pimpl::toolbarItem::clean() { Toolbar::Pimpl::toolbarItem & -Toolbar::Pimpl::toolbarItem::operator=(const toolbarItem & ti) { +Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & ti) { // Are we assigning the object onto itself? if (this == &ti) return *this; @@ -81,7 +81,7 @@ Toolbar::Pimpl::toolbarItem::operator=(const toolbarItem & ti) { Toolbar::Pimpl::Pimpl(LyXView * o, int x, int y) - : owner(o), sxpos(x), sypos(y) + : owner(static_cast(o)), sxpos(x), sypos(y) { combox = 0; #if FL_REVISION < 89 @@ -90,16 +90,17 @@ Toolbar::Pimpl::Pimpl(LyXView * o, int x, int y) } +namespace { + #if FL_REVISION < 89 // timer-cb for bubble-help (Matthias) -static void BubbleTimerCB(FL_OBJECT *, long data) { FL_OBJECT * ob = reinterpret_cast(data); // The trick we use to get the help text is to read the // argument of the callback that has been registered for // ToolBarCB. (JMarc) - string help = lyxaction.helpText(ob->argument); + string help = _(lyxaction.helpText(ob->argument)); fl_show_oneliner(help.c_str(), ob->form->x + ob->x, ob->form->y + ob->y + ob->h); } @@ -112,21 +113,20 @@ extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data) // post_handler for bubble-help (Matthias) -static int BubblePost(FL_OBJECT *ob, int event, FL_Coord /*mx*/, FL_Coord /*my*/, - int /*key*/, void */*xev*/) + int /*key*/, void * /*xev*/) { 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(); } @@ -142,6 +142,24 @@ extern "C" int C_Toolbar_BubblePost(FL_OBJECT * ob, int event, } #endif +} // namespace anon + + +// this one is not "C" because combox callbacks are really C++ %-| +void Toolbar::Pimpl::layoutSelectedCB(int sel, void * arg, Combox *) +{ + Toolbar::Pimpl * tb = reinterpret_cast(arg); + + tb->layoutSelected(sel); +} + + +void Toolbar::Pimpl::layoutSelected(int sel) +{ + string const tmp = tostr(sel); + owner->getLyXFunc()->dispatch(LFUN_LAYOUTNO, tmp); +} + void Toolbar::Pimpl::activate() { @@ -173,7 +191,7 @@ void Toolbar::Pimpl::update() for (; p != end; ++p) { if (p->icon) { int status = owner->getLyXFunc()->getStatus(p->action); - if (status & LyXFunc::ToggleOn) { + if (status & func_status::ToggleOn) { // I'd like to use a different color // here, but then the problem is to // know how to use transparency with @@ -186,7 +204,7 @@ void Toolbar::Pimpl::update() fl_set_object_boxtype(p->icon, FL_UP_BOX); } - if (status & LyXFunc::Disabled) { + if (status & func_status::Disabled) { // Is there a way here to specify a // mask in order to show that the // button is disabled? (JMarc) @@ -219,16 +237,17 @@ void Toolbar::Pimpl::updateLayoutList(bool force) LyXTextClass::const_iterator end = tc.end(); for (LyXTextClass::const_iterator cit = tc.begin(); cit != end; ++cit) { - if ((*cit).obsoleted_by().empty()) - combox->addline(_((*cit).name().c_str())); + if (cit->obsoleted_by().empty()) + combox->addline(_(cit->name())); else - combox->addline(("@N" + string(_((*cit).name().c_str()))).c_str()); + combox->addline("@N" + _(cit->name())); } } // we need to do this. combox->Redraw(); } + void Toolbar::Pimpl::clearLayoutList() { if (combox) { @@ -237,47 +256,37 @@ void Toolbar::Pimpl::clearLayoutList() } } + void Toolbar::Pimpl::openLayoutList() { if (combox) combox->Show(); } -static + +namespace { + void ToolbarCB(FL_OBJECT * ob, long ac) { - LyXView * owner = static_cast(ob->u_vdata); + XFormsView * owner = static_cast(ob->u_vdata); - string res = owner->getLyXFunc()->Dispatch(int(ac)); - if(!res.empty()) + string res = owner->getLyXFunc()->dispatch(int(ac)); + if (!res.empty()) lyxerr[Debug::GUI] << "ToolbarCB: Function returned: " << res << endl; } +} // namespace anon + extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data) { ToolbarCB(ob, data); } -#if 0 -// What are we supposed to do with that?? -int Toolbar::get_toolbar_func(string const & func) -{ - int action = lyxaction.LookupFunc(func.c_str()); - if (action == -1) { - if (func == "separator"){ - action = TOOL_SEPARATOR; - } else if (func == "layouts"){ - action = TOOL_LAYOUTS; - } else action = 0; - } - return action; -} -#endif +namespace { -static void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) { string name, arg, xpm_name; kb_action act; @@ -302,12 +311,16 @@ void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) { } if (act == LFUN_INSERT_MATH && !arg.empty()) { - lyxerr[Debug::GUI] << "Using mathed-provided icon" << endl; char const ** pixmap = get_pixmap_from_symbol(arg.c_str(), buttonwidth, height); - fl_set_pixmapbutton_data(obj, const_cast(pixmap)); - return; + if (pixmap) { + lyxerr[Debug::GUI] << "Using mathed-provided icon" + << endl; + fl_set_pixmapbutton_data(obj, + const_cast(pixmap)); + return; + } } lyxerr << "Unable to find icon `" << xpm_name << "'" << endl; @@ -319,6 +332,9 @@ void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) { } } +} // namespace anon + + void Toolbar::Pimpl::set(bool doingmain) { // we shouldn't set if we have not cleaned @@ -341,7 +357,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; @@ -353,7 +369,7 @@ void Toolbar::Pimpl::set(bool doingmain) if (!combox) combox = new Combox(FL_COMBOX_DROPLIST); combox->add(xpos, ypos, 135, height, 400); - combox->setcallback(LayoutsCB); + combox->setcallback(layoutSelectedCB, this); combox->resize(FL_RESIZE_ALL); combox->gravity(NorthWestGravity, NorthWestGravity); xpos += 135; @@ -376,7 +392,7 @@ void Toolbar::Pimpl::set(bool doingmain) // Set the tooltip #if FL_REVISION >= 89 - string help = lyxaction.helpText(item->action); + string const help(_(lyxaction.helpText(item->action))); fl_set_object_helper(obj, help.c_str()); #else fl_set_object_posthandler(obj, C_Toolbar_BubblePost); @@ -497,6 +513,7 @@ void Toolbar::Pimpl::reset() lightReset(); } + void Toolbar::Pimpl::lightReset() { xpos = sxpos - standardspacing; ypos = sypos;