implemented ScrollLines/Pages() for GTK+ 2
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28441 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -231,6 +231,7 @@ wxGTK:
|
|||||||
- fixed many rendering artifacts and wrong colours with lots of GTK+ themes
|
- fixed many rendering artifacts and wrong colours with lots of GTK+ themes
|
||||||
- implemented wxColourDialog as native dialog
|
- implemented wxColourDialog as native dialog
|
||||||
- implemented wxTextCtrl::HitTest() (GTK+ >= 2)
|
- implemented wxTextCtrl::HitTest() (GTK+ >= 2)
|
||||||
|
- implemented wxTextCtrl::ScrollLines() and ScrollPages for GTK+ 2.x
|
||||||
- wxTreeCtrl::GetCount() counts root as well now (compatible with MSW)
|
- wxTreeCtrl::GetCount() counts root as well now (compatible with MSW)
|
||||||
- added support for wxCHK_3STATE style (GTK2 only)
|
- added support for wxCHK_3STATE style (GTK2 only)
|
||||||
- implemented text underlining under GTK2
|
- implemented text underlining under GTK2
|
||||||
|
@@ -1718,16 +1718,18 @@ void wxTextCtrl::Thaw()
|
|||||||
|
|
||||||
GtkAdjustment *wxTextCtrl::GetVAdj() const
|
GtkAdjustment *wxTextCtrl::GetVAdj() const
|
||||||
{
|
{
|
||||||
|
if ( !IsMultiLine() )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
return NULL;
|
return gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(m_widget));
|
||||||
#else
|
#else
|
||||||
return HasFlag(wxTE_MULTILINE) ? GTK_TEXT(m_text)->vadj : NULL;
|
return GTK_TEXT(m_text)->vadj;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
|
bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
|
||||||
{
|
{
|
||||||
#ifndef __WXGTK20__
|
|
||||||
float value = adj->value + diff;
|
float value = adj->value + diff;
|
||||||
|
|
||||||
if ( value < 0 )
|
if ( value < 0 )
|
||||||
@@ -1746,39 +1748,38 @@ bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
|
|||||||
|
|
||||||
adj->value = value;
|
adj->value = value;
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
gtk_adjustment_value_changed(GTK_ADJUSTMENT(adj));
|
||||||
|
#else
|
||||||
gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
|
gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::ScrollLines(int lines)
|
bool wxTextCtrl::ScrollLines(int lines)
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
|
||||||
return FALSE;
|
|
||||||
#else
|
|
||||||
GtkAdjustment *adj = GetVAdj();
|
GtkAdjustment *adj = GetVAdj();
|
||||||
if ( !adj )
|
if ( !adj )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
int diff = (int)ceil(lines*adj->step_increment);
|
||||||
|
#else
|
||||||
// this is hardcoded to 10 in GTK+ 1.2 (great idea)
|
// this is hardcoded to 10 in GTK+ 1.2 (great idea)
|
||||||
static const int KEY_SCROLL_PIXELS = 10;
|
int diff = 10*lines;
|
||||||
|
|
||||||
return DoScroll(adj, lines*KEY_SCROLL_PIXELS);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return DoScroll(adj, diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::ScrollPages(int pages)
|
bool wxTextCtrl::ScrollPages(int pages)
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
|
||||||
return FALSE;
|
|
||||||
#else
|
|
||||||
GtkAdjustment *adj = GetVAdj();
|
GtkAdjustment *adj = GetVAdj();
|
||||||
if ( !adj )
|
if ( !adj )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return DoScroll(adj, (int)ceil(pages*adj->page_increment));
|
return DoScroll(adj, (int)ceil(pages*adj->page_increment));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1718,16 +1718,18 @@ void wxTextCtrl::Thaw()
|
|||||||
|
|
||||||
GtkAdjustment *wxTextCtrl::GetVAdj() const
|
GtkAdjustment *wxTextCtrl::GetVAdj() const
|
||||||
{
|
{
|
||||||
|
if ( !IsMultiLine() )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
return NULL;
|
return gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(m_widget));
|
||||||
#else
|
#else
|
||||||
return HasFlag(wxTE_MULTILINE) ? GTK_TEXT(m_text)->vadj : NULL;
|
return GTK_TEXT(m_text)->vadj;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
|
bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
|
||||||
{
|
{
|
||||||
#ifndef __WXGTK20__
|
|
||||||
float value = adj->value + diff;
|
float value = adj->value + diff;
|
||||||
|
|
||||||
if ( value < 0 )
|
if ( value < 0 )
|
||||||
@@ -1746,39 +1748,38 @@ bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
|
|||||||
|
|
||||||
adj->value = value;
|
adj->value = value;
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
gtk_adjustment_value_changed(GTK_ADJUSTMENT(adj));
|
||||||
|
#else
|
||||||
gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
|
gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::ScrollLines(int lines)
|
bool wxTextCtrl::ScrollLines(int lines)
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
|
||||||
return FALSE;
|
|
||||||
#else
|
|
||||||
GtkAdjustment *adj = GetVAdj();
|
GtkAdjustment *adj = GetVAdj();
|
||||||
if ( !adj )
|
if ( !adj )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
int diff = (int)ceil(lines*adj->step_increment);
|
||||||
|
#else
|
||||||
// this is hardcoded to 10 in GTK+ 1.2 (great idea)
|
// this is hardcoded to 10 in GTK+ 1.2 (great idea)
|
||||||
static const int KEY_SCROLL_PIXELS = 10;
|
int diff = 10*lines;
|
||||||
|
|
||||||
return DoScroll(adj, lines*KEY_SCROLL_PIXELS);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return DoScroll(adj, diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::ScrollPages(int pages)
|
bool wxTextCtrl::ScrollPages(int pages)
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
|
||||||
return FALSE;
|
|
||||||
#else
|
|
||||||
GtkAdjustment *adj = GetVAdj();
|
GtkAdjustment *adj = GetVAdj();
|
||||||
if ( !adj )
|
if ( !adj )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return DoScroll(adj, (int)ceil(pages*adj->page_increment));
|
return DoScroll(adj, (int)ceil(pages*adj->page_increment));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user