+#----------------------------------------------------------------------
+
+class DividedShape(wxDividedShape):
+ def __init__(self, width, height, canvas):
+ wxDividedShape.__init__(self, width, height)
+
+ region1 = wxShapeRegion()
+ region1.SetText('wxDividedShape')
+ region1.SetProportions(0.0, 0.2)
+ region1.SetFormatMode(FORMAT_CENTRE_HORIZ)
+ self.AddRegion(region1)
+
+ region2 = wxShapeRegion()
+ region2.SetText('This is Region number two.')
+ region2.SetProportions(0.0, 0.3)
+ region2.SetFormatMode(FORMAT_CENTRE_HORIZ|FORMAT_CENTRE_VERT)
+ self.AddRegion(region2)
+
+ region3 = wxShapeRegion()
+ region3.SetText('Region 3\nwith embedded\nline breaks')
+ region3.SetProportions(0.0, 0.5)
+ region3.SetFormatMode(FORMAT_NONE)
+ self.AddRegion(region3)
+
+ self.SetRegionSizes()
+ self.ReformatRegions(canvas)
+
+
+ def ReformatRegions(self, canvas=None):
+ rnum = 0
+ if canvas is None:
+ canvas = self.GetCanvas()
+ dc = wxClientDC(canvas) # used for measuring
+ for region in self.GetRegions():
+ text = region.GetText()
+ self.FormatText(dc, text, rnum)
+ rnum += 1
+
+
+ def OnSizingEndDragLeft(self, pt, x, y, keys, attch):
+ self.base_OnSizingEndDragLeft(pt, x, y, keys, attch)
+ self.SetRegionSizes()
+ self.ReformatRegions()
+ self.GetCanvas().Refresh()
+
+