«*»= #include <Pilot.h> #include "callback.h"
#include <mathf.h> #include "mapper.h" #include "mapperRsc.h"
void Redraw(Boolean); static void RedrawGrid(); static void RedrawLocations(); static void RedrawConnections(); static void FitLabel(char *, RectanglePtr); static char *MyStrTok(char *,char); static void DrawLocation(Item *); static void DrawText(Item *); static void DrawCircle(int,int,int); static void FillCircle(int,int,int,CustomPatternType); static Boolean getpoint(int, int, CustomPatternType); static void UnsetPoint(WinPtr,int,int); static void SetPoint(WinPtr,int,int); void DrawLine(int,int,int,int,Word pattern);
extern Map *currentMap; extern int section; extern Section *currentSection;
extern Byte mode; extern int fontResize;
extern Prefs prefs; extern Boolean menuDisplayed;
CustomPatternType EmptyPattern=0,0,0,0; CustomPatternType DottedPattern=0x1111,0x2222,0x4444,0x8888;
Word Line0Pattern=0xffff; Word Line1Pattern=0xf0f0; Word Line2Pattern=0x7676; Word Line3Pattern=0xcccc;
static RectangleType screenRect= 0,0, 160,MAPAREAHEIGHT ;
#define RECTRADIUS 0
void Redraw(Boolean grid) RectangleType r; UInt i;
if(menuDisplayed) return;
r.topLeft.x=0; r.topLeft.y=0; r.extent.x=160; r.extent.y=MAPAREAHEIGHT;
WinSetClip(&r);
WinEraseRectangle(&r,0); if(grid) RedrawGrid(); for(i=0;i<currentSection->itemNum;i++) DrawText(¤tSection->items[i]); RedrawConnections(); RedrawLocations();
r.extent.y=160; WinSetClip(&r); @
At the resolution of the palm it makes no sense to draw arrow heads at arbitrary slopes, so the direction is rounded to 45 deg. «*»= void DrawArrowHead(int x0, int y0, int x1, int y1) int dx,dy;
dx=x1-x0; dy=y0-y1;
if(2*dy<dx && 2*dy>-dx) WinDrawLine(x1,y1,x1-3,y1); WinDrawLine(x1-1,y1-1,x1-3,y1-1); WinDrawLine(x1-1,y1+1,x1-3,y1+1); WinDrawLine(x1-3,y1-2,x1-3,y1-2); WinDrawLine(x1-3,y1+2,x1-3,y1+2); return;
if(2*dy<-dx && 2*dy>dx) WinDrawLine(x1,y1,x1+3,y1); WinDrawLine(x1+1,y1-1,x1+3,y1-1); WinDrawLine(x1+1,y1+1,x1+3,y1+1); WinDrawLine(x1+3,y1-2,x1+3,y1-2); WinDrawLine(x1+3,y1+2,x1+3,y1+2); return;
if(2*dx<-dy && 2*dx>dy) WinDrawLine(x1,y1,x1,y1-3); WinDrawLine(x1+1,y1-1,x1+1,y1-3); WinDrawLine(x1-1,y1-1,x1-1,y1-3); WinDrawLine(x1+2,y1-3,x1+2,y1-3); WinDrawLine(x1-2,y1-3,x1-2,y1-3); return;
if(2*dx<dy && 2*dx>-dy) WinDrawLine(x1,y1,x1,y1+3); WinDrawLine(x1+1,y1+1,x1+1,y1+3); WinDrawLine(x1-1,y1+1,x1-1,y1+3); WinDrawLine(x1+2,y1+3,x1+2,y1+3); WinDrawLine(x1-2,y1+3,x1-2,y1+3); return;
if(2*dx>dy && 2*dy>dx) WinDrawLine(x1,y1,x1-2,y1); WinDrawLine(x1,y1+1,x1-4,y1+1); WinDrawLine(x1,y1+2,x1-3,y1+2); WinDrawLine(x1-1,y1+3,x1-3,y1+3); WinDrawLine(x1-1,y1+4,x1-1,y1+4); return;
if(-2*dx>-dy && -2*dy>-dx) WinDrawLine(x1,y1,x1+2,y1); WinDrawLine(x1,y1-1,x1+4,y1-1); WinDrawLine(x1,y1-2,x1+3,y1-2); WinDrawLine(x1+1,y1-3,x1+3,y1-3); WinDrawLine(x1+1,y1-4,x1+1,y1-4); return;
if(2*dx<dy && -2*dx>dy) WinDrawLine(x1,y1,x1+2,y1); WinDrawLine(x1,y1+1,x1+4,y1+1); WinDrawLine(x1,y1+2,x1+3,y1+2); WinDrawLine(x1+1,y1+3,x1+3,y1+3); WinDrawLine(x1+1,y1+4,x1+1,y1+4); return;
if(-2*dy>dx && dx>2*dy) WinDrawLine(x1,y1,x1-2,y1); WinDrawLine(x1,y1-1,x1-4,y1-1); WinDrawLine(x1,y1-2,x1-3,y1-2); WinDrawLine(x1-1,y1-3,x1-3,y1-3); WinDrawLine(x1-1,y1-4,x1-1,y1-4);
#define VERTEXRECT 3 @