X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FToolbar_pimpl.C;h=7c7a58e3bc5b447cf9c310c5280093bff07a7232;hb=14c60d0aaeff364a78f77e163e6eae5fc3dab8c0;hp=993e8f6d5d7a27feb0b8f46c4f47bff24066cc3c;hpb=c64f5752aeed8f2fad086e5163f746a6a6f1e2cd;p=lyx.git diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index 993e8f6d5d..7c7a58e3bc 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -26,14 +26,13 @@ #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 +62,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; @@ -99,7 +98,7 @@ void BubbleTimerCB(FL_OBJECT *, long 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); } @@ -115,18 +114,18 @@ extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data) 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,11 +141,27 @@ extern "C" int C_Toolbar_BubblePost(FL_OBJECT * ob, int event, } #endif +// 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() { ToolbarList::const_iterator p = toollist.begin(); - for (; p != toollist.end(); ++p) { + ToolbarList::const_iterator end = toollist.end(); + for (; p != end; ++p) { if (p->icon) { fl_activate_object(p->icon); } @@ -157,7 +172,8 @@ void Toolbar::Pimpl::activate() void Toolbar::Pimpl::deactivate() { ToolbarList::const_iterator p = toollist.begin(); - for (; p != toollist.end(); ++p) { + ToolbarList::const_iterator end = toollist.end(); + for (; p != end; ++p) { if (p->icon) { fl_deactivate_object(p->icon); } @@ -167,7 +183,8 @@ void Toolbar::Pimpl::deactivate() void Toolbar::Pimpl::update() { ToolbarList::const_iterator p = toollist.begin(); - for (; p != toollist.end(); ++p) { + ToolbarList::const_iterator end = toollist.end(); + for (; p != end; ++p) { if (p->icon) { int status = owner->getLyXFunc()->getStatus(p->action); if (status & LyXFunc::ToggleOn) { @@ -213,18 +230,20 @@ void Toolbar::Pimpl::updateLayoutList(bool force) LyXTextClass const & tc = textclasslist.TextClass(owner->buffer()-> params.textclass); + LyXTextClass::const_iterator end = tc.end(); for (LyXTextClass::const_iterator cit = tc.begin(); - cit != tc.end(); ++cit) { + cit != end; ++cit) { if ((*cit).obsoleted_by().empty()) - combox->addline(_((*cit).name().c_str())); + 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) { @@ -233,19 +252,21 @@ void Toolbar::Pimpl::clearLayoutList() } } + void Toolbar::Pimpl::openLayoutList() { if (combox) combox->Show(); } + static void ToolbarCB(FL_OBJECT * ob, long ac) { LyXView * owner = static_cast(ob->u_vdata); string res = owner->getLyXFunc()->Dispatch(int(ac)); - if(!res.empty()) + if (!res.empty()) lyxerr[Debug::GUI] << "ToolbarCB: Function returned: " << res << endl; } @@ -256,11 +277,12 @@ 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()); + int action = lyxaction.LookupFunc(func); if (action == -1) { if (func == "separator"){ action = TOOL_SEPARATOR; @@ -298,12 +320,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; @@ -335,8 +361,9 @@ void Toolbar::Pimpl::set(bool doingmain) #endif ToolbarList::iterator item = toollist.begin(); - for (; item != toollist.end(); ++item) { - switch(item->action){ + ToolbarList::iterator end = toollist.end(); + for (; item != end; ++item) { + switch (item->action){ case ToolbarDefaults::SEPARATOR: xpos += sepspace; break; @@ -348,7 +375,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; @@ -371,7 +398,7 @@ void Toolbar::Pimpl::set(bool doingmain) // Set the tooltip #if FL_REVISION >= 89 - string help = lyxaction.helpText(item->action); + string help = _(lyxaction.helpText(item->action)); fl_set_object_helper(obj, help.c_str()); #else fl_set_object_posthandler(obj, C_Toolbar_BubblePost); @@ -424,7 +451,8 @@ void Toolbar::Pimpl::add(int action, bool doclean) fl_freeze_form(owner->getForm()); ToolbarList::iterator p = toollist.begin(); - for (; p != toollist.end(); ++p) { + ToolbarList::iterator end = toollist.end(); + for (; p != end; ++p) { p->clean(); }