From 94b6e354b0c8a6c6cdd36479c2688ffeee2cad9e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 20 Feb 2015 19:39:58 -0800 Subject: [PATCH] Rename the FindHandler overloads as in Classic. Fixup the RTC demo to at least start, still needs some work. --- demo/RichTextCtrl.py | 116 +++++++++++++++++++++--------------------- etg/richtextbuffer.py | 10 +++- 2 files changed, 66 insertions(+), 60 deletions(-) diff --git a/demo/RichTextCtrl.py b/demo/RichTextCtrl.py index c260b69f..440ef706 100644 --- a/demo/RichTextCtrl.py +++ b/demo/RichTextCtrl.py @@ -240,30 +240,30 @@ class RichTextFrame(wx.Frame): def SetFontStyle(self, fontColor = None, fontBgColor = None, fontFace = None, fontSize = None, fontBold = None, fontItalic = None, fontUnderline = None): - if fontColor: - self.textAttr.SetTextColour(fontColor) - if fontBgColor: - self.textAttr.SetBackgroundColour(fontBgColor) - if fontFace: - self.textAttr.SetFontFaceName(fontFace) - if fontSize: - self.textAttr.SetFontSize(fontSize) - if fontBold != None: - if fontBold: - self.textAttr.SetFontWeight(wx.FONTWEIGHT_BOLD) - else: - self.textAttr.SetFontWeight(wx.FONTWEIGHT_NORMAL) - if fontItalic != None: - if fontItalic: - self.textAttr.SetFontStyle(wx.FONTSTYLE_ITALIC) - else: - self.textAttr.SetFontStyle(wx.FONTSTYLE_NORMAL) - if fontUnderline != None: - if fontUnderline: - self.textAttr.SetFontUnderlined(True) - else: - self.textAttr.SetFontUnderlined(False) - self.rtc.SetDefaultStyle(self.textAttr) + if fontColor: + self.textAttr.SetTextColour(fontColor) + if fontBgColor: + self.textAttr.SetBackgroundColour(fontBgColor) + if fontFace: + self.textAttr.SetFontFaceName(fontFace) + if fontSize: + self.textAttr.SetFontSize(fontSize) + if fontBold != None: + if fontBold: + self.textAttr.SetFontWeight(wx.FONTWEIGHT_BOLD) + else: + self.textAttr.SetFontWeight(wx.FONTWEIGHT_NORMAL) + if fontItalic != None: + if fontItalic: + self.textAttr.SetFontStyle(wx.FONTSTYLE_ITALIC) + else: + self.textAttr.SetFontStyle(wx.FONTSTYLE_NORMAL) + if fontUnderline != None: + if fontUnderline: + self.textAttr.SetFontUnderlined(True) + else: + self.textAttr.SetFontUnderlined(False) + self.rtc.SetDefaultStyle(self.textAttr) def OnURL(self, evt): wx.MessageBox(evt.GetString(), "URL Clicked") @@ -614,46 +614,46 @@ class RichTextFrame(wx.Frame): self.Bind(wx.EVT_UPDATE_UI, updateUI, item) tbar = self.CreateToolBar() - doBind( tbar.AddTool(-1, images._rt_open.GetBitmap(), - shortHelpString="Open"), self.OnFileOpen) - doBind( tbar.AddTool(-1, images._rt_save.GetBitmap(), - shortHelpString="Save"), self.OnFileSave) + doBind( tbar.AddTool(-1, '', images._rt_open.GetBitmap(), + shortHelp="Open"), self.OnFileOpen) + doBind( tbar.AddTool(-1, '', images._rt_save.GetBitmap(), + shortHelp="Save"), self.OnFileSave) tbar.AddSeparator() - doBind( tbar.AddTool(wx.ID_CUT, images._rt_cut.GetBitmap(), - shortHelpString="Cut"), self.ForwardEvent, self.ForwardEvent) - doBind( tbar.AddTool(wx.ID_COPY, images._rt_copy.GetBitmap(), - shortHelpString="Copy"), self.ForwardEvent, self.ForwardEvent) - doBind( tbar.AddTool(wx.ID_PASTE, images._rt_paste.GetBitmap(), - shortHelpString="Paste"), self.ForwardEvent, self.ForwardEvent) + doBind( tbar.AddTool(wx.ID_CUT, '', images._rt_cut.GetBitmap(), + shortHelp="Cut"), self.ForwardEvent, self.ForwardEvent) + doBind( tbar.AddTool(wx.ID_COPY, '', images._rt_copy.GetBitmap(), + shortHelp="Copy"), self.ForwardEvent, self.ForwardEvent) + doBind( tbar.AddTool(wx.ID_PASTE, '', images._rt_paste.GetBitmap(), + shortHelp="Paste"), self.ForwardEvent, self.ForwardEvent) tbar.AddSeparator() - doBind( tbar.AddTool(wx.ID_UNDO, images._rt_undo.GetBitmap(), - shortHelpString="Undo"), self.ForwardEvent, self.ForwardEvent) - doBind( tbar.AddTool(wx.ID_REDO, images._rt_redo.GetBitmap(), - shortHelpString="Redo"), self.ForwardEvent, self.ForwardEvent) + doBind( tbar.AddTool(wx.ID_UNDO, '', images._rt_undo.GetBitmap(), + shortHelp="Undo"), self.ForwardEvent, self.ForwardEvent) + doBind( tbar.AddTool(wx.ID_REDO, '', images._rt_redo.GetBitmap(), + shortHelp="Redo"), self.ForwardEvent, self.ForwardEvent) tbar.AddSeparator() - doBind( tbar.AddTool(-1, images._rt_bold.GetBitmap(), isToggle=True, - shortHelpString="Bold"), self.OnBold, self.OnUpdateBold) - doBind( tbar.AddTool(-1, images._rt_italic.GetBitmap(), isToggle=True, - shortHelpString="Italic"), self.OnItalic, self.OnUpdateItalic) - doBind( tbar.AddTool(-1, images._rt_underline.GetBitmap(), isToggle=True, - shortHelpString="Underline"), self.OnUnderline, self.OnUpdateUnderline) + doBind( tbar.AddCheckTool(-1, '', images._rt_bold.GetBitmap(), + shortHelp="Bold"), self.OnBold, self.OnUpdateBold) + doBind( tbar.AddCheckTool(-1, '', images._rt_italic.GetBitmap(), + shortHelp="Italic"), self.OnItalic, self.OnUpdateItalic) + doBind( tbar.AddCheckTool(-1, '', images._rt_underline.GetBitmap(), + shortHelp="Underline"), self.OnUnderline, self.OnUpdateUnderline) tbar.AddSeparator() - doBind( tbar.AddTool(-1, images._rt_alignleft.GetBitmap(), isToggle=True, - shortHelpString="Align Left"), self.OnAlignLeft, self.OnUpdateAlignLeft) - doBind( tbar.AddTool(-1, images._rt_centre.GetBitmap(), isToggle=True, - shortHelpString="Center"), self.OnAlignCenter, self.OnUpdateAlignCenter) - doBind( tbar.AddTool(-1, images._rt_alignright.GetBitmap(), isToggle=True, - shortHelpString="Align Right"), self.OnAlignRight, self.OnUpdateAlignRight) + doBind( tbar.AddCheckTool(-1, '', images._rt_alignleft.GetBitmap(), + shortHelp="Align Left"), self.OnAlignLeft, self.OnUpdateAlignLeft) + doBind( tbar.AddCheckTool(-1, '', images._rt_centre.GetBitmap(), + shortHelp="Center"), self.OnAlignCenter, self.OnUpdateAlignCenter) + doBind( tbar.AddCheckTool(-1, '', images._rt_alignright.GetBitmap(), + shortHelp="Align Right"), self.OnAlignRight, self.OnUpdateAlignRight) tbar.AddSeparator() - doBind( tbar.AddTool(-1, images._rt_indentless.GetBitmap(), - shortHelpString="Indent Less"), self.OnIndentLess) - doBind( tbar.AddTool(-1, images._rt_indentmore.GetBitmap(), - shortHelpString="Indent More"), self.OnIndentMore) + doBind( tbar.AddTool(-1, '', images._rt_indentless.GetBitmap(), + shortHelp="Indent Less"), self.OnIndentLess) + doBind( tbar.AddTool(-1, '', images._rt_indentmore.GetBitmap(), + shortHelp="Indent More"), self.OnIndentMore) tbar.AddSeparator() - doBind( tbar.AddTool(-1, images._rt_font.GetBitmap(), - shortHelpString="Font"), self.OnFont) - doBind( tbar.AddTool(-1, images._rt_colour.GetBitmap(), - shortHelpString="Font Colour"), self.OnColour) + doBind( tbar.AddTool(-1, '', images._rt_font.GetBitmap(), + shortHelp="Font"), self.OnFont) + doBind( tbar.AddTool(-1, '', images._rt_colour.GetBitmap(), + shortHelp="Font Colour"), self.OnColour) tbar.Realize() diff --git a/etg/richtextbuffer.py b/etg/richtextbuffer.py index 6b8d1bb4..c16b7219 100644 --- a/etg/richtextbuffer.py +++ b/etg/richtextbuffer.py @@ -302,9 +302,15 @@ def run(): c.find('InsertDrawingHandler.handler').transfer = True c.find('AddFieldType.fieldType').transfer = True - - + # TODO: Transfer ownership with AddEventHandler? TransferBack with Remove? + + + c.find('FindHandler').renameOverload('name', 'FindHandlerByName') + c.find('FindHandler').renameOverload('extension', 'FindHandlerByExtension') + c.find('FindHandler').pyName = 'FindHandlerByType' + + c.find('FindHandlerFilenameOrType').pyName = 'FindHandlerByFilename' #-------------------------------------------------------