diff --git a/src/base/bind.h b/src/base/bind.h index e29896b48..45cad5d7d 100644 --- a/src/base/bind.h +++ b/src/base/bind.h @@ -462,7 +462,7 @@ class BindAdapter3_mem X3 x3; public: template - BindAdapter3_mem(void (T::*m)(B1, B2, B3), T2* t, X1 x1, X2 x2) : m(m), t(t), x1(x1), x2(x2) { } + BindAdapter3_mem(void (T::*m)(B1, B2, B3), T2* t, X1 x1, X2 x2, X3 x3) : m(m), t(t), x1(x1), x2(x2), x3(x3) { } void operator()() { (t->*m)(x1, x2, x3); } @@ -483,9 +483,145 @@ template BindAdapter3_mem -Bind(R (T::*m)(B1, B2, B3), T2* t, X1 x1, X2 x2) +Bind(R (T::*m)(B1, B2, B3), T2* t, X1 x1, X2 x2, X3 x3) { - return BindAdapter3_mem(m, t, x1, x2); + return BindAdapter3_mem(m, t, x1, x2, x3); +} + + +// BindAdapter4_fun +template +class BindAdapter4_fun +{ + F f; + X1 x1; + X2 x2; + X3 x3; + X4 x4; +public: + BindAdapter4_fun(const F& f, X1 x1, X2 x2, X3 x3, X4 x4) : f(f), x1(x1), x2(x2), x3(x3), x4(x4) { } + + R operator()() { return f(x1, x2, x3, x4); } + + template + R operator()(const A1& a1) { return f(x1, x2, x3, x4); } + + template + R operator()(const A1& a1, const A2& a2) { return f(x1, x2, x3, x4); } + + template + R operator()(const A1& a1, const A2& a2, const A3& a3) { return f(x1, x2, x3, x4); } + + template + R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return f(x1, x2, x3, x4); } +}; + +template +class BindAdapter4_fun +{ + F f; + X1 x1; + X2 x2; + X3 x3; + X4 x4; +public: + BindAdapter4_fun(const F& f, X1 x1, X2 x2, X3 x3, X4 x4) : f(f), x1(x1), x2(x2), x3(x3), x4(x4) { } + + void operator()() { f(x1, x2, x3, x4); } + + template + void operator()(const A1& a1) { f(x1, x2, x3, x4); } + + template + void operator()(const A1& a1, const A2& a2) { f(x1, x2, x3, x4); } + + template + void operator()(const A1& a1, const A2& a2, const A3& a3) { f(x1, x2, x3, x4); } + + template + void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { f(x1, x2, x3, x4); } +}; + +template +BindAdapter4_fun +Bind(const F& f, X1 x1, X2 x2, X3 x3, X4 x4) +{ + return BindAdapter4_fun(f, x1, x2, x3, x4); +} + +// BindAdapter4_mem +template +class BindAdapter4_mem +{ + R (T::*m)(B1, B2, B3, B4); + T* t; + X1 x1; + X2 x2; + X3 x3; + X4 x4; +public: + template + BindAdapter4_mem(R (T::*m)(B1, B2, B3, B4), T2* t, X1 x1, X2 x2, X3 x3, X4 x4) + : m(m), t(t), x1(x1), x2(x2), x3(x3), x4(x4) { } + + R operator()() { return (t->*m)(x1, x2, x3, x4); } + + template + R operator()(const A1& a1) { return (t->*m)(x1, x2, x3, x4); } + + template + R operator()(const A1& a1, const A2& a2) { return (t->*m)(x1, x2, x3, x4); } + + template + R operator()(const A1& a1, const A2& a2, const A3& a3) { return (t->*m)(x1, x2, x3, x4); } + + template + R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return (t->*m)(x1, x2, x3, x4); } +}; + +template +class BindAdapter4_mem +{ + void (T::*m)(B1, B2, B3, B4); + T* t; + X1 x1; + X2 x2; + X3 x3; + X4 x4; +public: + template + BindAdapter4_mem(void (T::*m)(B1, B2, B3), T2* t, X1 x1, X2 x2, X3 x3, X4 x4) + : m(m), t(t), x1(x1), x2(x2), x3(x3), x4(x4) { } + + void operator()() { (t->*m)(x1, x2, x3, x4); } + + template + void operator()(const A1& a1) { (t->*m)(x1, x2, x3, x4); } + + template + void operator()(const A1& a1, const A2& a2) { (t->*m)(x1, x2, x3, x4); } + + template + void operator()(const A1& a1, const A2& a2, const A3& a3) { (t->*m)(x1, x2, x3, x4); } + + template + void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { (t->*m)(x1, x2, x3, x4); } +}; + +template +BindAdapter4_mem +Bind(R (T::*m)(B1, B2, B3, B4), T2* t, X1 x1, X2 x2, X3 x3, X4 x4) +{ + return BindAdapter4_mem(m, t, x1, x2, x3, x4); } // Helper class to holds references as pointers (to avoid copying the diff --git a/src/ui/entry.cpp b/src/ui/entry.cpp index 872faf41d..131733467 100644 --- a/src/ui/entry.cpp +++ b/src/ui/entry.cpp @@ -10,6 +10,7 @@ #include "ui/entry.h" +#include "base/bind.h" #include "base/string.h" #include "she/font.h" #include "ui/clipboard.h" @@ -24,7 +25,6 @@ #include #include #include -#include namespace ui { @@ -729,9 +729,9 @@ void Entry::showEditPopupMenu(const gfx::Point& pt) menu.addChild(&cut); menu.addChild(©); menu.addChild(&paste); - cut.Click.connect(std::bind(&Entry::executeCmd, this, EntryCmd::Cut, 0, false)); - copy.Click.connect(std::bind(&Entry::executeCmd, this, EntryCmd::Copy, 0, false)); - paste.Click.connect(std::bind(&Entry::executeCmd, this, EntryCmd::Paste, 0, false)); + cut.Click.connect(Bind(&Entry::executeCmd, this, EntryCmd::Cut, 0, false)); + copy.Click.connect(Bind(&Entry::executeCmd, this, EntryCmd::Copy, 0, false)); + paste.Click.connect(Bind(&Entry::executeCmd, this, EntryCmd::Paste, 0, false)); if (isReadOnly()) { cut.setEnabled(false);