dabo Commit
Revision 6435
Date: 2011-02-15 03:48:55 -0800 (Tue, 15 Feb 2011)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6435
Changed:
U trunk/dabo/ui/uiwx/dPemMixin.py
U trunk/dabo/ui/uiwx/object_inspector.py
U trunk/dabo/ui/uiwx/uiApp.py
Log:
Updated to address issues raised with initial commit of the Object Inspector.
Please let me know how this version works for you. I've tested under OS X and
WinXP, but not Linux yet.
Added code to account for platform differences in the way that forms report
their absolute position on the screen. Under Windows, instead of the position
of the entire form, the position of the interior (minus title bar, menus,
borders) is returned.
Diff:
Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py 2011-02-14 22:57:02 UTC (rev 6434)
+++ trunk/dabo/ui/uiwx/dPemMixin.py 2011-02-15 11:48:55 UTC (rev 6435)
@@ -1027,7 +1027,14 @@
of this control relative to the container.
"""
selfX, selfY = self.absoluteCoordinates()
- cntX, cntY = cnt.absoluteCoordinates()
+ if self.Application.Platform == "Win" and isinstance(cnt,
dabo.ui.dFormMixin):
+ # On Windows, absoluteCoordinates() returns the
position of the
+ # interior of the form, ignoring the menus, borders,
etc. On Mac, it
+ # properly returns position of the entire window frame
+ # NOTE: Need to check this on Gtk
+ cntX, cntY = cnt.Position
+ else:
+ cntX, cntY = cnt.absoluteCoordinates()
return (selfX-cntX, selfY-cntY)
@@ -1944,7 +1951,7 @@
def _getChildren(self):
if hasattr(self, "GetChildren"):
- return self.GetChildren()
+ return list(self.GetChildren())
else:
return None
@@ -2960,11 +2967,17 @@
"""
if not self.Visible or self._inInit:
return
+ srcObj = self.Parent
+ if isinstance(srcObj, dabo.ui.dFormMixin):
+ frm = srcObj
+ else:
+ frm = srcObj.Form
+ x, y = self.Xpos, self.Ypos
+
if dc is None:
- dc = self._dc or wx.ClientDC(self.Parent)
-
+ dc = self._dc or wx.WindowDC(frm)
if self.Shape == "bmp":
- dc.DrawBitmap(self._bitmap, self.Xpos, self.Ypos,
self._transparent)
+ dc.DrawBitmap(self._bitmap, x, y, self._transparent)
self._width = self._bitmap.GetWidth()
self._height = self._bitmap.GetHeight()
return
@@ -2974,16 +2987,15 @@
self._brushSettings(dc)
self._modeSettings(dc)
- srcObj = self.Parent
- if self.Application.Platform == "GTK" and \
- not (isinstance(srcObj, (dabo.ui.dPanel,
dabo.ui.dPage, dabo.ui.dGrid))):
- if isinstance(srcObj, dabo.ui.dForm):
- x, y = srcObj.containerCoordinates(srcObj,
(self.Xpos, self.Ypos))
- else:
- x, y =
self.Parent.containerCoordinates(srcObj.Parent, (self.Xpos, self.Ypos))
- else:
- x, y = self.Xpos, self.Ypos
-
+# if self.Application.Platform == "GTK" and \
+# not (isinstance(srcObj, (dabo.ui.dPanel,
dabo.ui.dPage, dabo.ui.dGrid))):
+# if isinstance(srcObj, dabo.ui.dForm):
+# x, y = srcObj.containerCoordinates(srcObj,
(self.Xpos, self.Ypos))
+# else:
+# x, y =
self.Parent.containerCoordinates(srcObj.Parent, (self.Xpos, self.Ypos))
+# else:
+# x, y = self.Xpos, self.Ypos
+#
if self.Shape == "circle":
dc.DrawCircle(x, y, self.Radius)
self._width = self._height = self.Radius * 2
Modified: trunk/dabo/ui/uiwx/object_inspector.py
===================================================================
--- trunk/dabo/ui/uiwx/object_inspector.py 2011-02-14 22:57:02 UTC (rev
6434)
+++ trunk/dabo/ui/uiwx/object_inspector.py 2011-02-15 11:48:55 UTC (rev
6435)
@@ -7,7 +7,7 @@
# 'InspectorFormClass' is defined at the bottom
inspector_source = '''<?xml version="1.0" encoding="mac-roman"
standalone="no"?>
-<dForm Name="dForm" Caption="Dabo Object Inspector"
SaveRestorePosition="False" Height="750" Width="850" designerClass="DesForm">
+<dForm Name="dForm" Caption="Dabo Object Inspector"
SaveRestorePosition="False" Top="168" Height="761" Width="846"
designerClass="DesForm" Left="537">
<code>
<addkids><![CDATA[
def addkids(self, obj, node):
@@ -27,6 +27,11 @@
except AttributeError:
# Not a dabo obj
return
+ if isinstance(obj, dabo.ui.dFormMixin):
+ if obj.ToolBar:
+ kids.append(obj.ToolBar)
+ if obj.StatusBar:
+ kids.append(obj.StatusBar)
for kid in kids:
if self.exclude(kid):
continue
@@ -70,7 +75,7 @@
frm.removeDrawnObject(toClear["drawingToClear"])
except ValueError:
pass
- frm.forceSizerOutline()
+# frm.forceSizerOutline()
else:
sz = toClear["outlinedSizer"]
frm.removeFromOutlinedSizers(sz)
@@ -78,6 +83,8 @@
sz.outlineStyle = toClear["outlineStyle"]
sz.outlineWidth = toClear["outlineWidth"]
frm.clear()
+ frm.refresh()
+ self.refresh()
]]>
</clearHighlight>
<onCollapseTree><![CDATA[
@@ -202,36 +209,27 @@
return isFloat or (obj is self)
]]>
</exclude>
- <onHighlightItem><![CDATA[
-def onHighlightItem(self, evt):
- obj = self.objectTree.Selection.Object
- try:
- frm = obj.Form
- except AttributeError:
- return
- # Remove the highlight after 3 seconds
- expires = time.time() + 3
- entry = self._highlights[expires] = {}
- entry["targetForm"] = frm
-
- if isinstance(obj, dabo.ui.dSizerMixin):
- entry["type"] = "sizer"
- frm.addToOutlinedSizers(obj)
- frm.refresh()
- entry["outlinedSizer"] = obj
- entry["drawSetting"] = frm._alwaysDrawSizerOutlines
- entry["outlineStyle"] = obj.outlineStyle
- obj.outlineStyle = "dot"
- entry["outlineWidth"] = obj.outlineWidth
- obj.outlineWidth = 4
- frm._alwaysDrawSizerOutlines = True
+ <_getHighlightInfo><![CDATA[
+def _getHighlightInfo(self, obj, frm):
+ pos = obj.ClientToScreen((0, 0))
+ if self.Application.Platform == "Mac":
+ pos = frm.ScreenToClient(pos)
+ dc = wx.WindowDC(frm)
else:
- entry["type"] = "drawing"
- x, y = obj.formCoordinates()
- entry["drawingToClear"] = frm.drawRectangle(x-3, y-3,
obj.Width+6, obj.Height+6,
- penWidth=3, penColor="magenta")
+ dc = wx.ScreenDC()
+ return pos, dc
]]>
- </onHighlightItem>
+ </_getHighlightInfo>
+ <setSelectedObject><![CDATA[
+def setSelectedObject(self, obj, silent=False):
+ try:
+ self.objectTree.showObject(obj, displayFail=False)
+ self.objectTree.expandCurrentNode()
+ except RuntimeError, e:
+ if not silent:
+ dabo.ui.stop(e, "Object Inspector")
+]]>
+ </setSelectedObject>
<onFindObject><![CDATA[
def onFindObject(self, evt):
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
@@ -309,6 +307,46 @@
self.OnCaptureLost(evt)
]]>
</OnLeftDown>
+ <onHighlightItem><![CDATA[
+def onHighlightItem(self, evt):
+ obj = self.objectTree.Selection.Object
+ try:
+ frm = obj.Form
+ except AttributeError:
+ return
+ # Remove the highlight after 3 seconds
+ expires = time.time() + 3
+ entry = self._highlights[expires] = {}
+ entry["targetForm"] = frm
+
+ if isinstance(obj, dabo.ui.dSizerMixin):
+ entry["type"] = "sizer"
+ frm.addToOutlinedSizers(obj)
+ frm.refresh()
+ entry["outlinedSizer"] = obj
+ entry["drawSetting"] = frm._alwaysDrawSizerOutlines
+ entry["outlineStyle"] = obj.outlineStyle
+ obj.outlineStyle = "dot"
+ entry["outlineWidth"] = obj.outlineWidth
+ obj.outlineWidth = 4
+ frm._alwaysDrawSizerOutlines = True
+ else:
+ if isinstance(obj, dabo.ui.dFormMixin):
+ # Don't highlight the form; just bring it to the
foreground
+ del self._highlights[expires]
+ obj.bringToFront()
+ return
+ x, y = obj.formCoordinates()
+ entry["type"] = "drawing"
+ # Make sure outline is visible
+ xDraw = max(0, x-3)
+ yDraw = max(0, y-3)
+ wDraw = min(frm.Width-xDraw, obj.Width+6)
+ hDraw = min(frm.Height-yDraw, obj.Height+6)
+ entry["drawingToClear"] = frm.drawRectangle(xDraw, yDraw,
wDraw, hDraw,
+ penWidth=3, penColor="magenta")
+]]>
+ </onHighlightItem>
<object_selected><![CDATA[
def object_selected(self, obj):
self.shell.interp.locals['obj'] = obj
@@ -357,26 +395,28 @@
<dSizer SlotCount="1" designerClass="LayoutSizer"
Orientation="Vertical">
<dSplitter SashPosition="380" sizerInfo="{'VAlign': 'Middle'}"
designerClass="controlMix" Split="True" Orientation="Horizontal">
- <dPanel designerClass="MixedSplitterPanel"
Name="dPanel2">
+ <dPanel Width="842" AlwaysResetSizer="True"
designerClass="MixedSplitterPanel" Name="dPanel2" Height="378">
<dSizer SlotCount="1"
designerClass="LayoutSizer" Orientation="Vertical">
<dSplitter SashPosition="322"
sizerInfo="{'VAlign': 'Middle'}" designerClass="controlMix" Split="True"
Orientation="Vertical">
- <dPanel
designerClass="MixedSplitterPanel" Name="dPanel2">
+ <dPanel Width="320"
AlwaysResetSizer="True" designerClass="MixedSplitterPanel" Name="dPanel2"
Height="374">
<dSizer SlotCount="1"
designerClass="LayoutSizer" Orientation="Vertical">
<dTreeView
RegID="objectTree" sizerInfo="{'VAlign': 'Middle'}" designerClass="controlMix">
<code>
<showObject><![CDATA[
-def showObject(self, obj):
+def showObject(self, obj, displayFail=True):
nd = self.nodeForObject(obj)
if nd:
nd.Selected = True
self.showNode(nd)
+ elif displayFail:
+ dabo.ui.stop(_("Couldn't find object: %s") % obj)
else:
- dabo.ui.stop("Couldn't find object: %s" % obj)
+ raise RuntimeError(_("Object '%s' not found") % obj)
]]>
</showObject>
<onTreeSelection><![CDATA[
def onTreeSelection(self, evt):
- self.Form.object_selected(self.Selection.Object)
+ dabo.ui.callAfter(self.Form.object_selected, self.Selection.Object)
]]>
</onTreeSelection>
<expandCurrentNode><![CDATA[
@@ -405,7 +445,7 @@
</dTreeView>
</dSizer>
</dPanel>
- <dPanel
designerClass="MixedSplitterPanel" Name="dPanel1">
+ <dPanel Width="511"
AlwaysResetSizer="True" designerClass="MixedSplitterPanel" Name="dPanel1"
Height="374">
<dSizer SlotCount="1"
designerClass="LayoutSizer" Orientation="Vertical">
<dGrid
ColumnCount="2" RegID="infoGrid" SelectionMode="Row" designerClass="controlMix"
sizerInfo="{}">
<code>
@@ -434,7 +474,7 @@
</dSplitter>
</dSizer>
</dPanel>
- <dPanel designerClass="MixedSplitterPanel"
Name="dPanel1">
+ <dPanel Width="842" AlwaysResetSizer="True"
designerClass="MixedSplitterPanel" Name="dPanel1" Height="332">
<dSizer SlotCount="1"
designerClass="LayoutSizer" Orientation="Vertical">
<dPanel RegID="shellPanel"
sizerInfo="{'VAlign': 'Middle'}" AlwaysResetSizer="True"
designerClass="controlMix"></dPanel>
</dSizer>
Modified: trunk/dabo/ui/uiwx/uiApp.py
===================================================================
--- trunk/dabo/ui/uiwx/uiApp.py 2011-02-14 22:57:02 UTC (rev 6434)
+++ trunk/dabo/ui/uiwx/uiApp.py 2011-02-15 11:48:55 UTC (rev 6435)
@@ -570,6 +570,7 @@
"""Display the object inspector window."""
if context is None:
context = self.ActiveForm
+ activeControl = context.ActiveControl
if not self.inspectorWindow:
# loc = os.path.dirname(dabo.ui.uiwx.__file__)
# pth = os.path.join(loc, "inspector.cdxml")
@@ -578,7 +579,9 @@
self.inspectorWindow =
InspectorFormClass(parent=context)
insp = self.inspectorWindow
insp.createObjectTree()
- insp.Visible = not insp.Visible
+ dabo.ui.callAfter(insp.setSelectedObject, activeControl,
silent=True)
+ insp.Visible = True
+ insp.bringToFront()
try:
mb = context.MenuBar
mb.inspectorMenuItem.Checked = insp.Visible
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]