stlab.adobe.com Adobe Systems Incorporated

platform_popup.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_POPUP_HPP
00010 #define ADOBE_WIDGET_POPUP_HPP
00011 
00012 /****************************************************************************************************/
00013 
00014 #include <adobe/config.hpp>
00015 
00016 #include <boost/smart_ptr.hpp>
00017 #include <boost/static_assert.hpp>
00018 #include <boost/type_traits.hpp>
00019 
00020 #include <adobe/array.hpp>
00021 #include <adobe/dictionary.hpp>
00022 #include <adobe/extents.hpp>
00023 #include <adobe/future/debounce.hpp>
00024 #include <adobe/future/macintosh_events.hpp>
00025 #include <adobe/future/widgets/headers/macintosh_metric_extractor.hpp>
00026 #include <adobe/future/widgets/headers/popup_common_fwd.hpp>
00027 #include <adobe/future/widgets/headers/widget_factory.hpp>
00028 #include <adobe/future/widgets/headers/widget_utils.hpp>
00029 #include <adobe/macintosh_carbon_safe.hpp>
00030 #include <adobe/memory.hpp>
00031 
00032 /****************************************************************************************************/
00033 
00034 namespace adobe {
00035 
00036 /****************************************************************************************************/
00037 #ifndef ADOBE_NO_DOCUMENTATION
00038 struct sheet_t;
00039 struct assemblage_t;
00040 
00041 struct popup_t;
00042 
00043 /****************************************************************************************************/
00044 
00045 struct popup_value_handler_t
00046 {
00047     explicit popup_value_handler_t(popup_t& widget) :
00048         widget_m(widget)
00049     {
00050         handler_m.insert(kEventClassControl, kEventControlValueFieldChanged);
00051 
00052         handler_m.monitor_proc_m = boost::bind(&popup_value_handler_t::handle_event,
00053                                                boost::ref(*this), _1, _2);
00054     }
00055 
00056     ::OSStatus handle_event(    ::EventHandlerCallRef   next,
00057                                 ::EventRef              event);
00058 
00059     event_handler_t            handler_m;
00060     popup_setter_type          setter_m;
00061     popup_extended_setter_type extended_setter_m;
00062     popup_t&                   widget_m;
00063 };
00064 
00065 /****************************************************************************************************/
00066 
00067 struct popup_key_handler_t
00068 {
00069     popup_key_handler_t()
00070     {
00071         handler_m.insert(kEventClassTextInput, kEventTextInputUnicodeForKeyEvent);
00072 
00073         handler_m.monitor_proc_m = boost::bind(&popup_key_handler_t::handle_event,
00074                                                boost::ref(*this), _1, _2);
00075     }
00076 
00077     ::OSStatus handle_event(::EventHandlerCallRef next,
00078                             ::EventRef            event);
00079 
00080     event_handler_t handler_m;
00081     popup_t*        popup_m;
00082 };
00083 #endif
00084 /****************************************************************************************************/
00085 
00098 struct popup_t
00099 {
00101     typedef any_regular_t model_type;
00102 
00104     typedef popup_setter_type          setter_type;
00105     typedef popup_extended_setter_type extended_setter_type;
00106 
00107 #ifndef ADOBE_NO_DOCUMENTATION
00108     typedef std::pair<std::string, any_regular_t> menu_item_t;
00109     typedef std::vector<menu_item_t> menu_item_set_t;
00110 #endif
00111 
00120     popup_t(const std::string& name,
00121             const std::string& alt_text,
00122             const std::string& custom_item_name,
00123             const menu_item_t* first,
00124             const menu_item_t* last,
00125             theme_t            theme);
00126 
00133     void reset_menu_item_set(const menu_item_t* first, const menu_item_t* last);
00134 
00138     inline void reset_menu_item_set(const menu_item_set_t& menu_item_set)
00139     {
00140         const menu_item_t* first(menu_item_set.empty() ? 0 : &menu_item_set[0]);
00141         std::size_t        n(menu_item_set.size());
00142 
00143         reset_menu_item_set(first, first + n);
00144     }
00145 
00151     void select_with_text(const std::string& text);
00152 
00159     void measure(extents_t& result);
00160 
00161     void place(const place_data_t& place_data);
00163 
00170     void display(const any_regular_t& value);
00172 
00179     void monitor(const setter_type& proc);
00180 
00181     void enable(bool make_enabled);
00183 
00184     void monitor_extended(const extended_setter_type& extended_proc);
00185 
00186 #ifndef ADOBE_NO_DOCUMENTATION
00187     ::ControlRef               control_m;
00188     theme_t                    theme_m;
00189     mutable metric_extractor_t metrics_m;
00190     std::string                name_m;
00191     std::string                alt_text_m;
00192     bool                       static_disabled_m;
00193     bool                       using_label_m;
00194     long                       label_width_m;
00195     menu_item_set_t            menu_items_m;
00196     popup_value_handler_t      value_handler_m;
00197     popup_key_handler_t        key_handler_m;
00198     bool                       type_2_debounce_m;
00199     any_regular_t              last_m;
00200     bool                       custom_m;
00201     std::string                custom_item_name_m;
00202 
00203 private:
00204     void display_custom();
00205 #endif
00206 };
00207 
00208 /****************************************************************************************************/
00209 
00210 namespace view_implementation {
00211 
00212 /****************************************************************************************************/
00213 #ifndef ADOBE_NO_DOCUMENTATION
00214 inline void set_value_from_model(popup_t& value, const any_regular_t& new_value)
00215 { value.display(new_value); }
00216 #endif
00217 /****************************************************************************************************/
00218 
00219 } // namespace view_implementation
00220 
00221 /****************************************************************************************************/
00222 #ifndef ADOBE_NO_DOCUMENTATION
00223 inline bool operator== (const popup_t& x, const popup_t& y)
00224 { return &x == &y; }
00225 #endif
00226 /****************************************************************************************************/
00227 
00228 } // namespace adobe
00229 
00230 /****************************************************************************************************/
00231 
00232 #endif
00233 
00234 /****************************************************************************************************/

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