Package arcmap :: Module visualwidget
[hide private]
[frames] | no frames]

Source Code for Module arcmap.visualwidget

 1  ################################################################################ 
 2  # Authors: Brian Schott (Sir Alaran) 
 3  # Copyright: Brian Schott (Sir Alaran) 
 4  # Date: Sep 23 2009 
 5  # License: 
 6  # 
 7  # This program is free software: you can redistribute it and/or modify 
 8  # it under the terms of the GNU General Public License as published by 
 9  # the Free Software Foundation, either version 3 of the License, or 
10  # (at your option) any later version. 
11  # 
12  # This program is distributed in the hope that it will be useful, 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
15  # GNU General Public License for more details. 
16  # 
17  # You should have received a copy of the GNU General Public License 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
19  ################################################################################ 
20   
21  """ 
22  Contains code for previewing graphical user preferences 
23  """ 
24   
25   
26  import cairo 
27  import gtk 
28   
29  import graphics 
30  import shapes 
31  import preferences 
32   
33   
34 -class VisualWidget(gtk.DrawingArea):
35 """ 36 Widget for previewing preferences 37 """ 38 __gsignals__ = {"expose-event" : "override"} 39
40 - def __init__(self):
41 gtk.DrawingArea.__init__(self) 42 self.__checkerBoard = graphics.getCheckerPattern(16) 43 44 self.shapes = [] 45 vPoly = shapes.Polygon([ 46 shapes.Point(10, 10), 47 shapes.Point(10, 86), 48 shapes.Point(40, 86), 49 shapes.Point(86, 10), 50 ]) 51 iPoly = shapes.Polygon([ 52 shapes.Point(106, 10), 53 shapes.Point(96, 86), 54 shapes.Point(140, 86), 55 shapes.Point(120, 50), 56 shapes.Point(160, 10), 57 ]) 58 circle = shapes.Circle(35) 59 circle.setCenter(shapes.Point(200, 48)) 60 self.shapes.append(vPoly) 61 self.shapes.append(iPoly) 62 self.shapes.append(circle) 63 64 self.set_size_request(256, 96)
65
66 - def update(self):
67 """ 68 Updates the preview 69 """ 70 self.queue_draw()
71
72 - def do_expose_event(self, event):
73 context = self.window.cairo_create() 74 context.set_source(self.__checkerBoard) 75 context.paint() 76 size = self.window.get_size() 77 graphics.drawGrid(context, 16, size[0], size[1]) 78 for shape in self.shapes: 79 graphics.drawShape(shape, context, True)
80