stlab.adobe.com Adobe Systems Incorporated

factory.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_UI_CORE_FACTORY_HPP
00010 #define ADOBE_UI_CORE_FACTORY_HPP
00011 
00012 /*************************************************************************************************/
00013 
00014 #include <adobe/config.hpp>
00015 
00016 #include <adobe/adam.hpp>
00017 #include <adobe/any_regular.hpp>
00018 #include <adobe/basic_sheet.hpp>
00019 #include <adobe/dictionary.hpp>
00020 #include <adobe/dictionary.hpp>
00021 #include <adobe/eve_parser.hpp>
00022 #include <adobe/eve.hpp>
00023 #include <adobe/future/assemblage.hpp>
00024 #include <adobe/future/behavior.hpp>
00025 #include <adobe/future/debounce.hpp>
00026 #include <adobe/future/widgets/headers/display.hpp>
00027 #include <adobe/future/widgets/headers/visible_change_queue.hpp>
00028 #include <adobe/future/widgets/headers/widget_tokens.hpp>
00029 #include <adobe/future/widgets/headers/widget_utils.hpp>
00030 #include <adobe/future/widgets/headers/widget_factory_registry.hpp>
00031 #include <adobe/istream.hpp>
00032 #include <adobe/keyboard.hpp>
00033 #include <adobe/memory.hpp>
00034 #include <adobe/name.hpp>
00035 
00036 #include <boost/filesystem/path.hpp>
00037 #include <boost/function.hpp>
00038 
00039 #include <list>
00040 #include <vector>
00041 
00042 /*************************************************************************************************/
00043 //
00056 //
00057 /*************************************************************************************************/
00058 
00059 namespace adobe {
00060 
00061 /*************************************************************************************************/
00062 
00063 struct eve_client_holder : public boost::noncopyable
00064 {
00065     eve_client_holder(behavior_t& sheet_scope_root_behavior) :
00066         visible_change_queue_m(eve_m),
00067         root_behavior_m(sheet_scope_root_behavior),
00068         root_display_m()
00069     {
00070         eve_eval_token_m = root_behavior_m.insert(boost::bind(&visible_change_queue_t::update,
00071                                                               boost::ref(visible_change_queue_m)));
00072     }
00073 
00074 
00075     ~eve_client_holder()
00076     {
00077         root_behavior_m.disconnect(eve_eval_token_m);
00078     }
00079 
00080     /*
00081     NOTE (sparent) : Order is important here - we want to destruct window_m prior to destructing
00082     eve_m so that any notifications sent by the system are sent to valid object. Slots and
00083     signals on the window widgets would be a better way to handle this connection but I'm not
00084     there yet.
00085     */
00086 
00087     //
00091     //
00092     eve_t                                    eve_m;
00093 
00094     //
00096     //
00097     basic_sheet_t                            layout_sheet_m;
00098     
00099     //
00103     //
00104     assemblage_t                             assemblage_m;
00105 
00106     //
00108     //
00109     dictionary_t                             contributing_m;
00110 
00111     //
00116     //
00117     boost::signal<void ()>                   show_window_m;
00118 
00119     //
00122     //
00123     visible_change_queue_t                   visible_change_queue_m;
00124     
00125     //
00135     //
00136     behavior_t&                               root_behavior_m;
00137 
00138     //
00140     //
00141     behavior_t::verb_token_t                  eve_eval_token_m;
00142 
00143     //
00146     //
00147     behavior_t*                              my_behavior_m;
00148 
00149     //
00151     //
00152     platform_display_type                    root_display_m;
00153 
00154     //
00156     //
00157     boost::filesystem::path                  path_m;
00158 };
00159 
00160 /*************************************************************************************************/
00161 
00162 typedef boost::function<void (name_t action, const any_regular_t&)> button_notifier_t;
00163 
00164 /****************************************************************************************************/
00165 
00166 /*
00167     REVISIT (sparent) : Size is inherited from the parent during initialization - the size
00168     specified to the client is relative to the parent's size. Does this ever need to
00169     be specified in absolutes?
00170 */
00171 
00172 enum size_enum_t
00173 {
00174     size_mini_s     = -2,
00175     size_small_s    = -1,
00176     size_normal_s   = 0,
00177 
00178     size_minimum_s  = size_mini_s,
00179     size_maximum_s  = size_normal_s
00180 };
00181 
00182 /*************************************************************************************************/
00183 
00184 //
00188 //
00189 struct factory_token_t
00190 {
00191     factory_token_t(display_t&                display,
00192                     sheet_t&                  sheet,
00193                     eve_client_holder& client_holder,
00194                     button_notifier_t  notifier) :
00195         display_m(display),
00196         sheet_m(sheet),
00197         client_holder_m(client_holder),
00198         notifier_m(notifier)
00199     { }
00200 
00201     //
00204     //
00205     display_t& display_m;
00206 
00207     //
00210     //
00211     sheet_t& sheet_m;
00212 
00213     //
00218     //
00219     eve_client_holder& client_holder_m;
00220 
00221     //
00225     //
00226     button_notifier_t notifier_m;
00227 };
00228 
00229 /*************************************************************************************************/
00230 //
00234 //
00235 struct widget_node_t
00236 {
00237     widget_node_t(  size_enum_t                     size,
00238                     const eve_t::iterator&          eve_token,
00239                     const platform_display_type&    display_token,
00240                     const keyboard_t::iterator&     keyboard_token
00241                     ) :
00242         size_m(size),
00243         eve_token_m(eve_token),
00244         display_token_m(display_token),
00245         keyboard_token_m(keyboard_token)
00246     { } 
00247     //
00250     //
00251     size_enum_t size_m;
00252     //
00254     //
00255     eve_t::iterator eve_token_m;
00256     //
00259     //
00260     mutable platform_display_type display_token_m;
00261 
00263     //
00264     keyboard_t::iterator keyboard_token_m;
00265 
00266 };
00267 
00268 /*************************************************************************************************/
00269 //
00280 //
00281 widget_node_t row_factory(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, const widget_factory_t& factory);
00282 
00283 /*************************************************************************************************/
00284 //
00295 //
00296 widget_node_t column_factory(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, const widget_factory_t& factory);
00297 
00298 /*************************************************************************************************/
00299 //
00310 //
00311 widget_node_t overlay_factory(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, const widget_factory_t& factory);
00312 
00313 /*************************************************************************************************/
00314 //
00319 //
00320 const widget_factory_t& default_asl_widget_factory();
00321 
00322 /*************************************************************************************************/
00323 
00324 inline widget_node_t default_factory(const widget_factory_t& factory,
00325                                      name_t                  widget_type,
00326                                      const dictionary_t&     parameters,
00327                                      const widget_node_t&    parent,
00328                                      const factory_token_t&  token)
00329 {
00330     return factory.method(widget_type)(parameters, parent, token, factory);
00331 }
00332 
00333 /*************************************************************************************************/
00334 
00335 typedef boost::function<widget_node_t (name_t                 widget_type,
00336                                        const dictionary_t&    parameters,
00337                                        const widget_node_t&   parent,
00338                                        const factory_token_t& token)> widget_factory_proc_t;
00339 
00340 /*************************************************************************************************/
00341 
00342 inline widget_factory_proc_t default_widget_factory_proc_with_factory(const widget_factory_t& factory)
00343 {
00344     return boost::bind(&default_factory,
00345                        boost::cref(factory),
00346                        _1, _2, _3, _4);
00347 }
00348 
00349 /*************************************************************************************************/
00350 
00351 inline widget_factory_proc_t default_widget_factory_proc()
00352 { return default_widget_factory_proc_with_factory(default_asl_widget_factory()); }
00353 
00354 /*************************************************************************************************/
00355 
00356 adobe::auto_ptr<eve_client_holder> make_view(name_t                                 file_name,
00357                                              const line_position_t::getline_proc_t& getline_proc,
00358                                              std::istream&                          stream,
00359                                              sheet_t&                               sheet,
00360                                              behavior_t&                            root_behavior,
00361                                              const button_notifier_t&               notifier,
00362                                              size_enum_t                            dialog_size,
00363                                              const widget_factory_proc_t&           proc = default_widget_factory_proc(),
00364                                              platform_display_type                  display_root=platform_display_type());
00365 
00366 /*************************************************************************************************/
00367 
00368 } // namespace adobe
00369 
00370 /*************************************************************************************************/
00371 
00372 #endif
00373 
00374 /*************************************************************************************************/
00375 

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