| 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 wxSkinObject import wx, wxSkinObject, wxSkinObjectNoData |
|---|
| 27 |
import os |
|---|
| 28 |
|
|---|
| 29 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 30 |
#~ Class |
|---|
| 31 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 32 |
|
|---|
| 33 |
class image(wxSkinObject, wxSkinObjectNoData): |
|---|
| 34 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 35 |
#~ Constants / Variables / Etc. |
|---|
| 36 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 37 |
|
|---|
| 38 |
default_settings = wxSkinObject.default_settings.copy() |
|---|
| 39 |
default_settings.update({ |
|---|
| 40 |
'type': 'wxBITMAP_TYPE_ANY', |
|---|
| 41 |
'call': None, |
|---|
| 42 |
'autosize': '1', |
|---|
| 43 |
'rescale': 'None' |
|---|
| 44 |
}) |
|---|
| 45 |
|
|---|
| 46 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 47 |
#~ Public |
|---|
| 48 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 49 |
|
|---|
| 50 |
def SkinInitialize(self): |
|---|
| 51 |
if self.settings['call'] is None: |
|---|
| 52 |
parentobject = self.wxGetParentObject(wx.wxWindowPtr) |
|---|
| 53 |
if hasattr(parentobject, 'SetBitmap'): |
|---|
| 54 |
self.settings['call'] = 'SetBitmap' |
|---|
| 55 |
elif hasattr(parentobject, 'SetBitmapLabel'): |
|---|
| 56 |
self.settings['call'] = 'SetBitmapLabel' |
|---|
| 57 |
elif isinstance(parentobject, wx.wxImageListPtr): |
|---|
| 58 |
self.settings['call'] = 'Add' |
|---|
| 59 |
else: self.settings['call'] = '' |
|---|
| 60 |
|
|---|
| 61 |
kwSettings = self.wxSettingDict(['type'], ['name']) |
|---|
| 62 |
kwSettings['name'] = os.path.join(self.context.__root__, kwSettings['name']) |
|---|
| 63 |
self.object = wx.wxImage(**kwSettings) |
|---|
| 64 |
rescale = self.wxEval('rescale') |
|---|
| 65 |
if rescale: |
|---|
| 66 |
if rescale[0] < 0: |
|---|
| 67 |
rescale = self.object.GetWidth(), rescale[1] |
|---|
| 68 |
if rescale[1] < 0: |
|---|
| 69 |
rescale = rescale[0], self.object.GetHeight() |
|---|
| 70 |
self.object.Rescale(*rescale) |
|---|
| 71 |
self.wxInitialStandardOptions() |
|---|
| 72 |
|
|---|
| 73 |
def SkinFinalize(self): |
|---|
| 74 |
if self.settings['call']: |
|---|
| 75 |
parentobject = self.wxGetParentObject(wx.wxWindowPtr) |
|---|
| 76 |
if self.wxEval('autosize'): |
|---|
| 77 |
newsize = (self.object.GetWidth(), self.object.GetHeight()) |
|---|
| 78 |
elif hasattr(parentobject, 'GetSize'): |
|---|
| 79 |
newsize = parentobject.GetSize() |
|---|
| 80 |
|
|---|
| 81 |
method = getattr(parentobject, 'SetBitmap' + self.settings['call'], None) |
|---|
| 82 |
if not method: method = getattr(parentobject, self.settings['call']) |
|---|
| 83 |
method(self.object.ConvertToBitmap()) |
|---|
| 84 |
|
|---|
| 85 |
if hasattr(parentobject, 'SetSize'): |
|---|
| 86 |
parentobject.SetSize(newsize) |
|---|
| 87 |
self.wxFinalStandardOptions() |
|---|
| 88 |
|
|---|
| 89 |
wx.wxInitAllImageHandlers() |
|---|