From fa70ec2b51af8dfab9053ec57757a883c93d6712 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 25 Sep 2008 16:10:27 +0000 Subject: [PATCH] Consolidate old and new implementations of Get/SetSelection git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55868 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/stc/stc.h | 27 ++++++++++++++++----------- src/stc/gen_iface.py | 6 +++--- src/stc/stc.cpp | 23 ++++------------------- src/stc/stc.cpp.in | 13 ++----------- src/stc/stc.h.in | 24 ++++++++++++++++-------- 5 files changed, 41 insertions(+), 52 deletions(-) diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 5ab192da78..985e10df14 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -2615,9 +2615,6 @@ public: // Is the document different from when it was last saved? bool GetModify() const; - // Select a range of text. - void SetSelection(int start, int end); - // Retrieve the selected text. wxString GetSelectedText(); @@ -3547,13 +3544,6 @@ public: void SetMargins(int left, int right); - // Retrieve the start and end positions of the current selection. -#ifdef SWIG - void GetSelection(int* OUTPUT, int* OUTPUT); -#else - void GetSelection(int* startPos, int* endPos); -#endif - // Retrieve the point in the window where a position is displayed. wxPoint PointFromPosition(int pos); @@ -3703,6 +3693,9 @@ public: } } +#ifdef SWIG + void GetSelection(long* OUTPUT, long* OUTPUT) const; +#else virtual void GetSelection(long *from, long *to) const { if ( from ) @@ -3710,7 +3703,19 @@ public: if ( to ) *to = GetSelectionEnd(); } - + + // kept for compatibility only + void GetSelection(int *from, int *to) + { + long f, t; + GetSelection(&f, &t); + if ( from ) + *from = f; + if ( to ) + *to = t; + } +#endif + virtual bool IsEditable() const { return !GetReadOnly(); } virtual void SetEditable(bool editable) { SetReadOnly(!editable); } diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 8dda03017d..5cfd86c85f 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -425,15 +425,15 @@ methodOverrideMap = { ('Retrieve the contents of a line.',)), - 'SetSel' : ('SetSelection', 0, 0, 0), + 'SetSel' : (None, 0,0,0), #'SetSelection', 0, 0, 0), 'GetSelText' : ('GetSelectedText', 'wxString %s();', '''wxString %s() { - int start; - int end; + long start; + long end; GetSelection(&start, &end); int len = end - start; diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index a81c6c71aa..2b01d9033f 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -1488,16 +1488,10 @@ bool wxStyledTextCtrl::GetModify() const return SendMsg(2159, 0, 0) != 0; } -// Select a range of text. -void wxStyledTextCtrl::SetSelection(int start, int end) -{ - SendMsg(2160, start, end); -} - // Retrieve the selected text. wxString wxStyledTextCtrl::GetSelectedText() { - int start; - int end; + long start; + long end; GetSelection(&start, &end); int len = end - start; @@ -3486,15 +3480,6 @@ void wxStyledTextCtrl::SetMargins(int left, int right) { } -// Retrieve the start and end positions of the current selection. -void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) { - if (startPos != NULL) - *startPos = SendMsg(SCI_GETSELECTIONSTART); - if (endPos != NULL) - *endPos = SendMsg(SCI_GETSELECTIONEND); -} - - // Retrieve the point in the window where a position is displayed. wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); @@ -3647,8 +3632,8 @@ wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line) wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw() { - int start; - int end; + long start; + long end; GetSelection(&start, &end); int len = end - start; diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 3ce719586b..2320b53268 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -489,15 +489,6 @@ void wxStyledTextCtrl::SetMargins(int left, int right) { } -// Retrieve the start and end positions of the current selection. -void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) { - if (startPos != NULL) - *startPos = SendMsg(SCI_GETSELECTIONSTART); - if (endPos != NULL) - *endPos = SendMsg(SCI_GETSELECTIONEND); -} - - // Retrieve the point in the window where a position is displayed. wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); @@ -650,8 +641,8 @@ wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line) wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw() { - int start; - int end; + long start; + long end; GetSelection(&start, &end); int len = end - start; diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 2cdc27b3d9..1f2622784f 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -180,13 +180,6 @@ public: void SetMargins(int left, int right); - // Retrieve the start and end positions of the current selection. -#ifdef SWIG - void GetSelection(int* OUTPUT, int* OUTPUT); -#else - void GetSelection(int* startPos, int* endPos); -#endif - // Retrieve the point in the window where a position is displayed. wxPoint PointFromPosition(int pos); @@ -336,6 +329,9 @@ public: } } +#ifdef SWIG + void GetSelection(long* OUTPUT, long* OUTPUT) const; +#else virtual void GetSelection(long *from, long *to) const { if ( from ) @@ -343,7 +339,19 @@ public: if ( to ) *to = GetSelectionEnd(); } - + + // kept for compatibility only + void GetSelection(int *from, int *to) + { + long f, t; + GetSelection(&f, &t); + if ( from ) + *from = f; + if ( to ) + *to = t; + } +#endif + virtual bool IsEditable() const { return !GetReadOnly(); } virtual void SetEditable(bool editable) { SetReadOnly(!editable); } -- 2.47.2