Add wxTextCtrl::PositionToCoords() functions for wxMSW and wxGTK.
The new method allows to find the coordinates in pixels of the given character in a text control. Closes #13221. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68450 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -574,6 +574,11 @@ public:
|
||||
virtual long XYToPosition(long x, long y) const = 0;
|
||||
virtual bool PositionToXY(long pos, long *x, long *y) const = 0;
|
||||
|
||||
// translate the given position (which is just an index in the text control)
|
||||
// to client coordinates
|
||||
wxPoint PositionToCoords(long pos) const;
|
||||
|
||||
|
||||
virtual void ShowPosition(long pos) = 0;
|
||||
|
||||
// find the character at position given in pixels
|
||||
@@ -592,6 +597,13 @@ protected:
|
||||
virtual bool DoLoadFile(const wxString& file, int fileType);
|
||||
virtual bool DoSaveFile(const wxString& file, int fileType);
|
||||
|
||||
// Return true if the given position is valid, i.e. positive and less than
|
||||
// the last position.
|
||||
virtual bool IsValidPosition(long pos) const = 0;
|
||||
|
||||
// Default stub implementation of PositionToCoords() always returns
|
||||
// wxDefaultPosition.
|
||||
virtual wxPoint DoPositionToCoords(long pos) const;
|
||||
|
||||
// the name of the last file loaded with LoadFile() which will be used by
|
||||
// SaveFile() by default
|
||||
@@ -625,6 +637,12 @@ public:
|
||||
wxTextEntryBase::SetValue(value);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool IsValidPosition(long pos) const
|
||||
{
|
||||
return pos >= 0 && pos <= GetLastPosition();
|
||||
}
|
||||
|
||||
private:
|
||||
wxDECLARE_NO_COPY_CLASS(wxTextCtrlIface);
|
||||
};
|
||||
@@ -723,6 +741,12 @@ protected:
|
||||
virtual bool DoLoadFile(const wxString& file, int fileType);
|
||||
virtual bool DoSaveFile(const wxString& file, int fileType);
|
||||
|
||||
// Another wxTextAreaBase override.
|
||||
virtual bool IsValidPosition(long pos) const
|
||||
{
|
||||
return pos >= 0 && pos <= GetLastPosition();
|
||||
}
|
||||
|
||||
// implement the wxTextEntry pure virtual method
|
||||
virtual wxWindow *GetEditableWindow() { return this; }
|
||||
|
||||
|
Reference in New Issue
Block a user