| 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 RenderItems.Shapes import ShapeRenderItem |
|---|
| 27 |
from SVGSkinObject import SVGSkinObject |
|---|
| 28 |
|
|---|
| 29 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 30 |
#~ Definitions |
|---|
| 31 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 32 |
|
|---|
| 33 |
class RectRenderItem(ShapeRenderItem): |
|---|
| 34 |
def DisplayOn(self, renderer): |
|---|
| 35 |
renderer.DisplayRect(self) |
|---|
| 36 |
|
|---|
| 37 |
def InterpretSettings(self, settings): |
|---|
| 38 |
ShapeRenderItem.InterpretSettings(self, settings) |
|---|
| 39 |
self.SetWidth(settings.get('width', 1.0)) |
|---|
| 40 |
self.SetHeight(settings.get('height', 1.0)) |
|---|
| 41 |
self.SetRX(settings.get('rx', 0.)) |
|---|
| 42 |
self.SetRY(settings.get('ry', 0.)) |
|---|
| 43 |
|
|---|
| 44 |
#~ rect attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 45 |
|
|---|
| 46 |
def GetWidth(self): |
|---|
| 47 |
try: |
|---|
| 48 |
return self._width |
|---|
| 49 |
except AttributeError: |
|---|
| 50 |
return 1.0 |
|---|
| 51 |
def SetWidth(self, value): |
|---|
| 52 |
width = self._asCoord(value) |
|---|
| 53 |
if width < 0: |
|---|
| 54 |
raise ValueError, '"width" attribute can not be negative"' |
|---|
| 55 |
self._width = width |
|---|
| 56 |
width = property(GetWidth, SetWidth) |
|---|
| 57 |
|
|---|
| 58 |
def GetHeight(self): |
|---|
| 59 |
try: |
|---|
| 60 |
return self._height |
|---|
| 61 |
except AttributeError: |
|---|
| 62 |
return 1.0 |
|---|
| 63 |
def SetHeight(self, value): |
|---|
| 64 |
height = self._asCoord(value) |
|---|
| 65 |
if height < 0: |
|---|
| 66 |
raise ValueError, '"height" attribute can not be negative"' |
|---|
| 67 |
self._height = height |
|---|
| 68 |
height = property(GetHeight, SetHeight) |
|---|
| 69 |
|
|---|
| 70 |
#~ rounded attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 71 |
|
|---|
| 72 |
def GetRX(self, useRYifempty=True): |
|---|
| 73 |
try: |
|---|
| 74 |
return min(self._rx, self.height*0.5) |
|---|
| 75 |
except AttributeError: |
|---|
| 76 |
if useRYifempty: |
|---|
| 77 |
return self.GetRY(self, useRXifempty=False) |
|---|
| 78 |
def SetRX(self, value): |
|---|
| 79 |
rx = self._asCoord(value) |
|---|
| 80 |
if rx < 0: |
|---|
| 81 |
raise ValueError, '"rx" attribute can not be negative"' |
|---|
| 82 |
self._rx = rx |
|---|
| 83 |
rx = property(GetRX, SetRX) |
|---|
| 84 |
|
|---|
| 85 |
def GetRY(self, useRXifempty=True): |
|---|
| 86 |
try: |
|---|
| 87 |
return min(self._ry, self.height*0.5) |
|---|
| 88 |
except AttributeError: |
|---|
| 89 |
if useRXifempty: |
|---|
| 90 |
return self.GetRY(self, useRYifempty=False) |
|---|
| 91 |
def SetRY(self, value): |
|---|
| 92 |
ry = self._asCoord(value) |
|---|
| 93 |
if ry < 0: |
|---|
| 94 |
raise ValueError, '"ry" attribute can not be negative"' |
|---|
| 95 |
self._ry = ry |
|---|
| 96 |
ry = property(GetRY, SetRY) |
|---|
| 97 |
|
|---|
| 98 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 99 |
|
|---|
| 100 |
class rect(SVGSkinObject): |
|---|
| 101 |
RenderItemFactory = RectRenderItem |
|---|
| 102 |
|
|---|