2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 // 2011 Free Software Foundation, Inc
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "HostInterface.h"
21 #include <boost/variant.hpp>
22 #include <boost/any.hpp>
30 struct MessageOutput
: public boost::static_visitor
<std::ostream
&>
32 MessageOutput(std::ostream
& os
) : _os(os
) {}
33 std::ostream
& operator()(const HostMessage
& e
) const {
34 return _os
<< e
.event();
36 std::ostream
& operator()(const CustomMessage
& e
) const {
37 return _os
<< e
.name();
46 operator<<(std::ostream
& os
, const HostInterface::Message
& e
)
48 return boost::apply_visitor(MessageOutput(os
), e
);
52 operator<<(std::ostream
& os
, HostMessage::KnownEvent e
)
55 Wrapper(std::ostream
& os
) : _os(os
<< "<") {}
56 ~Wrapper() { _os
<< ">"; }
61 case HostMessage::SHOW_MOUSE
:
62 return os
<< "show mouse";
63 case HostMessage::RESIZE_STAGE
:
64 return os
<< "resize stage";
65 case HostMessage::SHOW_MENU
:
66 return os
<< "show menu";
67 case HostMessage::UPDATE_STAGE
:
68 return os
<< "update stage";
69 case HostMessage::SET_DISPLAYSTATE
:
70 return os
<< "set display state";
71 case HostMessage::SET_CLIPBOARD
:
72 return os
<< "set clipboard";
73 case HostMessage::SCREEN_RESOLUTION
:
74 return os
<< "screen resolution";
75 case HostMessage::SCREEN_DPI
:
76 return os
<< "screen DPI";
77 case HostMessage::PIXEL_ASPECT_RATIO
:
78 return os
<< "pixel aspect ratio";
79 case HostMessage::PLAYER_TYPE
:
80 return os
<< "player type";
81 case HostMessage::SCREEN_COLOR
:
82 return os
<< "screen color";
83 case HostMessage::EXTERNALINTERFACE_ISPLAYING
:
84 return os
<< "ExternalInterface.isPlaying";
85 case HostMessage::EXTERNALINTERFACE_PAN
:
86 return os
<< "ExternalInterface.pan";
87 case HostMessage::EXTERNALINTERFACE_PLAY
:
88 return os
<< "ExternalInterface.play";
89 case HostMessage::EXTERNALINTERFACE_REWIND
:
90 return os
<< "ExternalInterface.rewind";
91 case HostMessage::EXTERNALINTERFACE_SETZOOMRECT
:
92 return os
<< "ExternalInterface.setZoomRect";
93 case HostMessage::EXTERNALINTERFACE_STOPPLAY
:
94 return os
<< "ExternalInterface.stopPlay";
95 case HostMessage::EXTERNALINTERFACE_ZOOM
:
96 return os
<< "ExternalInterface.zoom";
98 return os
<< "Unknown event " << +e
;