git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43870
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef __GTKTEXTCTRLH__
-#define __GTKTEXTCTRLH__
+#ifndef _WX_GTK_TEXTCTRL_H_
+#define _WX_GTK_TEXTCTRL_H_
+
+typedef struct _GtkTextMark GtkTextMark;
//-----------------------------------------------------------------------------
// wxTextCtrl
//-----------------------------------------------------------------------------
// wxTextCtrl
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
// has the control been frozen by Freeze()?
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
// has the control been frozen by Freeze()?
- bool IsFrozen() const { return m_frozenness > 0; }
+ bool IsFrozen() const { return m_freezeCount > 0; }
protected:
virtual wxSize DoGetBestSize() const;
protected:
virtual wxSize DoGetBestSize() const;
int m_countUpdatesToIgnore;
// Our text buffer. Convenient, and holds the buffer while using
int m_countUpdatesToIgnore;
// Our text buffer. Convenient, and holds the buffer while using
- // a dummy one when m_frozenness > 0
+ // a dummy one when frozen
GtkTextBuffer *m_buffer;
// number of calls to Freeze() minus number of calls to Thaw()
GtkTextBuffer *m_buffer;
// number of calls to Freeze() minus number of calls to Thaw()
- unsigned int m_frozenness;
+ unsigned m_freezeCount;
+ GtkTextMark* m_showPositionOnThaw;
// For wxTE_AUTO_URL
void OnUrlMouseEvent(wxMouseEvent&);
// For wxTE_AUTO_URL
void OnUrlMouseEvent(wxMouseEvent&);
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
};
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
};
-#endif // __GTKTEXTCTRLH__
-
+#endif // _WX_GTK_TEXTCTRL_H_
SetUpdateFont(false);
m_text = NULL;
SetUpdateFont(false);
m_text = NULL;
+ m_freezeCount = 0;
+ m_showPositionOnThaw = NULL;
m_gdkHandCursor = NULL;
m_gdkXTermCursor = NULL;
}
m_gdkHandCursor = NULL;
m_gdkXTermCursor = NULL;
}
m_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
m_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ // create "ShowPosition" marker
+ GtkTextIter iter;
+ gtk_text_buffer_get_start_iter(m_buffer, &iter);
+ gtk_text_buffer_create_mark(m_buffer, "ShowPosition", &iter, true);
+
// create scrolled window
m_widget = gtk_scrolled_window_new( NULL, NULL );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( m_widget ),
// create scrolled window
m_widget = gtk_scrolled_window_new( NULL, NULL );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( m_widget ),
GtkTextIter iter;
gtk_text_buffer_get_iter_at_offset( m_buffer, &iter, pos );
gtk_text_buffer_place_cursor( m_buffer, &iter );
GtkTextIter iter;
gtk_text_buffer_get_iter_at_offset( m_buffer, &iter, pos );
gtk_text_buffer_place_cursor( m_buffer, &iter );
- if (!IsFrozen())
- {
- // won't work when frozen, text view is not using m_buffer then
- gtk_text_view_scroll_mark_onscreen
- (
- GTK_TEXT_VIEW(m_text),
- gtk_text_buffer_get_insert( m_buffer )
- );
- }
+ GtkTextMark* mark = gtk_text_buffer_get_insert(m_buffer);
+ if (IsFrozen())
+ // defer until Thaw, text view is not using m_buffer now
+ m_showPositionOnThaw = mark;
+ else
+ gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(m_text), mark);
void wxTextCtrl::ShowPosition( long pos )
{
void wxTextCtrl::ShowPosition( long pos )
{
- // won't work when frozen, text view is not using m_buffer then
- if (IsMultiLine() && !IsFrozen())
- gtk_text_buffer_get_start_iter( m_buffer, &iter );
- gtk_text_iter_set_offset( &iter, pos );
- GtkTextMark *mark = gtk_text_buffer_create_mark( m_buffer, NULL, &iter, TRUE );
- gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text), mark, 0.0, FALSE, 0.0, 0.0 );
+ gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, int(pos));
+ GtkTextMark* mark = gtk_text_buffer_get_mark(m_buffer, "ShowPosition");
+ gtk_text_buffer_move_mark(m_buffer, mark, &iter);
+ if (IsFrozen())
+ // defer until Thaw, text view is not using m_buffer now
+ m_showPositionOnThaw = mark;
+ else
+ gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(m_text), mark);
if ( HasFlag(wxTE_MULTILINE) )
{
if ( HasFlag(wxTE_MULTILINE) )
{
- if (m_frozenness++ == 0)
+ if (m_freezeCount++ == 0)
{
// freeze textview updates and remove buffer
g_signal_connect (m_text, "expose_event",
{
// freeze textview updates and remove buffer
g_signal_connect (m_text, "expose_event",
{
if ( HasFlag(wxTE_MULTILINE) )
{
{
if ( HasFlag(wxTE_MULTILINE) )
{
- wxCHECK_RET(m_frozenness != 0, _T("Thaw() without matching Freeze()"));
+ wxCHECK_RET(m_freezeCount != 0, _T("Thaw() without matching Freeze()"));
- if (--m_frozenness == 0)
+ if (--m_freezeCount == 0)
{
// Reattach buffer and thaw textview updates
gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), m_buffer);
{
// Reattach buffer and thaw textview updates
gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), m_buffer);
(gpointer) gtk_text_exposed_callback, this);
g_signal_handlers_disconnect_by_func (m_text,
(gpointer) gtk_text_exposed_callback, this);
(gpointer) gtk_text_exposed_callback, this);
g_signal_handlers_disconnect_by_func (m_text,
(gpointer) gtk_text_exposed_callback, this);
+ if (m_showPositionOnThaw != NULL)
+ {
+ gtk_text_view_scroll_mark_onscreen(
+ GTK_TEXT_VIEW(m_text), m_showPositionOnThaw);
+ m_showPositionOnThaw = NULL;
+ }