Exemple #1
0
    def expose( self, *args ):
        """Draw the widget
        """
        if self.freeze_count > 0:
            return
            
        if not (self.flags() & gtk.REALIZED):
            return
        if not (self.flags() & gtk.MAPPED):
            return
            
        geom = self._area.get_allocation()
        pix = gtk.create_pixmap( self._area.get_window(), geom[2], geom[3] )    
        style = self.get_style()
        gtk.draw_rectangle(pix, style.white_gc, gtk.TRUE, 0, 0, 
                                  geom[2], geom[3])
        gtk.draw_rectangle(pix, style.black_gc, gtk.FALSE, 0, 0, 
                                  geom[2], geom[3])
        font = self.get_style().font
        
        v_offset = 0
        for line in self.contents[self.start_line:]:
            v_offset = v_offset + self.line_height
            gtk.draw_string( pix, font, style.black_gc, 3, 
                                    v_offset, line[self.start_col:] )
            if v_offset > geom[3]:
                break
        
        self._area.draw_pixmap(style.white_gc, pix, 0, 0, 0, 0, geom[2]-1, geom[3]-1 )

        return gtk.FALSE
Exemple #2
0
    def expose(self, *args):
        """Draw the widget
        """
        if self.freeze_count > 0:
            return

        if not (self.flags() & gtk.REALIZED):
            return
        if not (self.flags() & gtk.MAPPED):
            return

        geom = self._area.get_allocation()
        pix = gtk.create_pixmap(self._area.get_window(), geom[2], geom[3])
        style = self.get_style()
        gtk.draw_rectangle(pix, style.white_gc, gtk.TRUE, 0, 0, geom[2],
                           geom[3])
        gtk.draw_rectangle(pix, style.black_gc, gtk.FALSE, 0, 0, geom[2],
                           geom[3])
        font = self.get_style().font

        v_offset = 0
        for line in self.contents[self.start_line:]:
            v_offset = v_offset + self.line_height
            gtk.draw_string(pix, font, style.black_gc, 3, v_offset,
                            line[self.start_col:])
            if v_offset > geom[3]:
                break

        self._area.draw_pixmap(style.white_gc, pix, 0, 0, 0, 0, geom[2] - 1,
                               geom[3] - 1)

        return gtk.FALSE
Exemple #3
0
    def configure(self, widget, event, *args):
        """Track changes in width, height
        """
        #only do this if we have been realized
        if not self.flags() & gtk.REALIZED:
            return

        # create a memory pixmap to render into
        a_win = self._area.get_window()
        self._pixmap = gtk.create_pixmap(a_win, event.width, event.height)

        style = self.get_style()

        if self.title_font is None:
            try:
                self.title_font = gtk.load_font(self.title_font_spec)
            except:
                self.title_font = style.font
            self.title_height = self.title_font.ascent

        if self.cell_font is None:
            try:
                self.cell_font = gtk.load_font(self.cell_font_spec)
            except:
                self.cell_font = style.font
            self.row_height = self.cell_font.ascent

        self.bCalcAdjustments = gtk.TRUE
Exemple #4
0
    def configure( self, widget, event, *args ):
        """Track changes in width, height
        """
        #only do this if we have been realized
        if not self.flags() & gtk.REALIZED:
            return
            
        # create a memory pixmap to render into
        a_win = self._area.get_window()
        self._pixmap = gtk.create_pixmap( a_win, event.width, event.height )    
        
        style = self.get_style()

        if self.title_font is None:
            try:
                self.title_font = gtk.load_font( self.title_font_spec )
            except:
                self.title_font = style.font
            self.title_height = self.title_font.ascent

        if self.cell_font is None:
            try:
                self.cell_font = gtk.load_font( self.cell_font_spec )
            except:
                self.cell_font = style.font
            self.row_height = self.cell_font.ascent

        self.bCalcAdjustments=gtk.TRUE
Exemple #5
0
def configure_event(widget, event):
    global pixmap

    x, y, width, height = widget.get_allocation()
    pixmap = gtk.create_pixmap(widget.get_window(), width, height, -1)
    gtk.draw_rectangle(pixmap, widget.get_style().white_gc, gtk.TRUE, 0, 0, width, height)

    return gtk.TRUE
Exemple #6
0
def configure_event(widget, event):
    global pixmap

    x, y, width, height = widget.get_allocation()
    pixmap = gtk.create_pixmap(widget.get_window(), width, height, -1)
    gtk.draw_rectangle(pixmap, widget.get_style().white_gc,
                       gtk.TRUE, 0, 0, width, height)

    return gtk.TRUE
Exemple #7
0
    def __init__(self, width, height, title, zoom="100"):
        if zoom.endswith('%'):
            zoom = zoom[:-1]
        scale = float(zoom) / 100.0
        iscale = int(scale+0.001)
        if abs(scale - iscale) < 0.002:
            scale = iscale
        self.scale = scale
        
        self.width  = int(width * scale)
        self.height = int(height * scale)
        self.tempppmfile = caching.mktemp('.ppm')

        # create a top level window
        w = self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        w.connect("destroy", lambda w: sys.exit())
        w.connect("key-press-event", self.key_press_event)
        w.connect("key-release-event", self.key_release_event)
        w.connect("motion-notify-event", self.motion_notify_event)
        w.connect("button-press-event", self.button_press_event)
        w.add_events(gdk.KEY_PRESS_MASK |
                     gdk.POINTER_MOTION_MASK |
                     gdk.BUTTON_PRESS_MASK)
        w.resize(self.width, self.height)
        w.set_title(title)
        w.show()

        self.offscreen = gtk.create_pixmap(w.window, self.width, self.height)
        self.gc = gdk.gc_new(w.window)
        self.gc.set_rgb_fg_color(gdk.color_parse('#000000'))

        self.events_key = []
        self.events_mouse = []
        self.event_motion = None

        pixel = "\x00\x00\x80"
        hole  = "\x01\x01\x01"
        pb = self.pixmap(32, 32, ((pixel+hole)*16 + (hole+pixel)*16) * 16, 0x010101)
        self.taskbkgnd = self.renderpixbuf(pb)
 def resize(self):
     widget = self.area
     x, y, w, h = widget.get_allocation()
     self.scratch = gtk.create_pixmap(widget.get_window(), w, h, -1)
Exemple #9
0
 def resize(self):
     widget = self.area
     x, y, w, h = widget.get_allocation()
     self.scratch = gtk.create_pixmap(widget.get_window(), w, h, -1)
Exemple #10
0
    def draw(self,
             win,
             event,
             set_pixmap,
             del_pixmap,
             start_bar=None,
             numbars=None):
        """ chart arg is a hash from the table.py file, specifically the ChartT
        hash. The draw function calls the subchart draw functions.
        """
        # use temps to save on lookups
        if start_bar == None:
            start_bar = self.get_start_bar()
        else:
            self.set_start_bar(start_bar)
        if numbars == None:
            numbars = self.get_numbars()
        else:
            self.set_numbars(numbars)
        (x, y, width, height) = win.get_allocation()
        self.set_x(x)
        self.set_y(y)
        self.set_width(width)
        self.set_height(height)
        pixmap_x = x
        pixmap_y = y
        pixmap_width = width
        pixmap_height = height
        del_pixmap()
        p = gtk.create_pixmap(win, pixmap_width, pixmap_height)
        s = gtk.create_pixmap(win, pixmap_width, pixmap_height)
        drawing.set_primary_pixmap(p)
        drawing.set_secondary_pixmap(s)
        drawing.set_window(win)
        drawing.set_drawline_func(gtk.draw_line)
        drawing.set_drawrectangle_func(gtk.draw_rectangle)
        drawing.set_drawtext_func(gtk.draw_text)
        drawing.set_drawpoints_func(gtk.draw_points)
        self.set_start_bar(start_bar)
        start_bar = self.get_start_bar()
        self.prev_values['x'] = x
        self.prev_values['y'] = y
        self.prev_values['width'] = width
        self.prev_values['height'] = height
        self.prev_values['numbars'] = numbars
        self.prev_values['start_bar'] = start_bar
        self.draw_background(win, p)
        self.draw_background(win, s)
        width = width - (self.get_horizontal_border() * 2) - self.yscale_space
        self.set_xscale(float(width) / float(numbars))
        dataset = self.get_current_dataset()
        nsubchart = len(self.subchart_order)
        vertical_space = height - (self.get_vertical_border() * \
                                   nsubchart) - self.xscale_space
        if nsubchart > 1:
            # ssh is secondary subchart height
            ssh = 0.0
            ssh = (float(nsubchart) * float(10)) / (float(100) *
                                                    (float(nsubchart) - 1))
            secsubheight = vertical_space * ssh
            prisubheight = vertical_space - ((nsubchart - 1) * secsubheight)
            y1 = (self.get_vertical_border() * nsubchart) + \
                 prisubheight + ((nsubchart-1) * secsubheight)
        else:
            prisubheight = vertical_space
            y1 = self.get_vertical_border() + prisubheight

        x1 = self.get_horizontal_border()
        XScale.draw(self.dsget('date'), x1, y1, width, self.xscale_space,
                    start_bar, numbars, self.get_xscale(),
                    self.get_vertical_border(), self.get_current_scale())
        for sc in xrange(0, len(self.subchart_order)):
            if sc == 0:
                x1 = self.get_horizontal_border()
                y1 = self.get_vertical_border()
                sbheight = prisubheight
            else:
                x1 = self.get_horizontal_border()
                y1 = (self.get_vertical_border() * (sc + 1)) + \
                     prisubheight + (secsubheight * (sc - 1))
                sbheight = secsubheight
            self.subchart_coords[sc]['y'] = y1
            self.subchart_coords[sc]['height'] = sbheight
            self.subchart[self.subchart_order[sc]].draw(
                start_bar, numbars, self.get_xscale(),
                self.get_current_dataset(), x1, y1, sbheight, width,
                self.yscale_space, self.get_calc_next_draw(),
                self.get_current_scale())
        self.reset_calc_next_draw()
        set_pixmap(p, s)
        win.draw((pixmap_x, pixmap_y, pixmap_width, pixmap_height))
Exemple #11
0
def configure_event(widget, event):
  global pixmap
  win = widget.get_window()
  pixmap = gtk.create_pixmap(win, win.width, win.height, -1)
  return gtk.TRUE
Exemple #12
0
    def getppm(self, (x, y, w, h), int=int, ceil=math.ceil):
        scale = self.scale
        if isinstance(scale, int):
            x *= scale
            y *= scale
            w *= scale
            h *= scale
        else:
            w = int(ceil((x+w)*scale))
            h = int(ceil((y+h)*scale))
            x = int(x*scale)
            y = int(y*scale)
            w -= x
            h -= y
        bkgnd = gtk.create_pixmap(self.window.window, w, h)
        bkgnd.draw_drawable(self.gc, self.offscreen, x, y, 0, 0, w, h)
        return bkgnd, self.gc, None

    def putppm(self, x, y, (pixmap, gc, ignored), rect=None, int=int):
        if pixmap is None:
            return
        scale = self.scale
        if rect is None:
            srcx = srcy = 0
            w = h = 4095
        else:
            srcx, srcy, w, h = rect
        x = int(x*scale)
        y = int(y*scale)
        if gc is not self.gc: