dabo Commit
Revision 2192
Date: 2006-06-01 14:40:34 -0700 (Thu, 01 Jun 2006)
Author: ed
Changed:
U trunk/dabo/ui/uiwx/dEditor.py
U trunk/dabo/ui/uiwx/dSplitter.py
Log:
Added a few additional methods to the dEditor class to access the underlying
STC methods.
Added some properties to the dSplitter class to allow turning off the default
context menu for splitting/unsplitting the panes.
Diff:
Modified: trunk/dabo/ui/uiwx/dEditor.py
===================================================================
--- trunk/dabo/ui/uiwx/dEditor.py 2006-06-01 20:47:46 UTC (rev 2191)
+++ trunk/dabo/ui/uiwx/dEditor.py 2006-06-01 21:40:34 UTC (rev 2192)
@@ -22,7 +22,6 @@
## testing load performance:
delay = False
-## The following will eventually be properties:
#- fontMode = "proportional" # 'mono' or 'proportional'
fontMode = "mono" # 'mono' or 'proportional'
@@ -303,6 +302,26 @@
return ret
+ def getLineFromPosition(self, pos):
+ """Given a position within the text, returns the corresponding
line
+ number. If the position is invalid, returns -1.
+ """
+ try:
+ ret = self.LineFromPosition(pos)
+ except:
+ ret = -1
+ return ret
+
+
+ def getPositionFromXY(self, x, y=None):
+ """Given an x,y position, returns the position in the text if
that point
+ is close to any text; if not, returns -1.
+ """
+ if y is None and isinstance(x, (list, tuple)):
+ x, y = x
+ return self.PositionFromPointClose(x, y)
+
+
def getMarginWidth(self):
"""Returns the width of the non-editing area along the left
side."""
ret = 0
@@ -723,14 +742,6 @@
self.AutoCompCancel()
- def toggleSyntaxColoring(self):
- """Right now, just toggles between Python and none. In the
future,
- we will need to save the current lexer and toggle between that
and
- none.
- """
- self.SyntaxColoring = not self.SyntaxColoring
-
-
def setSyntaxColoring(self, color=None):
"""Sets the appropriate lexer for syntax coloring."""
if color:
@@ -745,11 +756,6 @@
self.ClearDocumentStyle()
self.SetLexer(stc.STC_LEX_CONTAINER)
-
-
- def toggleWordWrap(self):
- self.WordWrap = not self.WordWrap
-
def OnModified(self, evt):
if not self._syntaxColoring:
Modified: trunk/dabo/ui/uiwx/dSplitter.py
===================================================================
--- trunk/dabo/ui/uiwx/dSplitter.py 2006-06-01 20:47:46 UTC (rev 2191)
+++ trunk/dabo/ui/uiwx/dSplitter.py 2006-06-01 21:40:34 UTC (rev 2192)
@@ -12,8 +12,10 @@
class SplitterPanel(dabo.ui.dPanel):
def __init__(self, parent):
+ self._showSplitMenu = True
super(SplitterPanel, self).__init__(parent)
- self.bindEvent(dEvents.ContextMenu, self._onContextMenu)
+ if self.ShowSplitMenu:
+ self.bindEvent(dEvents.ContextMenu, self._onContextMenu)
def _onContextMenu(self, evt):
@@ -70,6 +72,26 @@
def unsplit(self, win=None):
self.splitter.unsplit(win)
+
+
+ # Property definitions start here
+ def _getShowSplitMenu(self):
+ return self._showSplitMenu
+
+ def _setShowSplitMenu(self, val):
+ if self._constructed():
+ self._showSplitMenu = val
+ if val:
+ self.bindEvent(dEvents.ContextMenu,
self._onContextMenu)
+ else:
+ self.unbindEvent(dEvents.ContextMenu)
+ else:
+ self._properties["ShowSplitMenu"] = val
+
+
+ ShowSplitMenu = property(_getShowSplitMenu, _setShowSplitMenu, None,
+ _("Determines if the Split/Unsplit context menu is
shown (default=True) (bool)"))
+
@@ -89,6 +111,8 @@
self._orientation = "v"
self._sashPos = 100
self._minPanelSize = 0
+ # Default to showing the context menus on the panels
+ self._showPanelSplitMenu = None
preClass = wx.PreSplitterWindow
cm.dControlMixin.__init__(self, preClass, parent, properties,
@@ -281,6 +305,18 @@
self._properties["SashPosition"] = val
+ def _getShowPanelSplitMenu(self):
+ return self._showPanelSplitMenu
+
+ def _setShowPanelSplitMenu(self, val):
+ if self._constructed():
+ self._showPanelSplitMenu = val
+ self.Panel1.ShowSplitMenu = val
+ self.Panel2.ShowSplitMenu = val
+ else:
+ self._properties["ShowPanelSplitMenu"] = val
+
+
def _getSplit(self):
return self.IsSplit()
@@ -293,26 +329,32 @@
MinimumPanelSize = property(_getMinPanelSize, _setMinPanelSize, None,
_("Controls the minimum width/height of the panels.
(int)"))
- DynamicMinimumPanelSize = makeDynamicProperty(MinimumPanelSize)
Orientation = property(_getOrientation, _setOrientation, None,
_("Determines if the window splits Horizontally or
Vertically. (string)"))
- DynamicOrientation = makeDynamicProperty(Orientation)
Panel1 = property(_getPanel1, _setPanel1, None,
_("Returns the Top/Left panel. (SplitterPanel)"))
- DynamicPanel1 = makeDynamicProperty(Panel1)
Panel2 = property(_getPanel2, _setPanel2, None,
_("Returns the Bottom/Right panel. (SplitterPanel)"))
- DynamicPanel2 = makeDynamicProperty(Panel2)
SashPosition = property(_getSashPosition, _setSashPosition, None,
_("Position of the sash when the window is split.
(int)"))
- DynamicSashPosition = makeDynamicProperty(SashPosition)
+ ShowPanelSplitMenu = property(_getShowPanelSplitMenu,
_setShowPanelSplitMenu, None,
+ _("""Determines if the default context menu for
split/unsplit is enabled
+ for the panels (default=True) (bool)"""))
+
Split = property(_getSplit, _setSplit, None,
_("Returns the split status of the control (bool)"))
+
+
+ DynamicMinimumPanelSize = makeDynamicProperty(MinimumPanelSize)
+ DynamicOrientation = makeDynamicProperty(Orientation)
+ DynamicPanel1 = makeDynamicProperty(Panel1)
+ DynamicPanel2 = makeDynamicProperty(Panel2)
+ DynamicSashPosition = makeDynamicProperty(SashPosition)
DynamicSplit = makeDynamicProperty(Split)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev