From: Ton v. O. <tvo...@us...> - 2006-09-13 13:18:08
|
Update of /cvsroot/easycalc/easycalc In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv9284 Modified Files: grtaps.c Log Message: Handle insufficient memory for offscreen window more gracefully when moving a plot in grtaps.c. Index: grtaps.c =================================================================== RCS file: /cvsroot/easycalc/easycalc/grtaps.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** grtaps.c 12 Sep 2006 19:40:55 -0000 1.24 --- grtaps.c 13 Sep 2006 13:17:57 -0000 1.25 *************** *** 141,146 **** { Boolean penDown,moved; ! Coord x,y; ! Coord oldx=-1,oldy=-1; WinHandle orgwindow; UInt16 err; --- 141,146 ---- { Boolean penDown,moved; ! Coord x,y,dx,dy; ! Coord oldx=begx,oldy=begy; WinHandle orgwindow; UInt16 err; *************** *** 151,160 **** orgwindow = clie_createoffscreenwindow(bounds->extent.x,bounds->extent.y, nativeFormat,&err); ! ErrFatalDisplayIf(err,"Error while creating tmp window."); ! clie_copyrectangle(NULL,orgwindow,bounds,0,0,winPaint); clie_getclip(&rs); clie_setclip(bounds); orgbounds = *bounds; ! orgbounds.topLeft.x = orgbounds.topLeft.y = 0; graph_setcolor(-1); --- 151,163 ---- orgwindow = clie_createoffscreenwindow(bounds->extent.x,bounds->extent.y, nativeFormat,&err); ! /* Note: orgwindow may be NULL if there is insufficient memory for the ! offscreen window. Then we need to copy inside the screen window */ ! if (orgwindow) ! clie_copyrectangle(NULL,orgwindow,bounds,0,0,winPaint); clie_getclip(&rs); clie_setclip(bounds); orgbounds = *bounds; ! if (orgwindow) ! orgbounds.topLeft.x = orgbounds.topLeft.y = 0; graph_setcolor(-1); *************** *** 172,179 **** } if ((oldx!=x || oldy!=y) && RctPtInRectangle(x,y,bounds)) { clie_copyrectangle(orgwindow,NULL,&orgbounds, ! bounds->topLeft.x + (x-begx), ! bounds->topLeft.y + (y-begy),winPaint); ! grtaps_clear_edges(x-begx,y-begy,bounds); oldx=x;oldy=y; } --- 175,184 ---- } if ((oldx!=x || oldy!=y) && RctPtInRectangle(x,y,bounds)) { + dx = (orgwindow ? x-begx : x-oldx); + dy = (orgwindow ? y-begy : y-oldy); clie_copyrectangle(orgwindow,NULL,&orgbounds, ! bounds->topLeft.x + dx, ! bounds->topLeft.y + dy,winPaint); ! grtaps_clear_edges(dx,dy,bounds); oldx=x;oldy=y; } *************** *** 185,194 **** xmin = graph_xscr2gr((bounds->topLeft.x)-(x-begx)); ymin = graph_yscr2gr((bounds->topLeft.y+bounds->extent.y-1)-(y-begy)); ! if (!RctPtInRectangle(x,y,bounds) \ ! || (graphPrefs.logx && xmin <= 0.0) \ || (graphPrefs.logy && ymin <= 0.0)) { ! clie_copyrectangle(orgwindow,NULL,&orgbounds,bounds->topLeft.x, bounds->topLeft.y,winPaint); ! moved = false; } else { --- 190,206 ---- xmin = graph_xscr2gr((bounds->topLeft.x)-(x-begx)); ymin = graph_yscr2gr((bounds->topLeft.y+bounds->extent.y-1)-(y-begy)); ! if (!RctPtInRectangle(x,y,bounds) ! || (graphPrefs.logx && xmin <= 0.0) || (graphPrefs.logy && ymin <= 0.0)) { ! /* Restore original plot from offscreen window if possible, ! otherwise force a redraw by setting moved to true */ ! if (orgwindow) { ! clie_copyrectangle(orgwindow,NULL,&orgbounds,bounds->topLeft.x, bounds->topLeft.y,winPaint); ! moved = false; ! } ! else { ! moved = true; ! } } else { *************** *** 201,205 **** clie_setclip(&rs); ! WinDeleteWindow(orgwindow,false); return moved; --- 213,218 ---- clie_setclip(&rs); ! if (orgwindow) ! WinDeleteWindow(orgwindow,false); return moved; |