| 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 |
|
|---|
| 28 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 29 |
#~ Definitions |
|---|
| 30 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 31 |
|
|---|
| 32 |
class event(wxSkinObject, wxSkinObjectNoData): |
|---|
| 33 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 34 |
#~ Constants / Variables / Etc. |
|---|
| 35 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 36 |
|
|---|
| 37 |
default_settings = wxSkinObject.default_settings.copy() |
|---|
| 38 |
del default_settings['wxid'] |
|---|
| 39 |
#default_settings['type'] = '' |
|---|
| 40 |
#default_settings['call'] = '' |
|---|
| 41 |
#default_settings['wxid'] = '-1' |
|---|
| 42 |
#default_settings['towxid'] = '-1' |
|---|
| 43 |
|
|---|
| 44 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 45 |
#~ Public |
|---|
| 46 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 47 |
|
|---|
| 48 |
def SkinInitialize(self): |
|---|
| 49 |
parentobjects = self.wxEvalCond('handler', None) |
|---|
| 50 |
if not isinstance(parentobjects, (tuple, list)): |
|---|
| 51 |
parentobjects = (parentobjects,) |
|---|
| 52 |
eventtypes = self.wxEval('type') |
|---|
| 53 |
call = self.wxEval('call') |
|---|
| 54 |
for parentobject in parentobjects: |
|---|
| 55 |
self._AddBinding(parentobject, eventtypes, call) |
|---|
| 56 |
|
|---|
| 57 |
def SkinFinalize(self): |
|---|
| 58 |
for call, params in self.object: |
|---|
| 59 |
call(*params) |
|---|
| 60 |
self.object = None |
|---|
| 61 |
|
|---|
| 62 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 63 |
|
|---|
| 64 |
def _AddBinding(self, parentobject, eventtypes, call): |
|---|
| 65 |
if parentobject is None: |
|---|
| 66 |
parentobject = self.wxGetParentObject(wx.wxEvtHandlerPtr) |
|---|
| 67 |
elif isinstance(parentobject, wx.wxEvtHandlerPtr): |
|---|
| 68 |
parentobject = parentobject |
|---|
| 69 |
elif issubclass(parentobject, wx.wxEvtHandlerPtr): |
|---|
| 70 |
parentobject = self.wxGetParentObject(parentobject) |
|---|
| 71 |
|
|---|
| 72 |
self.object = [] |
|---|
| 73 |
if callable(eventtypes): |
|---|
| 74 |
args = (parentobject, ) |
|---|
| 75 |
try: args += self.wxEval('wxid'), |
|---|
| 76 |
except KeyError: pass |
|---|
| 77 |
try: args += self.wxEval('towxid'), |
|---|
| 78 |
except KeyError: pass |
|---|
| 79 |
args += (call,) |
|---|
| 80 |
|
|---|
| 81 |
self.object.append((eventtypes, args)) |
|---|
| 82 |
else: |
|---|
| 83 |
if not isinstance(eventtypes, (tuple, list)): |
|---|
| 84 |
eventtypes = (eventtypes,) |
|---|
| 85 |
for eventtype in eventtypes: |
|---|
| 86 |
args = (self.wxEvalCond('wxid', -1), self.wxEvalCond('towxid', -1), eventtype, call) |
|---|
| 87 |
self.object.append((parentobject.Connect, args)) |
|---|
| 88 |
|
|---|