linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #01847
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2230: dump std::bind in dwt
------------------------------------------------------------
revno: 2230
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-09-02 20:22:51 +0800
message:
dump std::bind in dwt
modified:
dcpp/QueueManager.cpp
dwt/src/Theme.cpp
dwt/src/Widget.cpp
dwt/src/widgets/Control.cpp
dwt/src/widgets/Grid.cpp
dwt/src/widgets/GroupBox.cpp
dwt/src/widgets/Menu.cpp
dwt/src/widgets/ModalDialog.cpp
dwt/src/widgets/Notification.cpp
dwt/src/widgets/StatusBar.cpp
dwt/src/widgets/TabView.cpp
dwt/src/widgets/TextBox.cpp
dwt/src/widgets/ToolBar.cpp
dwt/src/widgets/ToolTip.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/QueueManager.cpp'
--- dcpp/QueueManager.cpp 2010-08-31 13:29:04 +0000
+++ dcpp/QueueManager.cpp 2010-09-02 12:22:51 +0000
@@ -1489,8 +1489,7 @@
// Put this here to avoid very many saves tries when disk is full...
lastSave = GET_TICK();
- ClientManager* cm = ClientManager::getInstance();
- std::for_each(cids.begin(), cids.end(), std::bind(&ClientManager::saveUser, cm, std::placeholders::_1));
+ std::for_each(cids.begin(), cids.end(), [](const CID& cid) { ClientManager::getInstance()->saveUser(cid); });
}
class QueueLoader : public SimpleXMLReader::CallBack {
=== modified file 'dwt/src/Theme.cpp'
--- dwt/src/Theme.cpp 2010-08-10 16:28:19 +0000
+++ dwt/src/Theme.cpp 2010-09-02 12:22:51 +0000
@@ -90,8 +90,9 @@
open(classes);
if(handleThemeChanges) {
+ // @todo Is it safe to assume that classes will still point to a valid string?
w->addCallback(Message(WM_THEMECHANGED),
- Dispatchers::VoidVoid<0, false>(std::bind(&Theme::themeChanged, this, classes)));
+ Dispatchers::VoidVoid<0, false>([this, classes] { themeChanged(classes); }));
}
}
}
=== modified file 'dwt/src/Widget.cpp'
--- dwt/src/Widget.cpp 2010-07-10 14:36:48 +0000
+++ dwt/src/Widget.cpp 2010-09-02 12:22:51 +0000
@@ -150,7 +150,8 @@
}
void Widget::callAsync(const Application::Callback& f) {
- Application::instance().callAsync(std::bind(&checkCall, handle(), f));
+ HWND h = handle();
+ Application::instance().callAsync([h, f] { checkCall(h, f); });
}
bool Widget::handleMessage(const MSG &msg, LRESULT &retVal) {
=== modified file 'dwt/src/widgets/Control.cpp'
--- dwt/src/widgets/Control.cpp 2010-07-10 14:36:48 +0000
+++ dwt/src/widgets/Control.cpp 2010-09-02 12:22:51 +0000
@@ -54,7 +54,7 @@
const size_t id = id_offset + accels.size();
ACCEL a = { static_cast<BYTE>(fVirt | FVIRTKEY), key, static_cast<WORD>(id) };
accels.push_back(a);
- onCommand(std::bind(&Widget::callAsync, this, f), id);
+ onCommand([this,f] { this->callAsync(f); }, id);
}
void Control::initAccels() {
=== modified file 'dwt/src/widgets/Grid.cpp'
--- dwt/src/widgets/Grid.cpp 2010-07-10 14:36:48 +0000
+++ dwt/src/widgets/Grid.cpp 2010-09-02 12:22:51 +0000
@@ -54,7 +54,7 @@
columns[i].align = GridInfo::STRETCH; // Default to stretch for horizontal alignment
}
- onEnabled(std::bind(&Grid::handleEnabled, this, _1));
+ onEnabled([this](bool b) { handleEnabled(b); });
}
Point Grid::getPreferedSize() {
=== modified file 'dwt/src/widgets/GroupBox.cpp'
--- dwt/src/widgets/GroupBox.cpp 2010-08-29 12:43:11 +0000
+++ dwt/src/widgets/GroupBox.cpp 2010-09-02 12:22:51 +0000
@@ -55,7 +55,7 @@
padding.x = ::GetSystemMetrics(SM_CXEDGE) * 2 + cs.padding.x * 2;
padding.y = ::GetSystemMetrics(SM_CYEDGE) + cs.padding.y * 2; // ignore the top border
- onEnabled(std::bind(&GroupBox::handleEnabled, this, _1));
+ onEnabled([this](bool b) { handleEnabled(b); });
}
Point GroupBox::getPreferedSize() {
=== modified file 'dwt/src/widgets/Menu.cpp'
--- dwt/src/widgets/Menu.cpp 2010-08-10 16:28:19 +0000
+++ dwt/src/widgets/Menu.cpp 2010-09-02 12:22:51 +0000
@@ -223,8 +223,8 @@
}
Control* control = static_cast<Control*>(getParent());
- control->onRaw(std::bind(&Menu::handleNCPaint, this, WM_NCPAINT, _1, menuWidth), Message(WM_NCPAINT));
- control->onRaw(std::bind(&Menu::handleNCPaint, this, WM_NCACTIVATE, _1, menuWidth), Message(WM_NCACTIVATE));
+ control->onRaw([this, menuWidth](WPARAM wParam, LPARAM) { return handleNCPaint(WM_NCPAINT, wParam, menuWidth); }, Message(WM_NCPAINT));
+ control->onRaw([this, menuWidth](WPARAM wParam, LPARAM) { return handleNCPaint(WM_NCACTIVATE, wParam, menuWidth); }, Message(WM_NCACTIVATE));
::DrawMenuBar(control->handle());
}
}
@@ -849,7 +849,8 @@
const unsigned index = getCount();
if(f) {
- Dispatcher::F async_f = std::bind(&Widget::callAsync, getParent(), f);
+ Widget *parent = getParent();
+ Dispatcher::F async_f = [this, parent, f] { parent->callAsync(f); };
if(getRootMenu()->popup) {
commands_type& commands_ref = getRootMenu()->commands;
if(!commands_ref.get())
=== modified file 'dwt/src/widgets/ModalDialog.cpp'
--- dwt/src/widgets/ModalDialog.cpp 2010-07-10 14:36:48 +0000
+++ dwt/src/widgets/ModalDialog.cpp 2010-09-02 12:22:51 +0000
@@ -47,9 +47,9 @@
quit(false),
ret(0)
{
- onClosing(std::bind(&ThisType::defaultClosing, this));
+ onClosing([this] { return this->ThisType::defaultClosing(); });
- filterIter = dwt::Application::instance().addFilter(std::bind(&ThisType::filter, this, _1));
+ filterIter = dwt::Application::instance().addFilter([this](MSG& msg) { return this->ThisType::filter(msg); });
}
ModalDialog::~ModalDialog() {
=== modified file 'dwt/src/widgets/Notification.cpp'
--- dwt/src/widgets/Notification.cpp 2010-07-10 14:36:48 +0000
+++ dwt/src/widgets/Notification.cpp 2010-09-02 12:22:51 +0000
@@ -47,8 +47,8 @@
tip = seed.tip;
// TODO Allow more than one icon per window
- parent->setCallback(Message(message), std::bind(&Notification::trayHandler, this, _1));
- parent->setCallback(Message(taskbar), std::bind(&Notification::redisplay, this));
+ parent->setCallback(Message(message), [this](const MSG& msg, LRESULT&) { return trayHandler(msg); });
+ parent->setCallback(Message(taskbar), [this](const MSG&, LRESULT&) { return redisplay(); });
}
void Notification::setIcon(const IconPtr& icon_) {
=== modified file 'dwt/src/widgets/StatusBar.cpp'
--- dwt/src/widgets/StatusBar.cpp 2010-07-10 14:36:48 +0000
+++ dwt/src/widgets/StatusBar.cpp 2010-09-02 12:22:51 +0000
@@ -69,10 +69,10 @@
setFont(cs.font);
tip = WidgetCreator<ToolTip>::create(this, ToolTip::Seed());
- tip->setTool(this, std::bind(&StatusBar::handleToolTip, this, _1));
+ tip->setTool(this, [this](tstring& text) { handleToolTip(text); });
- ClickType::onClicked(std::bind(&StatusBar::handleClicked, this));
- DblClickType::onDblClicked(std::bind(&StatusBar::handleDblClicked, this));
+ ClickType::onClicked([this] { handleClicked(); });
+ DblClickType::onDblClicked([this] { handleDblClicked(); });
}
void StatusBar::setSize(unsigned part, unsigned size) {
=== modified file 'dwt/src/widgets/TabView.cpp'
--- dwt/src/widgets/TabView.cpp 2010-08-11 16:48:27 +0000
+++ dwt/src/widgets/TabView.cpp 2010-09-02 12:22:51 +0000
@@ -75,8 +75,8 @@
void TabView::create(const Seed & cs) {
if(cs.ctrlTab) {
- addAccel(FCONTROL, VK_TAB, std::bind(&TabView::handleCtrlTab, this, false));
- addAccel(FCONTROL | FSHIFT, VK_TAB, std::bind(&TabView::handleCtrlTab, this, true));
+ addAccel(FCONTROL, VK_TAB, [this] { handleCtrlTab(false); });
+ addAccel(FCONTROL | FSHIFT, VK_TAB, [this] { handleCtrlTab(true); });
}
BaseType::create(cs);
@@ -112,11 +112,11 @@
if(!(cs.style & TCS_BUTTONS)) {
// we don't want pre-drawn borders to get in the way here, so we fully take over painting.
- onPainting(std::bind((void (TabView::*)(PaintCanvas&))(&TabView::handlePainting), this, _1));
+ onPainting([this](PaintCanvas& pc) { handlePainting(pc); });
}
// TCS_HOTTRACK seems to have no effect in owner-drawn tabs, so do the tracking ourselves.
- onMouseMove(std::bind(&TabView::handleMouseMove, this, _1));
+ onMouseMove([this](const MouseEvent& me) { return handleMouseMove(me); });
} else {
if(widthConfig <= 3)
@@ -129,17 +129,17 @@
TabCtrl_SetImageList(handle(), imageList->handle());
- onSelectionChanged(std::bind(&TabView::handleTabSelected, this));
- onLeftMouseDown(std::bind(&TabView::handleLeftMouseDown, this, _1));
- onLeftMouseUp(std::bind(&TabView::handleLeftMouseUp, this, _1));
- onContextMenu(std::bind(&TabView::handleContextMenu, this, _1));
- onMiddleMouseDown(std::bind(&TabView::handleMiddleMouseDown, this, _1));
- onXMouseUp(std::bind(&TabView::handleXMouseUp, this, _1));
+ onSelectionChanged([this] { handleTabSelected(); });
+ onLeftMouseDown([this](const MouseEvent& me) { return handleLeftMouseDown(me); });
+ onLeftMouseUp([this](const MouseEvent& me) { return handleLeftMouseUp(me); });
+ onContextMenu([this](const ScreenCoordinate& sc) { return handleContextMenu(sc); });
+ onMiddleMouseDown([this](const MouseEvent& me) { return handleMiddleMouseDown(me); });
+ onXMouseUp([this](const MouseEvent& me) { return handleXMouseUp(me); });
if(cs.style & TCS_TOOLTIPS) {
tip = WidgetCreator<ToolTip>::attach(this, TabCtrl_GetToolTips(handle())); // created and managed by the tab control thanks to the TCS_TOOLTIPS style
tip->addRemoveStyle(TTS_NOPREFIX, true);
- tip->onRaw(std::bind(&TabView::handleToolTip, this, _2), Message(WM_NOTIFY, TTN_GETDISPINFO));
+ tip->onRaw([this](WPARAM, LPARAM lParam) { return handleToolTip(lParam); }, Message(WM_NOTIFY, TTN_GETDISPINFO));
}
}
@@ -181,7 +181,7 @@
layout();
- w->onTextChanging(std::bind(&TabView::handleTextChanging, this, w, _1));
+ w->onTextChanging([this, w](const tstring& t) { handleTextChanging(w, t); });
}
ContainerPtr TabView::getActive() const {
@@ -588,7 +588,7 @@
if(i != -1 && i != highlighted) {
redraw(i);
highlighted = i;
- onMouseLeave(std::bind(&TabView::handleMouseLeave, this));
+ onMouseLeave([this]() { handleMouseLeave(); });
}
if(i != -1 && i == active) {
if(highlightClose ^ inCloseRect(mouseEvent.pos)) {
=== modified file 'dwt/src/widgets/TextBox.cpp'
--- dwt/src/widgets/TextBox.cpp 2010-07-10 14:36:48 +0000
+++ dwt/src/widgets/TextBox.cpp 2010-09-02 12:22:51 +0000
@@ -77,7 +77,7 @@
// multiline text-boxes don't handle ctrl + A so we have do it ourselves...
if((cs.style & ES_MULTILINE) == ES_MULTILINE)
- onKeyDown(std::bind(&TextBox::handleKeyDown, this, _1));
+ onKeyDown([this](bool c) { return handleKeyDown(c); });
}
void TextBox::setText(const tstring& txt) {
@@ -177,32 +177,27 @@
return ret;
}
-// wrapper because sendMessage returns a value
-static inline void sendMessage_(TextBoxBase* box, UINT message) {
- box->sendMessage(message);
-}
-
void TextBoxBase::addCommands(MenuPtr menu) {
const bool writable = !hasStyle(ES_READONLY);
const bool text = !getText().empty();
const bool selection = !getSelection().empty();
if(writable) {
- menu->appendItem(Texts::get(Texts::undo), std::bind(&sendMessage_, this, WM_UNDO),
+ menu->appendItem(Texts::get(Texts::undo), [this] { this->sendMessage(WM_UNDO); },
IconPtr(), sendMessage(EM_CANUNDO));
menu->appendSeparator();
- menu->appendItem(Texts::get(Texts::cut), std::bind(&sendMessage_, this, WM_CUT),
+ menu->appendItem(Texts::get(Texts::cut), [this] { this->sendMessage(WM_CUT); },
IconPtr(), selection);
}
- menu->appendItem(Texts::get(Texts::copy), std::bind(&sendMessage_, this, WM_COPY),
+ menu->appendItem(Texts::get(Texts::copy), [this] { this->sendMessage(WM_COPY); },
IconPtr(), selection);
if(writable) {
- menu->appendItem(Texts::get(Texts::paste), std::bind(&sendMessage_, this, WM_PASTE));
- menu->appendItem(Texts::get(Texts::del), std::bind(&sendMessage_, this, WM_CLEAR),
+ menu->appendItem(Texts::get(Texts::paste), [this] { this->sendMessage(WM_PASTE); });
+ menu->appendItem(Texts::get(Texts::del), [this] { this->sendMessage(WM_CLEAR); },
IconPtr(), selection);
}
menu->appendSeparator();
- menu->appendItem(Texts::get(Texts::selAll), std::bind(&TextBoxBase::setSelection, this, 0, -1),
+ menu->appendItem(Texts::get(Texts::selAll), [this] { this->setSelection(0, -1);},
IconPtr(), text);
}
=== modified file 'dwt/src/widgets/ToolBar.cpp'
--- dwt/src/widgets/ToolBar.cpp 2010-07-10 14:36:48 +0000
+++ dwt/src/widgets/ToolBar.cpp 2010-09-02 12:22:51 +0000
@@ -59,20 +59,20 @@
//// Telling the toolbar what the size of the TBBUTTON struct is
sendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON));
- onRaw(std::bind(&ToolBar::handleDropDown, this, _2), Message(WM_NOTIFY, TBN_DROPDOWN));
- onRaw(std::bind(&ToolBar::handleToolTip, this, _2), Message(WM_NOTIFY, TBN_GETINFOTIP));
+ onRaw([this](WPARAM, LPARAM lParam) { return handleDropDown(lParam); }, Message(WM_NOTIFY, TBN_DROPDOWN));
+ onRaw([this](WPARAM, LPARAM lParam) { return handleToolTip(lParam); }, Message(WM_NOTIFY, TBN_GETINFOTIP));
if((cs.style & CCS_ADJUSTABLE) == CCS_ADJUSTABLE) {
// customization-related messages
- onRaw(std::bind(&ToolBar::handleBeginAdjust, this), Message(WM_NOTIFY, TBN_BEGINADJUST));
- onRaw(std::bind(&ToolBar::handleChange, this), Message(WM_NOTIFY, TBN_TOOLBARCHANGE));
- onRaw(std::bind(&ToolBar::handleCustHelp, this), Message(WM_NOTIFY, TBN_CUSTHELP));
- onRaw(std::bind(&ToolBar::handleEndAdjust, this), Message(WM_NOTIFY, TBN_ENDADJUST));
- onRaw(std::bind(&ToolBar::handleGetButtonInfo, this, _2), Message(WM_NOTIFY, TBN_GETBUTTONINFO));
- onRaw(std::bind(&ToolBar::handleInitCustomize, this), Message(WM_NOTIFY, TBN_INITCUSTOMIZE));
- onRaw(std::bind(&ToolBar::handleQuery, this), Message(WM_NOTIFY, TBN_QUERYINSERT));
- onRaw(std::bind(&ToolBar::handleQuery, this), Message(WM_NOTIFY, TBN_QUERYDELETE));
- onRaw(std::bind(&ToolBar::handleReset, this), Message(WM_NOTIFY, TBN_RESET));
+ onRaw([this](WPARAM, LPARAM) { return handleBeginAdjust(); }, Message(WM_NOTIFY, TBN_BEGINADJUST));
+ onRaw([this](WPARAM, LPARAM) { return handleChange(); }, Message(WM_NOTIFY, TBN_TOOLBARCHANGE));
+ onRaw([this](WPARAM, LPARAM) { return handleCustHelp(); }, Message(WM_NOTIFY, TBN_CUSTHELP));
+ onRaw([this](WPARAM, LPARAM) { return handleEndAdjust(); }, Message(WM_NOTIFY, TBN_ENDADJUST));
+ onRaw([this](WPARAM, LPARAM lParam) { return handleGetButtonInfo(lParam); }, Message(WM_NOTIFY, TBN_GETBUTTONINFO));
+ onRaw([this](WPARAM, LPARAM) { return handleInitCustomize(); }, Message(WM_NOTIFY, TBN_INITCUSTOMIZE));
+ onRaw([this](WPARAM, LPARAM) { return handleQuery(); }, Message(WM_NOTIFY, TBN_QUERYINSERT));
+ onRaw([this](WPARAM, LPARAM) { return handleQuery(); }, Message(WM_NOTIFY, TBN_QUERYDELETE));
+ onRaw([this](WPARAM, LPARAM) { return handleReset(); }, Message(WM_NOTIFY, TBN_RESET));
}
}
=== modified file 'dwt/src/widgets/ToolTip.cpp'
--- dwt/src/widgets/ToolTip.cpp 2010-07-10 15:49:05 +0000
+++ dwt/src/widgets/ToolTip.cpp 2010-09-02 12:22:51 +0000
@@ -57,7 +57,7 @@
void ToolTip::setText(Widget* widget, const tstring& text_) {
text = text_;
- setTool(widget, std::bind(&ToolTip::handleGetTip, this, _1));
+ setTool(widget, [this](tstring& t) { handleGetTip(t); });
}
void ToolTip::setTool(Widget* widget, const Dispatcher::F& f) {