]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/tool/STCTextEditor.py
Applied patch [ 1212020 ] MediaCtrl DirectShow drawing and sample
[wxWidgets.git] / wxPython / samples / ide / activegrid / tool / STCTextEditor.py
index fca235ada21da433b091ec46749a1bdee1f667f2..113721029a12283b9d11ddb549ef67ee8ccf0db5 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
@@ -192,10 +194,15 @@ class TextView(wx.lib.docview.View):
         if activate and self.GetCtrl():
             # In MDI mode just calling set focus doesn't work and in SDI mode using CallAfter causes an endless loop
             if self.GetDocumentManager().GetFlags() & wx.lib.docview.DOC_SDI:
-                self.GetCtrl().SetFocus()
+                self.SetFocus()
             else:
-                wx.CallAfter(self.GetCtrl().SetFocus)
-                   
+                wx.CallAfter(self.SetFocus)
+
+
+    def SetFocus(self):
+        if self.GetCtrl():
+            self.GetCtrl().SetFocus()
+            
                                 
     def OnClose(self, deleteWindow = True):
         if not wx.lib.docview.View.OnClose(self, deleteWindow):
@@ -291,10 +298,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 +307,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 +368,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 +753,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 +967,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 +1207,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 +1229,7 @@ def getTextImage():
     return ImageFromStream(stream)
 
 def getTextIcon():
-    icon = EmptyIcon()
-    icon.CopyFromBitmap(getTextBitmap())
-    return icon
+    return wx.IconFromBitmap(getTextBitmap())
 
 
 #----------------------------------------------------------------------------