]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/tool/STCTextEditor.py
Add line control points before the end point
[wxWidgets.git] / wxPython / samples / ide / activegrid / tool / STCTextEditor.py
index fca235ada21da433b091ec46749a1bdee1f667f2..8d27a19d24ace33557902ea8182d9449b5934683 100644 (file)
@@ -53,6 +53,7 @@ class TextDocument(wx.lib.docview.Document):
         docFile.write(view.GetValue())
         docFile.close()
         self.Modify(False)
+        self.SetDocumentModificationDate()
         self.SetDocumentSaved(True)
         return True
 
@@ -64,6 +65,7 @@ class TextDocument(wx.lib.docview.Document):
         view.SetValue(data)
         self.SetFilename(filename, True)
         self.Modify(False)
+        self.SetDocumentModificationDate()
         self.UpdateAllViews()
         self._savedYet = True
         return True
@@ -291,10 +293,6 @@ class TextView(wx.lib.docview.View):
         if not self.GetCtrl():
             return False
 
-        hasSelection = self.GetCtrl().GetSelectionStart() != self.GetCtrl().GetSelectionEnd()
-        hasText = self.GetCtrl().GetTextLength() > 0
-        notOnLastChar = self.GetCtrl().GetSelectionStart() != self.GetCtrl().GetTextLength()
-
         id = event.GetId()
         if id == wx.ID_UNDO:
              event.Enable(self.GetCtrl().CanUndo())
@@ -304,41 +302,44 @@ class TextView(wx.lib.docview.View):
             event.Enable(self.GetCtrl().CanRedo())
             event.SetText(_("Redo") + '\t' + _('Ctrl+Y'))
             return True
-        elif id == wx.ID_CUT:
-            event.Enable(hasSelection)
-            return True
-        elif id == wx.ID_COPY:
+        elif (id == wx.ID_CUT
+        or id == wx.ID_COPY
+        or id == wx.ID_CLEAR):
+            hasSelection = self.GetCtrl().GetSelectionStart() != self.GetCtrl().GetSelectionEnd()
             event.Enable(hasSelection)
             return True
         elif id == wx.ID_PASTE:
             event.Enable(self.GetCtrl().CanPaste())
             return True
-        elif id == wx.ID_CLEAR:
-            event.Enable(hasSelection)
-            return True
         elif id == wx.ID_SELECTALL:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText)
             return True
         elif id == TEXT_ID:
             event.Enable(True)
             return True
         elif id == VIEW_WHITESPACE_ID:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText)
             event.Check(self.GetCtrl().GetViewWhiteSpace())
             return True
         elif id == VIEW_EOL_ID:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText)
             event.Check(self.GetCtrl().GetViewEOL())
             return True
         elif id == VIEW_INDENTATION_GUIDES_ID:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText)
             event.Check(self.GetCtrl().GetIndentationGuides())
             return True
         elif id == VIEW_RIGHT_EDGE_ID:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText)
             event.Check(self.GetCtrl().GetViewRightEdge())
             return True
         elif id == VIEW_LINE_NUMBERS_ID:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText)
             event.Check(self.GetCtrl().GetViewLineNumbers())
             return True
@@ -362,19 +363,23 @@ class TextView(wx.lib.docview.View):
             event.Check(self.GetCtrl().CanWordWrap() and self.GetCtrl().GetWordWrap())
             return True
         elif id == FindService.FindService.FIND_ID:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText)
             return True
         elif id == FindService.FindService.FIND_PREVIOUS_ID:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText and
                          self._FindServiceHasString() and
                          self.GetCtrl().GetSelection()[0] > 0)
             return True
         elif id == FindService.FindService.FIND_NEXT_ID:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText and
                          self._FindServiceHasString() and
                          self.GetCtrl().GetSelection()[0] < self.GetCtrl().GetLength())
             return True
         elif id == FindService.FindService.REPLACE_ID:
+            hasText = self.GetCtrl().GetTextLength() > 0
             event.Enable(hasText)
             return True
         elif id == FindService.FindService.GOTO_LINE_ID:
@@ -743,40 +748,18 @@ class TextService(wx.lib.pydocview.DocService):
 
     def ProcessUpdateUIEvent(self, event):
         id = event.GetId()
-        if id == TEXT_ID:
-            event.Enable(False)
-            return True
-        elif id == VIEW_WHITESPACE_ID:
-            event.Enable(False)
-            return True
-        elif id == VIEW_EOL_ID:
-            event.Enable(False)
-            return True
-        elif id == VIEW_INDENTATION_GUIDES_ID:
-            event.Enable(False)
-            return True
-        elif id == VIEW_RIGHT_EDGE_ID:
-            event.Enable(False)
-            return True
-        elif id == VIEW_LINE_NUMBERS_ID:
-            event.Enable(False)
-            return True
-        elif id == ZOOM_ID:
-            event.Enable(False)
-            return True
-        elif id == ZOOM_NORMAL_ID:
-            event.Enable(False)
-            return True
-        elif id == ZOOM_IN_ID:
-            event.Enable(False)
-            return True
-        elif id == ZOOM_OUT_ID:
-            event.Enable(False)
-            return True
-        elif id == CHOOSE_FONT_ID:
-            event.Enable(False)
-            return True
-        elif id == WORD_WRAP_ID:
+        if (id == TEXT_ID
+        or id == VIEW_WHITESPACE_ID
+        or id == VIEW_EOL_ID
+        or id == VIEW_INDENTATION_GUIDES_ID
+        or id == VIEW_RIGHT_EDGE_ID
+        or id == VIEW_LINE_NUMBERS_ID
+        or id == ZOOM_ID
+        or id == ZOOM_NORMAL_ID
+        or id == ZOOM_IN_ID
+        or id == ZOOM_OUT_ID
+        or id == CHOOSE_FONT_ID
+        or id == WORD_WRAP_ID):
             event.Enable(False)
             return True
         else:
@@ -979,8 +962,7 @@ class TextCtrl(wx.stc.StyledTextCtrl):
         self._font = None
         self._fontColor = None
         
-        self.SetVisiblePolicy(wx.stc.STC_VISIBLE_STRICT,0)
-        self.SetYCaretPolicy(0, 0)
+        self.SetVisiblePolicy(wx.stc.STC_VISIBLE_STRICT,1)
         
         self.CmdKeyClear(wx.stc.STC_KEY_ADD, wx.stc.STC_SCMOD_CTRL)
         self.CmdKeyClear(wx.stc.STC_KEY_SUBTRACT, wx.stc.STC_SCMOD_CTRL)
@@ -1220,7 +1202,6 @@ class TextCtrl(wx.stc.StyledTextCtrl):
 # Icon Bitmaps - generated by encode_bitmaps.py
 #----------------------------------------------------------------------------
 from wx import ImageFromStream, BitmapFromImage
-from wx import EmptyIcon
 import cStringIO
 
 
@@ -1243,9 +1224,7 @@ def getTextImage():
     return ImageFromStream(stream)
 
 def getTextIcon():
-    icon = EmptyIcon()
-    icon.CopyFromBitmap(getTextBitmap())
-    return icon
+    return wx.IconFromBitmap(getTextBitmap())
 
 
 #----------------------------------------------------------------------------