]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/tool/CodeEditor.py
Applied patch [ 1407318 ] bitmap clipping / transparency mask (X11 port)
[wxWidgets.git] / wxPython / samples / ide / activegrid / tool / CodeEditor.py
index d8a158a0ee9bf5ec31e4869cd48def8230bd7e14..7e245bcd1f79945232fb2fc114bda740d173b48f 100644 (file)
@@ -21,6 +21,7 @@ import string
 import sys
 import DebuggerService
 import MarkerService
+from UICommon import CaseInsensitiveCompare
 _ = wx.GetTranslation
 if wx.Platform == '__WXMSW__':
     _WINDOWS = True
@@ -354,18 +355,6 @@ class CodeView(STCTextEditor.TextView):
         return ['Put', 'Editor Specific', 'Keywords', 'Here']
 
 
-    def CaseInsensitiveCompare(self, s1, s2):
-        """ GetAutoCompleteKeywordList() method used to show keywords in case insensitive order """
-        s1L = s1.lower()
-        s2L = s2.lower()
-        if s1L == s2L:
-            return 0
-        elif s1L < s2L:
-            return -1
-        else:
-            return 1
-
-
     def GetAutoCompleteKeywordList(self, context, hint):            
         """ Replace this method with Editor specific keywords """
         kw = self.GetAutoCompleteDefaultKeywords()
@@ -380,7 +369,7 @@ class CodeView(STCTextEditor.TextView):
         else:
             replaceLen = 0
             
-        kw.sort(self.CaseInsensitiveCompare)
+        kw.sort(CaseInsensitiveCompare)
         return " ".join(kw), replaceLen
         
 
@@ -410,6 +399,7 @@ class CodeView(STCTextEditor.TextView):
 
     def OnSetIndentWidth(self):
         dialog = wx.TextEntryDialog(self._GetParentFrame(), _("Enter new indent width (2-10):"), _("Set Indent Width"), "%i" % self.GetCtrl().GetIndent())
+        dialog.CenterOnParent()
         if dialog.ShowModal() == wx.ID_OK:
             try:
                 indent = int(dialog.GetValue())
@@ -480,7 +470,7 @@ class CodeView(STCTextEditor.TextView):
         if hint == "ViewStuff":
             self.GetCtrl().SetViewDefaults()
         elif hint == "Font":
-            font, color = self.GetFontAndColorFromConfig()
+            font, color = self.GetCtrl().GetFontAndColorFromConfig()
             self.GetCtrl().SetFont(font)
             self.GetCtrl().SetFontColor(color)
         else:
@@ -633,10 +623,8 @@ class CodeCtrl(STCTextEditor.TextCtrl):
     BREAKPOINT_MARKER_MASK = 0x2
     
             
-    def __init__(self, parent, ID = -1, style = wx.NO_FULL_REPAINT_ON_RESIZE):
-        if ID == -1:
-            ID = wx.NewId()
-        STCTextEditor.TextCtrl.__init__(self, parent, ID, style)
+    def __init__(self, parent, id=-1, style = wx.NO_FULL_REPAINT_ON_RESIZE):
+        STCTextEditor.TextCtrl.__init__(self, parent, id, style)
         
         self.UsePopUp(False)
         self.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
@@ -672,10 +660,10 @@ class CodeCtrl(STCTextEditor.TextCtrl):
         if _WINDOWS:  # should test to see if menu item exists, if it does, add this workaround
             self.CmdKeyClear(wx.stc.STC_KEY_TAB, 0)  # menu item "Indent Lines" from CodeService.InstallControls() generates another INDENT_LINES_ID event, so we'll explicitly disable the tab processing in the editor
 
-        wx.stc.EVT_STC_MARGINCLICK(self, ID, self.OnMarginClick)
+        wx.stc.EVT_STC_MARGINCLICK(self, self.GetId(), self.OnMarginClick)
         wx.EVT_KEY_DOWN(self, self.OnKeyPressed)
         if self.GetMatchingBraces(): 
-            wx.stc.EVT_STC_UPDATEUI(self, ID, self.OnUpdateUI)
+            wx.stc.EVT_STC_UPDATEUI(self, self.GetId(), self.OnUpdateUI)
 
         self.StyleClearAll()
         self.UpdateStyles()
@@ -720,7 +708,8 @@ class CodeCtrl(STCTextEditor.TextCtrl):
                 item = menuBar.FindItemById(itemID)
                 if item:
                     menu.Append(itemID, item.GetLabel())
-
+                    wx.EVT_MENU(self, itemID, self.DSProcessEvent)  # wxHack: for customized right mouse menu doesn't work with new DynamicSashWindow
+                    wx.EVT_UPDATE_UI(self, itemID, self.DSProcessUpdateUIEvent)  # wxHack: for customized right mouse menu doesn't work with new DynamicSashWindow
         return menu
                 
 
@@ -834,6 +823,7 @@ class CodeCtrl(STCTextEditor.TextCtrl):
 
     def DoIndent(self):
         self.AddText('\n')
+        self.EnsureCaretVisible()
         # Need to do a default one for all languges