#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;
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);
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;
}
-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<FL_OBJECT *>(ob->u_cdata);
}
-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<Toolbar::Pimpl *>(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()
{
}
}
+
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
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)
}
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();
}
}
}
-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<Toolbar::Pimpl *>(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()));
+ }
}
LyXTextClass::const_iterator end = tc.end();
for (LyXTextClass::const_iterator cit = tc.begin();
cit != end; ++cit) {
+ // ignore obsolete entries
if (cit->obsoleted_by().empty())
combox->addline(_(cit->name()));
- else
- combox->addline("@N" + _(cit->name()));
}
}
// we need to do this.
- combox->Redraw();
+ combox->redraw();
}
{
if (combox) {
combox->clear();
- combox->Redraw();
+ combox->redraw();
}
}
void Toolbar::Pimpl::openLayoutList()
{
if (combox)
- combox->Show();
+ combox->show();
}
{
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);
}
-} // namespace anon
-
-extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
-{
- ToolbarCB(ob, data);
+extern "C" {
+
+ static
+ void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
+ {
+ ToolbarCB(ob, data);
+ }
+
}
-namespace {
-
-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");