platform_button.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_WIDGET_BUTTON_HPP 00010 #define ADOBE_WIDGET_BUTTON_HPP 00011 00012 /****************************************************************************************************/ 00013 00014 #include <adobe/config.hpp> 00015 00016 #include <adobe/future/macintosh_events.hpp> 00017 #include <adobe/future/widgets/headers/macintosh_metric_extractor.hpp> 00018 #include <adobe/future/widgets/headers/button_helper.hpp> 00019 #include <adobe/future/widgets/headers/widget_utils.hpp> 00020 #include <adobe/keyboard.hpp> 00021 #include <adobe/macintosh_carbon_safe.hpp> 00022 00023 /****************************************************************************************************/ 00024 00025 namespace adobe { 00026 00027 /****************************************************************************************************/ 00028 #ifndef ADOBE_NO_DOCUMENTATION 00029 struct button_t; 00030 00031 /****************************************************************************************************/ 00032 00033 struct button_hit_handler_t 00034 { 00035 explicit button_hit_handler_t(button_t* button) : 00036 button_m(button) 00037 { 00038 handler_m.insert(kEventClassControl, kEventControlHit); 00039 00040 handler_m.monitor_proc_m = boost::bind(&button_hit_handler_t::handle_event, 00041 boost::ref(*this), _1, _2); 00042 } 00043 00044 ::OSStatus handle_event(::EventHandlerCallRef next, 00045 ::EventRef event); 00046 00047 event_handler_t handler_m; 00048 button_t* button_m; 00049 }; 00050 00051 /****************************************************************************************************/ 00052 00053 struct button_modifier_key_handler_t 00054 { 00055 explicit button_modifier_key_handler_t(button_t* button) : 00056 button_m(button) 00057 { 00058 handler_m.insert(kEventClassKeyboard, kEventRawKeyModifiersChanged); 00059 00060 handler_m.monitor_proc_m = boost::bind(&button_modifier_key_handler_t::handle_event, 00061 boost::ref(*this), _1, _2); 00062 } 00063 00064 ::OSStatus handle_event(::EventHandlerCallRef next, 00065 ::EventRef event); 00066 00067 event_handler_t handler_m; 00068 button_t* button_m; 00069 }; 00070 #endif 00071 /****************************************************************************************************/ 00072 00092 struct button_t 00093 { 00095 typedef any_regular_t model_type; 00096 00117 button_t(bool is_default, 00118 bool is_cancel, 00119 modifiers_t modifier_mask, 00120 const button_state_descriptor_t* first, 00121 const button_state_descriptor_t* last, 00122 theme_t theme); 00123 00130 void measure(extents_t& result); 00131 00132 void place(const place_data_t& place_data); 00134 00144 void enable(bool make_enabled); 00146 00151 void set(modifiers_t modifiers, const model_type& value); 00152 00157 void set_contributing(modifiers_t modifiers, const dictionary_t& value); 00158 00167 any_regular_t underlying_handler() { return any_regular_t(control_m); } 00168 00176 bool handle_key(key_type key, bool pressed, modifiers_t modifiers); 00178 00179 #ifndef ADOBE_NO_DOCUMENTATION 00180 ::ControlRef control_m; 00181 theme_t theme_m; 00182 mutable metric_extractor_t metrics_m; 00183 button_state_set_t state_set_m; 00184 button_hit_handler_t hit_handler_m; 00185 button_modifier_key_handler_t mod_key_handler_m; 00186 modifiers_t modifier_mask_m; 00187 bool is_default_m; 00188 bool is_cancel_m; 00189 bool enabled_m; 00190 #endif 00191 }; 00192 00193 /****************************************************************************************************/ 00194 00195 } // namespace adobe 00196 00197 /****************************************************************************************************/ 00198 00199 #endif 00200 00201 /****************************************************************************************************/ |