Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2009-10-03 01:11:05 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2009-10-03 01:11:05 (GMT)
commit4a9da6d194c006b76bd6999cd00e5f763d37da8c (patch)
tree5db7571bb6dc6db213812ab0abaf3b0653117c97
parentb0e22b3b1ab7a16471f6ddd1e91e1f0c6a8b529d (diff)
removing suprious files
-rw-r--r--CardSortActivity.pycbin10328 -> 0 bytes
-rw-r--r--CardSortActivity.py~318
-rw-r--r--MANIFEST31
-rw-r--r--MANIFEST~24
-rw-r--r--NEWS~350
-rw-r--r--sprites.pycbin6338 -> 0 bytes
-rw-r--r--sprites.py~174
7 files changed, 0 insertions, 897 deletions
diff --git a/CardSortActivity.pyc b/CardSortActivity.pyc
deleted file mode 100644
index c46c8ec..0000000
--- a/CardSortActivity.pyc
+++ /dev/null
Binary files differ
diff --git a/CardSortActivity.py~ b/CardSortActivity.py~
deleted file mode 100644
index 3d24ad1..0000000
--- a/CardSortActivity.py~
+++ /dev/null
@@ -1,318 +0,0 @@
-#Copyright (c) 2009, Walter Bender
-
-#Permission is hereby granted, free of charge, to any person obtaining a copy
-#of this software and associated documentation files (the "Software"), to deal
-#in the Software without restriction, including without limitation the rights
-#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-#copies of the Software, and to permit persons to whom the Software is
-#furnished to do so, subject to the following conditions:
-
-#The above copyright notice and this permission notice shall be included in
-#all copies or substantial portions of the Software.
-
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-#THE SOFTWARE.
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-import gobject
-
-import sugar
-from sugar.activity import activity
-from sugar.bundle.activitybundle import ActivityBundle
-from sugar.activity.widgets import ActivityToolbarButton
-from sugar.activity.widgets import StopButton
-from sugar.graphics.toolbarbox import ToolbarBox
-from sugar.graphics.toolbarbox import ToolbarButton
-from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.menuitem import MenuItem
-from sugar.graphics.icon import Icon
-from sugar.graphics import style
-from sugar.datastore import datastore
-
-from sugar import profile
-from gettext import gettext as _
-import locale
-import os.path
-from sprites import *
-from math import sqrt
-
-class taWindow: pass
-
-SERVICE = 'org.sugarlabs.CardSortActivity'
-IFACE = SERVICE
-PATH = '/org/augarlabs/CardSortActivity'
-
-CARD_DIM = 135
-CARD_DEFS = ((1,3,-2,-3),(2,3,-3,-2),(2,3,-4,-4),\
- (2,1,-1,-4),(3,4,-4,-3),(4,2,-1,-2),\
- (1,1,-2,-4),(4,2,-3,-4),(1,3,-1,-2))
-
-
-#
-# class for defining 3x3 matrix of cards
-#
-class Grid:
- # 123
- # 456
- # 789
- def __init__(self,tw):
- self.grid = [1,2,3,4,5,6,7,8,9]
- self.card_table = {}
- # Initialize the cards
- i = 0
- x = (tw.width-(CARD_DIM*3))/2
- y = (tw.height-(CARD_DIM*3))/2
- for c in CARD_DEFS:
- self.card_table[i] = Card(tw,c,i,x,y)
- self.card_table[i].draw_card()
- x += CARD_DIM
- if x > (tw.width+(CARD_DIM*2))/2:
- x = (tw.width-(CARD_DIM*3))/2
- y += CARD_DIM
- i += 1
-
- def swap(self,a,b):
- # swap grid elements and x,y positions of sprites
- print "swapping cards " + str(a) + " and " + str(b)
- tmp = self.grid[a]
- x = self.card_table[a].spr.x
- y = self.card_table[a].spr.y
- self.grid[a] = self.grid[b]
- self.card_table[a].spr.x = self.card_table[b].spr.x
- self.card_table[a].spr.y = self.card_table[b].spr.y
- self.grid[b] = tmp
- self.card_table[b].spr.x = x
- self.card_table[b].spr.y = y
-
- def print_grid(self):
- print self.grid
- return
-
- def test(self):
- for i in (0,1,3,4,6,7):
- if self.card_table[self.grid[i]].east + \
- self.card_table[self.grid[i+1]].west != 0:
- return False
- for i in (0,1,2,3,4,5):
- if self.card_table[self.grid[i]].south + \
- self.card_table[self.grid[i+3]].north != 0:
- return False
- return True
-
-
-#
-# class for defining individual cards
-#
-class Card:
- # Spade = 1,-1
- # Heart = 2,-2
- # Club = 3,-3
- # Diamond = 4,-4
- def __init__(self,tw,c,i,x,y):
- self.north = c[0]
- self.east = c[1]
- self.south = c[2]
- self.west = c[3]
- self.rotate = 0
- # create sprite from svg file
- self.spr = sprNew(tw,x,y,self.load_image(tw.path,i))
- self.spr.label = i
-
- def draw_card(self):
- setlayer(self.spr,2000)
- draw(self.spr)
-
- def load_image(self, file, i):
- print "loading " + os.path.join(file + str(i) + '.svg')
- return gtk.gdk.pixbuf_new_from_file(os.path.join(file + \
- str(i) + "x" + \
- '.svg'))
-
- def rotate_ccw(self):
- # print "rotating card " + str(self.spr.label)
- tmp = self.north
- self.north = self.east
- self.east = self.south
- self.south = self.west
- self.west = tmp
- self.rotate += 90
- if self.rotate > 359:
- self.rotate -= 360
- tmp = self.spr.image.rotate_simple(90)
- self.spr.image = tmp
-
- def print_card(self):
- print "(" + str(self.north) + "," + str(self.east) + \
- "," + str(self.south) + "," + str(self.west) + \
- ") " + str(self.rotate) + "ccw" + \
- " x:" + str(self.spr.x) + " y:" + str(self.spr.y)
-
-#
-# Sugar activity
-#
-class CardSortActivity(activity.Activity):
-
- def __init__(self, handle):
- super(CardSortActivity,self).__init__(handle)
-
- # Use 0.86 toolbar design
- toolbar_box = ToolbarBox()
-
- # Buttons added to the Activity toolbar
- activity_button = ActivityToolbarButton(self)
- toolbar_box.toolbar.insert(activity_button, 0)
- activity_button.show()
-
- # Solver button
- self.solve_puzzle = ToolButton( "solve-off" )
- self.solve_puzzle.set_tooltip(_('Solve it'))
- self.solve_puzzle.props.sensitive = True
- self.solve_puzzle.connect('clicked', self._solver_cb)
- toolbar_box.toolbar.insert(self.solve_puzzle, -1)
- self.solve_puzzle.show()
-
- separator = gtk.SeparatorToolItem()
- separator.show()
- toolbar_box.toolbar.insert(separator, -1)
-
- # Label for showing status
- self.results_label = gtk.Label(_("click to rotate; drag to swap"))
- self.results_label.show()
- results_toolitem = gtk.ToolItem()
- results_toolitem.add(self.results_label)
- toolbar_box.toolbar.insert(results_toolitem,-1)
-
- separator = gtk.SeparatorToolItem()
- separator.props.draw = False
- separator.set_expand(True)
- separator.show()
- toolbar_box.toolbar.insert(separator, -1)
-
- # The ever-present Stop Button
- stop_button = StopButton(self)
- stop_button.props.accelerator = '<Ctrl>Q'
- toolbar_box.toolbar.insert(stop_button, -1)
- stop_button.show()
-
- self.set_toolbar_box(toolbar_box)
- toolbar_box.show()
-
- # Create a canvas
- canvas = gtk.DrawingArea()
- canvas.set_size_request(gtk.gdk.screen_width(), \
- gtk.gdk.screen_height())
- self.set_canvas(canvas)
- self.show_all()
-
- # Initialize the canvas
- self.tw = taWindow()
- self.tw.window = canvas
- canvas.set_flags(gtk.CAN_FOCUS)
- canvas.add_events(gtk.gdk.BUTTON_PRESS_MASK)
- canvas.add_events(gtk.gdk.BUTTON_RELEASE_MASK)
- canvas.connect("expose-event", self._expose_cb, self.tw)
- canvas.connect("button-press-event", self._button_press_cb, self.tw)
- canvas.connect("button-release-event", self._button_release_cb, self.tw)
- self.tw.width = gtk.gdk.screen_width()
- self.tw.height = gtk.gdk.screen_height()-style.GRID_CELL_SIZE
- self.tw.area = canvas.window
- self.tw.gc = self.tw.area.new_gc()
- self.tw.scale = 5
- self.tw.cm = self.tw.gc.get_colormap()
- self.tw.msgcolor = self.tw.cm.alloc_color('black')
- self.tw.sprites = []
-
- # Initialize the grid
- self.tw.path = os.path.join(activity.get_bundle_path(),'images/card')
- self.tw.grid = Grid(self.tw)
-
- # Start solving the puzzle
- self.tw.press = -1
- self.tw.release = -1
- self.tw.start_drag = [0,0]
-
- #
- # Solver
- #
- def _solver_cb(self, button):
- self.solve_puzzle.set_icon("solve-on")
- """
- We need to write this code
- """
- self.results_label.set_text(_("I don't know how to solve it."))
- self.results_label.show()
- self.solve_puzzle.set_icon("solve-off")
- return True
-
-
- #
- # Repaint
- #
- def _expose_cb(self, win, event, tw):
- redrawsprites(tw)
- return True
-
- #
- # Button press
- #
- def _button_press_cb(self, win, event, tw):
- win.grab_focus()
- x, y = map(int, event.get_coords())
- tw.start_drag = [x,y]
- spr = findsprite(tw,(x,y))
- if spr is None:
- tw.press = -1
- tw.release = -1
- return True
- # take note of card under button press
- tw.press = spr.label
- return True
-
- #
- # Button release
- #
- def _button_release_cb(self, win, event, tw):
- win.grab_focus()
- x, y = map(int, event.get_coords())
- spr = findsprite(tw,(x,y))
- if spr is None:
- tw.press = -1
- tw.release = -1
- return True
- # take note of card under button release
- tw.release = spr.label
- # if the same card (click) then rotate
- if tw.press == tw.release:
- # check to see if it was an aborted move
- if self.distance(tw.start_drag,[x,y]) < 20:
- tw.grid.card_table[tw.press].rotate_ccw()
- # tw.grid.card_table[tw.press].print_card()
- # if different card (drag) then swap
- else:
- tw.grid.swap(tw.press,tw.release)
- # tw.grid.print_grid()
- inval(tw.grid.card_table[tw.press].spr)
- inval(tw.grid.card_table[tw.release].spr)
- redrawsprites(tw)
- tw.press = -1
- tw.release = -1
- if tw.grid.test() == True:
- self.results_label.set_text(_("You solved the puzzle."))
- self.results_label.show()
- else:
- self.results_label.set_text(_("Keep trying."))
- self.results_label.show()
-
- return True
-
- def distance(self,start,stop):
- dx = start[0]-stop[0]
- dy = start[1]-stop[1]
- return sqrt(dx*dx+dy*dy)
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644
index e06c57a..0000000
--- a/MANIFEST
+++ /dev/null
@@ -1,31 +0,0 @@
-CardSortActivity.py
-NEWS
-COPYING
-sprites.py
-setup.py
-activity/application-x-turtle-art.svg
-activity/activity-cardsort.svg
-activity/activity.info
-activity/mimetypes.xml
-images/card4.svg
-images/card3.svg
-images/card7.svg
-images/card8.svg
-images/card6.svg
-
-images/card1.svg
-images/card0.svg
-images/card2.svg
-images/card5.svg
-icons/solve-on.svg
-icons/solve-off.svg
-po/CardSort.pot
-images/card1x.svg
-images/card7x.svg
-images/card4x.svg
-images/card2x.svg
-images/card3x.svg
-images/card0x.svg
-images/card5x.svg
-images/card8x.svg
-images/card6x.svg
diff --git a/MANIFEST~ b/MANIFEST~
deleted file mode 100644
index 8294cf1..0000000
--- a/MANIFEST~
+++ /dev/null
@@ -1,24 +0,0 @@
-CardSortActivity.py
-NEWS
-COPYING
-sprites.py
-
-setup.py
-activity/application-x-turtle-art.svg
-activity/activity-cardsort.svg
-activity/activity.info
-activity/mimetypes.xml
-images/card4.svg
-images/card3.svg
-images/card7.svg
-images/card8.svg
-images/card6.svg
-images/cards.svg
-images/card1.svg
-images/card0.svg
-images/card2.svg
-images/card1mask.svg
-images/card5.svg
-icons/solve-on.svg
-icons/solve-off.svg
-po/CardSort.pot
diff --git a/NEWS~ b/NEWS~
deleted file mode 100644
index 7143277..0000000
--- a/NEWS~
+++ /dev/null
@@ -1,350 +0,0 @@
-70
-
-* new translations/artwork for vi
-* added linewrap to help label (with rgs)
-* added label to Help toolbar
-* new translations for it
-* caught some exceptions that prevented TA from running outside of Sugar
-* fixed bug preventing simple save to HTML for pre-086 systems
-
-69
-
-* chmod +x svg factory
-* added missing import gettext from talogo.py
-* renamed xo-man to xo-child
-* caught missing attribute when running from outside of Sugar
-* new translations/artwork for de, fr, es, it
-* added translator comments
-* fixed several bugs in export to Logo code
-
-68
-
-* made case consistent on tool tips
-* fixed bug re i18n in debug panel
-* new artwork for es and fr
-* fixed some problems with svg factory
-* fixed bug in Export HTML
-* fixed naming problem with all save_as functions
-* fixed bug in Export Logo in regard to start block
-
-67
-
-* added mime-type icon
-* changed keyboard shortcuts to use Ctrl instead of Alt as per guidelines
-* fixed bug re wait time (now in seconds)
-* fixed problem with fractional wait times
-* fixed i18n problem with labels in hover help
-* reorganization of extras palette
-* fixed problem of empty file with "Save as HTML" (saving screen capture)
-
-66
-
-* fixed bug preventing launch on (0.82-0.84)
-* work around Rainbow problem with Save as image
-* fixed bug re activate Stop Button on launch (thanks to rgs)
-* added open from journal button (with rgs)
-* fixed bug re Erase Button (hides status blocks)
-* cleaned up some broken sample code
-
-65
-
-* fixed problem with View Toolbar
-* moved Samples button to Help Toolbar
-
-64
-
-* major refactoring for new toolbar design
-* stop sign turns off after execution is finished
-* added preliminary support for mg and ta
-* moved hover help to help toolbar
-* adjusted artwork on Turtle palette
-
-63
-
-* more sample programs
-* consolidated samples into one directory
-* fixed mask bug that prevented palette hiding
-
-62
-
-* first pass at hover help support (thanks Raul)
-* put samples button, keep button on project toolbar
-* fixed journal icons associated with html, python, logo
-* improved compatibility with old Sugar builds
-* images centered under turtle
-* text vertically centered under turtle
-* pop blocks snap into boxes
-* improved masks for fewer block-selection errors
-
-
-61
-
-* fixed es translation
-* fixed problem with save/load on old systems
-
-60
-
-* fixed sharing bug
-* began work on 701 backward compatibility
-* added more debugging code
-
-59
-
-* fixed leading bug for OLPC XO portfolio
-* enabled box to hold strings and journal objects
-
-58
-
-* fixed unicode string compare in equal block
-* fixed journal description bug introduced in v55
-* fixed misaligned myfunc block problem
-
-
-57
-
-* lots of artwork clean up
-* elimination of lock block
-* more dead key clean ups
-* truncated strings
-
-56
-
-* more dead key cleanup
-* empty (undefined) box error message
-
-55
-
-* dead key workaround
-
-54
-
-* debug button
-* no more decimals by default for print
-
-53
-
-* es updates
-
-52
-
-* first attempt at fixing the mimetypes
-* default behavior of tamyblock.py is to draw a dotted line
-
-51
-
-* caught ISO_Level3_Shift problem on OLPC XO keyboard
-
-50
-
-* fixed some problems with taexportlogo
-* cleaned up save/load icons
-* print uses title for Journal objects
-* cleaned up movie window destroy code
-* more consistent template management internally
-* support of a sort for show in taexporthtml
-
-49
-
-* fixed character input bug
-
-48
-
-* reworking of media blocks
-* json cleanup
-
-47
-
-* image export
-* pot update
-
-46
-
-* full screen mode
-* scrolled window
-* better support for running from the command line
-
-45
-
-* alt chars for keyboard shortcuts
-* visual feedback for user-defined blocks when "loaded"
-
-44
-
-* adding user defineable block
-
-43
-
-* new de artwork
-
-42
-
-* removed unneeded Numeric dependencies
-
-41
-
-* end run around addons bug?
-
-40
-
-* improvements to it artwork
-
-39
-
-* improvements to nl and sv artwork
-
-38
-
-* improvements to de artwork
-
-37
-
-* adding de sl sv
-* cleaned up SVGs
-
-36
-
-* added el, vi, zh_TW
-
-35
-
-* updated depreciated fields in activity.info
-* added svg/*.py files to generate svgs from .po
-* added nl
-
-34
-
-* added it; cleaned up fr; converted to cjson (with help from silbe)
-
-33
-
-* merge with TAPortfolio (and elimination of Sensor and myblock features)
-
-32
-
-* rebase on TAPortfolio code
-
-31
-
-* run and step
-
-30
-
-* fixed broken POT file
-
-29
-
-* new artwork, better i18n
-
-28
-
-* added push and pop (en only)
-
-27
-
-* add named boxes and stacks
-
-26
-
-* allow new blocks to be created by clicking in addition to drag and drop
-
-25
-
-* added sensor panel from TurtleArt with Sensors
-* catch exceptions where DC Audio is not available (non-OLPC_XO-1 hardware)
-
-24
-
-* add UCB logo export
-* check for conditions where image cache needs refreshing
-
-23
-
-* caching images
-
-22
-
-* added POT file
-
-21
-
-* added ru
-* fixed errors in fr and mn
-
-20
-
-* fixed translation problem with Spanish "poner en caja"
-* PT translation
-* height = toolbox.get_size()[1]
-* setyx
-* adding po files
-
-19
-
-* removed "sugar.activity import registry"
-
-18
-
-* Finnish
-* SVG cleanup
-
-17
-
-* SVG support
-* support for non-1200x900 displays
-
-16
-
-* Mongolian
-
-15
-
-* shebang patch
-
-14
-
-* Changed more file permissions (-x)
-* Deleted some redundant files (stray myblockgroup.gif files)
-* Add #!/usr/bin/env python to taturtle.py
-
-13
-
-* Added Turkish (tr) artwork
-* Changed permissions on artwork (-x)
-
-12
-
-* Added sqrt function
-
-11
-
-* Rename activity from TurtleArt to Turtle Art (dlo trac #2663)
-* Fix pen up in arc (dlo trac #7656)
-* Point update url at a protected page.
-
-10
-
-* licensing information in activity.info (dlo trac #6340)
-* new samples
-* improved icon (dlo trac #6836)
-
-9
-
-* added french images
-* fixed a few typos
-* fixed divide by zero bug
-
-8
-
-* added license
-
-7
-
-* simple i18n
-
-6
-
-* Graphics changes
-
-5
-
-* Multi instance happy
diff --git a/sprites.pyc b/sprites.pyc
deleted file mode 100644
index eba2b52..0000000
--- a/sprites.pyc
+++ /dev/null
Binary files differ
diff --git a/sprites.py~ b/sprites.py~
deleted file mode 100644
index 85993bc..0000000
--- a/sprites.py~
+++ /dev/null
@@ -1,174 +0,0 @@
-# -*- coding: utf-8 -*-
-
-#Copyright (c) 2007-8, Playful Invention Company.
-#Copyright (c) 2008-9, Walter Bender
-
-#Permission is hereby granted, free of charge, to any person obtaining a copy
-#of this software and associated documentation files (the "Software"), to deal
-#in the Software without restriction, including without limitation the rights
-#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-#copies of the Software, and to permit persons to whom the Software is
-#furnished to do so, subject to the following conditions:
-
-#The above copyright notice and this permission notice shall be included in
-#all copies or substantial portions of the Software.
-
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-#THE SOFTWARE.
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-import gobject
-import pango
-class taSprite: pass
-
-# Don't display the label for these blocks
-nolabel = ['audiooff', 'descriptionoff','journal']
-
-def findsprite(tw,pos):
- list = tw.sprites[:]
- list.reverse()
- for s in list:
- if hit(s,pos): return s
- return None
-
-def redrawsprites(tw):
- for s in tw.sprites: draw(s)
-
-def sprNew(tw,x,y,image,altlabel=False):
- spr = taSprite()
- spr.tw, spr.x, spr.y = tw,x,y
- setimage(spr,image)
- spr.label = None
- spr.ds_id = None
- if altlabel:
- spr.draw_label = draw_label2
- else: spr.draw_label = draw_label1
- return spr
-
-def setimage(spr,image):
- spr.image = image
- if isinstance(image,gtk.gdk.Pixbuf):
- spr.width = image.get_width()
- spr.height = image.get_height()
- else: spr.width,spr.height=image.get_size()
-
-def move(spr,pos):
- inval(spr)
- spr.x,spr.y = pos
- inval(spr)
-
-def setshape(spr,image):
- inval(spr)
- setimage(spr,image)
- inval(spr)
-
-def setshapex(spr):
- inval(spr)
-
-def setlayer(spr, layer):
- sprites = spr.tw.sprites
- if spr in sprites: sprites.remove(spr)
- spr.layer = layer
- for i in range(len(sprites)):
- if layer < sprites[i].layer:
- sprites.insert(i, spr)
- inval(spr)
- return
- sprites.append(spr)
- inval(spr)
-
-def hide(spr):
- if spr not in spr.tw.sprites: return
- inval(spr)
- spr.tw.sprites.remove(spr)
-
-def setlabel(spr,label):
- spr.label = label
- inval(spr)
-
-def inval(spr):
- spr.tw.area.invalidate_rect(gtk.gdk.Rectangle(spr.x,spr.y,spr.width, \
- spr.height), False)
-
-def draw(spr):
- if isinstance(spr.image,gtk.gdk.Pixbuf):
- spr.tw.area.draw_pixbuf(spr.tw.gc, spr.image, 0, 0, spr.x, spr.y)
- else:
- spr.tw.area.draw_drawable(spr.tw.gc,spr.image,0,0,spr.x,spr.y,-1,-1)
- if spr.label!=None:
- if hasattr(spr, 'proto') and hasattr(spr.proto, 'name'):
- name = spr.proto.name
- else:
- name = ""
- if name not in nolabel:
- spr.draw_label(spr,str(spr.label))
-
-def hit(spr,pos):
- x,y = pos
- if x<spr.x: return False
- if x>spr.x+spr.width: return False
- if y<spr.y: return False
- if y>spr.y+spr.height: return False
- if isinstance(spr.image,gtk.gdk.Pixmap): return True
- if hasattr(spr, 'proto') and hasattr(spr.proto, 'name') and \
- spr.proto.name == 'journal':
- return True
- dx,dy = x-spr.x, y-spr.y
- try:
- return ord(spr.image.get_pixels()[(dy*spr.width+dx)*4+3]) == 255
- except IndexError:
- if hasattr(spr, 'proto') and hasattr(spr.proto, 'name'):
- print spr.proto.name
- print "IndexError: string index out of range" + str(dx) + " " \
- + str(dy) + " " + str(spr.width) + " " + str(spr.height)
- return True
-
-def draw_label(spr, label, myscale, center_flag, truncate_flag):
- fd = pango.FontDescription('Sans')
- fd.set_size(int(myscale*spr.tw.scale*pango.SCALE))
- if type(label) == str or type(label) == unicode:
- mylabel = label.replace("\0"," ")
- l = len(mylabel)
- if truncate_flag and l > 8:
- pl = spr.tw.window.create_pango_layout("..."+mylabel[l-8:])
- else:
- pl = spr.tw.window.create_pango_layout(mylabel)
- pl.set_font_description(fd)
- if center_flag:
- swidth = pl.get_size()[0]/pango.SCALE
- centerx = spr.x+spr.width/2
- x = int(centerx-swidth/2)
- else:
- x = spr.x+70
- sheight = pl.get_size()[1]/pango.SCALE
- centery = spr.y+spr.height/2
- y = int(centery-sheight/2)
- spr.tw.gc.set_foreground(spr.tw.msgcolor)
- spr.tw.area.draw_layout(spr.tw.gc, x, y, pl)
- else:
- print type(label)
-
-# used for most things
-def draw_label1(spr, label):
- draw_label(spr, label, 7, True, True)
-
-# used for status blocks
-def draw_label2(spr, label):
- draw_label(spr, str(label), 9, False, False)
-
-# used to get pixel value from mask for category selector
-def getpixel(image,x,y):
- array = image.get_pixels()
- offset = (y*image.get_width()+x)*4
- r,g,b,a = ord(array[offset]),ord(array[offset+1]),ord(array[offset+2]), \
- ord(array[offset+3])
- return (a<<24)+(b<<16)+(g<<8)+r
-
-