1
// Example program showing passing of slots through an interface.
3
// Copyright Douglas Gregor 2001-2004.
4
// Copyright Frank Mori Hess 2009.
6
// Use, modification and
7
// distribution is subject to the Boost Software License, Version
8
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9
// http://www.boost.org/LICENSE_1_0.txt)
10
// For more information, see http://www.boost.org
13
#include <boost/signals2/signal.hpp>
15
//[ passing_slots_defs_code_snippet
16
// a pretend GUI button
19
typedef boost::signals2::signal<void (int x, int y)> OnClick;
21
typedef OnClick::slot_type OnClickSlotType;
22
// forward slots through Button interface to its private signal
23
boost::signals2::connection doOnClick(const OnClickSlotType & slot);
25
// simulate user clicking on GUI button at coordinates 52, 38
31
boost::signals2::connection Button::doOnClick(const OnClickSlotType & slot)
33
return onClick.connect(slot);
36
void Button::simulateClick()
41
void printCoordinates(long x, long y)
43
std::cout << "(" << x << ", " << y << ")\n";
49
//[ passing_slots_usage_code_snippet
51
button.doOnClick(&printCoordinates);
52
button.simulateClick();