diff --git a/utils/wxPython/demo/Main.py b/utils/wxPython/demo/Main.py index a7a1b42e0e..cd0052cb59 100644 --- a/utils/wxPython/demo/Main.py +++ b/utils/wxPython/demo/Main.py @@ -22,7 +22,8 @@ _useSplitter = true _useNestedSplitter = true _treeList = [ - ('New since last release', ['wxGrid', 'wxStyledTextCtrl_1', + ('New since last release', ['wxGrid', + 'wxStyledTextCtrl_1', 'wxStyledTextCtrl_2', 'ActiveXWrapper_Acrobat', 'ActiveXWrapper_IE', 'FileBrowseButton', 'wxCalendar']), diff --git a/utils/wxPython/demo/wxStyledTextCtrl_1.py b/utils/wxPython/demo/wxStyledTextCtrl_1.py index 3dd4a0b173..c7f4fbcbde 100644 --- a/utils/wxPython/demo/wxStyledTextCtrl_1.py +++ b/utils/wxPython/demo/wxStyledTextCtrl_1.py @@ -34,7 +34,7 @@ capabilities, (right click to try it out.) """ if wxPlatform == '__WXMSW__': - face1 = 'Ariel' + face1 = 'Arial' face2 = 'Times New Roman' face3 = 'Courier New' pb = 6 @@ -51,7 +51,7 @@ def runTest(frame, nb, log): ed = wxStyledTextCtrl(nb, -1) ed.SetText(demoText) - + ed.EmptyUndoBuffer() # make some styles ed.StyleSetSpec(wxSTC_STYLE_DEFAULT, "size:%d,face:%s" % (pb+2, face3)) diff --git a/utils/wxPython/demo/wxStyledTextCtrl_2.py b/utils/wxPython/demo/wxStyledTextCtrl_2.py new file mode 100644 index 0000000000..a031b68a1f --- /dev/null +++ b/utils/wxPython/demo/wxStyledTextCtrl_2.py @@ -0,0 +1,232 @@ + +from wxPython.wx import * +from wxPython.stc import * + +#---------------------------------------------------------------------- + +demoText = """\ +## This version of the editor has been set up to edit Python source +## code. Here is a copy of wxPython/demo/Main.py to play with. + + +""" + +#---------------------------------------------------------------------- + + +if wxPlatform == '__WXMSW__': + faces = { 'times': 'Times New Roman', + 'mono' : 'Courier New', + 'helv' : 'Arial', + 'other': 'Comic Sans MS', + 'size' : 8, + 'size2': 6, + } +else: + faces = { 'times': 'Times', + 'mono' : 'Courier', + 'helv' : 'Helvetica', + 'other': 'new century schoolbook', + 'size' : 11, + 'size2': 9, + } + + +#---------------------------------------------------------------------- + +class PythonSTC(wxStyledTextCtrl): + def __init__(self, parent, ID): + wxStyledTextCtrl.__init__(self, parent, ID) + + self.SetLexer(wxSTC_LEX_PYTHON) + self.SetKeywords(0, + "and assert break class continue def del elif else except " + "exec finally for from global if import in is lambda None " + "not or pass print raise return try while") + self.SetViewWhitespace(false) + self.SetProperty("fold", "1") + ##self.SetProperty("tab.timmy.whinge.level", "4") + + # Setup a margin to hold fold markers + self.SetFoldFlags(16) ### WHAT IS THIS VALUE? WHAT ARE THE OTHER FLAGS? + self.SetMarginType(2, wxSTC_MARGIN_SYMBOL) + self.SetMarginMask(2, wxSTC_MASK_FOLDERS) + self.SetMarginSensitive(2, true) + self.SetMarginWidth(2, 15) + self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_ARROW, "navy", "navy") + self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, "navy", "navy") + + + EVT_STC_UPDATEUI(self, ID, self.OnUpdateUI) + EVT_STC_MARGINCLICK(self, ID, self.OnMarginClick) + + + # Make some styles, The lexer defines what each style is used for, we + # just have to define what each style looks like. This set is adapted from + # Scintilla sample property files. + + self.StyleClearAll() + + # Global default styles for all languages + # Default + self.StyleSetSpec(32, "face:%(helv)s,size:%(size)d" % faces) + # Line number + self.StyleSetSpec(33, "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % faces) + # Brace highlight + self.StyleSetSpec(34, "fore:#0000FF,bold") + # Brace incomplete highlight + self.StyleSetSpec(35, "fore:#FF0000,bold") + # Control characters + self.StyleSetSpec(36, "face:%(other)s" % faces) + + # Python styles + # White space + self.StyleSetSpec(0, "fore:#808080") + # Comment + self.StyleSetSpec(1, "fore:#007F00,face:%(other)s" % faces) + # Number + self.StyleSetSpec(2, "fore:#007F7F") + # String + self.StyleSetSpec(3, "fore:#7F007F,italics,face:%(times)s" % faces) + # Single quoted string + self.StyleSetSpec(4, "fore:#7F007F,italics,face:%(times)s" % faces) + # Keyword + self.StyleSetSpec(5, "fore:#00007F,bold") + # Triple quotes + self.StyleSetSpec(6, "fore:#7F0000") + # Triple double quotes + self.StyleSetSpec(7, "fore:#7F0000") + # Class name definition + self.StyleSetSpec(8, "fore:#0000FF,bold") + # Function or method name definition + self.StyleSetSpec(9, "fore:#007F7F,bold") + # Operators + self.StyleSetSpec(10, "bold") + # Identifiers + #self.StyleSetSpec(11, "bold")#,fore:#FF00FF") + # Comment-blocks + self.StyleSetSpec(12, "fore:#7F7F7F") + # End of line where string is not closed + self.StyleSetSpec(13, "fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces) + # Matched Operators + self.StyleSetSpec(34, "fore:#FFFFFF,back:#0000FF,bold") + self.StyleSetSpec(35, "fore:#000000,back:#FF0000,bold") + + + + def OnUpdateUI(self, evt): + # check for matching braces + braceAtCaret = -1 + braceOpposite = -1 + charBefore = None + caretPos = self.GetCurrentPos() + if caretPos > 0: + charBefore = self.GetCharAt(caretPos - 1) + styleBefore = self.GetStyleAt(caretPos - 1) + + # check before + if charBefore and charBefore in "[]{}()" and ord(styleBefore) == 10: + braceAtCaret = caretPos - 1 + + # check after + if braceAtCaret < 0: + charAfter = self.GetCharAt(caretPos) + styleAfter = self.GetStyleAt(caretPos) + if charAfter and charAfter in "[]{}()" and ord(styleAfter) == 10: + braceAtCaret = caretPos + + if braceAtCaret >= 0: + braceOpposite = self.BraceMatch(braceAtCaret) + + if braceAtCaret != -1 and braceOpposite == -1: + self.BraceBadlight(braceAtCaret) + else: + self.BraceHighlight(braceAtCaret, braceOpposite) + + + def OnMarginClick(self, evt): + # fold and unfold as needed + if evt.GetMargin() == 2: + lineClicked = self.GetLineFromPos(evt.GetPosition()) + print lineClicked + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + ed = PythonSTC(nb, -1) + + ed.SetText(demoText + open('Main.py').read()) + ed.EmptyUndoBuffer() + + + ### Braces are only matched in operator style + ##braces.python.style, "10 + + + + + # line numbers in the margin + ed.SetMarginType(1, wxSTC_MARGIN_NUMBER) + ed.SetMarginWidth(1, 25) + + return ed + + + +#---------------------------------------------------------------------- + + +overview = """\ +""" + + + +if __name__ == '__main__': + import sys + app = wxPySimpleApp() + frame = wxFrame(None, -1, "Tester...", size=(640, 480)) + win = runTest(frame, frame, sys.stdout) + frame.Show(true) + app.MainLoop() + + + + + + +#---------------------------------------------------------------------- +#---------------------------------------------------------------------- + +## TODO: Figure out folding! + + + +## Line folding is also supported. Some of the language lexers support +## automatically setting the proper flags for fold-level, otherwise +## you can do it youself, as in this example. +## folded line +## folded line +## folded line +## another level +## another level +## another level +## folded line +## folded line +## folded line + + +## # setup folding and mark some lines as foldable +## ed.SetFoldFlags(16) ### WHAT IS THIS VALUE? WAHT ARE THE OTHER FLAGS? +## ed.SetMarginType(2, wxSTC_MARGIN_SYMBOL) +## ed.SetMarginMask(2, wxSTC_MASK_FOLDERS) +## ed.SetMarginSensitive(2, true) +## ed.SetMarginWidth(2, 10) +## ed.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_ARROW, "black", "black") +## ed.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, "black", "black") + + +## ed.SetFoldLevel(27, wxSTC_FOLDLEVELBASE + 1) +## ed.SetFoldLevel(28, wxSTC_FOLDLEVELBASE + 1) +## ed.ToggleFold(26) + diff --git a/utils/wxPython/modules/stc/_stcextras.py b/utils/wxPython/modules/stc/_stcextras.py new file mode 100644 index 0000000000..77c6a83cc0 --- /dev/null +++ b/utils/wxPython/modules/stc/_stcextras.py @@ -0,0 +1,3 @@ +# Stuff these names into the wx namespace so wxPyConstructObject can find them + +wx.wxStyledTextEventPtr = wxStyledTextEventPtr diff --git a/utils/wxPython/modules/stc/build.cfg b/utils/wxPython/modules/stc/build.cfg index da7db95305..db7f45a650 100644 --- a/utils/wxPython/modules/stc/build.cfg +++ b/utils/wxPython/modules/stc/build.cfg @@ -10,6 +10,8 @@ PYFILES = ['stc.py'] OTHERCFLAGS = '-I$(WXWIN)/contrib/include' OTHERSWIGFLAGS = '-I$(WXWIN)/contrib/include/wx/stc' +SWIGDEPS = '$(WXWIN)/contrib/include/wx/stc/stc.h' + if sys.platform == 'win32': OTHERLIBS = '$(WXWIN)/contrib/lib/stc$(LIBEXT).lib' else: diff --git a/utils/wxPython/modules/stc/stc_.cpp b/utils/wxPython/modules/stc/stc_.cpp index 31a82eded4..3ad2027eff 100644 --- a/utils/wxPython/modules/stc/stc_.cpp +++ b/utils/wxPython/modules/stc/stc_.cpp @@ -5501,13 +5501,13 @@ static void *SwigwxStyledTextEventTowxEvent(void *ptr) { static PyObject *_wrap_new_wxStyledTextEvent(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; wxStyledTextEvent * _result; - wxEventType _arg0; - int _arg1; + wxEventType _arg0 = (wxEventType ) 0; + int _arg1 = (int ) 0; char *_kwnames[] = { "commandType","id", NULL }; char _ptemp[128]; self = self; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,"ii:new_wxStyledTextEvent",_kwnames,&_arg0,&_arg1)) + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"|ii:new_wxStyledTextEvent",_kwnames,&_arg0,&_arg1)) return NULL; { wxPy_BEGIN_ALLOW_THREADS; @@ -7238,6 +7238,11 @@ SWIGEXPORT(void) initstc_c() { PyDict_SetItemString(d,"wxEVT_STC_MACRORECORD", PyInt_FromLong((long) wxEVT_STC_MACRORECORD)); PyDict_SetItemString(d,"wxEVT_STC_MARGINCLICK", PyInt_FromLong((long) wxEVT_STC_MARGINCLICK)); PyDict_SetItemString(d,"wxEVT_STC_NEEDSHOWN", PyInt_FromLong((long) wxEVT_STC_NEEDSHOWN)); + + + wxClassInfo::CleanUpClasses(); + wxClassInfo::InitializeClasses(); + { int i; for (i = 0; _swig_mapping[i].n1; i++) diff --git a/utils/wxPython/modules/stc/stc_.i b/utils/wxPython/modules/stc/stc_.i index 09056752b5..38a8f83d6b 100644 --- a/utils/wxPython/modules/stc/stc_.i +++ b/utils/wxPython/modules/stc/stc_.i @@ -29,496 +29,15 @@ %extern events.i %extern controls.i -// Get all our defs from the real header file. This is a trial... + +//---------------------------------------------------------------------- +// Get all our defs from the REAL header file. + %include stc.h //---------------------------------------------------------------------- -#ifdef THE_OLD_WAY - - -// constants and stuff - -enum wxSTC_UndoType { - wxSTC_UndoCollectNone, - wxSTC_UndoCollectAutoStart -}; - - -enum wxSTC_EOL { - wxSTC_EOL_CRLF, - wxSTC_EOL_CR, - wxSTC_EOL_LF -}; - -enum wxSTC_EDGE { - wxSTC_EDGE_NONE, - wxSTC_EDGE_LINE, - wxSTC_EDGE_BACKGROUND -}; - - -enum { - wxSTC_LEX_STYLE_MAX, - wxSTC_STYLE_DEFAULT, - wxSTC_STYLE_LINENUMBER, - wxSTC_STYLE_BRACELIGHT, - wxSTC_STYLE_BRACEBAD, - wxSTC_STYLE_CONTROLCHAR, - wxSTC_STYLE_MAX, - wxSTC_STYLE_MASK, - - wxSTC_MARKER_MAX, - wxSTC_MARK_CIRCLE, - wxSTC_MARK_ROUNDRECT, - wxSTC_MARK_ARROW, - wxSTC_MARK_SMALLRECT, - wxSTC_MARK_SHORTARROW, - wxSTC_MARK_EMPTY, - wxSTC_MARK_ARROWDOWN, - wxSTC_MARK_MINUS, - wxSTC_MARK_PLUS, - wxSTC_MARKNUM_FOLDER, - wxSTC_MARKNUM_FOLDEROPEN, - wxSTC_MASK_FOLDERS, - - wxSTC_INDIC_PLAIN, - wxSTC_INDIC_SQUIGGLE, - wxSTC_INDIC_TT, - wxSTC_INDIC0_MASK, - wxSTC_INDIC1_MASK, - wxSTC_INDIC2_MASK, - wxSTC_INDICS_MASK, - - wxSTC_FOLDLEVELBASE, - wxSTC_FOLDLEVELWHITEFLAG, - wxSTC_FOLDLEVELHEADERFLAG, - wxSTC_FOLDLEVELNUMBERMASK, - -}; - -// key commands -enum { - wxSTC_CMD_LINEDOWN = 2300, - wxSTC_CMD_LINEDOWNEXTEND, - wxSTC_CMD_LINEUP, - wxSTC_CMD_LINEUPEXTEND, - wxSTC_CMD_CHARLEFT, - wxSTC_CMD_CHARLEFTEXTEND, - wxSTC_CMD_CHARRIGHT, - wxSTC_CMD_CHARRIGHTEXTEND, - wxSTC_CMD_WORDLEFT, - wxSTC_CMD_WORDLEFTEXTEND, - wxSTC_CMD_WORDRIGHT, - wxSTC_CMD_WORDRIGHTEXTEND, - wxSTC_CMD_HOME, - wxSTC_CMD_HOMEEXTEND, - wxSTC_CMD_LINEEND, - wxSTC_CMD_LINEENDEXTEND, - wxSTC_CMD_DOCUMENTSTART, - wxSTC_CMD_DOCUMENTSTARTEXTEND, - wxSTC_CMD_DOCUMENTEND, - wxSTC_CMD_DOCUMENTENDEXTEND, - wxSTC_CMD_PAGEUP, - wxSTC_CMD_PAGEUPEXTEND, - wxSTC_CMD_PAGEDOWN, - wxSTC_CMD_PAGEDOWNEXTEND, - wxSTC_CMD_EDITTOGGLEOVERTYPE, - wxSTC_CMD_CANCEL, - wxSTC_CMD_DELETEBACK, - wxSTC_CMD_TAB, - wxSTC_CMD_BACKTAB, - wxSTC_CMD_NEWLINE, - wxSTC_CMD_FORMFEED, - wxSTC_CMD_VCHOME, - wxSTC_CMD_VCHOMEEXTEND, - wxSTC_CMD_ZOOMIN, - wxSTC_CMD_ZOOMOUT, - wxSTC_CMD_DELWORDLEFT, - wxSTC_CMD_DELWORDRIGHT, - wxSTC_CMD_LINECUT, - wxSTC_CMD_LINEDELETE, - wxSTC_CMD_LINETRANSPOSE, - wxSTC_CMD_LOWERCASE, - wxSTC_CMD_UPPERCASE -}; - - -enum wxSTC_LEX { - wxSTC_LEX_CONTAINER=0, - wxSTC_LEX_NULL, - wxSTC_LEX_PYTHON, - wxSTC_LEX_CPP, - wxSTC_LEX_HTML, - wxSTC_LEX_XML, - wxSTC_LEX_PERL, - wxSTC_LEX_SQL, - wxSTC_LEX_VB, - wxSTC_LEX_PROPERTIES, - wxSTC_LEX_ERRORLIST, - wxSTC_LEX_MAKEFILE, - wxSTC_LEX_BATCH, -}; - - -enum { - wxSTC_CARET_SLOP, - WXSTC_CARET_CENTER, - wxSTC_CARET_STRICT, - - wxSTC_MARGIN_SYMBOL, - wxSTC_MARGIN_NUMBER, -}; - - -class ScintillaWX; // forward declare -class WordList; -struct SCNotification; - - -extern const wxChar* wxSTCNameStr; - -//---------------------------------------------------------------------- - -class wxStyledTextCtrl : public wxControl { -public: - - wxStyledTextCtrl(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const char* name = wxSTCNameStr); - //~wxStyledTextCtrl(); - - - - // Text retrieval and modification - wxString GetText(); - bool SetText(const wxString& text); - wxString GetLine(int line); - void ReplaceSelection(const wxString& text); - void SetReadOnly(bool readOnly); - bool GetReadOnly(); - wxString GetTextRange(int startPos, int endPos); - wxString GetStyledTextRange(int startPos, int endPos); - //void GetTextRange(int startPos, int endPos, char* buff); - //void GetStyledTextRange(int startPos, int endPos, char* buff); - void AddText(const wxString& text); - void AddStyledText(const wxString& text); - void InsertText(int pos, const wxString& text); - void ClearAll(); - char GetCharAt(int pos); - char GetStyleAt(int pos); - void SetStyleBits(int bits); - int GetStyleBits(); - - - // Clipboard - void Cut(); - void Copy(); - void Paste(); - bool CanPaste(); - void ClearClipbrd(); // avoiding name conflict with virtual in wxWindow - - - // Undo and Redo - void Undo(); - bool CanUndo(); - void EmptyUndoBuffer(); - void Redo(); - bool CanRedo(); - void SetUndoCollection(wxSTC_UndoType type); - wxSTC_UndoType GetUndoCollection(); - void BeginUndoAction(); - void EndUndoAction(); - - - // Selection and information - void GetSelection(int* OUTPUT, int* OUTPUT); - void SetSelection(int startPos, int endPos); - wxString GetSelectedText(); - void HideSelection(bool hide); - bool GetHideSelection(); - - int GetTextLength(); - int GetFirstVisibleLine(); - bool GetModified(); - int GetLineCount(); - wxRect GetRect(); - int GetLineFromPos(int pos); - int GetLineStartPos(int line); - int GetLineLengthAtPos(int pos); - int GetLineLength(int line); - wxString GetCurrentLineText(/* TODO?? int* linePos=NULL*/); - int GetCurrentLine(); - int PositionFromPoint(wxPoint pt); - int LineFromPoint(wxPoint pt); - wxPoint PointFromPosition(int pos); - int GetCurrentPos(); - int GetAnchor(); - void SelectAll(); - void SetCurrentPosition(int pos); - void SetAnchor(int pos); - void GotoPos(int pos); - void GotoLine(int line); - void ChangePosition(int delta, bool extendSelection); - void PageMove(int cmdKey, bool extendSelection); - - void ScrollBy(int columnDelta, int lineDelta); - void ScrollToLine(int line); - void ScrollToColumn(int column); - void EnsureCaretVisible(); - void SetCaretPolicy(int policy, int slop=0); - int GetSelectionType(); - - - - // Searching - int FindText(int minPos, int maxPos, const wxString& text, - bool caseSensitive, bool wholeWord); - void SearchAnchor(); - int SearchNext(const wxString& text, bool caseSensitive, bool wholeWord); - int SearchPrev(const wxString& text, bool caseSensitive, bool wholeWord); - - - // Visible whitespace - bool GetViewWhitespace(); - void SetViewWhitespace(bool visible); - - - // Line endings - wxSTC_EOL GetEOLMode(); - void SetEOLMode(wxSTC_EOL mode); - bool GetViewEOL(); - void SetViewEOL(bool visible); - void ConvertEOL(wxSTC_EOL mode); - - - // Styling - int GetEndStyled(); - void StartStyling(int pos, int mask); - void SetStyleFor(int length, int style); - void SetStyleBytes(int length, char* styleBytes); - - - // Style Definition - void StyleClearAll(); - void StyleResetDefault(); - void StyleSetSpec(int styleNum, const wxString& spec); - void StyleSetForeground(int styleNum, const wxColour& colour); - void StyleSetBackground(int styleNum, const wxColour& colour); - void StyleSetFont(int styleNum, wxFont& font); - void StyleSetFontAttr(int styleNum, int size, const wxString& faceName, bool bold, bool italic); - void StyleSetBold(int styleNum, bool bold); - void StyleSetItalic(int styleNum, bool italic); - void StyleSetFaceName(int styleNum, const wxString& faceName); - void StyleSetSize(int styleNum, int pointSize); - void StyleSetEOLFilled(int styleNum, bool fillEOL); - - - // Margins in the edit area - int GetLeftMargin(); - int GetRightMargin(); - void SetMargins(int left, int right); - - - // Margins for selection, markers, etc. - void SetMarginType(int margin, int type); - int GetMarginType(int margin); - void SetMarginWidth(int margin, int pixelWidth); - int GetMarginWidth(int margin); - void SetMarginMask(int margin, int mask); - int GetMarginMask(int margin); - void SetMarginSensitive(int margin, bool sensitive); - bool GetMarginSensitive(int margin); - - - // Selection and Caret styles - void SetSelectionForeground(const wxColour& colour); - void SetSelectionBackground(const wxColour& colour); - void SetCaretForeground(const wxColour& colour); - int GetCaretPeriod(); - void SetCaretPeriod(int milliseconds); - - - // Other settings - void SetBufferedDraw(bool isBuffered); - void SetTabWidth(int numChars); - void SetWordChars(const wxString& wordChars); - - - // Brace highlighting - void BraceHighlight(int pos1, int pos2); - void BraceBadlight(int pos); - int BraceMatch(int pos, int maxReStyle=0); - - - // Markers - void MarkerDefine(int markerNumber, int markerSymbol, - const wxColour& foreground, - const wxColour& background); - void MarkerSetType(int markerNumber, int markerSymbol); - void MarkerSetForeground(int markerNumber, const wxColour& colour); - void MarkerSetBackground(int markerNumber, const wxColour& colour); - int MarkerAdd(int line, int markerNumber); - void MarkerDelete(int line, int markerNumber); - void MarkerDeleteAll(int markerNumber); - int MarkerGet(int line); - int MarkerGetNextLine(int lineStart, int markerMask); - int MarkerGetPrevLine(int lineStart, int markerMask); - int MarkerLineFromHandle(int handle); - void MarkerDeleteHandle(int handle); - - - // Indicators - void IndicatorSetStyle(int indicNum, int indicStyle); - int IndicatorGetStyle(int indicNum); - void IndicatorSetColour(int indicNum, const wxColour& colour); - - - // Auto completion - void AutoCompShow(const wxString& listOfWords); - void AutoCompCancel(); - bool AutoCompActive(); - int AutoCompPosAtStart(); - void AutoCompComplete(); - void AutoCompStopChars(const wxString& stopChars); - - - // Call tips - void CallTipShow(int pos, const wxString& text); - void CallTipCancel(); - bool CallTipActive(); - int CallTipPosAtStart(); - void CallTipSetHighlight(int start, int end); - void CallTipSetBackground(const wxColour& colour); - - - // Key bindings - void CmdKeyAssign(int key, int modifiers, int cmd); - void CmdKeyClear(int key, int modifiers); - void CmdKeyClearAll(); - void CmdKeyExecute(int cmd); - - - // Print formatting - int FormatRange(bool doDraw, - int startPos, - int endPos, - wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? - wxRect renderRect, - wxRect pageRect); - - - // Document Sharing (multiple views) - void* GetDocument(); - void SetDocument(void* document); - // TODO: create a wx wrapper for Scintilla's document class - - - // Folding - int VisibleFromDocLine(int docLine); - int DocLineFromVisible(int displayLine); - int SetFoldLevel(int line, int level); - int GetFoldLevel(int line); - int GetLastChild(int line); - int GetFoldParent(int line); - void ShowLines(int lineStart, int lineEnd); - void HideLines(int lineStart, int lineEnd); - bool GetLineVisible(int line); - void SetFoldExpanded(int line, bool expanded); - bool GetFoldExpanded(int line); - void ToggleFold(int line); - void EnsureVisible(int line); - void SetFoldFlags(int flags); - - - // Long Lines - int GetEdgeColumn(); - void SetEdgeColumn(int column); - wxSTC_EDGE GetEdgeMode(); - void SetEdgeMode(wxSTC_EDGE mode); - wxColour GetEdgeColour(); - void SetEdgeColour(const wxColour& colour); - - - // Lexer - void SetLexer(wxSTC_LEX lexer); - wxSTC_LEX GetLexer(); - void Colourise(int start, int end); - void SetProperty(const wxString& key, const wxString& value); - void SetKeywords(int keywordSet, const wxString& keywordList); - - -}; - -//---------------------------------------------------------------------- - -class wxStyledTextEvent : public wxCommandEvent { -public: - wxStyledTextEvent(wxEventType commandType, int id); - ~wxStyledTextEvent() {} - - void SetPosition(int pos); - void SetKey(int k); - void SetModifiers(int m); - void SetModificationType(int t); - void SetText(const char* t); - void SetLength(int len); - void SetLinesAdded(int num); - void SetLine(int val); - void SetFoldLevelNow(int val); - void SetFoldLevelPrev(int val); - void SetMargin(int val); - void SetMessage(int val); - void SetWParam(int val); - void SetLParam(int val); - - int GetPosition() const; - int GetKey() const; - int GetModifiers() const; - int GetModificationType() const; - wxString GetText() const; - int GetLength() const; - int GetLinesAdded() const; - int GetLine() const; - int GetFoldLevelNow() const; - int GetFoldLevelPrev() const; - int GetMargin() const; - int GetMessage() const; - int GetWParam() const; - int GetLParam() const; - - bool GetShift() const; - bool GetControl() const; - bool GetAlt() const; - -}; - - - -enum { - wxEVT_STC_CHANGE = 1650, - wxEVT_STC_STYLENEEDED, - wxEVT_STC_CHARADDED, - wxEVT_STC_UPDATEUI, - wxEVT_STC_SAVEPOINTREACHED, - wxEVT_STC_SAVEPOINTLEFT, - wxEVT_STC_ROMODIFYATTEMPT, - wxEVT_STC_DOUBLECLICK, - wxEVT_STC_MODIFIED, - wxEVT_STC_KEY, - wxEVT_STC_MACRORECORD, - wxEVT_STC_MARGINCLICK, - wxEVT_STC_NEEDSHOWN -}; - - - -// End of THE_OLD_WAY -#endif - - +// Python functions to act like the event macros %pragma(python) code = " def EVT_STC_CHANGE(win, id, fn): @@ -551,11 +70,32 @@ def EVT_STC_MODIFIED(win, id, fn): def EVT_STC_CMDKEY(win, id, fn): win.Connect(id, -1, wxEVT_STC_CMDKEY, fn) -def EVT_STC_UNKNOWNCMDKEY(win, id, fn): - win.Connect(id, -1, wxEVT_STC_UNKNOWNCMDKEY, fn) +def EVT_STC_MACRORECORD(win, id, fn): + win.Connect(id, -1, wxEVT_STC_MACRORECORD, fn) + +def EVT_STC_MARGINCLICK(win, id, fn): + win.Connect(id, -1, wxEVT_STC_MARGINCLICK, fn) + +def EVT_STC_NEEDSHOWN(win, id, fn): + win.Connect(id, -1, wxEVT_STC_NEEDSHOWN, fn) + " +//---------------------------------------------------------------------- + +%init %{ + + wxClassInfo::CleanUpClasses(); + wxClassInfo::InitializeClasses(); + +%} + + +//---------------------------------------------------------------------- + +%pragma(python) include="_stcextras.py"; + //---------------------------------------------------------------------- //---------------------------------------------------------------------- diff --git a/utils/wxPython/modules/stc/stc_.py b/utils/wxPython/modules/stc/stc_.py index 1aa3105ab6..1d0d745a4b 100644 --- a/utils/wxPython/modules/stc/stc_.py +++ b/utils/wxPython/modules/stc/stc_.py @@ -65,8 +65,15 @@ def EVT_STC_MODIFIED(win, id, fn): def EVT_STC_CMDKEY(win, id, fn): win.Connect(id, -1, wxEVT_STC_CMDKEY, fn) -def EVT_STC_UNKNOWNCMDKEY(win, id, fn): - win.Connect(id, -1, wxEVT_STC_UNKNOWNCMDKEY, fn) +def EVT_STC_MACRORECORD(win, id, fn): + win.Connect(id, -1, wxEVT_STC_MACRORECORD, fn) + +def EVT_STC_MARGINCLICK(win, id, fn): + win.Connect(id, -1, wxEVT_STC_MARGINCLICK, fn) + +def EVT_STC_NEEDSHOWN(win, id, fn): + win.Connect(id, -1, wxEVT_STC_NEEDSHOWN, fn) + class wxStyledTextCtrlPtr(wxControlPtr): @@ -838,3 +845,10 @@ wxEVT_STC_KEY = stc_c.wxEVT_STC_KEY wxEVT_STC_MACRORECORD = stc_c.wxEVT_STC_MACRORECORD wxEVT_STC_MARGINCLICK = stc_c.wxEVT_STC_MARGINCLICK wxEVT_STC_NEEDSHOWN = stc_c.wxEVT_STC_NEEDSHOWN + + +#-------------- USER INCLUDE ----------------------- + +# Stuff these names into the wx namespace so wxPyConstructObject can find them + +wx.wxStyledTextEventPtr = wxStyledTextEventPtr