* \author Lars Gullik Bjønnes
* \author Jean-Marc Lasgouttes
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
// Added pseudo-action handling, asierra 180296
#include <config.h>
-
#include "XFormsToolbar.h"
-#include "debug.h"
+
+#include "Tooltips.h"
+#include "xforms_helpers.h"
#include "XFormsView.h"
-#include "lyxfunc.h"
-#include "FuncStatus.h"
+
#include "buffer.h"
+#include "bufferparams.h"
+#include "debug.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
-#include "Tooltips.h"
+#include "lyxfunc.h"
+
#include "lyx_forms.h"
#include "combox.h"
-#include "xforms_helpers.h"
-
-#include "LyXAction.h"
-
-#include "support/LAssert.h"
-#include "support/filetools.h"
-#include "support/lstrings.h"
using std::endl;
+using std::string;
+
// some constants
const int standardspacing = 2; // the usual space between items
const int height = 30; // the height of all items in the toolbar
XFormsToolbar::toolbarItem::toolbarItem()
- : action(LFUN_NOACTION), icon(0)
+ : icon(0)
{}
// But we don't copy the icon from ti
kill_icon();
- action = ti.action;
+ func = ti.func;
return *this;
}
XFormsToolbar::XFormsToolbar(LyXView * o, int x, int y)
: owner_(static_cast<XFormsView *>(o)), combox_(0), xpos(x), ypos(y)
{
- tooltip_ = new Tooltips();
+ tooltip_ = new Tooltips;
}
ToolbarList::const_iterator p = toollist_.begin();
ToolbarList::const_iterator end = toollist_.end();
for (; p != end; ++p) {
- if (p->action == ToolbarBackend::LAYOUTS && combox_) {
+ if (p->func.action == int(ToolbarBackend::LAYOUTS) && combox_) {
LyXFunc const & lf = owner_->getLyXFunc();
bool const disable =
- lf.getStatus(LFUN_LAYOUT).disabled();
+ lf.getStatus(FuncRequest(LFUN_LAYOUT)).disabled();
setEnabled(combox_, !disable);
continue;
}
if (!p->icon)
continue;
- FuncStatus const status = owner_->getLyXFunc().getStatus(p->action);
+ FuncStatus const status = owner_->getLyXFunc().getStatus(p->func);
if (status.onoff(true)) {
// I'd like to use a different color
// here, but then the problem is to
string const & layoutguiname = getString(combox_);
LyXTextClass const & tc =
- owner_->buffer()->params.getLyXTextClass();
+ owner_->buffer()->params().getLyXTextClass();
LyXTextClass::const_iterator end = tc.end();
for (LyXTextClass::const_iterator cit = tc.begin();
if (!combox_)
return;
- LyXTextClass const & tc = owner_->buffer()->params.getLyXTextClass();
+ LyXTextClass const & tc = owner_->buffer()->params().getLyXTextClass();
string const layoutname = _(tc[layout]->name());
int const nnames = fl_get_combox_maxitems(combox_);
return;
fl_clear_combox(combox_);
- LyXTextClass const & tc = owner_->buffer()->params.getLyXTextClass();
+ LyXTextClass const & tc = owner_->buffer()->params().getLyXTextClass();
LyXTextClass::const_iterator end = tc.end();
for (LyXTextClass::const_iterator cit = tc.begin();
cit != end; ++cit) {
if (!combox_)
return;
+ Toolbar::clearLayoutList();
fl_clear_combox(combox_);
fl_redraw_object(combox_);
}
void ToolbarCB(FL_OBJECT * ob, long ac)
{
- XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata);
+ if (!ob || !ob->u_vdata)
+ return;
- owner->getLyXFunc().dispatch(int(ac), true);
+ XFormsToolbar * ptr = static_cast<XFormsToolbar *>(ob->u_vdata);
+ XFormsView * owner = ptr->owner_;
+ owner->getLyXFunc().dispatch(ptr->funcs[ac], true);
}
if (!toollist_.empty())
return;
+ funcs.clear();
+
ToolbarBackend::item_iterator it = tb.items.begin();
ToolbarBackend::item_iterator end = tb.items.end();
for (; it != end; ++it)
}
-void XFormsToolbar::add(int action, string const & tooltip)
+void XFormsToolbar::add(FuncRequest const & func, string const & tooltip)
{
toolbarItem item;
- item.action = action;
+ item.func = func;
- switch (action) {
+ switch (func.action) {
case ToolbarBackend::SEPARATOR:
xpos += sepspace;
break;
fl_set_object_gravity(obj,
NorthWestGravity,
NorthWestGravity);
- fl_set_object_callback(obj, C_Toolbar_ToolbarCB,
- static_cast<long>(action));
+
+ Funcs::iterator fit = funcs.insert(funcs.end(), func);
+ int const index = std::distance(funcs.begin(), fit);
+ fl_set_object_callback(obj, C_Toolbar_ToolbarCB, index);
// Remove the blue feedback rectangle
fl_set_pixmapbutton_focus_outline(obj, 0);
tooltip_->init(obj, tooltip);
// The view that this object belongs to.
- obj->u_vdata = owner_;
+ obj->u_vdata = this;
- string const xpm = toolbarbackend.getIcon(action);
+ string const xpm = toolbarbackend.getIcon(func);
fl_set_pixmapbutton_file(obj, xpm.c_str());
// we must remember to update the positions