| 1 |
#!/usr/bin/env python |
|---|
| 2 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 3 |
##~ License |
|---|
| 4 |
##~ |
|---|
| 5 |
##- The RuneBlade Foundation library is intended to ease some |
|---|
| 6 |
##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.) |
|---|
| 7 |
##- applications, while providing the flexibility to modularly change the |
|---|
| 8 |
##- architecture. Enjoy. |
|---|
| 9 |
##~ |
|---|
| 10 |
##~ Copyright (C) 2002 TechGame Networks, LLC. |
|---|
| 11 |
##~ |
|---|
| 12 |
##~ This library is free software; you can redistribute it and/or |
|---|
| 13 |
##~ modify it under the terms of the BSD style License as found in the |
|---|
| 14 |
##~ LICENSE file included with this distribution. |
|---|
| 15 |
##~ |
|---|
| 16 |
##~ TechGame Networks, LLC can be reached at: |
|---|
| 17 |
##~ 3578 E. Hartsel Drive #211 |
|---|
| 18 |
##~ Colorado Springs, Colorado, USA, 80920 |
|---|
| 19 |
##~ |
|---|
| 20 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 21 |
|
|---|
| 22 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 23 |
#~ Imports |
|---|
| 24 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 25 |
|
|---|
| 26 |
from SVGItems.Shapes import ShapeSVGItem |
|---|
| 27 |
from SVGSkinObject import SVGSkinObject |
|---|
| 28 |
|
|---|
| 29 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 30 |
#~ Definitions |
|---|
| 31 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 32 |
|
|---|
| 33 |
class rect(ShapeSVGItem, SVGSkinObject): |
|---|
| 34 |
def InterpretSettings(self, settings): |
|---|
| 35 |
ShapeSVGItem.InterpretSettings(self, settings) |
|---|
| 36 |
|
|---|
| 37 |
width = self._asCoord(settings['width']) |
|---|
| 38 |
if width < 0: |
|---|
| 39 |
raise ValueError, '"width" attribute can not be negative"' |
|---|
| 40 |
|
|---|
| 41 |
height = self._asCoord(settings['height']) |
|---|
| 42 |
if height < 0: |
|---|
| 43 |
raise ValueError, '"height" attribute can not be negative"' |
|---|
| 44 |
self.object.SetDimensions(width, height) |
|---|
| 45 |
|
|---|
| 46 |
radiusx = settings.get('rx', None) |
|---|
| 47 |
radiusy = settings.get('ry', None) |
|---|
| 48 |
if radiusx is None: |
|---|
| 49 |
if radiusy is None: |
|---|
| 50 |
radiusx = radiusy = 0. |
|---|
| 51 |
else: |
|---|
| 52 |
radiusx = radiusy |
|---|
| 53 |
elif radiusy is None: |
|---|
| 54 |
radiusy = radiusx |
|---|
| 55 |
|
|---|
| 56 |
radiusx = min(self._asCoord(radiusx), width*0.5) |
|---|
| 57 |
if radiusx < 0: |
|---|
| 58 |
raise ValueError, '"rx" radius attribute can not be negative"' |
|---|
| 59 |
|
|---|
| 60 |
radiusy = min(self._asCoord(radiusy), height*0.5) |
|---|
| 61 |
if radiusy < 0: |
|---|
| 62 |
raise ValueError, '"ry" radius attribute can not be negative"' |
|---|
| 63 |
|
|---|
| 64 |
self.object.SetRadi(radiusx, radiusy) |
|---|