Added new scrolling code.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14241 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-02-15 20:25:40 +00:00
parent 923d52d6fe
commit 4125131be6
3 changed files with 66 additions and 17 deletions

View File

@@ -763,6 +763,12 @@ int wxWindow::GetScrollRange(int orient) const
void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
{ {
#ifdef __WXX11__
wxWindowX11::ScrollWindow( dx, dy, rect );
#else
// before scrolling it, ensure that we don't have any unpainted areas // before scrolling it, ensure that we don't have any unpainted areas
Update(); Update();
@@ -779,6 +785,8 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
r = ScrollNoRefresh(0, dy, rect); r = ScrollNoRefresh(0, dy, rect);
Refresh(TRUE /* erase bkgnd */, &r); Refresh(TRUE /* erase bkgnd */, &r);
} }
#endif
} }
wxRect wxWindow::ScrollNoRefresh(int dx, int dy, const wxRect *rectTotal) wxRect wxWindow::ScrollNoRefresh(int dx, int dy, const wxRect *rectTotal)

View File

@@ -405,7 +405,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
wxWindow* win = NULL; wxWindow* win = NULL;
Window window = event->xany.window; Window window = event->xany.window;
Window actualWindow = window; Window actualWindow = window;
// Find the first wxWindow that corresponds to this event window // Find the first wxWindow that corresponds to this event window
// Because we're receiving events after a window // Because we're receiving events after a window
// has been destroyed, assume a 1:1 match between // has been destroyed, assume a 1:1 match between
@@ -548,6 +548,26 @@ void wxApp::ProcessXEvent(WXEvent* _event)
return; return;
} }
case GraphicsExpose:
{
if (win)
{
wxLogDebug( "GraphicsExpose from %s", win->GetName().c_str(),
event->xgraphicsexpose.x, event->xgraphicsexpose.y,
event->xgraphicsexpose.width, event->xgraphicsexpose.height);
win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
event->xgraphicsexpose.width, event->xgraphicsexpose.height);
win->GetClearRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
event->xgraphicsexpose.width, event->xgraphicsexpose.height);
// if (event->xgraphicsexpose.count == 0)
// win->Update();
}
return;
}
case EnterNotify: case EnterNotify:
case LeaveNotify: case LeaveNotify:
case ButtonPress: case ButtonPress:
@@ -585,7 +605,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
if (win && event->xfocus.detail != NotifyPointer) if (win && event->xfocus.detail != NotifyPointer)
#endif #endif
{ {
wxLogDebug( "FocusOut from %s\n", win->GetName().c_str() ); wxLogDebug( "FocusOut from %s", win->GetName().c_str() );
wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId()); wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
focusEvent.SetEventObject(win); focusEvent.SetEventObject(win);

View File

@@ -469,34 +469,55 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect)
GC xgc = XCreateGC( xdisplay, xwindow, 0, NULL ); GC xgc = XCreateGC( xdisplay, xwindow, 0, NULL );
XSetGraphicsExposures( xdisplay, xgc, True ); XSetGraphicsExposures( xdisplay, xgc, True );
int cw = 0; int s_x;
int ch = 0; int s_y;
GetClientSize( &cw, &ch ); int cw;
int ch;
if (rect)
{
s_x = rect->x;
s_y = rect->y;
cw = rect->width;
ch = rect->height;
}
else
{
s_x = 0;
s_y = 0;
GetClientSize( &cw, &ch );
}
wxPoint offset = GetClientAreaOrigin();
s_x += offset.x;
s_y += offset.y;
int w = cw - abs(dx); int w = cw - abs(dx);
int h = ch - abs(dy); int h = ch - abs(dy);
if ((h < 0) || (w < 0)) if ((h < 0) || (w < 0))
{ {
Refresh(); Refresh();
} }
else else
{ {
int s_x = 0; wxRect rect;
int s_y = 0; if (dx < 0) rect.x = cw+dx; else rect.x = s_x;
if (dx < 0) s_x = -dx; if (dy < 0) rect.y = ch+dy; else rect.y = s_y;
if (dy < 0) s_y = -dy; if (dy != 0) rect.width = cw; else rect.width = abs(dx);
int d_x = 0; if (dx != 0) rect.height = ch; else rect.height = abs(dy);
int d_y = 0;
int d_x = s_x;
int d_y = s_y;
if (dx < 0) s_x += -dx;
if (dy < 0) s_y += -dy;
if (dx > 0) d_x = dx; if (dx > 0) d_x = dx;
if (dy > 0) d_y = dy; if (dy > 0) d_y = dy;
XCopyArea( xdisplay, xwindow, xwindow, xgc, s_x, s_y, w, h, d_x, d_y ); XCopyArea( xdisplay, xwindow, xwindow, xgc, s_x, s_y, w, h, d_x, d_y );
// printf( "s_x %d s_y %d w %d h %d d_x %d d_y %d\n", s_x, s_y, w, h, d_x, d_y );
wxRect rect; // printf( "rect %d %d %d %d\n", rect.x, rect.y, rect.width, rect.height );
if (dx < 0) rect.x = cw+dx; else rect.x = 0;
if (dy < 0) rect.y = ch+dy; else rect.y = 0;
if (dy != 0) rect.width = cw; else rect.width = abs(dx);
if (dx != 0) rect.height = ch; else rect.height = abs(dy);
m_updateRegion.Union( rect ); m_updateRegion.Union( rect );
m_clearRegion.Union( rect ); m_clearRegion.Union( rect );