virtual void ShowPosition(long pos);
+#ifdef __WXGTK20__
+ virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
+#endif // __WXGTK20__
+
// Clipboard operations
virtual void Copy();
virtual void Cut();
void DoApplyWidgetStyle(GtkRcStyle *style);
void CalculateScrollbar();
void OnInternalIdle();
+
+#ifdef __WXGTK20__
+ void SetUpdateFont(bool WXUNUSED(update)) { }
+#else // !__WXGTK20__
+ void SetUpdateFont(bool update) { m_updateFont = update; }
void UpdateFontIfNeeded();
+#endif // __WXGTK20__/!__WXGTK20__
void SetModified() { m_modified = TRUE; }
bool m_modified:1;
bool m_vScrollbarVisible:1;
+#ifndef __WXGTK20__
bool m_updateFont:1;
+#endif // !__WXGTK20__
bool m_ignoreNextUpdate:1;
DECLARE_EVENT_TABLE()
virtual void ShowPosition(long pos);
+#ifdef __WXGTK20__
+ virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
+#endif // __WXGTK20__
+
// Clipboard operations
virtual void Copy();
virtual void Cut();
void DoApplyWidgetStyle(GtkRcStyle *style);
void CalculateScrollbar();
void OnInternalIdle();
+
+#ifdef __WXGTK20__
+ void SetUpdateFont(bool WXUNUSED(update)) { }
+#else // !__WXGTK20__
+ void SetUpdateFont(bool update) { m_updateFont = update; }
void UpdateFontIfNeeded();
+#endif // __WXGTK20__/!__WXGTK20__
void SetModified() { m_modified = TRUE; }
bool m_modified:1;
bool m_vScrollbarVisible:1;
+#ifndef __WXGTK20__
bool m_updateFont:1;
+#endif // !__WXGTK20__
bool m_ignoreNextUpdate:1;
DECLARE_EVENT_TABLE()
wxapp_install_idle_handler();
win->SetModified();
+#ifndef __WXGTK20__
win->UpdateFontIfNeeded();
+#endif // !__WXGTK20__
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetEventObject( win );
{
m_ignoreNextUpdate =
m_modified = FALSE;
- m_updateFont = FALSE;
+ SetUpdateFont(FALSE);
m_text =
m_vScrollbar = (GtkWidget *)NULL;
}
if ( text.empty() )
return;
+ // gtk_text_changed_callback() will set m_modified to true but m_modified
+ // shouldn't be changed by the program writing to the text control itself,
+ // so save the old value and restore when we're done
+ bool oldModified = m_modified;
+
if ( m_windowStyle & wxTE_MULTILINE )
{
#ifdef __WXGTK20__
// in UpdateFontIfNeeded() any longer
if ( !text.empty() )
{
- m_updateFont = FALSE;
+ SetUpdateFont(FALSE);
}
// Bring editable's cursor back uptodate.
gtk_entry_set_position( GTK_ENTRY(m_text), len );
}
- m_modified = TRUE;
+ m_modified = oldModified;
}
void wxTextCtrl::AppendText( const wxString &text )
if ( m_windowStyle & wxTE_MULTILINE )
{
- m_updateFont = TRUE;
+ SetUpdateFont(TRUE);
m_defaultStyle.SetFont(font);
{
// this method is very inefficient and hence should be called as rarely as
// possible!
- wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE) && m_updateFont,
+ //
+ // TODO: it can be implemented much more efficiently for GTK2
+ wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE)
+#ifndef __WXGTK20__
+ && m_updateFont
+#endif // GTK+ 1.x
+ ,
_T("shouldn't be called for single line controls") );
wxString value = GetValue();
if ( !value.IsEmpty() )
{
- m_updateFont = FALSE;
+ SetUpdateFont(FALSE);
Clear();
AppendText(value);
}
}
+#ifndef __WXGTK20__
+
void wxTextCtrl::UpdateFontIfNeeded()
{
if ( m_updateFont )
ChangeFontGlobally();
}
+#endif // GTK+ 1.x
+
bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
{
if ( !wxControl::SetForegroundColour(colour) )
wxapp_install_idle_handler();
win->SetModified();
+#ifndef __WXGTK20__
win->UpdateFontIfNeeded();
+#endif // !__WXGTK20__
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetEventObject( win );
{
m_ignoreNextUpdate =
m_modified = FALSE;
- m_updateFont = FALSE;
+ SetUpdateFont(FALSE);
m_text =
m_vScrollbar = (GtkWidget *)NULL;
}
if ( text.empty() )
return;
+ // gtk_text_changed_callback() will set m_modified to true but m_modified
+ // shouldn't be changed by the program writing to the text control itself,
+ // so save the old value and restore when we're done
+ bool oldModified = m_modified;
+
if ( m_windowStyle & wxTE_MULTILINE )
{
#ifdef __WXGTK20__
// in UpdateFontIfNeeded() any longer
if ( !text.empty() )
{
- m_updateFont = FALSE;
+ SetUpdateFont(FALSE);
}
// Bring editable's cursor back uptodate.
gtk_entry_set_position( GTK_ENTRY(m_text), len );
}
- m_modified = TRUE;
+ m_modified = oldModified;
}
void wxTextCtrl::AppendText( const wxString &text )
if ( m_windowStyle & wxTE_MULTILINE )
{
- m_updateFont = TRUE;
+ SetUpdateFont(TRUE);
m_defaultStyle.SetFont(font);
{
// this method is very inefficient and hence should be called as rarely as
// possible!
- wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE) && m_updateFont,
+ //
+ // TODO: it can be implemented much more efficiently for GTK2
+ wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE)
+#ifndef __WXGTK20__
+ && m_updateFont
+#endif // GTK+ 1.x
+ ,
_T("shouldn't be called for single line controls") );
wxString value = GetValue();
if ( !value.IsEmpty() )
{
- m_updateFont = FALSE;
+ SetUpdateFont(FALSE);
Clear();
AppendText(value);
}
}
+#ifndef __WXGTK20__
+
void wxTextCtrl::UpdateFontIfNeeded()
{
if ( m_updateFont )
ChangeFontGlobally();
}
+#endif // GTK+ 1.x
+
bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
{
if ( !wxControl::SetForegroundColour(colour) )