implemented ScrollLines/Pages() for all classes in wxGTK, not just wxTextCtrl (patch 1281503)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-02-09 03:53:34 +00:00
parent a8e24848f6
commit 0c131a5ad2
7 changed files with 48 additions and 72 deletions

View File

@@ -618,7 +618,10 @@ bool wxTextCtrl::Create( wxWindow *parent,
PostCreation(size);
if (multi_line)
{
gtk_widget_show(m_text);
SetVScrollAdjustment(gtk_scrolled_window_get_vadjustment((GtkScrolledWindow*)m_widget));
}
if (!value.empty())
{
@@ -1704,64 +1707,6 @@ void wxTextCtrl::OnUrlMouseEvent(wxMouseEvent& event)
GetEventHandler()->ProcessEvent(url_event);
}
// ----------------------------------------------------------------------------
// scrolling
// ----------------------------------------------------------------------------
GtkAdjustment *wxTextCtrl::GetVAdj() const
{
if ( !IsMultiLine() )
return NULL;
return gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(m_widget));
}
bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
{
float value = adj->value + diff;
if ( value < 0 )
value = 0;
float upper = adj->upper - adj->page_size;
if ( value > upper )
value = upper;
// did we noticeably change the scroll position?
if ( fabs(adj->value - value) < 0.2 )
{
// well, this is what Robert does in wxScrollBar, so it must be good...
return false;
}
adj->value = value;
gtk_adjustment_value_changed(GTK_ADJUSTMENT(adj));
return true;
}
bool wxTextCtrl::ScrollLines(int lines)
{
GtkAdjustment *adj = GetVAdj();
if ( !adj )
return false;
int diff = (int)ceil(lines*adj->step_increment);
return DoScroll(adj, diff);
}
bool wxTextCtrl::ScrollPages(int pages)
{
GtkAdjustment *adj = GetVAdj();
if ( !adj )
return false;
return DoScroll(adj, (int)ceil(pages*adj->page_increment));
}
// static
wxVisualAttributes
wxTextCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))