platform_toggle.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_TOGGLE_HPP 00010 #define ADOBE_WIDGET_TOGGLE_HPP 00011 00012 /****************************************************************************************************/ 00013 00014 #include <adobe/config.hpp> 00015 00016 #include <adobe/macintosh_carbon_safe.hpp> 00017 #include <adobe/future/macintosh_events.hpp> 00018 #include <adobe/future/widgets/headers/macintosh_metric_extractor.hpp> 00019 #include <adobe/future/widgets/headers/button_helper.hpp> 00020 #include <adobe/future/widgets/headers/widget_utils.hpp> 00021 #include <adobe/keyboard.hpp> 00022 00023 #include <boost/gil/gil_all.hpp> 00024 00025 /****************************************************************************************************/ 00026 00027 namespace adobe { 00028 00029 /****************************************************************************************************/ 00030 #ifndef ADOBE_NO_DOCUMENTATION 00031 struct toggle_t; 00032 00033 /****************************************************************************************************/ 00034 00035 struct toggle_hit_handler_t 00036 { 00037 explicit toggle_hit_handler_t(toggle_t* toggle) : 00038 toggle_m(toggle) 00039 { 00040 handler_m.insert(kEventClassControl, kEventControlHit); 00041 00042 handler_m.monitor_proc_m = boost::bind(&toggle_hit_handler_t::handle_event, 00043 boost::ref(*this), _1, _2); 00044 } 00045 00046 ::OSStatus handle_event(::EventHandlerCallRef next, 00047 ::EventRef event); 00048 00049 event_handler_t handler_m; 00050 toggle_t* toggle_m; 00051 }; 00052 00053 #endif 00054 /****************************************************************************************************/ 00055 00067 struct toggle_t 00068 { 00070 typedef any_regular_t model_type; 00071 00073 typedef boost::function<void (const model_type&)> setter_type; 00074 00076 typedef boost::gil::rgba8_image_t image_type; 00077 00081 toggle_t(const std::string& alt_text, 00082 const any_regular_t value_on, 00083 const image_type& image_on, 00084 const image_type& image_off, 00085 const image_type& image_disabled, 00086 theme_t theme); 00087 00094 void measure(extents_t& result); 00095 00096 void place(const place_data_t& place_data); 00098 00105 void monitor(const setter_type& proc); 00106 00107 void enable(bool make_enabled); 00109 00124 void display(const any_regular_t& to_value); 00126 00127 #ifndef ADOBE_NO_DOCUMENTATION 00128 ::ControlRef control_m; 00129 theme_t theme_m; 00130 mutable metric_extractor_t metrics_m; 00131 toggle_hit_handler_t hit_handler_m; 00132 std::string alt_text_m; 00133 image_type image_on_m; 00134 image_type image_off_m; 00135 image_type image_disabled_m; 00136 setter_type setter_proc_m; 00137 any_regular_t value_on_m; 00138 any_regular_t last_m; 00139 #endif 00140 }; 00141 00142 /****************************************************************************************************/ 00143 00144 } // namespace adobe 00145 00146 /****************************************************************************************************/ 00147 00148 #endif 00149 00150 /****************************************************************************************************/ |