X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FToolbar_pimpl.C;h=5a82a991bc02b660352a6ff4151eeb02f804683d;hb=d719688df38b73e915ea36c8357a3c57376c4ef7;hp=d40dd171b6bca1a4d1fb4086e4ad11703bf961c1;hpb=ec57ed1e96f6ca1b36c094b9a0083351ac313890;p=lyx.git diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index d40dd171b6..5a82a991bc 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 @@ -21,15 +21,18 @@ #include "Toolbar_pimpl.h" #include "debug.h" -#include "LyXView.h" +#include "XFormsView.h" #include "lyxfunc.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; @@ -41,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); @@ -62,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; @@ -80,7 +87,7 @@ Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & 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 @@ -105,16 +112,20 @@ void BubbleTimerCB(FL_OBJECT *, long data) } -extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data) +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, - FL_Coord /*mx*/, FL_Coord /*my*/, - int /*key*/, void * /*xev*/) + FL_Coord /*mx*/, FL_Coord /*my*/, + int /*key*/, void * /*xev*/) { FL_OBJECT * bubble_timer = reinterpret_cast(ob->u_cdata); @@ -133,32 +144,21 @@ int BubblePost(FL_OBJECT *ob, int event, } -extern "C" int C_Toolbar_BubblePost(FL_OBJECT * ob, int event, - FL_Coord /*mx*/, FL_Coord /*my*/, - int key, void * xev) +extern "C" { + +static +int C_Toolbar_BubblePost(FL_OBJECT * ob, int event, + FL_Coord /*mx*/, FL_Coord /*my*/, + int key, void * xev) { return BubblePost(ob, event, 0, 0, key, xev); } -#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); } +#endif +} // namespace anon -void Toolbar::Pimpl::layoutSelected(int sel) -{ - string const tmp = tostr(sel); - owner->getLyXFunc()->Dispatch(LFUN_LAYOUTNO, tmp); -} - void Toolbar::Pimpl::activate() { @@ -183,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 & LyXFunc::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 @@ -202,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 & LyXFunc::Disabled) { + if (status.disabled()) { // Is there a way here to specify a // mask in order to show that the // button is disabled? (JMarc) @@ -216,9 +216,43 @@ void Toolbar::Pimpl::update() } -void Toolbar::Pimpl::setLayout(int layout) { - if (combox) - combox->select(layout+1); +// this one is not "C" because combox callbacks are really C++ %-| +void Toolbar::Pimpl::layoutSelectedCB(int, void * arg, Combox *) +{ + Toolbar::Pimpl * tb = reinterpret_cast(arg); + + tb->layoutSelected(); +} + + +void Toolbar::Pimpl::layoutSelected() +{ + string const & layoutguiname = combox->getline(); + LyXTextClass const & tc = + textclasslist.TextClass(owner->buffer()-> + params.textclass); + + LyXTextClass::const_iterator end = tc.end(); + for (LyXTextClass::const_iterator cit = tc.begin(); + cit != end; ++cit) { + if (_(cit->name()) == layoutguiname) { + owner->getLyXFunc()->dispatch(LFUN_LAYOUT, cit->name()); + return; + } + } + lyxerr << "ERROR (Toolbar::Pimpl::layoutSelected): layout not found!" + << endl; +} + + +void Toolbar::Pimpl::setLayout(int layout) +{ + if (combox) { + LyXTextClass const & tc = + textclasslist.TextClass(owner->buffer()-> + params.textclass); + combox->select(_(tc[layout].name())); + } } @@ -236,14 +270,13 @@ 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())); - else - combox->addline("@N" + _((*cit).name())); + // ignore obsolete entries + if (cit->obsoleted_by().empty()) + combox->addline(_(cit->name())); } } // we need to do this. - combox->Redraw(); + combox->redraw(); } @@ -251,7 +284,7 @@ void Toolbar::Pimpl::clearLayoutList() { if (combox) { combox->clear(); - combox->Redraw(); + combox->redraw(); } } @@ -259,7 +292,7 @@ void Toolbar::Pimpl::clearLayoutList() void Toolbar::Pimpl::openLayoutList() { if (combox) - combox->Show(); + combox->show(); } @@ -267,44 +300,31 @@ 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)); + 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); - if (action == -1) { - if (func == "separator"){ - action = TOOL_SEPARATOR; - } else if (func == "layouts"){ - action = TOOL_LAYOUTS; - } else action = 0; +extern "C" { + + static + void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data) + { + ToolbarCB(ob, data); } - return action; + } -#endif -namespace { - -void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) { - string name, arg, xpm_name; +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)) { @@ -408,7 +428,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); @@ -529,6 +549,7 @@ void Toolbar::Pimpl::reset() lightReset(); } + void Toolbar::Pimpl::lightReset() { xpos = sxpos - standardspacing; ypos = sypos;