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

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