Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathalia <you@yourdomain.example.com>2007-08-17 18:37:54 (GMT)
committer nathalia <you@yourdomain.example.com>2007-08-17 18:37:54 (GMT)
commitd4f602d3ae8932e9f566df868c706f740d59acab (patch)
treed03d311f6bec11f20ed1cd5b927dfe9518d94796
parentb672db33902f3f237f01007729d1f543111069a7 (diff)
modifing some functions: square, circle, selection
-rw-r--r--[-rwxr-xr-x]Area.py124
-rw-r--r--[-rwxr-xr-x]Desenho.py164
-rw-r--r--[-rwxr-xr-x]toolbox.py17
3 files changed, 208 insertions, 97 deletions
diff --git a/Area.py b/Area.py
index 751a89d..fb3bf22 100755..100644
--- a/Area.py
+++ b/Area.py
@@ -61,7 +61,8 @@ import gtk, gobject, logging, os
import math
import pango
from fill import *
-
+import Image
+import StringIO
from Desenho import Desenho
WIDTH = 800
@@ -75,7 +76,7 @@ class Area(gtk.DrawingArea):
'action-saved' : (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])),
#TODO: these signals still not used.
# 'copy' : (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])),
-# 'selected' : (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])),
+ 'selected' : (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])),
}
def __init__(self, janela):
@@ -294,17 +295,18 @@ class Area(gtk.DrawingArea):
# ellipse
elif self.tool == 'ellipse':
self.configure_line(self.line_size)
- self.d.circle(widget,coords)
+ self.d.circle(widget,coords,True,True)
# rectangle
elif self.tool == 'rectangle':
self.configure_line(self.line_size)
- self.d.square(widget,coords)
+ self.d.square(widget,coords,True,True)
# selection
elif self.tool == 'marquee-rectangular' and not self.selmove:
- self.d.selection(widget,coords)
+ x1, y1, x2, y2 = self.d.selection(widget,coords,True,False)
+ self._set_selection_bounds(x1, y1, x2, y2)
# selection
elif self.tool == 'marquee-rectangular' and self.selmove:
- self.d.moveSelection(widget, coords)
+ self.d.moveSelection(widget,coords)
#polygon
elif self.tool == 'polygon':
self.configure_line(self.line_size)
@@ -312,28 +314,28 @@ class Area(gtk.DrawingArea):
#triangle
elif self.tool == 'triangle':
self.configure_line(self.line_size)
- self.d.triangle(widget,coords,True)
+ self.d.triangle(widget,coords,True,True)
#trapezoid
elif self.tool == 'trapezoid':
self.configure_line(self.line_size)
- self.d.trapezoid(widget,coords,True)
+ self.d.trapezoid(widget,coords,True,True)
#arrow
elif self.tool == 'arrow':
self.configure_line(self.line_size)
- self.d.arrow(widget,coords,True)
+ self.d.arrow(widget,coords,True,True)
#parallelogram
elif self.tool == 'parallelogram':
self.configure_line(self.line_size)
- self.d.parallelogram(widget,coords,True)
+ self.d.parallelogram(widget,coords,True,True)
#star
elif self.tool == 'star':
self.configure_line(self.line_size)
- self.d.star(widget,coords,True)
+ self.d.star(widget,coords,True,True)
#polygon regular
elif self.tool == 'polygon_regular':
self.configure_line(self.line_size)
n = 7
- self.d.polygon_regular(widget,coords,n,True)
+ self.d.polygon_regular(widget,coords,n,True,True)
def mouseup(self,widget,event):
"""Make the Area object (GtkDrawingArea) recognize that the mouse was released.
@@ -345,6 +347,7 @@ class Area(gtk.DrawingArea):
"""
coords = int(event.x), int(event.y)
+ width, height = self.window.get_size()
if self.desenha == True:
# line
if self.tool == 'line':
@@ -353,34 +356,37 @@ class Area(gtk.DrawingArea):
self.enableUndo(widget)
# ellipse
elif self.tool == 'ellipse':
- self.pixmap.draw_arc(self.gc, True, self.newx, self.newy, self.newx_, self.newy_, 0, 360*64)
- self.pixmap.draw_arc(self.gc_line, False, self.newx, self.newy, self.newx_, self.newy_, 0, 360*64)
- widget.queue_draw()
+ self.d.circle(widget,coords,False,True)
+ #self.pixmap.draw_arc(self.gc, True, self.newx, self.newy, self.newx_, self.newy_, 0, 360*64)
+ #self.pixmap.draw_arc(self.gc_line, False, self.newx, self.newy, self.newx_, self.newy_, 0, 360*64)
+ #widget.queue_draw()
self.enableUndo(widget)
# rectangle
- elif self.tool == 'rectangle':
- self.pixmap.draw_rectangle(self.gc, True, self.newx,self.newy, self.newx_,self.newy_)
- self.pixmap.draw_rectangle(self.gc_line, False, self.newx,self.newy, self.newx_,self.newy_)
- widget.queue_draw()
+ elif self.tool == 'rectangle':
+ self.d.square(widget,coords,False,True)
+ #self.pixmap.draw_rectangle(self.gc, True, self.newx,self.newy, self.newx_,self.newy_)
+ #self.pixmap.draw_rectangle(self.gc_line, False, self.newx,self.newy, self.newx_,self.newy_)
+ #widget.queue_draw()
self.enableUndo(widget)
# selection
elif self.tool == 'marquee-rectangular':
# FIXME: Adicionar cursor formato selecao
if self.selmove == False:
- self.pixmap_temp.draw_drawable(self.gc,self.pixmap, 0 , 0 ,0,0, WIDTH, HEIGHT)
- self.pixmap_sel.draw_drawable(self.gc,self.pixmap, 0 , 0 ,0,0, WIDTH, HEIGHT)#avoid blink
+ self.pixmap_temp.draw_drawable(self.gc,self.pixmap, 0 , 0 ,0,0, width, height)
+ self.pixmap_sel.draw_drawable(self.gc,self.pixmap, 0 , 0 ,0,0, width, height)#avoid blink
self.sx = int (event.x)
self.sy = int(event.y)
self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))
self.selmove = True
self.sel_get_out = False
elif self.selmove and self.sel_get_out: #get out of the func selection
- self.pixmap.draw_drawable(self.gc, self.pixmap_temp, 0,0,0,0, WIDTH, HEIGHT)
+ self.pixmap.draw_drawable(self.gc, self.pixmap_temp, 0,0,0,0, width, height)
self.selmove = False
self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.TCROSS))
self.oldx = event.x
self.oldy = event.y
self.enableUndo(widget)
+ self.emit('selected')
# polygon
elif self.tool == 'polygon':
self.d.polygon(widget, coords, False, False)
@@ -396,28 +402,28 @@ class Area(gtk.DrawingArea):
self.enableUndo(widget)
#triangle
elif self.tool == 'triangle':
- self.d.triangle(widget,coords,False)
+ self.d.triangle(widget,coords,False,True)
self.enableUndo(widget)
#trapezoid
elif self.tool == 'trapezoid':
- self.d.trapezoid(widget,coords,False)
+ self.d.trapezoid(widget,coords,False,True)
self.enableUndo(widget)
#arrow
elif self.tool == 'arrow':
- self.d.arrow(widget,coords,False)
+ self.d.arrow(widget,coords,False,True)
self.enableUndo(widget)
#parallelogram
elif self.tool == 'parallelogram':
- self.d.parallelogram(widget,coords,False)
+ self.d.parallelogram(widget,coords,False,True)
self.enableUndo(widget)
#star
elif self.tool == 'star':
- self.d.star(widget,coords,False)
+ self.d.star(widget,coords,False,True)
self.enableUndo(widget)
#polygon regular
elif self.tool == 'polygon_regular':
n = 7
- self.d.polygon_regular(widget,coords,n,False)
+ self.d.polygon_regular(widget,coords,n,False,True)
self.enableUndo(widget)
if self.tool == 'brush' or self.tool == 'eraser':
@@ -435,6 +441,7 @@ class Area(gtk.DrawingArea):
"""
logging.debug('Area.undo(self)')
+ width, height = self.window.get_size()
if self.first_undo:#if is the first time you click on UNDO
self.undo_times -= 1
@@ -445,7 +452,7 @@ class Area(gtk.DrawingArea):
self.redo_times += 1
try: #to not try paint someting wrong
#print "Drawing undo[%d]" %(self.undo_times)
- self.pixmap.draw_drawable(self.gc, self.undo_list[self.undo_times], 0,0,0,0, WIDTH, HEIGHT)
+ self.pixmap.draw_drawable(self.gc, self.undo_list[self.undo_times], 0,0,0,0, width, height)
except:
print "Can't draw"
pass
@@ -479,6 +486,7 @@ class Area(gtk.DrawingArea):
"""
logging.debug('Area.redo(self)')
+ width, height = self.window.get_size()
#print "REDO no.%d" %(self.redo_times)
if (self.redo_times>0):
@@ -487,7 +495,7 @@ class Area(gtk.DrawingArea):
try: #to not try paint someting wrong
#print "Drawing undo[%d]" %(self.undo_times)
- self.pixmap.draw_drawable(self.gc, self.undo_list[self.undo_times], 0,0,0,0, WIDTH, HEIGHT)
+ self.pixmap.draw_drawable(self.gc, self.undo_list[self.undo_times], 0,0,0,0, width, height)
except:
print "Can't draw"
self.undo_times-=1
@@ -512,13 +520,14 @@ class Area(gtk.DrawingArea):
"""
logging.debug('Area.enableUndo(self,widget)')
+ width, height = self.window.get_size()
if self.undo_surf:
self.undo_times += 1
self.undo_list.append(None)#alloc memory
- self.undo_list[self.undo_times] = gtk.gdk.Pixmap(widget.window, WIDTH, HEIGHT, -1) #define type
- self.undo_list[self.undo_times].draw_drawable(self.gc,self.pixmap,0,0,0,0, WIDTH, HEIGHT) #copy workarea
+ self.undo_list[self.undo_times] = gtk.gdk.Pixmap(widget.window, width, height, -1) #define type
+ self.undo_list[self.undo_times].draw_drawable(self.gc,self.pixmap,0,0,0,0, width, height) #copy workarea
self.undo_times += 1
self.redo_times = 0
self.first_undo = True
@@ -668,7 +677,22 @@ class Area(gtk.DrawingArea):
self.queue_draw()
self.enableUndo(widget)
- def _rotate_left(self):
+ def _pixbuf2Image(self, pb):
+ width,height = pb.get_width(),pb.get_height()
+ return Image.fromstring("RGB",(width,height),pb.get_pixels() )
+
+ def _image2pixbuf(self, im):
+ file1 = StringIO.StringIO()
+ im.save(file1, "ppm")
+ contents = file1.getvalue()
+ file1.close()
+ loader = gtk.gdk.PixbufLoader("pnm")
+ loader.write(contents, len(contents))
+ pixbuf = loader.get_pixbuf()
+ loader.close()
+ return pixbuf
+
+ def _rotate_left(self, widget):
"""Rotate the image.
Keyword arguments:
@@ -676,13 +700,27 @@ class Area(gtk.DrawingArea):
"""
logging.debug('Area._rotate_left(self)')
-
- pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, WIDTH, HEIGHT)
- pix_ = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, WIDTH, HEIGHT)
- pix.get_from_drawable(self.pixmap, gtk.gdk.colormap_get_system(), 0, 0, 0, 0, -1, -1)
- pix_ = pix.rotate_simple(gtk.gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE)
- self.pixmap.draw_pixbuf(self.gc, pix_, 0, 0, 0, 0, width=-1, height=-1, dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
- self.queue_draw()
+
+ x1, y1, x2, y2 = self.get_selection_bounds()
+ #x1, y1, x2, y2 = 0, 0, 100, 200
+ if self.selmove:
+ pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, x2 - x1, y2 - y1)
+ pix_ = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, x2 - x1, y2 - y1)
+ pix.get_from_drawable(self.pixmap, gtk.gdk.colormap_get_system(), x1, y1, 0, 0, x2 - x1, y2 - y1)
+
+ im = self._pixbuf2Image(pix)
+ #pix_ = pix.rotate_simple(gtk.gdk.PIXBUF_ROTATE_CLOCKWISE)
+
+ im_ = im.rotate(90)
+
+ pix_ = self._image2pixbuf(im_)
+
+ self.pixmap.draw_pixbuf(self.gc, pix_, 0, 0, x1, y1, width=-1, height=-1, dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
+ self.queue_draw()
+ self.enableUndo(widget)
+
+ else :
+ print "Please select some area first"
def can_undo(self):
'''
@@ -705,4 +743,10 @@ class Area(gtk.DrawingArea):
return False
else:
return True
+
+ def _set_selection_bounds(self, x1, y1, x2, y2):
+ self._selection_corners = (x1, y1, x2, y2)
+
+ def get_selection_bounds(self):
+ return self._selection_corners[0], self._selection_corners[1], self._selection_corners[2], self._selection_corners[3]
diff --git a/Desenho.py b/Desenho.py
index 1049e27..3c3c767 100755..100644
--- a/Desenho.py
+++ b/Desenho.py
@@ -87,8 +87,8 @@ class Desenho:
"""
self.d.pixmap_temp.draw_drawable(self.d.gc,self.d.pixmap, 0 , 0 ,0,0, WIDTH, HEIGHT)
self.d.pixmap_temp.draw_line(self.d.gc_line,self.d.oldx,self.d.oldy,coords[0],coords[1])
- self.d.newx = coords[0]
- self.d.newy = coords[1]
+ #self.d.newx = coords[0]
+ #self.d.newy = coords[1]
widget.queue_draw()
def eraser(self, widget, coords, size = 30, shape = 'circle'):
@@ -135,7 +135,7 @@ class Desenho:
self.d.oldy = coords[1]
widget.queue_draw()
- def square(self, widget, coords):
+ def square(self, widget, coords, temp, fill):
"""Draw a square.
Keyword arguments:
@@ -143,9 +143,7 @@ class Desenho:
widget -- Area object (GtkDrawingArea)
coords -- Two value tuple
- """
- widget.queue_draw()
-
+
if coords[0] > WIDTH:
coords0 = WIDTH
else:
@@ -178,13 +176,33 @@ class Desenho:
else:
self.d.newy = 0
self.d.newy_ = self.d.oldy
-
- self.d.pixmap_temp.draw_drawable(self.d.gc,self.d.pixmap, 0 , 0 ,0,0, WIDTH, HEIGHT)
- self.d.pixmap_temp.draw_rectangle(self.d.gc, True ,self.d.newx,self.d.newy,self.d.newx_,self.d.newy_)
- self.d.pixmap_temp.draw_rectangle(self.d.gc_line, False ,self.d.newx,self.d.newy,self.d.newx_,self.d.newy_)
+ """
+ if temp == True:
+ pixmap = self.d.pixmap_temp
+ else:
+ pixmap = self.d.pixmap
+ width, height = self.d.window.get_size()
+
+ dx = math.fabs(coords[0] - self.d.oldx)
+ dy = math.fabs(coords[1] - self.d.oldy)
+
+ if coords[0] < self.d.oldx:
+ x = coords[0]
+ else:
+ x = self.d.oldx
+ if coords[1] < self.d.oldy:
+ y = coords[1]
+ else:
+ y = self.d.oldy
+
+ pixmap.draw_drawable(self.d.gc,self.d.pixmap,0,0,0,0,width,height)
+ if fill == True:
+ pixmap.draw_rectangle(self.d.gc,True,x,y,dx,dy)
+ pixmap.draw_rectangle(self.d.gc_line,False,x,y,dx,dy)
+ widget.queue_draw()
- def triangle(self, widget, coords, temp):
+ def triangle(self, widget, coords, temp, fill):
"""Draw a triangle.
Keyword arguments:
@@ -201,13 +219,14 @@ class Desenho:
width, height = self.d.window.get_size()
points = [(self.d.oldx,self.d.oldy), (self.d.oldx+int((coords[0]-self.d.oldx)/2),coords[1]), (coords[0],self.d.oldy)]
- pixmap.draw_drawable(self.d.gc, self.d.pixmap, 0, 0, 0, 0, width, height)
- pixmap.draw_polygon(self.d.gc, True, points)
- pixmap.draw_polygon(self.d.gc_line, False, points)
+ pixmap.draw_drawable(self.d.gc,self.d.pixmap,0,0,0,0,width,height)
+ if fill == True:
+ pixmap.draw_polygon(self.d.gc,True,points)
+ pixmap.draw_polygon(self.d.gc_line,False,points)
widget.queue_draw()
- def trapezoid(self, widget, coords, temp):
+ def trapezoid(self, widget, coords, temp, fill):
"""Draw a trapezoid.
Keyword arguments:
@@ -225,13 +244,14 @@ class Desenho:
dif = int((coords[0] - self.d.oldx)/4)
points = [(self.d.oldx, self.d.oldy), (self.d.oldx+dif, coords[1]), (coords[0]-dif, coords[1]) , (coords[0],self.d.oldy)]
- pixmap.draw_drawable(self.d.gc,self.d.pixmap, 0 , 0 , 0, 0, width, height)
- pixmap.draw_polygon(self.d.gc, True, points)
- pixmap.draw_polygon(self.d.gc_line, False, points)
+ pixmap.draw_drawable(self.d.gc,self.d.pixmap,0,0,0,0,width,height)
+ if fill == True:
+ pixmap.draw_polygon(self.d.gc, True, points)
+ pixmap.draw_polygon(self.d.gc_line,False,points)
widget.queue_draw()
- def arrow(self, widget, coords, temp):
+ def arrow(self, widget, coords, temp, fill):
"""Draw a arrow.
Keyword arguments:
@@ -255,13 +275,14 @@ class Desenho:
(self.d.oldx+x,self.d.oldy-int(y/3)),\
(self.d.oldx+int(x/6),self.d.oldy-int(y/3)),\
(self.d.oldx+int(x/6),self.d.oldy-y)]
- pixmap.draw_drawable(self.d.gc,self.d.pixmap, 0, 0, 0, 0, width, height)
- pixmap.draw_polygon(self.d.gc, True, points)
- pixmap.draw_polygon(self.d.gc_line, False, points)
+ pixmap.draw_drawable(self.d.gc,self.d.pixmap,0,0,0,0,width,height)
+ if fill == True:
+ pixmap.draw_polygon(self.d.gc,True,points)
+ pixmap.draw_polygon(self.d.gc_line,False,points)
widget.queue_draw()
- def parallelogram(self, widget, coords, temp):
+ def parallelogram(self, widget, coords, temp, fill):
"""Draw a parallelogram.
Keyword arguments:
@@ -279,12 +300,13 @@ class Desenho:
x = int((coords[0] - self.d.oldx)/4)
points = [(self.d.oldx,self.d.oldy), (coords[0]-x, self.d.oldy), (coords[0],coords[1]), (self.d.oldx+x,coords[1])]
pixmap.draw_drawable(self.d.gc,self.d.pixmap,0,0,0,0,width,height)
- pixmap.draw_polygon(self.d.gc, True, points)
- pixmap.draw_polygon(self.d.gc_line, False, points)
+ if fill == True:
+ pixmap.draw_polygon(self.d.gc,True,points)
+ pixmap.draw_polygon(self.d.gc_line,False,points)
widget.queue_draw()
- def star(self, widget, coords, temp):
+ def star(self, widget, coords, temp, fill):
"""Draw a arrow.
Keyword arguments:
@@ -312,13 +334,14 @@ class Desenho:
(self.d.oldx-int(x*0.35), self.d.oldy+int(y*0.6)),\
(self.d.oldx-int(x), self.d.oldy+int(y*0.4)),\
(self.d.oldx-int(x*0.25), self.d.oldy+int(y*0.4))]
- pixmap.draw_drawable(self.d.gc,self.d.pixmap, 0 , 0 ,0,0, width, height)
- pixmap.draw_polygon(self.d.gc, True, points)
- pixmap.draw_polygon(self.d.gc_line, False, points)
+ pixmap.draw_drawable(self.d.gc,self.d.pixmap,0,0,0,0,width,height)
+ if fill == True:
+ pixmap.draw_polygon(self.d.gc,True,points)
+ pixmap.draw_polygon(self.d.gc_line,False,points)
widget.queue_draw()
- def polygon_regular(self, widget, coords, n, temp):
+ def polygon_regular(self, widget, coords, n, temp, fill):
"""Draw polygon with n sides.
Keyword arguments:
@@ -346,13 +369,14 @@ class Desenho:
p.append((self.d.oldx+int(r*math.cos(A)),self.d.oldy+int(r*math.sin(A))))
tp = tuple(p)
- pixmap.draw_drawable(self.d.gc, self.d.pixmap, 0, 0, 0, 0, width, height)
- pixmap.draw_polygon(self.d.gc, True, tp)
- pixmap.draw_polygon(self.d.gc_line, False, tp)
+ pixmap.draw_drawable(self.d.gc,self.d.pixmap,0,0,0,0,width,height)
+ if fill == True:
+ pixmap.draw_polygon(self.d.gc,True,tp)
+ pixmap.draw_polygon(self.d.gc_line,False,tp)
widget.queue_draw()
- def circle(self, widget, coords):
+ def circle(self, widget, coords, temp, fill):
"""Draw a circle.
Keyword arguments:
@@ -360,9 +384,6 @@ class Desenho:
widget -- Area object (GtkDrawingArea)
coords -- Two value tuple
- """
- widget.queue_draw()
-
if coords[0] > WIDTH:
coords0 = WIDTH
else:
@@ -375,7 +396,6 @@ class Desenho:
self.d.newx_ = coords0 - self.d.oldx
self.d.newy_ = coords1 - self.d.oldy
- #print "coords0", coords0
if self.d.newx_ >= 0:
self.d.newx = self.d.oldx
@@ -386,22 +406,44 @@ class Desenho:
else:
self.d.newx = 0
self.d.newx_ = self.d.oldx
-
+
if self.d.newy_ >= 0:
self.d.newy = self.d.oldy
- else:
- if coords1 > 0:
- self.d.newy = coords1
+ else:
+ if coords1 > 0:
self.d.newy_ = - self.d.newy_
+ self.d.newy = coords1
else:
self.d.newy = 0
self.d.newy_ = self.d.oldy
- self.d.pixmap_temp.draw_drawable(self.d.gc,self.d.pixmap, 0 , 0 ,0,0, WIDTH, HEIGHT)
- self.d.pixmap_temp.draw_arc(self.d.gc, True, self.d.newx, self.d.newy, self.d.newx_,self.d.newy_, 0, 360*64)
- self.d.pixmap_temp.draw_arc(self.d.gc_line, False, self.d.newx, self.d.newy, self.d.newx_, self.d.newy_, 0, 360*64)
+ """
+
+ if temp == True:
+ pixmap = self.d.pixmap_temp
+ else:
+ pixmap = self.d.pixmap
+ width, height = self.d.window.get_size()
+
+ if coords[0] < self.d.oldx:
+ x = coords[0]
+ else:
+ x = self.d.oldx
+ if coords[1] < self.d.oldy:
+ y = coords[1]
+ else:
+ y = self.d.oldy
+
+ dx = math.fabs(coords[0] - self.d.oldx)
+ dy = math.fabs(coords[1] - self.d.oldy)
+
+ pixmap.draw_drawable(self.d.gc,self.d.pixmap,0,0,0,0,width,height)
+ if fill == True:
+ pixmap.draw_arc(self.d.gc,True,x,y,dx,dy,0,360*64)
+ pixmap.draw_arc(self.d.gc_line,False,x,y,dx,dy,0,360*64)
+ widget.queue_draw()
+
-
def pencil(self, widget, coords):
"""Draw a pencil.
@@ -474,7 +516,7 @@ class Desenho:
self.d.queue_draw()
- def selection(self, widget, coords):
+ def selection(self, widget, coords, temp, fill):
"""Make a selection.
Keyword arguments:
@@ -482,7 +524,7 @@ class Desenho:
widget -- Area object (GtkDrawingArea)
coords -- Two value tuple
- """
+
widget.queue_draw()
if coords[0] > WIDTH:
@@ -522,6 +564,32 @@ class Desenho:
self.d.pixmap_temp.draw_rectangle(self.d.gc_selection, False ,self.d.newx,self.d.newy,self.d.newx_,self.d.newy_)
self.d.pixmap_temp.draw_rectangle(self.d.gc_selection1, False, \
self.d.newx-1,self.d.newy-1,self.d.newx_+2,self.d.newy_+2)
+ """
+
+ if temp == True:
+ pixmap = self.d.pixmap_temp
+ else:
+ pixmap = self.d.pixmap
+ width, height = self.d.window.get_size()
+
+ dx = math.fabs(coords[0] - self.d.oldx)
+ dy = math.fabs(coords[1] - self.d.oldy)
+
+ if coords[0] < self.d.oldx:
+ x = coords[0]
+ else:
+ x = self.d.oldx
+ if coords[1] < self.d.oldy:
+ y = coords[1]
+ else:
+ y = self.d.oldy
+
+ pixmap.draw_drawable(self.d.gc,self.d.pixmap,0,0,0,0,width,height)
+ if fill == True:
+ pixmap.draw_rectangle(self.d.gc,True,x,y,dx,dy)
+ pixmap.draw_rectangle(self.d.gc_line,False,x,y,dx,dy)
+ widget.queue_draw()
+ return self.d.oldx, self.d.oldy, coords[0], coords[1]
def moveSelection(self, widget, coords):
"""Move the selection.
diff --git a/toolbox.py b/toolbox.py
index cac41c0..4a9bfc7 100755..100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -205,15 +205,15 @@ class ToolsToolbar(gtk.Toolbar):
self.insert(self._tool_brush, -1)
self._tool_brush.show()
#self._tool_brush.set_tooltip(_('Brush'))
- self._brush_palette = self.create_palette(_('Brush'))
- self._tool_brush.set_palette(self._brush_palette)
+ #self._brush_palette = self.create_palette(_('Brush'))
+ #self._tool_brush.set_palette(self._brush_palette)
self._tool_eraser = ToolButton('tool-eraser')
self.insert(self._tool_eraser, -1)
self._tool_eraser.show()
#self._tool_eraser.set_tooltip(_('Eraser'))
- self._eraser_palette = self.create_palette(_('Eraser'))
- self._tool_eraser.set_palette(self._eraser_palette)
+ #self._eraser_palette = self.create_palette(_('Eraser'))
+ #self._tool_eraser.set_palette(self._eraser_palette)
self._tool_polygon = ToolButton('tool-polygon')
self.insert(self._tool_polygon, -1)
@@ -825,13 +825,12 @@ class ImageToolbar(gtk.Toolbar):
separator.set_draw(True)
self.insert(separator, -1)
separator.show()
-
- """
- self._object_rotate_left = ToolButton('object-rotate-left')
+ """
+ self._object_rotate_left = ToolButton('object-rotate-left')
self.insert(self._object_rotate_left, -1)
self._object_rotate_left.show()
self._object_rotate_left.set_tooltip(_('Rotate Left'))
-
+
self._object_rotate_right = ToolButton('object-rotate-right')
self.insert(self._object_rotate_right, -1)
self._object_rotate_right.show()
@@ -857,7 +856,7 @@ class ImageToolbar(gtk.Toolbar):
#self._object_width.connect('clicked', set_tool, activity, 'object-width', self._OBJECT_WIDTH)
def rotate_left(self, widget, activity):
- #activity._area._rotate_left()
+ #activity._area._rotate_left(widget)
pass