Class ScaledTextBox
DrawObject
--+
|
XYObjectMixin
--+ |
| |
TextObjectMixin
--+
|
ScaledTextBox
This class creates a TextBox object that is scaled when zoomed. It is
placed at the coordinates, x,y.
If the Width parameter is defined, the text will be wrapped to the width given.
A Box can be drawn around the text, be specifying:
LineWidth and/or FillColor
A space(margin) can be put all the way around the text, be specifying:
the PadSize argument in world coordinates.
The spacing between lines can be adjusted with the:
LineSpacing argument.
The "Position" argument is a two character string, indicating where
in relation to the coordinates the Box should be oriented.
-The first letter is: t, c, or b, for top, center and bottom.
-The second letter is: l, c, or r, for left, center and right The
position refers to the position relative to the text itself. It
defaults to "tl" (top left).
Size is the size of the font in world coordinates.
Family:
Font family, a generic way of referring to fonts without
specifying actual facename. One of:
wx.DEFAULT: Chooses a default font.
wx.DECORATIVE: A decorative font.
wx.ROMAN: A formal, serif font.
wx.SCRIPT: A handwriting font.
wx.SWISS: A sans-serif font.
wx.MODERN: A fixed pitch font.
NOTE: these are only as good as the wxWindows defaults, which aren't so good.
Style:
One of wx.NORMAL, wx.SLANT and wx.ITALIC.
Weight:
One of wx.NORMAL, wx.LIGHT and wx.BOLD.
Underline:
The value can be True or False. At present this may have an an
effect on Windows only.
Alternatively, you can set the kw arg: Font, to a wx.Font, and the
above will be ignored. The size of the font you specify will be
ignored, but the rest of its attributes will be preserved.
The size will scale as the drawing is zoomed.
Bugs/Limitations:
As fonts are scaled, they do end up a little different, so you don't
get exactly the same picture as you scale up and down, but it's
pretty darn close.
On wxGTK1 on my Linux system, at least, using a font of over about
1000 pts. brings the system to a halt. It's the Font Server using
huge amounts of memory. My work around is to max the font size to
1000 points, so it won't scale past there. GTK2 uses smarter font
drawing, so that may not be an issue in future versions, so feel
free to test. Another smarter way to do it would be to set a global
zoom limit at that point.
The hit-test is done on the entire box. This could be made
optional, but I haven't gotten around to it.
Method Summary |
|
__init__(self,
String,
Point,
Size,
Color,
BackgroundColor,
LineColor,
LineStyle,
LineWidth,
Width,
PadSize,
Family,
Style,
Weight,
Underline,
Position,
Alignment,
Font,
LineSpacing,
InForeground)
|
|
CalcBoundingBox (self)
Calculates the Bounding Box |
|
GetBoxRect(self)
|
|
LayoutText (self)
Calculates the positions of the words of text. |
|
ReWrap(self,
Width)
|
|
WrapToWidth(self)
|
LayoutText(self)
Calculates the positions of the words of text.
This isn't exact, as fonts don't scale exactly.
To help this, the position of each individual word
is stored separately, so that the general layout stays
the same in world coordinates, as the fonts scale.
-
- Overrides:
wx.lib.floatcanvas.FloatCanvas.TextObjectMixin.LayoutText
|