Add an emoticons menu

This commit is contained in:
Marco Pesenti Gritti
2006-05-21 22:20:37 -04:00
parent 3841ac9983
commit 325fb8ff25
7 changed files with 102 additions and 133 deletions
+5 -8
View File
@@ -1,27 +1,25 @@
from SVGdraw import path
class Sketch:
def __init__(self, rgb):
def __init__(self):
self._points = []
self._rgb = (float(rgb[0]), float(rgb[1]), float(rgb[2]))
def add_point(self, x, y):
self._points.append((x, y))
self._points.append([x, y])
def draw(self, ctx):
start = True
for (x, y) in self._points:
for [x, y] in self._points:
if start:
ctx.move_to(x, y)
start = False
else:
ctx.line_to(x, y)
ctx.set_source_rgb(self._rgb[0], self._rgb[1], self._rgb[2])
ctx.stroke()
def draw_to_svg(self):
i = 0
for (x, y) in self._points:
for [x, y] in self._points:
coords = str(x) + ' ' + str(y) + ' '
if i == 0:
path_data = 'M ' + coords
@@ -30,5 +28,4 @@ class Sketch:
else:
path_data += coords
i += 1
color = "#%02X%02X%02X" % (255 * self._rgb[0], 255 * self._rgb[1], 255 * self._rgb[2])
return path(path_data, fill = 'none', stroke = color)
return path(path_data, fill = 'none', stroke = '#000000')
+1 -9
View File
@@ -13,7 +13,6 @@ class SketchPad(gtk.DrawingArea):
gtk.DrawingArea.__init__(self)
self._active_sketch = None
self._rgb = (0.0, 0.0, 0.0)
self._sketches = []
self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
@@ -24,7 +23,6 @@ class SketchPad(gtk.DrawingArea):
self.connect('expose_event', self.expose)
def expose(self, widget, event):
"""Draw the background of the sketchpad."""
rect = self.get_allocation()
ctx = widget.window.cairo_create()
@@ -40,11 +38,6 @@ class SketchPad(gtk.DrawingArea):
return False
def set_color(self, color):
"""Sets the current drawing color of the sketchpad.
color agument should be 3-item tuple of rgb values between 0 and 1."""
self._rgb = color
def add_sketch(self, sketch):
self._sketches.append(sketch)
@@ -54,7 +47,7 @@ class SketchPad(gtk.DrawingArea):
self.window.invalidate_rect(None, False)
def __button_press_cb(self, widget, event):
self._active_sketch = Sketch(self._rgb)
self._active_sketch = Sketch()
self.add_sketch(self._active_sketch)
self.add_point(event)
@@ -66,7 +59,6 @@ class SketchPad(gtk.DrawingArea):
self.add_point(event)
def to_svg(self):
"""Return a string containing an SVG representation of this sketch."""
d = drawing()
s = svg()
for sketch in self._sketches:
+2 -8
View File
@@ -18,9 +18,6 @@ class ColorButton(gtk.RadioButton):
self.add(drawing_area)
drawing_area.show()
def color(self):
return self._rgb
def expose(self, widget, event):
rect = widget.get_allocation()
ctx = widget.window.cairo_create()
@@ -34,9 +31,7 @@ class ColorButton(gtk.RadioButton):
class Toolbox(gtk.VBox):
__gsignals__ = {
'tool-selected': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([gobject.TYPE_STRING])),
'color-selected': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([gobject.TYPE_PYOBJECT]))
([gobject.TYPE_STRING]))
}
def __init__(self):
@@ -101,5 +96,4 @@ class Toolbox(gtk.VBox):
self.emit("tool-selected", tool_id)
def __color_clicked_cb(self, button, rgb):
self.emit("color-selected", button.color())
pass