[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8487 - in trunk/gnue-designer/src: app base base/tools forms/Pag
From: |
jcater |
Subject: |
[gnue] r8487 - in trunk/gnue-designer/src: app base base/tools forms/PagePainter/skins ui/wx/uihelpers ui/wx/uihelpers/doccanvas |
Date: |
Mon, 29 May 2006 23:19:16 -0500 (CDT) |
Author: jcater
Date: 2006-05-29 23:19:14 -0500 (Mon, 29 May 2006)
New Revision: 8487
Modified:
trunk/gnue-designer/src/app/objectext.py
trunk/gnue-designer/src/base/Incubator.py
trunk/gnue-designer/src/base/MultiObjectGridEditor.py
trunk/gnue-designer/src/base/tools/EventEditor.py
trunk/gnue-designer/src/base/tools/PropertyEditor.py
trunk/gnue-designer/src/forms/PagePainter/skins/common.py
trunk/gnue-designer/src/ui/wx/uihelpers/GridCellEditors.py
trunk/gnue-designer/src/ui/wx/uihelpers/doccanvas/canvas.py
Log:
* Finished the "union"-ization of the property editor tool (if multiple objects
are
selected, a "union" of the attributes is displayed)
* Minor code cleanup
Modified: trunk/gnue-designer/src/app/objectext.py
===================================================================
--- trunk/gnue-designer/src/app/objectext.py 2006-05-24 14:38:04 UTC (rev
8486)
+++ trunk/gnue-designer/src/app/objectext.py 2006-05-30 04:19:14 UTC (rev
8487)
@@ -25,10 +25,10 @@
Extensions to GNUe Common's GObjects
"""
-__all__ = ['GObj', 'GUndividedCollection']
-
from gnue.common.definitions.GObjects import GObj
+__all__ = ['GObjectExtender', 'install']
+
class GObjectExtender(object):
"""
Our extensions to the gnue.common.definitions.GObjects class
Modified: trunk/gnue-designer/src/base/Incubator.py
===================================================================
--- trunk/gnue-designer/src/base/Incubator.py 2006-05-24 14:38:04 UTC (rev
8486)
+++ trunk/gnue-designer/src/base/Incubator.py 2006-05-30 04:19:14 UTC (rev
8487)
@@ -92,9 +92,9 @@
o.name = name
self.document.nameMappings[o.name] = o
o._buildObject()
- o.dispatchEvent('ObjectCreated')
+ o.dispatch_designer_event('ObjectCreated')
if select:
- o.dispatchEvent('ObjectSelected')
+ o.dispatch_designer_event('ObjectSelected')
return o
# ----------------------------------------------------------------------
@@ -110,7 +110,7 @@
if not child._type == '_content_':
self.deleteObject(rootObject, child, firstRun=0)
- object.dispatchEvent('ObjectDeleted')
+ object.dispatch_designer_event('ObjectDeleted')
if firstRun:
o = parent
@@ -119,7 +119,7 @@
o = o.getParent()
if newCurrentObject:
- object.dispatchEvent('ObjectSelected')
+ object.dispatch_designer_event('ObjectSelected')
# ----------------------------------------------------------------------
Modified: trunk/gnue-designer/src/base/MultiObjectGridEditor.py
===================================================================
--- trunk/gnue-designer/src/base/MultiObjectGridEditor.py 2006-05-24
14:38:04 UTC (rev 8486)
+++ trunk/gnue-designer/src/base/MultiObjectGridEditor.py 2006-05-30
04:19:14 UTC (rev 8487)
@@ -31,7 +31,6 @@
import weakref, types
import wx
from wx.grid import *
-from gnue.common.apps import GDebug, RuntimeSettings
class MultiObjectGridEditor(Grid):
Modified: trunk/gnue-designer/src/base/tools/EventEditor.py
===================================================================
--- trunk/gnue-designer/src/base/tools/EventEditor.py 2006-05-24 14:38:04 UTC
(rev 8486)
+++ trunk/gnue-designer/src/base/tools/EventEditor.py 2006-05-30 04:19:14 UTC
(rev 8487)
@@ -28,14 +28,16 @@
import os
import string
+
import wx
-from wx.grid import *
+import wx.grid
+
from gnue.common.apps import GDebug
from gnue.common.formatting import GTypecast
from gnue.common.logic.GTrigger import GTrigger
from gnue.common.definitions.GParserHelpers import GContent
from gnue.designer.base.ToolBase import ToolNotebook
-from gnue.designer.ui.wx.uihelpers.GridCellEditors import CharCellEditor
+from gnue.designer.ui.wx.uihelpers.GridCellEditors import RestrictedCellEditor
class EventEditor (ToolNotebook):
@@ -141,7 +143,7 @@
self.rowList = []
# Set up our grid
- self.grid = Grid(self, -1, pos=wx.Point(0,0))
+ self.grid = wx.grid.Grid(self, -1, pos=wx.Point(0,0))
self.grid.SetDefaultCellFont(wx.SMALL_FONT)
self.grid.SetLabelFont(wx.SMALL_FONT)
self.grid.CreateGrid(1,1)
@@ -149,9 +151,9 @@
self.namedMap = {}
- EVT_GRID_SELECT_CELL(self.grid, self.OnCellSelected)
- EVT_GRID_CELL_CHANGE(self.grid, self.OnCellChange)
- EVT_GRID_CELL_LEFT_DCLICK(self.grid, self.OnLeftDClick)
+ wx.grid.EVT_GRID_SELECT_CELL(self.grid, self.OnCellSelected)
+ wx.grid.EVT_GRID_CELL_CHANGE(self.grid, self.OnCellChange)
+ wx.grid.EVT_GRID_CELL_LEFT_DCLICK(self.grid, self.OnLeftDClick)
wx.EVT_SIZE(self, self.onSize)
self.editor.rootObject.walk(self.inventoryObject)
@@ -322,10 +324,11 @@
try:
trigger = self.triggerMap[attr]
- new = 0
+ new = False
except KeyError:
- trigger = GTrigger(self.object, trigType)
- new = 1
+ trigger = GTrigger(self.object)
+ trigger['type'] = trigType
+ new = True
oldStuff = {}
newStuff = {}
@@ -381,9 +384,11 @@
##
##
##
-class EventCellEditor (CharCellEditor):
+class EventCellEditor(wx.grid.GridCellChoiceEditor):
def __init__(self, grid, attributes):
- CharCellEditor.__init__(self, grid, attributes)
+ self.grid = grid
+ self.attributes = attributes
+
self.valueList = attributes.keys()
self.valueList.sort()
@@ -391,21 +396,28 @@
self.valueMap = {}
i = 0
+ if not (attributes.has_key('Required') and attributes['Required'] ):
+ self.valueMap[''] = 0
+ self.selectionList.append(u_(' <Not Set> '))
+ i = 1
+
for v in self.valueList:
self.valueMap[v] = i
self.selectionList.append("%s" % (attributes[v] or v))
- i = i + 1
+ i += 1
-## self.valueList.insert(0, '')
+ self.valueList.insert(0, '')
- def Create(self, parent, id, evtHandler):
- assert gDebug(10,'Creating CharCellEditor')
- self._tc = wx.ComboBox(parent, id, "", style=wx.CB_READONLY,
- choices=self.selectionList)
- self.SetControl(self._tc)
- if evtHandler:
- self._tc.PushEventHandler(evtHandler)
+ wx.grid.GridCellChoiceEditor.__init__(self, self.selectionList, False)
+ #def Create(self, parent, id, evtHandler):
+ #assert gDebug(10,'Creating CharCellEditor')
+ #self._tc = wx.ComboBox(parent, id, "", style=wx.CB_READONLY,
+ #choices=self.selectionList)
+ #self.SetControl(self._tc)
+ #if evtHandler:
+ #self._tc.PushEventHandler(evtHandler)
+
def BeginEdit(self, row, col, grid):
self.startValue = grid.GetTable().GetValue(row, col)
self._tc.SetSelection(self.valueMap[self.startValue])
@@ -434,7 +446,7 @@
ch = None
if key in [wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2,
wx.WXK_NUMPAD3, wx.WXK_NUMPAD4,
wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7,
wx.WXK_NUMPAD8, wx.WXK_NUMPAD9]:
- ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
+ ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
elif key < 256 and key >= 0 and chr(key):
ch = chr(key)
@@ -449,3 +461,22 @@
# self._tc.SetInsertionPointEnd()
else:
evt.Skip()
+
+
+ def EndEdit(self, row, col, grid):
+ changed = False
+
+ val = self.valueList[self._tc.GetSelection()]
+ if val != self.startValue:
+ changed = True
+ grid.GetTable().SetValue(row, col, "%s" % val) # update the table
+
+ self.startValue = ''
+ self._tc.SetSelection(0)
+ return changed
+
+
+ def Reset(self):
+ self._tc.SetSelection(self.valueMap[self.startValue])
+ #self._tc.SetInsertionPointEnd()
+
Modified: trunk/gnue-designer/src/base/tools/PropertyEditor.py
===================================================================
--- trunk/gnue-designer/src/base/tools/PropertyEditor.py 2006-05-24
14:38:04 UTC (rev 8486)
+++ trunk/gnue-designer/src/base/tools/PropertyEditor.py 2006-05-30
04:19:14 UTC (rev 8487)
@@ -65,9 +65,19 @@
self.SetAutoLayout(True)
self.SetSizer(sizer)
+# self.Bind(wx.EVT_COMMAND_LIST_END_LABEL_EDIT,
+# self.property_changed, listctrl)
+
listctrl.SetFont(wx.SMALL_FONT)
+ def property_changed(self, event):
+ """
+ Called after the user has edited a property
+ value
+ """
+ print event
+
def object_selected_event (self, event):
"""
Called on the ObjectSelected event.
@@ -97,10 +107,11 @@
return
# Merge the attribute lists from the selected properties.
+ # common_attributes is of the format:
+ # attribute_name: [attribute def, gobject count, common value]
common_attributes = {}
- common_values = {}
+
unique_attributes = {}
- dropped_attributes = {}
first_object = True
for gobject in objects:
@@ -114,41 +125,34 @@
except:
value = attributes.get('Default',None)
- # If we've already decided this attribute isn't
- # common, don't do the tests again
- if dropped_attributes.has_key(attribute_name):
- continue
-
# This may be a tad drastic; drop any deprecated attributes
if attribute['Deprecated']:
continue
if first_object:
# First loop thru, nothing to compare
- common_attributes[attribute_name] = attribute
- common_values[attribute_name] = value
- elif first_object or \
- not common_attributes.has_key(attribute_name):
- # First time seeing attribute, so nothing to compare
- common_attributes[attribute_name] = attribute
- common_values[attribute_name] = value
+ common_attributes[attribute_name] = [attribute, 1, value]
+ elif not common_attributes.has_key(attribute_name):
+ # First time seeing attribute, but not the first object,
+ # so this can't be a common attribute
+ continue
else:
# Do a diff of current and previous attribute instance
- common = common_attributes[attribute_name]
- if attribute['Typecast'] == common['Typecast'] and \
- attribute['Label'] == common['Label'] and \
- attribute['References'] == common['References'] and \
- attribute['ValidSet'].keys() == common['ValidSet'].keys():
+ common, common_count, common_value = (
+ common_attributes[attribute_name])
+ if (attribute['Typecast'] == common['Typecast'] and
+ attribute['Label'] == common['Label'] and
+ attribute['References'] == common['References'] and
+ attribute['ValidSet'].keys() ==
common['ValidSet'].keys()):
+
# Attributes match. Do the values?
- if common_values.has_key(attribute_name) and \
- value != common_values:
- value = MixedValues
+ if value != common_value:
+ common_attributes[attribute_name][2] = MixedValues
- common_values[attribute_name] == value
+ common_attributes[attribute_name][1] += 1
else:
# Attributes don't match, so add to our black list
- dropped_attributes[attribute_name] = True
del common_attributes[attribute_name]
# Keep track of attributes that are unique
@@ -156,15 +160,26 @@
unique_attributes[attribute_name] = True
first_object = False
+
# Remove all "Unique" attributes if there's more than one object
if len(objects) > 1:
for attribute_name in unique_attributes.keys():
del common_attributes[attribute_name]
+ # Remove any "common" attribute not actually in all definitions
+ sorted_attributes = []
+ add = sorted_attributes.append
+ gobject_count = len(objects)
+ for attribute_name, attribute_pair in common_attributes.items():
+ attribute, matched_gobject_count, common_value = attribute_pair
+ if matched_gobject_count == gobject_count:
+ add((attribute['Label'],
+ (attribute_name, attribute, common_value)))
+
# Sort by label
- sorted_attributes = [(attribute['Label'], (attribute_name, attribute))
- for attribute_name, attribute in common_attributes.items()]
sorted_attributes.sort()
+
+ # ... remove the label
sorted_attributes = [ attribute_pair \
for label, attribute_pair in sorted_attributes]
@@ -172,18 +187,19 @@
self.attribute_list = sorted_attributes
# We have all the data we need, so add them to our edit list
- for attribute_name, attribute in sorted_attributes:
+ for attribute_name, attribute, common_value in sorted_attributes:
# Define our rows
index = self.listctrl.InsertStringItem(sys.maxint,
attribute['Label'])
self.listctrl.SetStringItem(index, 0, attribute['Label'])
- self.listctrl.SetStringItem(index, 1,
- str(common_values[attribute_name]))
- #self.listctrl.SetItemData(index, attribute_name)
+ if common_value is MixedValues:
+ common_value = u_('(Multiple)')
+ self.listctrl.SetStringItem(index, 1, str(common_value))
+
## Determine the type of Cell Editor we want
## (Integer, Boolean, Dropdown, Char)
#if self.attributes[key].has_key('ValueSet'):
@@ -234,8 +250,6 @@
"""
Used internally
"""
- def __str__(self):
- return u_("(Multiple)")
class PropertyEditorListCtrl(wx.ListCtrl, mixins.TextEditMixin,
mixins.ListCtrlAutoWidthMixin):
Modified: trunk/gnue-designer/src/forms/PagePainter/skins/common.py
===================================================================
--- trunk/gnue-designer/src/forms/PagePainter/skins/common.py 2006-05-24
14:38:04 UTC (rev 8486)
+++ trunk/gnue-designer/src/forms/PagePainter/skins/common.py 2006-05-30
04:19:14 UTC (rev 8487)
@@ -156,8 +156,13 @@
delta_char_height = int(round(delta_height / float(char_y_scale)))
if delta_char_width or delta_char_height:
+ try:
+ char_width = gobject['Char:width']
+ except KeyError:
+ char_width = self.char_default_width
+
char_width = min(max(delta_char_width +
- gobject['Char:width'],
+ char_width,
self.char_min_width),
self.char_max_width)
Modified: trunk/gnue-designer/src/ui/wx/uihelpers/GridCellEditors.py
===================================================================
--- trunk/gnue-designer/src/ui/wx/uihelpers/GridCellEditors.py 2006-05-24
14:38:04 UTC (rev 8486)
+++ trunk/gnue-designer/src/ui/wx/uihelpers/GridCellEditors.py 2006-05-30
04:19:14 UTC (rev 8487)
@@ -29,16 +29,16 @@
import sys, os, string
import wx
-from wx.grid import *
+import wx.grid
from gnue.common.apps import GDebug
from gnue.common.formatting import GTypecast
#
#
#
-class CharCellEditor (PyGridCellEditor):
+class CharCellEditor (wx.grid.PyGridCellEditor):
def __init__(self, grid, attributes):
- PyGridCellEditor.__init__(self)
+ wx.grid.PyGridCellEditor.__init__(self)
self.grid = grid
self.attributes = attributes
self.__created = 0
@@ -164,9 +164,11 @@
evt.Skip()
-class RestrictedCellEditor (CharCellEditor):
+class RestrictedCellEditor (wx.grid.GridCellChoiceEditor):
def __init__(self, grid, attributes):
- CharCellEditor.__init__(self, grid, attributes)
+ self.grid = grid
+ self.attributes = attributes
+
self.valueList = attributes['ValueSet'].keys()
self.valueList.sort()
@@ -182,18 +184,20 @@
for v in self.valueList:
self.valueMap[v] = i
self.selectionList.append("%s" % (attributes['ValueSet'][v] or v))
- i = i + 1
+ i += 1
self.valueList.insert(0, '')
- def Create(self, parent, id, evtHandler):
- assert gDebug(10,'Creating CharCellEditor')
- self._tc = wx.ComboBox(parent, id, "", style=wx.CB_READONLY,
- choices=self.selectionList)
- self.SetControl(self._tc)
- if evtHandler:
- self._tc.PushEventHandler(evtHandler)
+ wx.grid.PyGridCellEditor.__init__(self.selectionList, False)
+ #def Create(self, parent, id, evtHandler):
+ #assert gDebug(10,'Creating CharCellEditor')
+ #self._tc = wx.ComboBox(parent, id, "", style=wx.CB_READONLY,
+ #choices=self.selectionList)
+ #self.SetControl(self._tc)
+ #if evtHandler:
+ #self._tc.PushEventHandler(evtHandler)
+
def BeginEdit(self, row, col, grid):
self.startValue = grid.GetTable().GetValue(row, col)
self._tc.SetSelection(self.valueMap[self.startValue])
Modified: trunk/gnue-designer/src/ui/wx/uihelpers/doccanvas/canvas.py
===================================================================
--- trunk/gnue-designer/src/ui/wx/uihelpers/doccanvas/canvas.py 2006-05-24
14:38:04 UTC (rev 8486)
+++ trunk/gnue-designer/src/ui/wx/uihelpers/doccanvas/canvas.py 2006-05-30
04:19:14 UTC (rev 8487)
@@ -123,16 +123,16 @@
has no action.
create: Clicking the canvas creates a new object. This mode
- doesn't actually do anything... your "method" passed in
+ doesn't actually do anything... your "function" passed in
should handle the actual creation.
delete: Clicking an object "deletes" the object. This mode
- doesn't do anything ... your method should handle it.
+ doesn't do anything ... your "function" should handle it.
picker: Objects can only be "selected"... no operations permitted.
(Useful for setting tab order, etc.)
- method A python method to call once the target action happens.
+ function A python method to call once the target action happens.
"""
self.__mouse_mode = mode
@@ -144,7 +144,7 @@
# ---------------------------------------------------------------
def set_grid_scale(self, x, y):
"""
- Sets the grid x,y spacing
+ Sets the grid x, y spacing
"""
self.grid_x_spacing = x
self.grid_y_spacing = y
@@ -388,10 +388,10 @@
(x - 2 + width / 2 , y + height - 3, 'resize-bottom'), # bottom
middle
):
- rect = wx.Rect(bx,by,5,5)
+ rect = wx.Rect(bx, by, 5, 5)
target_dc.DrawRectangleRect(rect)
if not xor:
- add_hotspot((rect,position))
+ add_hotspot((rect, position))
# Add hotspot markers for the selection box
if not xor:
@@ -424,7 +424,7 @@
if not x % SOLIDSPACING:
switch_pens = True
target_dc.SetPen(pen2)
- target_dc.DrawLine(x,0,x,height-1)
+ target_dc.DrawLine(x, 0, x, height - 1)
if switch_pens:
target_dc.SetPen(pen1)
switch_pens = False
@@ -447,19 +447,21 @@
pen = wx.Pen(color_map['workspaceGrid'], 1, wx.SOLID)
target_dc.SetPen(pen)
- for x in xrange(self.grid_x_spacing,width,self.grid_x_spacing):
- for y in xrange(self.grid_y_spacing, height,
self.grid_y_spacing):
- target_dc.DrawPoint(x,y)
+ for x in xrange(self.grid_x_spacing, width,
+ self.grid_x_spacing):
+ for y in xrange(self.grid_y_spacing, height,
+ self.grid_y_spacing):
+ target_dc.DrawPoint(x, y)
# Draw vertical grid lines
- for x in xrange(self.grid_x_spacing*SOLIDSPACING, width,
- self.grid_x_spacing*SOLIDSPACING):
- target_dc.DrawLine(x,0,x,height-1)
+ for x in xrange(self.grid_x_spacing * SOLIDSPACING, width,
+ self.grid_x_spacing * SOLIDSPACING):
+ target_dc.DrawLine(x, 0, x, height - 1)
# Draw horizontal grid lines
- for y in xrange(self.grid_y_spacing*SOLIDSPACING, height,
- self.grid_y_spacing*SOLIDSPACING):
+ for y in xrange(self.grid_y_spacing * SOLIDSPACING, height,
+ self.grid_y_spacing * SOLIDSPACING):
target_dc.DrawLine(0, y, width, y)
@@ -565,12 +567,12 @@
return True
elif mode == 'picker':
- widget = self.select_hit_test(x,y)
+ widget = self.select_hit_test(x, y)
if widget:
widget.pick_from_canvas()
elif mode == 'edit':
- widget = self.select_hit_test(x,y)
+ widget = self.select_hit_test(x, y)
if widget:
self.widget_picked(widget)
@@ -650,13 +652,13 @@
if event.Dragging():
if mode == 'normal':
if current_action == 'rubberband':
- self.__update_rubberband(x,y)
+ self.__update_rubberband(x, y)
elif current_action == 'move':
- self.__update_moving(x,y)
+ self.__update_moving(x, y)
elif current_action == 'resize':
- self.__update_resizing(x,y)
+ self.__update_resizing(x, y)
else:
@@ -745,10 +747,10 @@
self.CaptureMouse()
- # These will visually move, but not necessarily have their x,y changed.
+ # These will visually move, but not necessarily have their x, y
changed.
self.__mouse_move_all = all_widgets = []
- # These will move and have their x,y changed in the end
+ # These will move and have their x, y changed in the end
self.__mouse_move_items = movable_widgets = []
# Start out with the selected widgets
@@ -910,7 +912,7 @@
self.__mouse_resize_last_area = None
self.__mouse_resize_start_x = x
self.__mouse_resize_start_y = y
- ##self.__update_resizing(x,y)
+ ##self.__update_resizing(x, y)
self.end_refresh_batch()
@@ -992,18 +994,18 @@
delta_height = y - self.__mouse_resize_start_y
# Discard width or height if only a side was moved
- if orientation in ('top','bottom'):
+ if orientation in ('top', 'bottom'):
delta_width = 0
- if orientation in ('left','right'):
+ if orientation in ('left', 'right'):
delta_height = 0
# Determine if the widget moved while being resized
delta_x = 0
delta_y = 0
- if orientation in ('left','ul','ll') and delta_width:
+ if orientation in ('left', 'ul', 'll') and delta_width:
delta_x = delta_width
delta_width *= -1
- if orientation in ('top','ul','ur') and delta_height:
+ if orientation in ('top', 'ul', 'ur') and delta_height:
delta_y = delta_height
delta_height *= -1
@@ -1055,9 +1057,9 @@
# Draw the new box
if x is not None:
- r = wx.RectPP(start, (x,y))
+ r = wx.RectPP(start, (x, y))
target_dc.DrawRectangleRect(r)
- self.__mouse_rubberband_last = (x,y)
+ self.__mouse_rubberband_last = (x, y)
target_dc.EndDrawing()
@@ -1111,7 +1113,7 @@
Return the first widget at a point
"""
for widget in self.ordered_widget_list:
- if widget.select_hit_test(x,y):
+ if widget.select_hit_test(x, y):
return widget
return None
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8487 - in trunk/gnue-designer/src: app base base/tools forms/PagePainter/skins ui/wx/uihelpers ui/wx/uihelpers/doccanvas,
jcater <=