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
This commit is contained in:
Robin Dunn
2008-09-25 16:10:27 +00:00
parent e4a0fe083d
commit fa70ec2b51
5 changed files with 41 additions and 52 deletions

View File

@@ -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 )
@@ -3711,6 +3704,18 @@ public:
*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); }

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 )
@@ -344,6 +340,18 @@ public:
*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); }