1 |
# |
# |
2 |
# Copyright 2001-2002 Free Software Foundation |
# Copyright 2001-2003 Free Software Foundation |
3 |
# |
# |
4 |
# This file is part of GNU Enterprise. |
# This file is part of GNU Enterprise. |
5 |
# |
# |
58 |
|
|
59 |
for widget in self.mainWidget.widgets: |
for widget in self.mainWidget.widgets: |
60 |
widget.SetCursor (wxSTANDARD_CURSOR) |
widget.SetCursor (wxSTANDARD_CURSOR) |
61 |
if isinstance(widget, wxWindow): |
|
62 |
widget.Enable(0) |
# try: |
63 |
|
# widget.Enable(0) |
64 |
|
# except: |
65 |
|
# pass |
66 |
|
|
67 |
|
try: |
68 |
|
widget.SetEditable(0) |
69 |
|
except: |
70 |
|
pass |
71 |
|
|
72 |
self.setAllChildren(EVT_KEY_UP, widget, self.instance.keyTrap) |
self.setAllChildren(EVT_KEY_UP, widget, self.instance.keyTrap) |
73 |
self.setAllChildren(EVT_SET_FOCUS, widget, self.focusGainedTrap) |
self.setAllChildren(EVT_SET_FOCUS, widget, self.focusGainedTrap) |
74 |
self.setAllChildren(EVT_KILL_FOCUS, widget, self.focusLostTrap) |
self.setAllChildren(EVT_KILL_FOCUS, widget, self.focusLostTrap) |
137 |
|
|
138 |
if not self.instance._currentSelection.has_key(self): |
if not self.instance._currentSelection.has_key(self): |
139 |
self.instance._currentSelection[self] = 1 |
self.instance._currentSelection[self] = 1 |
140 |
self.instance._instance.onSetCurrentObject(self.object,"Forms::LayoutEditor") |
self.instance._instance.dispatchEvent('ObjectSelected',object=self.object,originator="Forms::LayoutEditor") |
141 |
self.setSelected(1) |
self.setSelected(1) |
142 |
self._alreadySelected = 0 |
self._alreadySelected = 0 |
143 |
else: |
else: |
156 |
|
|
157 |
data = [ { "Type" : "selectedWidgets", |
data = [ { "Type" : "selectedWidgets", |
158 |
"Attributes": { |
"Attributes": { |
159 |
'startingX': object.x + int(x/self.instance.gridWidth), |
'startingX': object.Char__x + int(x/self.instance.gridWidth), |
160 |
'startingY': object.y + int(y/self.instance.gridHeight), |
'startingY': object.Char__y + int(y/self.instance.gridHeight), |
161 |
} |
} |
162 |
}] |
}] |
163 |
# "name": dname, |
# "name": dname, |
208 |
|
|
209 |
def OnRightUp(self, event): |
def OnRightUp(self, event): |
210 |
pt = event.GetPositionTuple() |
pt = event.GetPositionTuple() |
211 |
self.instance._instance.onSetCurrentObject(self.object, None) |
self.instance.dispatchEvent('ObjectSelected',object=self.object, originator=None) |
212 |
wxPyTypeCast(event.GetEventObject(),'wxWindow') \ |
wxPyTypeCast(event.GetEventObject(),'wxWindow') \ |
213 |
.PopupMenu(self.object._popupMenu, pt) |
.PopupMenu(self.object._popupMenu, pt) |
214 |
event.Skip() |
event.Skip() |
216 |
|
|
217 |
def _endPopupEditor(self, success, value=""): |
def _endPopupEditor(self, success, value=""): |
218 |
if success: |
if success: |
219 |
self.object.__dict__[self.__popupAttr] = value |
|
220 |
self.instance._instance.onModifyObject(self.object, |
try: |
221 |
"Forms::LayoutEditor", ((self.__popupAttr, value),)) |
oldVals = {self.__popupAttr:self.object.__dict__[self.__popupAttr]} |
222 |
|
except KeyError: |
223 |
|
oldVals = {self.__popupAttr:None} |
224 |
|
newVals = {self.__popupAttr: value} |
225 |
|
self.object.__dict__.update(newVals) |
226 |
|
self.instance.dispatchEvent('ObjectModified', object=self.object, |
227 |
|
originator="Forms::LayoutEditor", |
228 |
|
old=oldVals, |
229 |
|
new=newVals) |
230 |
|
|
231 |
self._popup_editor.Destroy() |
self._popup_editor.Destroy() |
232 |
self._popup_editor = None |
self._popup_editor = None |
233 |
self.widget.SetLabel(value or "<Unset>") |
self.widget.SetLabel(value or "<Unset>") |
246 |
if self.object._type == 'GFBox': |
if self.object._type == 'GFBox': |
247 |
self.__popupAttr = 'label' |
self.__popupAttr = 'label' |
248 |
x = self.widget.GetPosition().x + (self.instance.gridWidth/2) |
x = self.widget.GetPosition().x + (self.instance.gridWidth/2) |
249 |
width = (self.object.width - 2) * self.instance.gridWidth |
width = (self.object.Char__width - 2) * self.instance.gridWidth |
250 |
else: |
else: |
251 |
self.__popupAttr = 'text' |
self.__popupAttr = 'text' |
252 |
x = self.widget.GetPosition().x |
x = self.widget.GetPosition().x |
280 |
|
|
281 |
nx = dx * self.instance.gridWidth |
nx = dx * self.instance.gridWidth |
282 |
ny = dy * self.instance.gridHeight |
ny = dy * self.instance.gridHeight |
283 |
|
|
284 |
|
try: |
285 |
|
self.object.Char__height |
286 |
|
except: |
287 |
|
self.object.Char__height = 1 |
288 |
|
|
289 |
if (self.object.width + dx < 0 or self.object.height + dy < 0): |
if (self.object.Char__width + dx < 0 or self.object.Char__height + dy < 0): |
290 |
return 0 |
return 0 |
291 |
else: |
else: |
292 |
for widget in self.mainWidget.widgets: |
for widget in self.mainWidget.widgets: |
293 |
x,y = widget.GetSizeTuple() |
x,y = widget.GetSizeTuple() |
294 |
widget.SetSize(wxSize(x + nx,y + ny)) |
widget.SetSize(wxSize(x + nx,y + ny)) |
295 |
changes = [] |
|
296 |
|
oldVals = {} |
297 |
|
newVals = {} |
298 |
if dx: |
if dx: |
299 |
self.object.width = self.object.width + dx |
oldVals['Char:width'] = self.object.Char__width |
300 |
changes.append(['width',self.object.width]) |
self.object.Char__width = self.object.Char__width + dx |
301 |
|
newVals['Char:width'] = self.object.Char__width |
302 |
if dy: |
if dy: |
303 |
self.object.height = self.object.height + dy |
oldVals['Char:height'] = self.object.Char__height |
304 |
changes.append(['height',self.object.height]) |
self.object.Char__height = self.object.Char__height + dy |
305 |
self.instance._instance.onModifyObject(self.object, "Forms::LayoutEditor", changes) |
newVals['Char:height'] = self.object.Char__height |
306 |
|
|
307 |
|
self.instance.dispatchEvent('ObjectModified', object=self.object, |
308 |
|
originator="Forms::LayoutEditor", |
309 |
|
old=oldVals, |
310 |
|
new=newVals) |
311 |
|
|
312 |
self.recalcBoundaries() |
self.recalcBoundaries() |
313 |
|
|
314 |
|
|
324 |
nx = dx * self.instance.gridWidth |
nx = dx * self.instance.gridWidth |
325 |
ny = dy * self.instance.gridHeight |
ny = dy * self.instance.gridHeight |
326 |
|
|
327 |
if (self.object.x + dx < 0 or self.object.y + dy < 0): |
if (self.object.Char__x + dx < 0 or self.object.Char__y + dy < 0): |
328 |
return 0 |
return 0 |
329 |
else: |
else: |
330 |
for widget in self.mainWidget.widgets: |
for widget in self.mainWidget.widgets: |
331 |
x,y = widget.GetPositionTuple() |
x,y = widget.GetPositionTuple() |
332 |
widget.SetPosition(wxPoint(x + nx,y + ny)) |
widget.SetPosition(wxPoint(x + nx,y + ny)) |
333 |
changes = [] |
oldVals = {} |
334 |
|
newVals = {} |
335 |
if dx: |
if dx: |
336 |
self.object.x = self.object.x + dx |
oldVals['Char:x'] = self.object.Char__x |
337 |
changes.append(['x',self.object.x]) |
self.object.Char__x += dx |
338 |
|
newVals['Char:x'] = self.object.Char__x |
339 |
if dy: |
if dy: |
340 |
self.object.y = self.object.y + dy |
oldVals['Char:y'] = self.object.Char__y |
341 |
changes.append(['y',self.object.y]) |
self.object.Char__y += dy |
342 |
self.instance._instance.onModifyObject(self.object, |
newVals['Char:y'] = self.object.Char__y |
343 |
"Forms::LayoutEditor", changes) |
|
344 |
|
self.instance.dispatchEvent('ObjectModified', object=self.object, |
345 |
|
originator="Forms::LayoutEditor", |
346 |
|
old=oldVals, |
347 |
|
new=newVals) |
348 |
|
|
349 |
self.recalcBoundaries() |
self.recalcBoundaries() |
350 |
|
|
351 |
# |
# |
352 |
# Recursively destroy this widget set |
# Recursively destroy this widget set |
353 |
# |
# |
354 |
def Destroy(self): |
def Destroy(self): |
355 |
|
|
356 |
# TODO: Why the fsck can't I Destroy() this thing!?!??!? |
# TODO: Why the fsck can't I Destroy() this thing!?!??!? |
357 |
self.widget.Show(0) |
self.widget.Show(0) |
358 |
|
|