19 |
# Copyright 2001-2003 Free Software Foundation |
# Copyright 2001-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# curses/Renderer.py |
# native/Driver.py |
23 |
# |
# |
24 |
# DESCRIPTION: |
# DESCRIPTION: |
25 |
# |
# |
26 |
# NOTES: |
# NOTES: |
27 |
# |
# |
28 |
|
|
29 |
|
from wxPython.wx import * |
30 |
from gnue.designer.forms.LayoutEditor.renderers.Base import * |
from gnue.designer.forms.LayoutEditor.renderers.Base import * |
31 |
|
from gnue.forms.uidrivers.wx import UIdriver as UIwxpython |
32 |
|
from gnue.common.events import Event |
33 |
|
from WidgetHandler import WidgetHandler |
34 |
|
|
35 |
class Renderer(BaseRenderer): |
class Renderer(BaseRenderer): |
36 |
|
|
37 |
|
########## |
38 |
|
# |
39 |
|
# Public methods |
40 |
|
# |
41 |
|
|
42 |
def init(self): |
def init(self): |
43 |
pass |
# Create our own WX GFUserInterface instance |
44 |
|
self.uidriver = uidriver = UIwxpython.GFUserInterface(self.instance, 0) |
45 |
|
|
46 |
|
# Create a list of all UI widgets |
47 |
|
self.widgets = {} |
48 |
|
self.widgets.update(uidriver._supportedWidgets) |
49 |
|
|
50 |
|
# But we don't want a page to act like normal objects... |
51 |
|
# we have special plans for it (bwahahaha) |
52 |
|
del self.widgets['GFPage'] |
53 |
|
|
54 |
|
self.widgetList = [] |
55 |
|
|
56 |
|
self.resetFont() |
57 |
|
|
58 |
|
|
59 |
|
def removeWidget(self, object): |
60 |
|
# We don't need to do anything special |
61 |
|
# if a widget is removed |
62 |
|
try: |
63 |
|
self.widgetList.remove(object) |
64 |
|
except: |
65 |
|
pass |
66 |
|
|
67 |
|
|
68 |
|
def redrawWidget(self, object): |
69 |
|
# We don't need to do anything special, |
70 |
|
# other than recreate the bitmap, if a |
71 |
|
# widget is redrawn/updated |
72 |
|
return self.addWidget(object) |
73 |
|
|
74 |
|
|
75 |
|
def addWidget(self, object): |
76 |
|
if self.widgets.has_key(object._type) and \ |
77 |
|
(not hasattr(object, 'hidden') or not object.hidden): |
78 |
|
if hasattr(object, 'name'): |
79 |
|
GDebug.printMesg(7, 'Drawing item %s of type %s' % (object.name, object._type)) |
80 |
|
else: |
81 |
|
GDebug.printMesg(7, 'Drawing item of type %s' % (object._type)) |
82 |
|
object._widgetHandler = WidgetHandler(self.layouteditor, object) |
83 |
|
|
84 |
|
cevent = Event('CreateUIWidget',None, |
85 |
|
parent=None, |
86 |
|
object=object, |
87 |
|
container=self.layouteditor.workspace.panel, |
88 |
|
textWidth=self.textWidth, |
89 |
|
textHeight=self.textHeight, |
90 |
|
widgetWidth=self.widgetWidth, |
91 |
|
widgetHeight=self.widgetHeight, |
92 |
|
interface=self, |
93 |
|
eventHandler=None, |
94 |
|
ui=self, |
95 |
|
initialize=0) |
96 |
|
|
97 |
|
object._widget = widget = self.widgets[object._type].configuration['baseClass'](cevent) |
98 |
|
|
99 |
|
# TODO: This segfaults us... yay!!! (is this fixed???) |
100 |
|
widget.phaseInit(widget._buildObject()) |
101 |
|
|
102 |
|
object._widget._object = object |
103 |
|
object._widgetHandler.initialize(object._widget) |
104 |
|
self.widgetList.append(object) |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
########## |
110 |
|
# |
111 |
|
# Internal methods |
112 |
|
# |
113 |
|
|
114 |
|
|