source: subversion/applications/routing/pyroute/menuIcons.py @ 5708

Last change on this file since 5708 was 5708, checked in by ojw, 12 years ago

Split overlay module into helper files

File size: 883 bytes
Line 
1import cairo
2import os
3class menuIcons:
4    def __init__(self):
5        self.images = {}
6        self.cantLoad = []
7    def load(self,name):
8        filename = "icons/bitmap/%s.png" % name
9        if(not os.path.exists(filename)):
10            return(0)
11        self.images[name] = cairo.ImageSurface.create_from_png(filename)
12        if(self.images[name]):
13            return(1)
14        return(0)
15    def draw(self,cr,name,x,y,w,h):
16        if not name in self.images.keys():
17            if(name in self.cantLoad):
18                return
19            if(not self.load(name)):
20                self.cantLoad.append(name)
21                return
22        imagesize = 120.0
23        cr.save()
24        cr.translate(x,y)
25        cr.scale(w / imagesize, h / imagesize)
26        cr.set_source_surface(self.images[name],0,0)
27        cr.paint()
28        cr.restore()
29   
Note: See TracBrowser for help on using the repository browser.