30 MessageWindow::CreateWindow(
"Window 1", 0, 0, 10, 10, handlerChain);
31 MessageWindow::CreateWindow(
"Window 2", 20, 0, 5, 5, handlerChain);
32 MessageWindow::CreateWindow(
"Window 3", 30, 10, 15, 15, handlerChain);
59 std::cout << std::endl;
60 std::cout <<
"HandlerChain Exercise" << std::endl;
67 std::cout <<
" Handler Chain at start:" << std::endl;
68 std::cout << handlerChain->ToString() << std::endl;
72 std::cout <<
" Select Window 2" << std::endl;
75 std::cout <<
" Current handler chain:" << std::endl;
76 std::cout << handlerChain->ToString() << std::endl;
78 std::cout <<
" Select Window 3" << std::endl;
81 std::cout <<
" Current handler chain:" << std::endl;
82 std::cout << handlerChain->ToString() << std::endl;
84 std::cout <<
" Select Window 1" << std::endl;
87 std::cout <<
" Current handler chain:" << std::endl;
88 std::cout << handlerChain->ToString() << std::endl;
90 std::cout <<
" Close Window 2" << std::endl;
93 std::cout <<
" Current handler chain:" << std::endl;
94 std::cout << handlerChain->ToString() << std::endl;
96 std::cout <<
" Done." << std::endl;
Implementation of the HandlerChain class and declaration of the IMessageHandler interface used in the...
static void _HandlerChain_ConstructWindowChain(int windowIds[3])
Helper function to construct a list of windows. Messages will be passed to these windows via the Hand...
Implementation of the Message and MessagePosition structs used in the HandlerChain Pattern.
Declaration of the MessageWindow class and WindowRectangle class used in the HandlerChain Pattern.
Represents a list of handlers that all implement the IMessageHandler interface. This list can be dyna...
std::unique_ptr< HandlerChain > unique_ptr_t
Declaration of the HandlerChain_Exercise() function as used in the HandlerChain Pattern.
The namespace containing all Design Pattern Examples implemented in C++.
void HandlerChain_Exercise()
Example of using the Handle Chain or Chain of Responsibility design pattern.
@ ButtonUp
Take an action on the currently selected window.
@ ButtonDown
Selects a window based on position.
Position of the message in global coordinates (same scope of coordinates as windows)....