stlab.adobe.com Adobe Systems Incorporated

macintosh_focus_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_UI_CORE_FOCUS_HANDLER_HPP
00010 #define ADOBE_UI_CORE_FOCUS_HANDLER_HPP
00011 
00012 /**************************************************************************************************/
00013 
00014 // REVISIT (sparent) : I believe anything in here should be in an implementation namespace.
00015 
00016 #if !defined(ADOBE_NO_DOCUMENTATION)
00017 
00018 /**************************************************************************************************/
00019 
00020 #include <adobe/config.hpp>
00021 #include <adobe/future/macintosh_events.hpp>
00022 #include <adobe/macintosh_carbon_safe.hpp>
00023 
00024 #include <adobe/future/widgets/headers/widget_utils.hpp>
00025 
00026 /**************************************************************************************************/
00027 
00028 namespace adobe {
00029 
00030 /**************************************************************************************************/
00031 
00032 struct focus_handler_t
00033 {
00034     focus_handler_t()
00035     {
00036         event_handler_m.insert(kEventClassControl, kEventControlSetFocusPart);
00037 
00038         event_handler_m.monitor_proc_m = boost::bind(&focus_handler_t::handle_event,
00039                                                      boost::ref(*this), _1, _2);
00040     }
00041 
00042     ::OSStatus handle_event(    ::EventHandlerCallRef   next,
00043                                 ::EventRef              event)
00044     {
00045         ::OSStatus result(::CallNextEventHandler(next, event)); // Handle us last
00046 
00047         if (user_callback_m.empty())
00048             return result;
00049 
00050         ::ControlPartCode part(kControlFocusNoPart);
00051 
00052         get_event_parameter<kEventParamControlPart>(event, part);
00053 
00054         user_callback_m(part != kControlFocusNoPart);
00055 
00056         return result;
00057     }
00058 
00059     boost::function<void (bool)> user_callback_m;
00060     event_handler_t              event_handler_m;
00061 };
00062 
00063 /**************************************************************************************************/
00064 
00065 } // namespace adobe
00066 
00067 /**************************************************************************************************/
00068 
00069 #endif
00070 // !defined(ADOBE_NO_DOCUMENTATION)
00071 
00072 #endif
00073 // ADOBE_UI_CORE_FOCUS_HANDLER_HPP
00074 
00075 /**************************************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google