Phoenix Logo

phoenix_title wx.lib.floatcanvas.FCObjects.ScaledTextBox

Draws a text object

The object is scaled when zoomed.

The hit-test is done on the entire text extent

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.


class_hierarchy Class Hierarchy

Inheritance diagram for class ScaledTextBox:


method_summary Methods Summary

__init__ Default class constructor.
CalcBoundingBox Calculates the Bounding Box
GetBoxRect  
LayoutText Calculates the positions of the words of text.
ReWrap  
WrapToWidth  

api Class API



class ScaledTextBox(TextObjectMixin, DrawObject)

Draws a text object

The object is scaled when zoomed.

The hit-test is done on the entire text extent

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.


Methods



__init__(self, String, Point, Size, Color = "Black", BackgroundColor = None, LineColor = 'Black', LineStyle = 'Solid', LineWidth = 1, Width = None, PadSize = None, Family = wx.FONTFAMILY_MODERN, Style = wx.FONTSTYLE_NORMAL, Weight = wx.FONTWEIGHT_NORMAL, Underlined = False, Position = 'tl', Alignment = "left", Font = None, LineSpacing = 1.0, InForeground = False)

Default class constructor.

Parameters:
  • Point – takes a 2-tuple, or a (2,) NumPy array of point coordinates
  • Size (integer) – size in World units
  • Color – see SetColor
  • BackgroundColor – see SetColor
  • LineColor – see SetColor
  • LineWidth – see SetLineWidth
  • Width – width in pixels or None, text will be wrapped to the given width.
  • PadSize – padding in world units or None, if specified it will creating a space (margin) around the text
  • Family (FontFamily) – a valid wx.FontFamily
  • Style (FontStyle) – a valid wx.FontStyle
  • Weight (FontWeight) – a valid wx.FontWeight
  • Underlined (boolean) – underline the text
  • Position (string) – a two character string indicating where in relation to the coordinates the box should be oriented

    1st character Meaning
    t top
    c center
    b bottom
    2nd character Meaning
    l left
    c center
    r right
  • Alignment – see SetLineWidth
  • Font (wx.Font) – alternatively a valid wx.Font can be defined in which case the above will be ignored
  • LineSpacing (float) – the line space to be used
  • InForeground (boolean) – should object be in foreground


CalcBoundingBox(self)

Calculates the Bounding Box



GetBoxRect(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.



ReWrap(self, Width)


WrapToWidth(self)