|
From: Foster B. <fos...@us...> - 2006-02-27 20:42:12
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8667/adobe/future/source Modified Files: modal_dialog_interface.cpp Added Files: alert.cpp Log Message: image_t (icons and pictures) support for Mac and Win32, along with a GIL image factory and a (sample) Targa file format importing module for that factory. Also added alert.adm/eve as a sample for the icon support. Added the notion of a working directory to the modal dialog interface to reference external resources. Also added an alert API that leverages modal_dialog_interface. Other misc. bug fixes and changes. Index: modal_dialog_interface.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/source/modal_dialog_interface.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** modal_dialog_interface.cpp 3 Feb 2006 18:33:36 -0000 1.2 --- modal_dialog_interface.cpp 27 Feb 2006 20:41:58 -0000 1.3 *************** *** 9,14 **** --- 9,17 ---- #include <adobe/future/modal_dialog_interface.hpp> + #include <adobe/config.hpp> #include <adobe/adam_evaluate.hpp> #include <adobe/adam_parser.hpp> + #include <adobe/xstring.hpp> + #include <adobe/future/widgets/headers/client_assembler.hpp> #include <adobe/future/widgets/headers/factory.hpp> *************** *** 83,92 **** typedef adobe::auto_ptr<eve_client::eve_client_holder> auto_view_t; ! adobe::dialog_result_t handle_dialog( const adobe::dictionary_t& input, ! const adobe::record_info_t& record, ! const adobe::dictionary_t& display_state, ! adobe::display_options_t display_options, ! std::istream& layout_definition, ! std::istream& sheet_definition); void end_dialog(adobe::name_t terminating_action); --- 86,97 ---- typedef adobe::auto_ptr<eve_client::eve_client_holder> auto_view_t; ! adobe::dialog_result_t handle_dialog( const adobe::dictionary_t& input, ! const adobe::record_info_t& record, ! const adobe::dictionary_t& display_state, ! adobe::display_options_t display_options, ! std::istream& layout_definition, ! std::istream& sheet_definition, ! adobe::action_callback_t callback, ! const boost::filesystem::path& working_directory); void end_dialog(adobe::name_t terminating_action); *************** *** 98,116 **** void monitor_invariant(bool valid); ! adobe::sheet_t sheet_m; ! auto_view_t view_m; ! bool need_ui_m; ! adobe::dialog_result_t result_m; }; /****************************************************************************************************/ ! adobe::dialog_result_t mdi_implementation_t::handle_dialog( const adobe::dictionary_t& input, ! const adobe::record_info_t& record, ! const adobe::dictionary_t& display_state, ! adobe::display_options_t display_options, ! std::istream& layout_definition, ! std::istream& sheet_definition) { result_m = adobe::dialog_result_t(); --- 103,126 ---- void monitor_invariant(bool valid); ! adobe::sheet_t sheet_m; ! auto_view_t view_m; ! bool need_ui_m; ! adobe::dialog_result_t result_m; ! adobe::action_callback_t callback_m; }; /****************************************************************************************************/ ! adobe::dialog_result_t mdi_implementation_t::handle_dialog( const adobe::dictionary_t& input, ! const adobe::record_info_t& record, ! const adobe::dictionary_t& display_state, ! adobe::display_options_t display_options, ! std::istream& layout_definition, ! std::istream& sheet_definition, ! adobe::action_callback_t callback, ! const boost::filesystem::path& working_directory) { + callback_m = callback; + result_m = adobe::dialog_result_t(); *************** *** 171,175 **** boost::bind(&mdi_implementation_t::latch_callback, boost::ref(*this), _1, _2), size_normal_s, ! default_factory ).release() ); // --- 181,186 ---- boost::bind(&mdi_implementation_t::latch_callback, boost::ref(*this), _1, _2), size_normal_s, ! default_factory, ! working_directory ).release() ); // *************** *** 254,296 **** /****************************************************************************************************/ ! void mdi_implementation_t::latch_callback(adobe::name_t action, const adobe::value_t&) try { assert(view_m); ! static const adobe::static_name_t reset_s ("reset"); ! static const adobe::static_name_t cancel_s ("cancel"); ! static const adobe::static_name_t dialog_s ("dialog"); ! static const adobe::static_name_t ok_s ("ok"); ! ! if (action == reset_s) ! { ! /* ! REVISIT (sparent) : Getting the contributing from a zero mark should always return an ! empty array. Since we know this, we should need to haul around the array! ! */ ! ! assert(view_m->contributing_m.second.empty()); ! ! sheet_m.set(view_m->contributing_m.first); ! sheet_m.update(); ! } ! else if (action == dialog_s) ! { ! assert(!"not implemented"); ! //push_back(parameter.get<std::string>().c_str(), size_normal_s); ! } ! else if (action == cancel_s) ! { ! assert(view_m->contributing_m.second.empty()); ! ! sheet_m.set(view_m->contributing_m.first); ! end_dialog(action); ! sheet_m.update(); ! } ! else if (action == ok_s) ! { end_dialog(action); - } } catch(...) --- 265,276 ---- /****************************************************************************************************/ ! void mdi_implementation_t::latch_callback(adobe::name_t action, const adobe::value_t& value) try { assert(view_m); + assert(callback_m); ! if (callback_m(action, value)) end_dialog(action); } catch(...) *************** *** 322,331 **** /****************************************************************************************************/ ! adobe::dialog_result_t handle_dialog( const adobe::dictionary_t& input, ! const adobe::record_info_t& record, ! const adobe::dictionary_t& display_state, ! adobe::display_options_t display_options, ! std::istream& layout_definition, ! std::istream& sheet_definition) { assert ( !layout_definition.fail() ); --- 302,313 ---- /****************************************************************************************************/ ! adobe::dialog_result_t handle_dialog( const adobe::dictionary_t& input, ! const adobe::record_info_t& record, ! const adobe::dictionary_t& display_state, ! adobe::display_options_t display_options, ! std::istream& layout_definition, ! std::istream& sheet_definition, ! action_callback_t callback, ! const boost::filesystem::path& working_directory) { assert ( !layout_definition.fail() ); *************** *** 334,339 **** mdi_implementation_t impl; ! return impl.handle_dialog( input, record, display_state, display_options, ! layout_definition, sheet_definition); } --- 316,327 ---- mdi_implementation_t impl; ! return impl.handle_dialog( input, ! record, ! display_state, ! display_options, ! layout_definition, ! sheet_definition, ! callback, ! working_directory); } --- NEW FILE: alert.cpp --- /* Copyright 2005-2006 Adobe Systems Incorporated Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt or a copy at http://opensource.adobe.com/licenses.html) */ /****************************************************************************************************/ #include <adobe/future/alert.hpp> #include <adobe/future/modal_dialog_interface.hpp> #include <adobe/name.hpp> #include <cassert> #include <string> #include <sstream> /****************************************************************************************************/ namespace { /****************************************************************************************************/ bool always_break(adobe::name_t, const adobe::value_t&) { return true; } /****************************************************************************************************/ } // namespace /****************************************************************************************************/ namespace adobe { /****************************************************************************************************/ std::pair<adobe::name_t, bool> alert(const char* window_name, const char* message_text, adobe::name_t* first_button_name, adobe::name_t* last_button_name, const char* checkbox_name, const boost::filesystem::path& icon_path, std::size_t default_button_index, std::size_t cancel_button_index) { long button_count = static_cast<long>(std::distance(first_button_name, last_button_name)); assert(button_count); std::stringstream sheet; std::stringstream layout; boost::filesystem::path icon_directory_path; // The sheet for the alert dialog sheet << "sheet alert_sheet\n" "{\n" "interface:\n" " checkbox_value: false;\n" "output:\n" " result <== { checkbox_value: checkbox_value };\n" "}\n" ; // Start by filling out the header for the layout of the alert layout << "layout alert_layout\n" "{\n" " view dialog(name: '" << window_name << "', placement: place_row, spacing: 10)\n" " {\n"; if (icon_path != boost::filesystem::path()) { icon_directory_path = icon_path.branch_path(); layout << " label_t(image: '" << icon_path.leaf() << "')\n" ; } layout << " column()\n" " {\n" " static_text(name:'" << message_text << "', horizontal: align_fill, wrap: true);\n" ; // add the checkbox if we have a name for one if (checkbox_name) { layout << "checkbox(name: '" << checkbox_name << "', bind: @checkbox_value);\n" ; } // add the buttons in *reverse* order, so the first is rightmost layout << "row(horizontal: align_right)\n" "{\n" ; for (long i(button_count - 1); i >= 0; --i) { const char* current = (first_button_name + i)->get(); // NOTE (fbrereto) : For the sake of indexing the name of the action must be "bN" layout << "button(name: '" << current << "', action: @b" << i ; // A button cannot be both the default and the cancel button if (default_button_index == static_cast<std::size_t>(i)) layout << ", default: true"; else if (cancel_button_index == static_cast<std::size_t>(i)) layout << ", cancel: true"; layout << ");\n" ; } // close out the rest of the layout layout << " }\n" // row " }\n" // column " }\n" // dialog "}\n" // layout ; // finally set up the params for the modal dialog interface call adobe::dialog_result_t result(adobe::handle_dialog(adobe::dictionary_t(), adobe::record_info_t(), adobe::dictionary_t(), adobe::dialog_display_s, layout, sheet, &always_break, icon_directory_path)); bool is_checked(result.command_m[adobe::static_name_t("checkbox_value")].get<bool>()); // NOTE (fbrereto) : Here is why we require the name of the action to be "bN", where N is the index std::size_t index(std::atoi(&result.terminating_action_m.get()[1])); return std::make_pair(*(first_button_name + index), is_checked); } /****************************************************************************************************/ } // namespace adobe /****************************************************************************************************/ |