modal_dialog_interface.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 #include <adobe/dictionary.hpp> 00010 #include <adobe/array.hpp> 00011 00012 #include <boost/function.hpp> 00013 #include <boost/filesystem/path.hpp> 00014 00015 #include <utility> 00016 00017 #if ADOBE_PLATFORM_WIN 00018 #include <windows.h> 00019 #endif 00020 00021 #include <adobe/future/platform_primitives.hpp> 00022 #include <adobe/future/widgets/headers/factory.hpp> 00023 #include <adobe/future/widgets/headers/virtual_machine_extension.hpp> 00024 00025 /****************************************************************************************************/ 00026 00027 namespace adobe { 00028 00029 /****************************************************************************************************/ 00030 00047 /****************************************************************************************************/ 00054 enum display_options_t 00055 { 00059 dialog_display_s, 00060 00067 dialog_no_display_s, 00068 00073 dialog_never_display_s 00074 }; 00075 00076 /****************************************************************************************************/ 00082 struct dialog_result_t 00083 { 00084 dialog_result_t& operator=(const dialog_result_t& x) 00085 { 00086 record_m = x.record_m; 00087 display_state_m = x.display_state_m; 00088 command_m = x.command_m; 00089 terminating_action_m = x.terminating_action_m; 00090 return *this; 00091 } 00109 dictionary_t record_m; 00110 00117 dictionary_t display_state_m; 00118 00128 dictionary_t command_m; 00129 00135 name_t terminating_action_m; 00136 }; 00137 00138 /****************************************************************************************************/ 00153 typedef boost::function <bool (name_t, const any_regular_t&)> action_callback_t; 00154 00155 /****************************************************************************************************/ 00161 class modal_dialog_t 00162 { 00163 public: 00164 typedef any_regular_t model_type; 00165 typedef auto_ptr<eve_client_holder> auto_view_t; 00166 00167 modal_dialog_t(); 00168 00169 dialog_result_t go(std::istream& layout, std::istream& sheet); 00170 00171 dictionary_t input_m; 00172 dictionary_t record_m; 00173 dictionary_t display_state_m; 00174 display_options_t display_options_m; 00175 action_callback_t callback_m; 00176 boost::filesystem::path working_directory_m; 00177 platform_display_type parent_m; 00178 vm_lookup_t vm_lookup_m; 00179 00180 /* Clients: no need to call these. */ 00181 bool end_dialog(); 00182 void display(const model_type& value); 00183 00184 private: 00185 void latch_callback(name_t action, const any_regular_t&); 00186 00187 void monitor_record(const dictionary_t& record_info); 00188 void monitor_invariant(bool valid); 00189 00190 sheet_t sheet_m; 00191 behavior_t root_behavior_m; 00192 auto_view_t view_m; 00193 bool defer_view_close_m; 00194 bool need_ui_m; 00195 dialog_result_t result_m; 00196 dictionary_t contributing_m; 00197 }; 00198 00199 /****************************************************************************************************/ 00255 inline dialog_result_t handle_dialog(const dictionary_t& input, 00256 const dictionary_t& record, 00257 const dictionary_t& display_state, 00258 display_options_t display_options, 00259 std::istream& layout_definition, 00260 std::istream& sheet_definition, 00261 action_callback_t callback, 00262 const boost::filesystem::path& working_directory, 00263 platform_display_type parent=platform_display_type()) 00264 { 00265 assert ( !layout_definition.fail() ); 00266 assert ( !sheet_definition.fail() ); 00267 00268 modal_dialog_t dialog; 00269 00270 dialog.input_m = input; 00271 dialog.record_m = record; 00272 dialog.display_state_m = display_state; 00273 dialog.display_options_m = display_options; 00274 dialog.callback_m = callback; 00275 dialog.working_directory_m = working_directory; 00276 dialog.parent_m = parent; 00277 00278 return dialog.go(layout_definition, sheet_definition); 00279 } 00280 00281 /****************************************************************************************************/ 00282 00283 } // namespace adobe 00284 00285 /****************************************************************************************************/ |