stlab.adobe.com Adobe Systems Incorporated

poly_placeable.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2006-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     Author(s): Mat Marcus
00007 */
00008 
00009 /*************************************************************************************************/
00010 #ifndef ADOBE_POLY_PLACEABLE_HPP
00011 #define ADOBE_POLY_PLACEABLE_HPP
00012 
00013 #include <boost/ref.hpp>
00014 
00015 #include <adobe/config.hpp>
00016 #include <adobe/poly.hpp>
00017 #include <adobe/placeable_concept.hpp>
00018 #include <adobe/layout_attributes.hpp>
00019 
00020 
00021 
00022 /*************************************************************************************************/
00023 
00024 namespace adobe {
00025     
00026 /*************************************************************************************************/
00038 struct poly_placeable_interface : poly_copyable_interface
00039 {
00040     virtual void measure(extents_t& result) = 0;
00041     virtual void place(const place_data_t& place_data) = 0;
00042 };
00043 
00044 /*************************************************************************************************/
00045 
00053 template <typename T>
00054 struct poly_placeable_instance : optimized_storage_type<T, poly_placeable_interface>::type
00055 {
00056     typedef typename optimized_storage_type<T, poly_placeable_interface>::type base_t;
00057 
00058     BOOST_CLASS_REQUIRE(T, adobe, PlaceableConcept);
00059 
00060     poly_placeable_instance(const T& x) 
00061         : base_t(x) {}
00062     poly_placeable_instance(move_from<poly_placeable_instance> x) 
00063         : base_t(move_from<base_t>(x.source)) {}
00064 
00065     void measure(extents_t& result)
00066     { 
00067         PlaceableConcept<T>::measure(this->get(), result); 
00068     }
00069 
00070     void place(const place_data_t& place_data)
00071     { 
00072         PlaceableConcept<T>::place(this->get(), place_data); 
00073     }
00074 };
00075 
00076     
00077 /*************************************************************************************************/
00078 
00086 struct placeable : public poly_base<poly_placeable_interface, poly_placeable_instance>
00087 {
00088     typedef poly_base<poly_placeable_interface, poly_placeable_instance> base_t;
00089 
00090     template <typename T>
00091     explicit placeable(const T& x) : base_t(x) {}
00092     
00093     placeable(move_from<placeable> x) : base_t(move_from<base_t>(x.source)) {}
00094 
00095     void measure(extents_t& result)
00096     { interface_ref().measure(result); }
00097 
00098     void place(const place_data_t& place_data)
00099     { interface_ref().place(place_data); }
00100 };
00101 
00102 /*************************************************************************************************/
00103 
00112 typedef poly<placeable> poly_placeable_t;
00113 
00114 /*************************************************************************************************/
00115 
00122 struct poly_placeable_twopass_interface : public poly_placeable_interface
00123 {
00124     virtual void measure_vertical(extents_t& in_out_attrs,
00125                                   const place_data_t& placed_horizontal) = 0;
00126 };
00127 
00128 /*************************************************************************************************/
00129 
00135 template <typename T>
00136 struct poly_placeable_twopass_instance : optimized_storage_type<T, poly_placeable_twopass_interface>::type
00137 {
00138     typedef typename optimized_storage_type<T, poly_placeable_twopass_interface>::type base_t;
00139 
00140     BOOST_CLASS_REQUIRE(T, adobe, PlaceableTwoPassConcept);
00141 
00142     poly_placeable_twopass_instance(const T& x) 
00143         : base_t(x) {}  
00144     poly_placeable_twopass_instance(move_from<poly_placeable_twopass_instance> x) 
00145         : base_t(move_from<base_t>(x.source)) {}
00146 
00147     void measure(extents_t& result)
00148     { 
00149         PlaceableTwoPassConcept<T>::measure(this->get(), result); 
00150     }
00151     
00152     void measure_vertical(extents_t& calculated_horizontal, const place_data_t& placed_horizontal)
00153     { 
00154         PlaceableTwoPassConcept<T>::measure_vertical(this->get(), calculated_horizontal, placed_horizontal); 
00155     }
00156 
00157     void place(const place_data_t& place_data)
00158     { 
00159         PlaceableTwoPassConcept<T>::place(this->get(), place_data); 
00160     }
00161     
00162 };
00163 
00164 /*************************************************************************************************/
00165 
00169 struct placeable_twopass 
00170     : public poly_base<poly_placeable_twopass_interface, poly_placeable_twopass_instance>
00171 {
00172     typedef poly_base<poly_placeable_twopass_interface, poly_placeable_twopass_instance> base_t;
00173 
00174     template <typename T>
00175     explicit placeable_twopass(const T& x) : base_t(x) {}
00176  
00177     placeable_twopass(move_from<placeable_twopass> x) : base_t(move_from<base_t>(x.source)) {}
00178 
00179     void measure(extents_t& result)
00180         { interface_ref().measure(result); }
00181 
00182     void measure_vertical(extents_t& calculated_horizontal, const place_data_t& placed_horizontal)
00183         { interface_ref().measure_vertical(calculated_horizontal, placed_horizontal); }
00184 
00185     void place(const place_data_t& place_data)
00186         { interface_ref().place(place_data); }
00187 };
00188 
00189 /*************************************************************************************************/
00190 
00200 typedef poly<placeable_twopass> poly_placeable_twopass_t;
00201 
00202 /*************************************************************************************************/
00203 
00204 } // namespace adobe
00205 
00206 /*************************************************************************************************/
00207 
00208 #endif

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