Make wxGTK's wxScrolledWindow set m_x/xScrollLines to 0
if scrollbars disappear (instead of 1) as per wxMSW. Expose m_x/yScrollLines in public getters. Correct window origin for scrolled window in RTL. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41186 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -68,6 +68,10 @@ public:
|
|||||||
int GetScrollPageSize(int orient) const;
|
int GetScrollPageSize(int orient) const;
|
||||||
void SetScrollPageSize(int orient, int pageSize);
|
void SetScrollPageSize(int orient, int pageSize);
|
||||||
|
|
||||||
|
// get the number of lines the window can scroll,
|
||||||
|
// returns 0 if no scrollbars are there.
|
||||||
|
int GetScrollLines( int orient ) const;
|
||||||
|
|
||||||
// Set the x, y scrolling increments.
|
// Set the x, y scrolling increments.
|
||||||
void SetScrollRate( int xstep, int ystep );
|
void SetScrollRate( int xstep, int ystep );
|
||||||
|
|
||||||
|
@@ -844,6 +844,15 @@ void wxScrollHelper::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const
|
|||||||
*y_unit = m_yScrollPixelsPerLine;
|
*y_unit = m_yScrollPixelsPerLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wxScrollHelper::GetScrollLines( int orient ) const
|
||||||
|
{
|
||||||
|
if ( orient == wxHORIZONTAL )
|
||||||
|
return m_xScrollLines;
|
||||||
|
else
|
||||||
|
return m_yScrollLines;
|
||||||
|
}
|
||||||
|
|
||||||
int wxScrollHelper::GetScrollPageSize(int orient) const
|
int wxScrollHelper::GetScrollPageSize(int orient) const
|
||||||
{
|
{
|
||||||
if ( orient == wxHORIZONTAL )
|
if ( orient == wxHORIZONTAL )
|
||||||
@@ -881,7 +890,7 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos )
|
|||||||
|
|
||||||
// Calculate page size i.e. number of scroll units you get on the
|
// Calculate page size i.e. number of scroll units you get on the
|
||||||
// current client window
|
// current client window
|
||||||
int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
|
int noPagePositions = w/m_xScrollPixelsPerLine;
|
||||||
if (noPagePositions < 1) noPagePositions = 1;
|
if (noPagePositions < 1) noPagePositions = 1;
|
||||||
|
|
||||||
// Correct position if greater than extent of canvas minus
|
// Correct position if greater than extent of canvas minus
|
||||||
@@ -889,7 +898,8 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos )
|
|||||||
m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition );
|
m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition );
|
||||||
m_xScrollPosition = wxMax( 0, m_xScrollPosition );
|
m_xScrollPosition = wxMax( 0, m_xScrollPosition );
|
||||||
|
|
||||||
if (old_x != m_xScrollPosition) {
|
if (old_x != m_xScrollPosition)
|
||||||
|
{
|
||||||
m_win->SetScrollPos( wxHORIZONTAL, m_xScrollPosition );
|
m_win->SetScrollPos( wxHORIZONTAL, m_xScrollPosition );
|
||||||
m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0,
|
m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0,
|
||||||
GetScrollRect() );
|
GetScrollRect() );
|
||||||
@@ -902,7 +912,7 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos )
|
|||||||
|
|
||||||
// Calculate page size i.e. number of scroll units you get on the
|
// Calculate page size i.e. number of scroll units you get on the
|
||||||
// current client window
|
// current client window
|
||||||
int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
|
int noPagePositions = h/m_yScrollPixelsPerLine;
|
||||||
if (noPagePositions < 1) noPagePositions = 1;
|
if (noPagePositions < 1) noPagePositions = 1;
|
||||||
|
|
||||||
// Correct position if greater than extent of canvas minus
|
// Correct position if greater than extent of canvas minus
|
||||||
@@ -910,7 +920,8 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos )
|
|||||||
m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
|
m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
|
||||||
m_yScrollPosition = wxMax( 0, m_yScrollPosition );
|
m_yScrollPosition = wxMax( 0, m_yScrollPosition );
|
||||||
|
|
||||||
if (old_y != m_yScrollPosition) {
|
if (old_y != m_yScrollPosition)
|
||||||
|
{
|
||||||
m_win->SetScrollPos( wxVERTICAL, m_yScrollPosition );
|
m_win->SetScrollPos( wxVERTICAL, m_yScrollPosition );
|
||||||
m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine,
|
m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine,
|
||||||
GetScrollRect() );
|
GetScrollRect() );
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/fontutil.h"
|
#include "wx/fontutil.h"
|
||||||
|
#include "wx/scrolwin.h"
|
||||||
|
|
||||||
#include "wx/gtk/win_gtk.h"
|
#include "wx/gtk/win_gtk.h"
|
||||||
#include "wx/gtk/private.h"
|
#include "wx/gtk/private.h"
|
||||||
@@ -326,11 +327,40 @@ wxWindowDC::wxWindowDC( wxWindow *window )
|
|||||||
|
|
||||||
if (m_owner && m_owner->m_wxwindow && (m_owner->GetLayoutDirection() == wxLayout_RightToLeft))
|
if (m_owner && m_owner->m_wxwindow && (m_owner->GetLayoutDirection() == wxLayout_RightToLeft))
|
||||||
{
|
{
|
||||||
|
// reverse sense
|
||||||
m_signX = -1;
|
m_signX = -1;
|
||||||
gint width;
|
|
||||||
gdk_window_get_geometry( GTK_PIZZA(m_owner->m_wxwindow)->bin_window,
|
// origin in the upper right corner
|
||||||
NULL, NULL, &width, NULL, NULL );
|
wxScrolledWindow *sw = wxDynamicCast( m_owner, wxScrolledWindow );
|
||||||
m_deviceOriginX = width;;
|
if (sw)
|
||||||
|
{
|
||||||
|
// We cannot use just the virtual size here, because
|
||||||
|
// the virtual size may be less than the visible area
|
||||||
|
// due to rounding errors of the scroll steps. If the
|
||||||
|
// horizontal scroll step is 10 pixels and the virtual
|
||||||
|
// area is 97 pixels, we should be able to see or scroll
|
||||||
|
// to 100 pixels, so the origin is at -100, not -97.
|
||||||
|
if (sw->GetScrollLines(wxHORIZONTAL) == 0)
|
||||||
|
{
|
||||||
|
int client_width = m_owner->GetClientSize().x;
|
||||||
|
m_deviceOriginX = client_width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int scroll_step = 0;
|
||||||
|
sw->GetScrollPixelsPerUnit( &scroll_step, NULL );
|
||||||
|
int client_width = m_owner->GetClientSize().x;
|
||||||
|
int virtual_size = sw->GetVirtualSize().x;
|
||||||
|
int steps = (virtual_size + scroll_step - 1) / scroll_step;
|
||||||
|
int width = steps * scroll_step + (client_width % scroll_step);
|
||||||
|
m_deviceOriginX = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int client_width = m_owner->GetClientSize().x;
|
||||||
|
m_deviceOriginX = client_width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -88,15 +88,10 @@ void wxScrollHelperNative::DoAdjustScrollbar(GtkRange* range,
|
|||||||
int *lines,
|
int *lines,
|
||||||
int *linesPerPage)
|
int *linesPerPage)
|
||||||
{
|
{
|
||||||
// GtkRange won't allow upper == lower, so for disabled state use [0,1]
|
|
||||||
// with a page size of 1. This will also clamp position to 0.
|
|
||||||
int upper = 1;
|
|
||||||
int page_size = 1;
|
|
||||||
if (pixelsPerLine > 0 && winSize > 0 && winSize < virtSize)
|
if (pixelsPerLine > 0 && winSize > 0 && winSize < virtSize)
|
||||||
{
|
{
|
||||||
upper = (virtSize + pixelsPerLine - 1) / pixelsPerLine;
|
int upper = (virtSize + pixelsPerLine - 1) / pixelsPerLine;
|
||||||
page_size = winSize / pixelsPerLine;
|
int page_size = winSize / pixelsPerLine;
|
||||||
}
|
|
||||||
|
|
||||||
*lines = upper;
|
*lines = upper;
|
||||||
*linesPerPage = page_size;
|
*linesPerPage = page_size;
|
||||||
@@ -107,6 +102,23 @@ void wxScrollHelperNative::DoAdjustScrollbar(GtkRange* range,
|
|||||||
adj->page_size = page_size;
|
adj->page_size = page_size;
|
||||||
gtk_range_set_range(range, 0, upper);
|
gtk_range_set_range(range, 0, upper);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// GtkRange won't allow upper == lower, so for disabled state use [0,1]
|
||||||
|
// with a page size of 1. This will also clamp position to 0.
|
||||||
|
int upper = 1;
|
||||||
|
int page_size = 1;
|
||||||
|
|
||||||
|
*lines = 0;
|
||||||
|
*linesPerPage = 0;
|
||||||
|
|
||||||
|
GtkAdjustment* adj = range->adjustment;
|
||||||
|
adj->step_increment = 1;
|
||||||
|
adj->page_increment =
|
||||||
|
adj->page_size = page_size;
|
||||||
|
gtk_range_set_range(range, 0, upper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxScrollHelperNative::AdjustScrollbars()
|
void wxScrollHelperNative::AdjustScrollbars()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user