Beispiel #1
0
    def area_expose_cb(self, area, event):

        style = self.get_style()
        self.gc = style.fg_gc[Gtk.StateType.NORMAL]

        gcx = Gdk.GC(self.window); gcx.copy(self.gc)
        gcx.set_foreground(self.fgcolor)

        self.setfont("system", 14)
        self.pangolayout.set_text(self.head)
        x = 2 * self.gap; y = self.gap
        self.window.draw_layout(gcx, x, y, self.pangolayout, self.fgcolor, self.bgcolor)
        cxx, cyy = self.pangolayout.get_pixel_size()

        self.setfont("system", 11)
        self.pangolayout.set_text(self.text)
        x = 2 * self.gap; y += self.cyy + self.cyy / 2
        self.window.draw_layout(gcx, x, y, self.pangolayout, self.fgcolor, self.bgcolor)
        cxx2, cyy2 = self.pangolayout.get_pixel_size()

        #print  cxx, cyy, cxx2, cyy2

        # Resize if needed:
        if cxx < cxx2: cxx = cxx2
        rqx = cxx + 4 * self.gap;
        rqy = cyy + cyy2 + 2 * self.gap

        self.ww, self.hh = self.get_size_request()
        if self.ww != rqx or self.hh != rqy:
            self.set_size_request(rqx, rqy)

        win = self.get_window()
        ww, hh = Gdk.Window.get_size(win)

        #print "ww,hh", ww, hh
        ww -= 1; hh -= 1

        # Draw Closer cross
        ulx = ww -  12;  uly = 2
        urx = ww -   2;  ury = 2
        llx = ww -  12;  lly = 12
        lrx = ww -   2;  lry = 12

        gcx.set_line_attributes(1, Gdk.LINE_SOLID,
                        Gdk.CAP_NOT_LAST, Gdk.JOIN_MITER)

        win.draw_line(gcx, ulx, uly, lrx, lry)
        win.draw_line(gcx, llx, lly, urx, ury)

        # Draw frame
        gcx.set_line_attributes(2, Gdk.LINE_SOLID,
            Gdk.CAP_BUTT, Gdk.JOIN_MITER)
        gcx.set_foreground(self.frcolor)
        win.draw_line(gcx, 0, 0, ww, 0)
        win.draw_line(gcx, ww, 0, ww, hh)
        win.draw_line(gcx, 0, 0, 0, hh)
        win.draw_line(gcx, 0, hh, ww, hh)
Beispiel #2
0
 def on_realize(self, entry):
     layout = self.get_layout().copy()
     layout.set_markup("<span foreground='dark gray'>%s</span>" %
                       self.default_text)
     extents = layout.get_pixel_extents()[1]
     drawable = Gdk.Pixmap(self.get_parent_window(), extents[2], extents[3])
     gc = Gdk.GC(drawable)
     gc2 = entry.props.style.base_gc[0]
     drawable.draw_rectangle(gc2, True, *extents)
     drawable.draw_layout(gc, 0, 0, layout)
     pixbuf = GdkPixbuf.Pixbuf(Gdk.COLORSPACE_RGB, True, 8, extents[2],
                               extents[3])
     pixbuf.get_from_drawable(drawable, drawable.get_colormap(), 0, 0,
                              *extents)
     self.empty_pixbuf = pixbuf
     if not Gtk.Entry.get_text(self):
         self.props.primary_icon_pixbuf = pixbuf