| 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 |
import warnings |
|---|
| 27 |
from SVGSkinObject import SVGSkinObject |
|---|
| 28 |
from SVGItems.Styled import StyledSVGItem |
|---|
| 29 |
|
|---|
| 30 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 31 |
#~ Definitions |
|---|
| 32 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 33 |
|
|---|
| 34 |
class use(StyledSVGItem, SVGSkinObject): |
|---|
| 35 |
def InterpretSettings(self, settings): |
|---|
| 36 |
StyledSVGItem.InterpretSettings(self, settings) |
|---|
| 37 |
|
|---|
| 38 |
width = settings.get('width', None) |
|---|
| 39 |
if width is not None: |
|---|
| 40 |
width = self._asCoord(width) |
|---|
| 41 |
if width < 0 and width is not None: |
|---|
| 42 |
raise ValueError, '"width" attribute can not be negative"' |
|---|
| 43 |
height = settings.get('height', None) |
|---|
| 44 |
if height is not None: |
|---|
| 45 |
height = self._asCoord(height) |
|---|
| 46 |
if height < 0 and height is not None: |
|---|
| 47 |
raise ValueError, '"height" attribute can not be negative"' |
|---|
| 48 |
self.object.SetDimensions(width, height) |
|---|
| 49 |
|
|---|
| 50 |
xlink = settings[('http://www.w3.org/1999/xlink', 'href')] |
|---|
| 51 |
try: |
|---|
| 52 |
xlinkbase, xlinktag = xlink.split('#', 1) |
|---|
| 53 |
except ValueError: |
|---|
| 54 |
xlinkbase, xlinktag = xlink, None |
|---|
| 55 |
|
|---|
| 56 |
if xlinkbase or not xlinktag: |
|---|
| 57 |
warnings.warn('All xlinks must be document relative for now, but xlink contained %r' % xlink) |
|---|
| 58 |
|
|---|
| 59 |
useitem = self.context.idmapping[xlinktag] |
|---|
| 60 |
self.object.SetUseItem(useitem) |
|---|
| 61 |
|
|---|