macintosh_mouse_wheel_handler.hpp
Go to the documentation of this file.
00001 /* 00002 Copyright 2005-2007 Adobe Systems Incorporated 00003 Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt 00004 or a copy at http://stlab.adobe.com/licenses.html) 00005 */ 00006 00007 /****************************************************************************************************/ 00008 00009 #ifndef ADOBE_CARBON_MOUSE_WHEEL_HANDLER_HPP 00010 #define ADOBE_CARBON_MOUSE_WHEEL_HANDLER_HPP 00011 00012 /****************************************************************************************************/ 00013 00014 #include <adobe/config.hpp> 00015 00016 #include <adobe/future/macintosh_events.hpp> 00017 00018 #include <boost/function.hpp> 00019 00020 /****************************************************************************************************/ 00021 00022 namespace adobe { 00023 00024 /*************************************************************************************************/ 00025 00026 typedef boost::function<void (long, bool)> mouse_wheel_handler_proc_t; 00027 00028 /*************************************************************************************************/ 00029 00030 struct mouse_wheel_handler_t 00031 { 00032 mouse_wheel_handler_t() 00033 { 00034 // REVISIT (fbrereto) : When the minimum supported OS is 10.4, we should hook 00035 // kEventClassMouse / kEventMouseScroll instead. 00036 00037 handler_m.insert(kEventClassMouse, kEventMouseWheelMoved); 00038 } 00039 00040 ::OSStatus handle_event(::EventHandlerCallRef /*next*/, 00041 ::EventRef event) 00042 { 00043 if (!callback_m) 00044 return noErr; 00045 00046 ::EventMouseWheelAxis axis; 00047 ::UInt32 modifiers; 00048 ::SInt32 delta; 00049 00050 get_event_parameter<kEventParamMouseWheelAxis>(event, axis); 00051 get_event_parameter<kEventParamMouseWheelDelta>(event, delta); 00052 get_event_parameter<kEventParamKeyModifiers>(event, modifiers); 00053 00054 callback_m(delta, modifiers & optionKey != 0); 00055 00056 return noErr; 00057 } 00058 00059 event_handler_t handler_m; 00060 mouse_wheel_handler_proc_t callback_m; 00061 }; 00062 00063 /****************************************************************************************************/ 00064 00065 } // namespace adobe 00066 00067 /****************************************************************************************************/ 00068 00069 // ADOBE_CARBON_MOUSE_WHEEL_HANDLER_HPP 00070 #endif 00071 00072 /****************************************************************************************************/ |