stlab.adobe.com Adobe Systems Incorporated

popup_common.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_POPUP_COMMON_HPP
00010 #define ADOBE_POPUP_COMMON_HPP
00011 
00012 /****************************************************************************************************/
00013 
00014 #include <adobe/future/widgets/headers/platform_popup.hpp>
00015 
00016 #include <adobe/array.hpp>
00017 #include <adobe/name.hpp>
00018 #include <adobe/dictionary.hpp>
00019 #include <adobe/future/assemblage.hpp>
00020 #include <adobe/future/widgets/headers/factory.hpp>
00021 #include <adobe/future/widgets/headers/widget_tokens.hpp>
00022 
00023 /****************************************************************************************************/
00024 
00025 namespace adobe {
00026 
00027 /****************************************************************************************************/
00028 
00029 static popup_t::menu_item_set_t array_to_menu_item_set(const array_t& value)
00030 {
00031     popup_t::menu_item_set_t set;
00032 
00033     for (array_t::const_iterator iter(value.begin()), last(value.end());
00034          iter != last; ++iter)
00035     {
00036         if (iter->type_info() != type_info<dictionary_t>())
00037             continue;
00038 
00039         const dictionary_t&          cur_new_item(iter->cast<dictionary_t>());
00040         dictionary_t::const_iterator name_iter(cur_new_item.find(key_name));
00041         dictionary_t::const_iterator value_iter(cur_new_item.find(key_value));
00042 
00043         if (name_iter == cur_new_item.end() ||
00044             name_iter->second.type_info() != type_info<string_t>() ||
00045             value_iter == cur_new_item.end())
00046             continue;
00047 
00048         set.push_back(popup_t::menu_item_t(name_iter->second.cast<std::string>(), value_iter->second));
00049     }
00050 
00051     return set;
00052 } 
00053 
00054 /****************************************************************************************************/
00055 
00056 struct dynamic_menu_item_set_view_t
00057 {
00058     typedef array_t model_type;
00059 
00060     explicit dynamic_menu_item_set_view_t(popup_t& popup) :
00061         popup_m(popup)
00062     { }
00063 
00064     void display(const model_type& value)
00065     { popup_m.reset_menu_item_set(array_to_menu_item_set(value)); }
00066 
00067     popup_t& popup_m;
00068 };
00069 
00070 /****************************************************************************************************/
00071 
00072 template <typename Sheet>
00073 void attach_popup_menu_item_set(popup_t&           control,
00074                                 name_t             cell,
00075                                 Sheet&             sheet,
00076                                 assemblage_t&      assemblage,
00077                                 eve_client_holder& /*client_holder*/)
00078 {
00079     dynamic_menu_item_set_view_t* tmp = new dynamic_menu_item_set_view_t(control);
00080 
00081     assemblage.cleanup(boost::bind(delete_ptr(), tmp));
00082 
00083     attach_view(assemblage, cell, *tmp, sheet);
00084 }
00085 
00086 /****************************************************************************************************/
00087 
00088 } // namespace adobe
00089 
00090 /****************************************************************************************************/
00091 
00092 // ADOBE_POPUP_COMMON_HPP
00093 #endif
00094 
00095 /****************************************************************************************************/

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