Patch from Rob McMullen allowing the plot title to be optional
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45068 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -554,6 +554,7 @@ class PlotCanvas(wx.Panel):
|
|||||||
self._ySpec= 'auto'
|
self._ySpec= 'auto'
|
||||||
self._gridEnabled= False
|
self._gridEnabled= False
|
||||||
self._legendEnabled= False
|
self._legendEnabled= False
|
||||||
|
self._titleEnabled= True
|
||||||
|
|
||||||
# Fonts
|
# Fonts
|
||||||
self._fontCache = {}
|
self._fontCache = {}
|
||||||
@@ -807,6 +808,17 @@ class PlotCanvas(wx.Panel):
|
|||||||
"""True if Legend enabled."""
|
"""True if Legend enabled."""
|
||||||
return self._legendEnabled
|
return self._legendEnabled
|
||||||
|
|
||||||
|
def SetEnableTitle(self, value):
|
||||||
|
"""Set True to enable title."""
|
||||||
|
if value not in [True,False]:
|
||||||
|
raise TypeError, "Value should be True or False"
|
||||||
|
self._titleEnabled= value
|
||||||
|
self.Redraw()
|
||||||
|
|
||||||
|
def GetEnableTitle(self):
|
||||||
|
"""True if title enabled."""
|
||||||
|
return self._titleEnabled
|
||||||
|
|
||||||
def SetEnablePointLabel(self, value):
|
def SetEnablePointLabel(self, value):
|
||||||
"""Set True to enable pointLabel."""
|
"""Set True to enable pointLabel."""
|
||||||
if value not in [True,False]:
|
if value not in [True,False]:
|
||||||
@@ -1046,11 +1058,14 @@ class PlotCanvas(wx.Panel):
|
|||||||
textSize_scale= _Numeric.array([rhsW+lhsW,bottomH+topH]) # make plot area smaller by text size
|
textSize_scale= _Numeric.array([rhsW+lhsW,bottomH+topH]) # make plot area smaller by text size
|
||||||
textSize_shift= _Numeric.array([lhsW, bottomH]) # shift plot area by this amount
|
textSize_shift= _Numeric.array([lhsW, bottomH]) # shift plot area by this amount
|
||||||
|
|
||||||
# drawing title and labels text
|
# draw title if requested
|
||||||
dc.SetFont(self._getFont(self._fontSizeTitle))
|
if self._titleEnabled:
|
||||||
titlePos= (self.plotbox_origin[0]+ lhsW + (self.plotbox_size[0]-lhsW-rhsW)/2.- titleWH[0]/2.,
|
dc.SetFont(self._getFont(self._fontSizeTitle))
|
||||||
self.plotbox_origin[1]- self.plotbox_size[1])
|
titlePos= (self.plotbox_origin[0]+ lhsW + (self.plotbox_size[0]-lhsW-rhsW)/2.- titleWH[0]/2.,
|
||||||
dc.DrawText(graphics.getTitle(),titlePos[0],titlePos[1])
|
self.plotbox_origin[1]- self.plotbox_size[1])
|
||||||
|
dc.DrawText(graphics.getTitle(),titlePos[0],titlePos[1])
|
||||||
|
|
||||||
|
# draw label text
|
||||||
dc.SetFont(self._getFont(self._fontSizeAxis))
|
dc.SetFont(self._getFont(self._fontSizeAxis))
|
||||||
xLabelPos= (self.plotbox_origin[0]+ lhsW + (self.plotbox_size[0]-lhsW-rhsW)/2.- xLabelWH[0]/2.,
|
xLabelPos= (self.plotbox_origin[0]+ lhsW + (self.plotbox_size[0]-lhsW-rhsW)/2.- xLabelWH[0]/2.,
|
||||||
self.plotbox_origin[1]- xLabelWH[1])
|
self.plotbox_origin[1]- xLabelWH[1])
|
||||||
@@ -1365,8 +1380,11 @@ class PlotCanvas(wx.Panel):
|
|||||||
"""Draws Title and labels and returns width and height for each"""
|
"""Draws Title and labels and returns width and height for each"""
|
||||||
# TextExtents for Title and Axis Labels
|
# TextExtents for Title and Axis Labels
|
||||||
dc.SetFont(self._getFont(self._fontSizeTitle))
|
dc.SetFont(self._getFont(self._fontSizeTitle))
|
||||||
title= graphics.getTitle()
|
if self._titleEnabled:
|
||||||
titleWH= dc.GetTextExtent(title)
|
title= graphics.getTitle()
|
||||||
|
titleWH= dc.GetTextExtent(title)
|
||||||
|
else:
|
||||||
|
titleWH= (0,0)
|
||||||
dc.SetFont(self._getFont(self._fontSizeAxis))
|
dc.SetFont(self._getFont(self._fontSizeAxis))
|
||||||
xLabel, yLabel= graphics.getXLabel(),graphics.getYLabel()
|
xLabel, yLabel= graphics.getXLabel(),graphics.getYLabel()
|
||||||
xLabelWH= dc.GetTextExtent(xLabel)
|
xLabelWH= dc.GetTextExtent(xLabel)
|
||||||
|
Reference in New Issue
Block a user