diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 19b2875fb8..60522a04c0 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -105,7 +105,7 @@ methodOverrideMap = { 0), 'AppendText' : (0, - 'void %s(const wxString& text);', + 'void %s(const wxString& text) wxOVERRIDE;', '''void %s(const wxString& text) { const wxWX2MBbuf buf = wx2stc(text); @@ -1001,6 +1001,21 @@ constNonGetterMethods = ( 'CanUndo', ) +# several methods require wxOVERRIDE +overrideNeeded = ( + 'Redo', + 'SelectAll', + 'Undo', + 'Cut', + 'Copy', + 'Paste', + 'CanPaste', + 'CanRedo', + 'CanUndo', + 'Clear', + 'AppendText', +) + #---------------------------------------------------------------------------- def processIface(iface, h_tmplt, cpp_tmplt, ih_tmplt, h_dest, cpp_dest, docstr_dest, ih_dest, msgcodes): @@ -1120,7 +1135,7 @@ def processMethods(methods): imps = [] dstr = [] - for retType, name, number, param1, param2, docs, is_const in methods: + for retType, name, number, param1, param2, docs, is_const, is_override in methods: retType = retTypeMap.get(retType, retType) params = makeParamString(param1, param2) @@ -1143,9 +1158,15 @@ def processMethods(methods): theDef = ' %s %s(%s)' % (retType, name, params) if is_const: theDef = theDef + ' const' + if is_override: + theDef = theDef + ' wxOVERRIDE' theDef = theDef + ';' defs.append(theDef) + # Skip override from the interface file + if is_override: + theDef = theDef.replace(' wxOVERRIDE', '') + # Build the method definition for the interface .h file if docs: idefs.append('') @@ -1167,6 +1188,8 @@ def processMethods(methods): theImp = '%s wxStyledTextCtrl::%s(%s)' % (retType, name, params) if is_const: theImp = theImp + ' const' + if is_override: + theImp = theImp + ' wxOVERRIDE' theImp = theImp + '\n{\n ' if retType == 'wxColour': theImp = theImp + 'long c = ' @@ -1300,7 +1323,7 @@ def parseFun(line, methods, docs, values, is_const, msgcodes): else: code = number methods.append( (retType, name, code, param1, param2, tuple(docs), - is_const or name in constNonGetterMethods) ) + is_const or name in constNonGetterMethods, name in overrideNeeded) ) #---------------------------------------------------------------------------- diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 6c6e770e58..51c99cc2d0 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -335,7 +335,7 @@ int wxStyledTextCtrl::GetStyleAt(int pos) const { } // Redoes the next action on the undo history. -void wxStyledTextCtrl::Redo() +void wxStyledTextCtrl::Redo() wxOVERRIDE { SendMsg(SCI_REDO, 0, 0); } @@ -348,7 +348,7 @@ void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) } // Select all the text in the document. -void wxStyledTextCtrl::SelectAll() +void wxStyledTextCtrl::SelectAll() wxOVERRIDE { SendMsg(SCI_SELECTALL, 0, 0); } @@ -380,7 +380,7 @@ wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { } // Are there any redoable actions in the undo history? -bool wxStyledTextCtrl::CanRedo() const +bool wxStyledTextCtrl::CanRedo() const wxOVERRIDE { return SendMsg(SCI_CANREDO, 0, 0) != 0; } @@ -1751,13 +1751,13 @@ void wxStyledTextCtrl::SetReadOnly(bool readOnly) } // Will a paste succeed? -bool wxStyledTextCtrl::CanPaste() const +bool wxStyledTextCtrl::CanPaste() const wxOVERRIDE { return SendMsg(SCI_CANPASTE, 0, 0) != 0; } // Are there any undoable actions in the undo history? -bool wxStyledTextCtrl::CanUndo() const +bool wxStyledTextCtrl::CanUndo() const wxOVERRIDE { return SendMsg(SCI_CANUNDO, 0, 0) != 0; } @@ -1769,31 +1769,31 @@ void wxStyledTextCtrl::EmptyUndoBuffer() } // Undo one action in the undo history. -void wxStyledTextCtrl::Undo() +void wxStyledTextCtrl::Undo() wxOVERRIDE { SendMsg(SCI_UNDO, 0, 0); } // Cut the selection to the clipboard. -void wxStyledTextCtrl::Cut() +void wxStyledTextCtrl::Cut() wxOVERRIDE { SendMsg(SCI_CUT, 0, 0); } // Copy the selection to the clipboard. -void wxStyledTextCtrl::Copy() +void wxStyledTextCtrl::Copy() wxOVERRIDE { SendMsg(SCI_COPY, 0, 0); } // Paste the contents of the clipboard into the document replacing the selection. -void wxStyledTextCtrl::Paste() +void wxStyledTextCtrl::Paste() wxOVERRIDE { SendMsg(SCI_PASTE, 0, 0); } // Clear the selection. -void wxStyledTextCtrl::Clear() +void wxStyledTextCtrl::Clear() wxOVERRIDE { SendMsg(SCI_CLEAR, 0, 0); } diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index b57b01705b..7a7c93e900 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -293,16 +293,16 @@ public: // implement wxTextEntryBase pure virtual methods // ---------------------------------------------- - virtual void WriteText(const wxString& text) + virtual void WriteText(const wxString& text) wxOVERRIDE { ReplaceSelection(text); } - virtual void Remove(long from, long to) + virtual void Remove(long from, long to) wxOVERRIDE { Replace(from, to, ""); } - virtual void Replace(long from, long to, const wxString& text) + virtual void Replace(long from, long to, const wxString& text) wxOVERRIDE { SetTargetStart((int)from); SetTargetEnd((int)to); @@ -324,14 +324,14 @@ public: */ - virtual void SetInsertionPoint(long pos) + virtual void SetInsertionPoint(long pos) wxOVERRIDE { SetCurrentPos(int(pos == -1 ? GetLastPosition() : pos)); } - virtual long GetInsertionPoint() const { return GetCurrentPos(); } - virtual long GetLastPosition() const { return GetTextLength(); } + virtual long GetInsertionPoint() const wxOVERRIDE { return GetCurrentPos(); } + virtual long GetLastPosition() const wxOVERRIDE { return GetTextLength(); } - virtual void SetSelection(long from, long to) + virtual void SetSelection(long from, long to) wxOVERRIDE { if ( from == -1 && to == -1 ) { @@ -344,7 +344,7 @@ public: } } - virtual void SelectNone() + virtual void SelectNone() wxOVERRIDE { ClearSelections(); } @@ -352,7 +352,7 @@ public: #ifdef SWIG void GetSelection(long* OUTPUT, long* OUTPUT) const; #else - virtual void GetSelection(long *from, long *to) const + virtual void GetSelection(long *from, long *to) const wxOVERRIDE { if ( from ) *from = GetSelectionStart(); @@ -372,14 +372,14 @@ public: } #endif - virtual bool IsEditable() const { return !GetReadOnly(); } - virtual void SetEditable(bool editable) { SetReadOnly(!editable); } + virtual bool IsEditable() const wxOVERRIDE { return !GetReadOnly(); } + virtual void SetEditable(bool editable) wxOVERRIDE { SetReadOnly(!editable); } // implement wxTextAreaBase pure virtual methods // --------------------------------------------- - virtual int GetLineLength(long lineNo) const { return static_cast(GetLineText(lineNo).length()); } - virtual wxString GetLineText(long lineNo) const + virtual int GetLineLength(long lineNo) const wxOVERRIDE { return static_cast(GetLineText(lineNo).length()); } + virtual wxString GetLineText(long lineNo) const wxOVERRIDE { wxString text = GetLine(static_cast(lineNo)); size_t lastNewLine = text.find_last_not_of(wxS("\r\n")); @@ -390,42 +390,42 @@ public: text.clear(); return text; } - virtual int GetNumberOfLines() const { return GetLineCount(); } + virtual int GetNumberOfLines() const wxOVERRIDE { return GetLineCount(); } - virtual bool IsModified() const { return GetModify(); } - virtual void MarkDirty() { wxFAIL_MSG("not implemented"); } - virtual void DiscardEdits() { SetSavePoint(); } + virtual bool IsModified() const wxOVERRIDE { return GetModify(); } + virtual void MarkDirty() wxOVERRIDE { wxFAIL_MSG("not implemented"); } + virtual void DiscardEdits() wxOVERRIDE { SetSavePoint(); } virtual bool SetStyle(long WXUNUSED(start), long WXUNUSED(end), - const wxTextAttr& WXUNUSED(style)) + const wxTextAttr& WXUNUSED(style)) wxOVERRIDE { wxFAIL_MSG("not implemented"); return false; } - virtual bool GetStyle(long WXUNUSED(position), wxTextAttr& WXUNUSED(style)) + virtual bool GetStyle(long WXUNUSED(position), wxTextAttr& WXUNUSED(style)) wxOVERRIDE { wxFAIL_MSG("not implemented"); return false; } - virtual bool SetDefaultStyle(const wxTextAttr& WXUNUSED(style)) + virtual bool SetDefaultStyle(const wxTextAttr& WXUNUSED(style)) wxOVERRIDE { wxFAIL_MSG("not implemented"); return false; } - virtual long XYToPosition(long x, long y) const + virtual long XYToPosition(long x, long y) const wxOVERRIDE { long pos = PositionFromLine((int)y); pos += x; return pos; } - virtual bool PositionToXY(long pos, long *x, long *y) const + virtual bool PositionToXY(long pos, long *x, long *y) const wxOVERRIDE { int l = LineFromPosition((int)pos); if ( l == -1 ) @@ -440,11 +440,11 @@ public: return true; } - virtual void ShowPosition(long pos) { GotoPos((int)pos); } + virtual void ShowPosition(long pos) wxOVERRIDE { GotoPos((int)pos); } using wxWindow::HitTest; - virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const + virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const wxOVERRIDE { const long l = PositionFromPoint(pt); if ( l == -1 ) @@ -459,7 +459,7 @@ public: // just unhide it virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, wxTextCoord *col, - wxTextCoord *row) const + wxTextCoord *row) const wxOVERRIDE { return wxTextAreaBase::HitTest(pt, col, row); } @@ -467,13 +467,13 @@ public: static wxVersionInfo GetLibraryVersionInfo(); protected: - virtual void DoSetValue(const wxString& value, int flags); - virtual wxString DoGetValue() const { return GetText(); } - virtual wxWindow *GetEditableWindow() { return this; } + virtual void DoSetValue(const wxString& value, int flags) wxOVERRIDE; + virtual wxString DoGetValue() const wxOVERRIDE { return GetText(); } + virtual wxWindow *GetEditableWindow() wxOVERRIDE { return this; } #ifndef SWIG - virtual bool DoLoadFile(const wxString& file, int fileType); - virtual bool DoSaveFile(const wxString& file, int fileType); + virtual bool DoLoadFile(const wxString& file, int fileType) wxOVERRIDE; + virtual bool DoSaveFile(const wxString& file, int fileType) wxOVERRIDE; // Event handlers void OnPaint(wxPaintEvent& evt); @@ -497,7 +497,7 @@ protected: void OnListBox(wxCommandEvent& evt); void OnIdle(wxIdleEvent& evt); - virtual wxSize DoGetBestSize() const; + virtual wxSize DoGetBestSize() const wxOVERRIDE; // Turn notifications from Scintilla into events void NotifyChange();