X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1f780e48af479e7bf9a07eaaa1ab6b41f1ffb17b..d167fc518a2f59d76f683da70a07f55bcbb95345:/wxPython/samples/ide/activegrid/tool/STCTextEditor.py?ds=sidebyside diff --git a/wxPython/samples/ide/activegrid/tool/STCTextEditor.py b/wxPython/samples/ide/activegrid/tool/STCTextEditor.py index fca235ada2..8d27a19d24 100644 --- a/wxPython/samples/ide/activegrid/tool/STCTextEditor.py +++ b/wxPython/samples/ide/activegrid/tool/STCTextEditor.py @@ -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()) #----------------------------------------------------------------------------