]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/lib/plot.py
added wxDisplay::GetClientArea() (currently implemented for single display and MSW...
[wxWidgets.git] / wxPython / wx / lib / plot.py
index 5fabf66063e2fba3f408e700bc2e0343b5155607..251d3a54beabd14c0a68335b0a72adaa489ba714 100644 (file)
@@ -201,7 +201,9 @@ class PolyLine(PolyPoints):
         colour = self.attributes['colour']
         width = self.attributes['width'] * printerScale
         style= self.attributes['style']
-        pen = wx.Pen(wx.NamedColour(colour), width, style)
+        if not isinstance(colour, wx.Colour):
+            colour = wx.NamedColour(colour)
+        pen = wx.Pen(colour, width, style)
         pen.SetCap(wx.CAP_BUTT)
         dc.SetPen(pen)
         if coord == None:
@@ -262,11 +264,16 @@ class PolyMarker(PolyPoints):
         fillstyle = self.attributes['fillstyle']
         marker = self.attributes['marker']
 
-        dc.SetPen(wx.Pen(wx.NamedColour(colour), width))
+        if colour and not isinstance(colour, wx.Colour):
+            colour = wx.NamedColour(colour)
+        if fillcolour and not isinstance(fillcolour, wx.Colour):
+            fillcolour = wx.NamedColour(fillcolour)
+            
+        dc.SetPen(wx.Pen(colour, width))
         if fillcolour:
-            dc.SetBrush(wx.Brush(wx.NamedColour(fillcolour),fillstyle))
+            dc.SetBrush(wx.Brush(fillcolour,fillstyle))
         else:
-            dc.SetBrush(wx.Brush(wx.NamedColour(colour), fillstyle))
+            dc.SetBrush(wx.Brush(colour, fillstyle))
         if coord == None:
             self._drawmarkers(dc, self.scaled, marker, size)
         else:
@@ -487,6 +494,17 @@ class PlotCanvas(wx.Window):
         if wx.Platform != "__WXMAC__":
             self.OnSize(None) # sets the initial size based on client size
 
+        self._gridColour = wx.NamedColour('black')
+
+    def GetGridColour(self):
+        return self._gridColour
+
+    def SetGridColour(self, colour):
+        if isinstance(colour, wx.Colour):
+            self._gridColour = colour
+        else:
+            self._gridColour = wx.NamedColour(colour)
+
         
     # SaveFile
     def SaveFile(self, fileName= ''):
@@ -556,7 +574,7 @@ class PlotCanvas(wx.Window):
                 self.pageSetupData.SetMarginBottomRight(data.GetMarginBottomRight())
                 self.pageSetupData.SetMarginTopLeft(data.GetMarginTopLeft())
                 self.pageSetupData.SetPrintData(data.GetPrintData())
-                self.print_data=data.GetPrintData() # updates print_data
+                self.print_data=wx.PrintData(data.GetPrintData()) # updates print_data
         finally:
             dlg.Destroy()
                 
@@ -564,13 +582,12 @@ class PlotCanvas(wx.Window):
         """Print current plot."""
         if paper != None:
             self.print_data.SetPaperId(paper)
-        pdd = wx.PrintDialogData()
-        pdd.SetPrintData(self.print_data)
+        pdd = wx.PrintDialogData(self.print_data)
         printer = wx.Printer(pdd)
         out = PlotPrintout(self)
         print_ok = printer.Print(self.parent, out)
         if print_ok:
-            self.print_data = printer.GetPrintDialogData().GetPrintData()
+            self.print_data = wx.PrintData(printer.GetPrintDialogData().GetPrintData())
         out.Destroy()
 
     def PrintPreview(self):
@@ -630,8 +647,8 @@ class PlotCanvas(wx.Window):
 
     def SetEnableGrid(self, value):
         """Set True to enable grid."""
-        if value not in [True,False]:
-            raise TypeError, "Value should be True or False"
+        if value not in [True,False,'Horizontal','Vertical']:
+            raise TypeError, "Value should be True, False, Horizontal or Vertical"
         self._gridEnabled= value
         self.Redraw()
 
@@ -689,9 +706,11 @@ class PlotCanvas(wx.Window):
     def ScrollUp(self, units):
         """Move view up number of axis units."""
         self.last_PointLabel = None        #reset pointLabel
-        if self.BeenDrawn():
-            self._drawCmd.scrollAxisY(units, self._ySpec)
-            self._draw()
+        if self.last_draw is not None:
+             graphics, xAxis, yAxis= self.last_draw
+             yAxis= (yAxis[0]+units, yAxis[1]+units)
+             self.Draw(graphics,xAxis,yAxis)
+
         
     def GetXY(self,event):
         """Takes a mouse event and returns the XY user axis values."""
@@ -1025,7 +1044,9 @@ class PlotCanvas(wx.Window):
         # The Buffer init is done here, to make sure the buffer is always
         # the same size as the Window
         Size  = self.GetClientSize()
-
+        if Size.width <= 0 or Size.height <= 0:
+            return
+        
         # Make new offscreen bitmap: this bitmap will always have the
         # current drawing in it, so it can be used to save the image to
         # a file, or whatever.
@@ -1223,13 +1244,20 @@ class PlotCanvas(wx.Window):
     def _drawAxes(self, dc, p1, p2, scale, shift, xticks, yticks):
         
         penWidth= self.printerScale        # increases thickness for printing only
-        dc.SetPen(wx.Pen(wx.NamedColour('BLACK'), penWidth))
+        dc.SetPen(wx.Pen(self._gridColour, penWidth))
         
         # set length of tick marks--long ones make grid
         if self._gridEnabled:
             x,y,width,height= self._point2ClientCoord(p1,p2)
-            yTickLength= width/2.0 +1
-            xTickLength= height/2.0 +1
+            if self._gridEnabled == 'Horizontal':
+                yTickLength= width/2.0 +1
+                xTickLength= 3 * self.printerScale
+            elif self._gridEnabled == 'Vertical':
+                yTickLength= 3 * self.printerScale
+                xTickLength= height/2.0 +1
+            else:
+                yTickLength= width/2.0 +1
+                xTickLength= height/2.0 +1
         else:
             yTickLength= 3 * self.printerScale  # lengthens lines for printing
             xTickLength= 3 * self.printerScale