+wxPoint wxTextCtrl::DoPositionToCoords(long pos) const
+{
+ if ( !IsMultiLine() )
+ {
+ // Single line text entry (GtkTextEntry) doesn't have support for
+ // getting the coordinates for the given offset. Perhaps we could
+ // find them ourselves by using GetTextExtent() but for now just leave
+ // it unimplemented, this function is more useful for multiline
+ // controls anyhow.
+ return wxDefaultPosition;
+ }
+
+ // Window coordinates for the given position is calculated by getting
+ // the buffer coordinates and converting them to window coordinates.
+ GtkTextView *textview = GTK_TEXT_VIEW(m_text);
+
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos);
+
+ GdkRectangle bufferCoords;
+ gtk_text_view_get_iter_location(textview, &iter, &bufferCoords);
+
+ gint winCoordX = 0,
+ winCoordY = 0;
+ gtk_text_view_buffer_to_window_coords(textview, GTK_TEXT_WINDOW_WIDGET,
+ bufferCoords.x, bufferCoords.y,
+ &winCoordX, &winCoordY);
+
+ return wxPoint(winCoordX, winCoordY);
+}
+