From: Ton v. O. <tvo...@us...> - 2007-07-29 01:31:22
|
Update of /cvsroot/easycalc/easycalc In directory sc8-pr-cvs17:/tmp/cvs-serv6707 Modified Files: graph.c grtaps.c grtaps.h Log Message: Change drawing of axes labels: y-axis labels are drawn to the right of the y-axis, but clipped by the graph gadget. x-axis labels are drawn just below the x-axis, but clipped by the graph gadget. Also the labels do not interfere with the tracking information. Index: graph.c =================================================================== RCS file: /cvsroot/easycalc/easycalc/graph.c,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** graph.c 26 May 2007 14:52:10 -0000 1.58 --- graph.c 29 Jul 2007 01:31:18 -0000 1.59 *************** *** 472,476 **** for (tmpy=ystart;tmpy < graphPrefs.ymax;tmpy+=yscale) { y = graph_ygr2scr(tmpy); ! clie_drawline(x,y,x,y); } } --- 472,483 ---- for (tmpy=ystart;tmpy < graphPrefs.ymax;tmpy+=yscale) { y = graph_ygr2scr(tmpy); ! if (gHrMode != hrNone) { ! /* Draw crosses in hi res ... */ ! clie_drawline(x,y-1,x,y+1); ! clie_drawline(x-1,y,x+1,y); ! } ! else ! /* otherwise just dots */ ! clie_drawline(x,y,x,y); } } *************** *** 487,491 **** RectangleType natbounds; // bounds in native coordinates RectangleType clip; // clip rectangle in standard coordinates ! Coord x, y; #ifdef SUPPORT_DIA Coord dx, dy; --- 494,498 ---- RectangleType natbounds; // bounds in native coordinates RectangleType clip; // clip rectangle in standard coordinates ! Coord x, y, xstd, ystd; #ifdef SUPPORT_DIA Coord dx, dy; *************** *** 518,564 **** graph_setcolor(-1); clie_eraserectangle(&natbounds,0); if (graphPrefs.grEnable[6]) { /* axes drawing enabled */ /* y axis */ - x = graph_xgr2scr(0.0); if (x>ScrPrefs.xmin && x<ScrPrefs.xmax) clie_drawline(x,ScrPrefs.ymax,x,ScrPrefs.ymin); /* x axis */ - y = graph_ygr2scr(0.0); if (y>ScrPrefs.ymax && y<ScrPrefs.ymin) clie_drawline(ScrPrefs.xmin,y,ScrPrefs.xmax,y); } graph_unsetcolor(); /* Draw axes labels */ if (graphPrefs.grEnable[6] && graphPrefs.grEnable[8]) { /* axes and labels enabled */ ! Coord dy1 = HanderaCoord(-11); ! Coord dy2 = HanderaCoord(-1); ! Coord dy3 = HanderaCoord(-10); ! Coord dy4 = HanderaCoord(-1); ! grtaps_print_val("ymin:",graphPrefs.ymin, ! stdbounds.topLeft.x + stdbounds.extent.x/2, ! stdbounds.topLeft.y + stdbounds.extent.y + dy1, ! align_center); ! grtaps_print_val("ymax:",graphPrefs.ymax, ! stdbounds.topLeft.x + stdbounds.extent.x/2, ! stdbounds.topLeft.y + dy2, align_center); ! grtaps_print_val("xmin:",graphPrefs.xmin, stdbounds.topLeft.x, ! stdbounds.topLeft.y + stdbounds.extent.y/2 + dy3, align_left); ! grtaps_print_val("xmax:",graphPrefs.xmax, stdbounds.topLeft.x + stdbounds.extent.x, - stdbounds.topLeft.y + stdbounds.extent.y/2 + dy4, align_right); } - - /* Only (re)draw grid when whole graph gadget is inside the - clip rectangle */ - WinGetClip(&clip); - if (graphPrefs.grEnable[7] /* grid drawing enabled */ && - clip.topLeft.y <= stdbounds.topLeft.y && - clip.topLeft.y + clip.extent.y >= stdbounds.topLeft.y + stdbounds.extent.y) - graph_grid(&natbounds); } --- 525,598 ---- graph_setcolor(-1); clie_eraserectangle(&natbounds,0); + + /* Only (re)draw grid when whole graph gadget is inside the + clip rectangle */ + WinGetClip(&clip); + if (graphPrefs.grEnable[7] /* grid drawing enabled */ && + clip.topLeft.y <= stdbounds.topLeft.y && + clip.topLeft.y + clip.extent.y >= stdbounds.topLeft.y + stdbounds.extent.y) + graph_grid(&natbounds); + + /* Draw axes */ + x = graph_xgr2scr(0.0); + y = graph_ygr2scr(0.0); if (graphPrefs.grEnable[6]) { /* axes drawing enabled */ /* y axis */ if (x>ScrPrefs.xmin && x<ScrPrefs.xmax) clie_drawline(x,ScrPrefs.ymax,x,ScrPrefs.ymin); /* x axis */ if (y>ScrPrefs.ymax && y<ScrPrefs.ymin) clie_drawline(ScrPrefs.xmin,y,ScrPrefs.xmax,y); } + graph_unsetcolor(); /* Draw axes labels */ + if (gHrMode == hrPalm) { + UInt16 save = WinSetCoordinateSystem(kCoordinatesNative); + xstd = WinUnscaleCoord(x, true); + ystd = WinUnscaleCoord(y, true); + WinSetCoordinateSystem(save); + } + else { + xstd = x / gSonyFactor; + ystd = y / gSonyFactor; + } if (graphPrefs.grEnable[6] && graphPrefs.grEnable[8]) { /* axes and labels enabled */ ! Coord dy1 = HanderaCoord(1); ! Coord dy10 = HanderaCoord(10); ! Coord dy15 = HanderaCoord(15); ! Coord dy26 = HanderaCoord(26); ! grtaps_print_val("y>",graphPrefs.ymin, ! xstd + 1, ! stdbounds.topLeft.y + stdbounds.extent.y - dy10, stdbounds.topLeft.x, ! stdbounds.topLeft.x + stdbounds.extent.x, align_left); ! grtaps_print_val("y<",graphPrefs.ymax, ! xstd + 1, ! stdbounds.topLeft.y - dy1, ! stdbounds.topLeft.x, ! stdbounds.topLeft.x + stdbounds.extent.x, ! align_left); ! ystd -= dy1; ! if (ystd < stdbounds.topLeft.y + dy15) ! ystd = stdbounds.topLeft.y + dy15; ! if (ystd > stdbounds.topLeft.y + stdbounds.extent.y - dy26) ! ystd = stdbounds.topLeft.y + stdbounds.extent.y - dy26; ! grtaps_print_val("x>",graphPrefs.xmin, ! stdbounds.topLeft.x + dy1, ! ystd, ! stdbounds.topLeft.x, ! stdbounds.topLeft.x + stdbounds.extent.x, ! align_left); ! grtaps_print_val("x<",graphPrefs.xmax, ! stdbounds.topLeft.x + stdbounds.extent.x, ! ystd, ! stdbounds.topLeft.x, stdbounds.topLeft.x + stdbounds.extent.x, align_right); } } Index: grtaps.c =================================================================== RCS file: /cvsroot/easycalc/easycalc/grtaps.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** grtaps.c 10 Nov 2006 04:12:56 -0000 1.30 --- grtaps.c 29 Jul 2007 01:31:18 -0000 1.31 *************** *** 377,380 **** --- 377,381 ---- * value - number to be drawn * x,y - coordinates + * xmin,xmax - keep text between xmin and xmax * align - alignment w.r.t. coordinates * *************** *** 383,391 **** ***********************************************************************/ void ! grtaps_print_val(char *name, double value, Coord x, Coord y, Ttxtalign align) { char text[MAX_FP_NUMBER+10]; TdispPrefs oldprefs; Char *numtxt; #ifdef SUPPORT_DIA --- 384,394 ---- ***********************************************************************/ void ! grtaps_print_val(char *name, double value, Coord x, Coord y, Coord xmin, Coord xmax, ! Ttxtalign align) { char text[MAX_FP_NUMBER+10]; TdispPrefs oldprefs; Char *numtxt; + Coord txtwidth; #ifdef SUPPORT_DIA *************** *** 399,408 **** if (finite(value)) { fp_print_double(numtxt, value); if (align == align_center) { ! x -= FntCharsWidth(text, StrLen(text)) / 2; } else if (align == align_right) { ! x -= FntCharsWidth(text, StrLen(text)); } WinInvertChars(text, StrLen(text), x, y); } --- 402,416 ---- if (finite(value)) { fp_print_double(numtxt, value); + txtwidth = FntCharsWidth(text, StrLen(text)); if (align == align_center) { ! x -= txtwidth / 2; } else if (align == align_right) { ! x -= txtwidth; } + if (x < xmin) + x = xmin; + if ((x + txtwidth) > xmax) + x = xmax - txtwidth; WinInvertChars(text, StrLen(text), x, y); } *************** *** 435,442 **** dy += HanderaCoord(7); grtaps_print_val("r:", r, bounds->topLeft.x + dx1, ! bounds->topLeft.y + bounds->extent.y - dy, align_left); grtaps_print_val("fi:", angle, bounds->topLeft.x + bounds->extent.x, ! bounds->topLeft.y + bounds->extent.y - dy, align_right); } --- 443,456 ---- dy += HanderaCoord(7); grtaps_print_val("r:", r, bounds->topLeft.x + dx1, ! bounds->topLeft.y + bounds->extent.y - dy, ! bounds->topLeft.x, ! bounds->topLeft.x + bounds->extent.x, ! align_left); grtaps_print_val("fi:", angle, bounds->topLeft.x + bounds->extent.x, ! bounds->topLeft.y + bounds->extent.y - dy, ! bounds->topLeft.x, ! bounds->topLeft.x + bounds->extent.x, ! align_right); } *************** *** 451,455 **** dy += HanderaCoord(7); grtaps_print_val("T:", t, bounds->topLeft.x + dx1, ! bounds->topLeft.y + bounds->extent.y - dy, align_left); } --- 465,472 ---- dy += HanderaCoord(7); grtaps_print_val("T:", t, bounds->topLeft.x + dx1, ! bounds->topLeft.y + bounds->extent.y - dy, ! bounds->topLeft.x, ! bounds->topLeft.x + bounds->extent.x, ! align_left); } *************** *** 466,473 **** if (graphPrefs.grEnable[8]) y += dy7; ! grtaps_print_val("x:", realx, bounds->topLeft.x + dx1, y, align_left); ! grtaps_print_val("y:", realy, bounds->topLeft.x + bounds->extent.x, ! y, align_right); } --- 483,495 ---- if (graphPrefs.grEnable[8]) y += dy7; ! grtaps_print_val("x:", realx, bounds->topLeft.x + dx1, y, ! bounds->topLeft.x, ! bounds->topLeft.x + bounds->extent.x, ! align_left); ! grtaps_print_val("y:", realy, bounds->topLeft.x + bounds->extent.x, y, ! bounds->topLeft.x, ! bounds->topLeft.x + bounds->extent.x, ! align_right); } Index: grtaps.h =================================================================== RCS file: /cvsroot/easycalc/easycalc/grtaps.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** grtaps.h 10 Nov 2006 04:12:56 -0000 1.7 --- grtaps.h 29 Jul 2007 01:31:18 -0000 1.8 *************** *** 42,46 **** Boolean grtaps_track_but(void) GRAPH; void grtaps_print_val(char *name, double value, ! Coord x, Coord y, Ttxtalign align) GRAPH; void grtaps_track_manual(double value,TtrackAction action) GRAPH; void grtaps_track_pause(void) GRAPH; --- 42,46 ---- Boolean grtaps_track_but(void) GRAPH; void grtaps_print_val(char *name, double value, ! Coord x, Coord y, Coord xmin, Coord xmax, Ttxtalign align) GRAPH; void grtaps_track_manual(double value,TtrackAction action) GRAPH; void grtaps_track_pause(void) GRAPH; |