On Thu, Sep 9, 2010 at 15:48, Paul McNett <[email protected]> wrote: > On 9/9/10 12:31 PM, Nate Lowrie wrote: >> Is there an easy way to center an object? > > Say you want to center a string object between the left and right margins of > the page: > > <String> > <align>"center"</align> > <expr>"Hello"</expr> > <hAnchor>"center"</hAnchor> > <x>self.Bands["detail"]["width"]/2.0</x> > <width>self.Bands["detail"]["width"]</width> > </String> > > This will create a string object with centered text alignment, saying > "Hello". The x > value specifies the center point, and the x value is set to the center of the > band. > We also set the width to the width of the band. > > You could use absolute values for everything, of course. You could also > accomplish > the same thing with hAnchor of "left": > > <String> > <align>"center"</align> > <expr>"Hello"</expr> > <hAnchor>"left"</hAnchor> > <x>0</x> > <width>self.Bands["detail"]["width"]</width> > </String> > > In this case though you have to set width to the width of the band or the > string will > still be centered in the width of the string object but not in the band. > > I show all this in XML to be explicit, but all these properties can be edited > using > the designer as well.
I like the non-explicit version because it is applicable to any sized page. It lends itself well to a printing system. Regards, Nate _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
