stlab.adobe.com Adobe Systems Incorporated

layout_attributes.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 
00007 /*************************************************************************************************/
00008 
00009 #ifndef ADOBE_LAYOUT_ATTRIBUTES_HPP
00010 #define ADOBE_LAYOUT_ATTRIBUTES_HPP
00011 
00012 #include <adobe/config.hpp>
00013 #include <adobe/extents.hpp>
00014 
00021 namespace adobe {
00022 
00023     /*************************************************************************************************/
00024 
00028 struct layout_attributes_alignment_t {   
00029     enum alignment_t
00030     {
00031         align_forward = 0, // Used as index for guide array.
00032         align_reverse = 1, // Used as index for guide array.
00033         align_center,
00034         align_proportional,
00035         align_forward_fill,
00036         align_reverse_fill,
00037         
00038         align_default,
00039         
00040         align_fill          = align_forward_fill,
00041         align_left_fill     = align_forward_fill,
00042         align_right_fill    = align_reverse_fill,
00043         align_top_fill      = align_forward_fill,
00044         align_bottom_fill   = align_reverse_fill,
00045         align_left          = align_forward,
00046         align_right         = align_reverse,
00047         align_top           = align_forward,
00048         align_bottom        = align_reverse
00049     };
00050 };
00051 
00055 struct layout_attributes_placement_t {   
00056     enum placement_t
00057     {
00058         place_leaf,
00059         place_column,
00060         place_row,
00061         place_overlay
00062     };
00063 };
00064 
00068 struct layout_attributes_t
00069 #if !defined(ADOBE_NO_DOCUMENTATION)
00070     : public extents_slices_t, 
00071       public layout_attributes_alignment_t, 
00072       public layout_attributes_placement_t
00073 #endif
00074 {
00075     layout_attributes_t() :
00076         indent_m(0),
00077         create_m(true),
00078         spacing_m(2, 0),
00079         placement_m(place_leaf)
00080     {
00081         spacing_m[1] = 10; /* REVISIT FIXED VALUE container_spacing */
00082     }
00083 
00084     typedef std::vector<int> spacing_t;
00085 
00086     struct slice_t
00087     {
00088         slice_t() : alignment_m(align_default),
00089                     suppress_m(false),
00090                     balance_m(false),
00091                     child_alignment_m(align_forward) {}
00092 
00093         alignment_t             alignment_m;
00094         bool                    suppress_m;
00095         bool                    balance_m;
00096 
00097         // containers only
00098         pair_long_t             margin_m;
00099         alignment_t             child_alignment_m;
00100     };
00101     
00102     extents_t                   extents_m;
00103     int                         indent_m;
00104     bool                        create_m;
00105     spacing_t                   spacing_m;
00106     boost::array<slice_t, 2>    slice_m;
00107 
00108     // containers only
00109     placement_t                 placement_m;
00110 
00111     slice_t&                    vertical()          { return slice_m[extents_slices_t::vertical]; }
00112     slice_t&                    horizontal()        { return slice_m[extents_slices_t::horizontal]; }
00113 
00114     const slice_t&              vertical() const    { return slice_m[extents_slices_t::vertical]; }
00115     const slice_t&              horizontal() const  { return slice_m[extents_slices_t::horizontal]; }
00116 
00117 
00118     int&                        height()            { return extents_m.height(); }
00119     int&                        width()             { return extents_m.width(); }
00120 
00121     const int&                  height() const      { return extents_m.height(); }
00122     const int&                  width() const       { return extents_m.width(); }
00123 };
00124 
00125 /*************************************************************************************************/
00126 
00130 struct place_data_t
00131 #if !defined(ADOBE_NO_DOCUMENTATION)
00132     : extents_slices_t
00133 #endif
00134 {
00135     struct slice_t
00136     {
00137 #if !defined(ADOBE_NO_DOCUMENTATION)
00138         slice_t();
00139 #endif
00140 
00141         int         length_m;
00142         int         position_m;
00143         pair_long_t outset_m;
00144         guide_set_t guide_set_m;
00145     };
00146 
00147     boost::array<slice_t, 2>    slice_m;
00148 
00149     slice_t&                    vertical()          { return slice_m[extents_slices_t::vertical]; }
00150     slice_t&                    horizontal()        { return slice_m[extents_slices_t::horizontal]; }
00151 
00152     const slice_t&              vertical() const    { return slice_m[extents_slices_t::vertical]; }
00153     const slice_t&              horizontal() const  { return slice_m[extents_slices_t::horizontal]; }
00154 };
00155 
00156 
00160 inline int top(const place_data_t& place_data)    { return place_data.vertical().position_m; }
00161 
00165 inline int left(const place_data_t& place_data)   { return place_data.horizontal().position_m; }
00166 
00170 inline int& top(place_data_t& place_data)         { return place_data.vertical().position_m; }
00171 
00175 inline int& left(place_data_t& place_data)        { return place_data.horizontal().position_m; }
00176 
00180 inline int height(const place_data_t& place_data) { return place_data.vertical().length_m; }
00181 
00185 inline int width(const place_data_t& place_data)  { return place_data.horizontal().length_m; }
00186 
00190 inline int& height(place_data_t& place_data)      { return place_data.vertical().length_m; }
00191 
00195 inline int& width(place_data_t& place_data)       { return place_data.horizontal().length_m; }
00196 
00200 inline int bottom(const place_data_t& place_data) { return top(place_data) + height(place_data); }
00201 
00205 inline int right(const place_data_t& place_data)  { return left(place_data) + width(place_data); }
00206 
00207 /*************************************************************************************************/
00208 }
00209 
00210 
00211 #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