From 01cbd87929d18cf495d86ea17a00313efad68249 Mon Sep 17 00:00:00 2001 From: Alexandre Antonino Gonçalves Martinazzo Date: Wed, 12 Sep 2007 15:30:53 +0000 Subject: Bug #3320 fixed; Default tab now is 'Tools' MANIFEST file updated Merging with other commits (at svn): - Updated translations files (nathalia.sautchuk) - adding greek name of the activity (nathalia.sautchuk) - adding greek and arabic translations (nathalia.sautchuk) - resize func is changed, work better but pixmaps are confused , Andre knows more about this (pekayatt) - New coments standard with doxygen compatibility (pekayatt) --- (limited to 'Area.py') diff --git a/Area.py b/Area.py index 448ee45..80e6961 100644 --- a/Area.py +++ b/Area.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- + """ -Area.py +@namespace Area -Tools and events manipulation + Tools and events manipulation Copyright 2007, NATE-LSI-EPUSP @@ -53,44 +54,35 @@ Roseli de Deus Lopes (roseli@lsi.usp.br) """ -# import pygtk -# pygtk.require('2.0') + import gtk, gobject, logging, os -# import sys, socket -# from gtk import gdk import math import pango from fill import * -# import Image -# import StringIO from Desenho import Desenho -WIDTH = 800 -HEIGHT = 600 - +##Tools and events manipulation are handle with this class. class Area(gtk.DrawingArea): + __gsignals__ = { 'undo' : (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])), 'redo' : (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])), 'action-saved' : (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])), - #TODO: this signal still not used. -# 'copy' : (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])), 'selected' : (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])), } def __init__(self, janela): """ Initialize the object from class Area which is derived from gtk.DrawingArea. - Keyword arguments: - self -- the Area object (GtkDrawingArea) - janela -- the parent window + @param self -- the Area object (GtkDrawingArea) + @param janela -- the parent window """ logging.debug('Area.__init__(self, janela)') gtk.DrawingArea.__init__(self) - self.set_size_request(WIDTH, HEIGHT) + self.set_size_request(800, 600) self.set_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_PRESS_MASK | @@ -103,7 +95,7 @@ class Area(gtk.DrawingArea): self.connect("button_release_event", self.mouseup) self.set_extension_events(gtk.gdk.EXTENSION_EVENTS_CURSOR) - + ##Define which tool is been used self.tool = None self.desenha = False self.selmove = False @@ -138,26 +130,28 @@ class Area(gtk.DrawingArea): self._set_selection_bounds(0,0,0,0) #start of UNDO and REDO + ## This flag is used when is the first time you click on Undo self.first_undo = True + ## When you are just clicking on undo or redo and not drawing undo_surf is True self.undo_surf = False self.undo_times = 0 self.redo_times = 0 - self.undo_list=[]#pixmaps list to Undo func + ##pixmaps list to Undo func + self.undo_list=[] - # Number of sides for regular polygon + ##Number of sides for regular polygon self.polygon_sides = 5 - # Shapes will be filled or not? + ##Shapes will be filled or not? self.fill = True - # Create a new backing pixmap of the appropriate size + def configure_event(self, widget, event): """Configure the Area object. - Keyword arguments: - self -- the Area object (GtkDrawingArea) - widget -- the Area object (GtkDrawingArea) - event -- GdkEvent + @param self -- the Area object (GtkDrawingArea) + @param widget -- the Area object (GtkDrawingArea) + @param event -- GdkEvent """ logging.debug('Area.configure_event(self, widget, event)') @@ -166,12 +160,13 @@ class Area(gtk.DrawingArea): width = win.get_geometry()[2] height = win.get_geometry()[3] + ##It is the main pixmap, who is display most of the time. self.pixmap = gtk.gdk.Pixmap(win, width, height, -1) self.pixmap.draw_rectangle(widget.get_style().white_gc, True, 0, 0, width, height) - + ##This pixmap is showed when we need show something and not draw it. self.pixmap_temp = gtk.gdk.Pixmap(win, width, height, -1) self.pixmap_temp.draw_rectangle(widget.get_style().white_gc, True, 0, 0, width, height) - + ##When something is selected this pixmap draw and rectangular box out of the selection self.pixmap_sel = gtk.gdk.Pixmap(win, width, height, -1) self.pixmap_sel.draw_rectangle(widget.get_style().white_gc, True, 0, 0, width, height) @@ -201,13 +196,11 @@ class Area(gtk.DrawingArea): return True - # set the new line size def configure_line(self, size): - """Configure the line's size. + """Configure the new line's size. - Keyword arguments: - self -- the Area object (GtkDrawingArea) - size -- + @param self -- the Area object (GtkDrawingArea) + @param size -- the size of the new line """ #logging.debug('Area.configure_line(self, size)') @@ -216,12 +209,12 @@ class Area(gtk.DrawingArea): self.gc_line.set_line_attributes(size, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_ROUND) def expose(self, widget, event): - """Show up the Area object (GtkDrawingArea). + """ This function define which pixmap will be showed to the user. + Show up the Area object (GtkDrawingArea). - Keyword arguments: - self -- the Area object (GtkDrawingArea) - widget -- the Area object (GtkDrawingArea) - event -- GdkEvent + @param self -- the Area object (GtkDrawingArea) + @param widget -- the Area object (GtkDrawingArea) + @param event -- GdkEvent """ #logging.debug('Area.expose(self, widget, event)') @@ -237,12 +230,11 @@ class Area(gtk.DrawingArea): return False def mousedown(self,widget,event): - """Make the Area object (GtkDrawingArea) recognize that the mouse button was pressed. + """Make the Area object (GtkDrawingArea) recognize that the mouse button has been pressed. - Keyword arguments: - self -- the Area object (GtkDrawingArea) - widget -- the Area object (GtkDrawingArea) - event -- GdkEvent + @param self -- the Area object (GtkDrawingArea) + @param widget -- the Area object (GtkDrawingArea) + @param event -- GdkEvent """ width, height = self.window.get_size() @@ -278,24 +270,24 @@ class Area(gtk.DrawingArea): self.last = -1, -1 self.d.eraser(widget, coords, self.last, self.line_size, self.eraser_shape) self.last = coords - if self.tool == 'brush': + elif self.tool == 'brush': self.last = -1, -1 self.d.brush(widget, coords, self.last, self.line_size, self.brush_shape) self.last = coords - if self.tool == 'rainbow': + elif self.tool == 'rainbow': self.last = -1, -1 self.d.rainbow(widget, coords, self.last, self.rainbow_counter,self.line_size, self.brush_shape) self.last = coords - if self.tool == 'polygon': + elif self.tool == 'polygon': self.configure_line(self.line_size) x , y, state = event.window.get_pointer() x0, y0, x1, y1 = self.get_selection_bounds() - - if (state & gtk.gdk.BUTTON3_MASK): + + if (state & gtk.gdk.BUTTON3_MASK):#Handle with the right button click event. self.sel_get_out = True self.pixmap_sel.draw_drawable(self.gc, self.pixmap_temp, 0,0,0,0, width, height) - elif state & gtk.gdk.BUTTON1_MASK: + elif state & gtk.gdk.BUTTON1_MASK:#Handle with the left button click event. if not (x0