From: Arun Persaud Date: Mon, 28 May 2012 20:50:50 +0000 (-0700) Subject: bug #36229: changed PEN_* from define to enum X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=72f96a2581a9b7b0682e34cbf391d19d834c3d15;p=xboard.git bug #36229: changed PEN_* from define to enum This should allow better checks by the compiler --- diff --git a/evalgraph.c b/evalgraph.c index 55c4f97..c18d3d2 100644 --- a/evalgraph.c +++ b/evalgraph.c @@ -63,7 +63,7 @@ int MarginH = 4; // back-end static void -DrawLine (int x1, int y1, int x2, int y2, int penType) +DrawLine (int x1, int y1, int x2, int y2, enum PEN penType) { DrawSegment( x1, y1, NULL, NULL, PEN_NONE ); DrawSegment( x2, y2, NULL, NULL, penType ); @@ -71,7 +71,7 @@ DrawLine (int x1, int y1, int x2, int y2, int penType) // back-end static void -DrawLineEx (int x1, int y1, int x2, int y2, int penType) +DrawLineEx (int x1, int y1, int x2, int y2, enum PEN penType) { int savX, savY; DrawSegment( x1, y1, &savX, &savY, PEN_NONE ); @@ -245,7 +245,7 @@ DrawHistogramAsDiagram (int cy, int paint_width, int hist_count) /* Extend line up to current point */ if( currPvInfo[index].depth > 0 ) { - DrawSegment((int) x, GetValueY( GetPvScore(index) ), NULL, NULL, PEN_BOLD + side ); + DrawSegment((int) x, GetValueY( GetPvScore(index) ), NULL, NULL, (side==0 ? PEN_BOLDWHITE: PEN_BOLDBLACK) ); } index += 2; diff --git a/evalgraph.h b/evalgraph.h index 1d4de3d..ff85c03 100644 --- a/evalgraph.h +++ b/evalgraph.h @@ -21,17 +21,13 @@ * along with this program. If not, see http://www.gnu.org/licenses/. * * *------------------------------------------------------------------------ - ** See the file ChangeLog for a revision history. + ** See the file ChangeLog for a revision history. */ #define MIN_HIST_WIDTH 4 #define MAX_HIST_WIDTH 10 -#define PEN_NONE 0 -#define PEN_BLACK 1 -#define PEN_DOTTED 2 -#define PEN_BLUEDOTTED 3 -#define PEN_BOLD 4 /* or 5 for black */ +enum PEN { PEN_NONE, PEN_BLACK, PEN_DOTTED, PEN_BLUEDOTTED, PEN_BOLDWHITE, PEN_BOLDBLACK }; #define FILLED 1 #define OPEN 0 @@ -50,7 +46,7 @@ extern int MarginW; extern int MarginH; // calls from back-end part into front-end part -void DrawSegment( int x, int y, int *lastX, int *lastY, int penType ); +void DrawSegment( int x, int y, int *lastX, int *lastY, enum PEN ); void DrawRectangle( int left, int top, int right, int bottom, int side, int style ); void DrawEvalText(char *buf, int cbBuf, int y); diff --git a/winboard/wevalgraph.c b/winboard/wevalgraph.c index 1adf410..5a6ca62 100644 --- a/winboard/wevalgraph.c +++ b/winboard/wevalgraph.c @@ -123,11 +123,11 @@ static VOID DisplayEvalGraph( HWND hWnd, HDC hDC ) /* Create or recreate paint box if needed */ if( hbmPB == NULL || width != nWidthPB || height != nHeightPB ) { if( pens[PEN_DOTTED] == NULL ) { - pens[PEN_BLACK] = GetStockObject(BLACK_PEN); - pens[PEN_DOTTED] = CreatePen( PS_DOT, 0, RGB(0xA0,0xA0,0xA0) ); + pens[PEN_BLACK] = GetStockObject(BLACK_PEN); + pens[PEN_DOTTED] = CreatePen( PS_DOT, 0, RGB(0xA0,0xA0,0xA0) ); pens[PEN_BLUEDOTTED] = CreatePen( PS_DOT, 0, RGB(0x00,0x00,0xFF) ); - pens[PEN_BOLD] = CreatePen( PS_SOLID, 2, crWhite ); - pens[PEN_BOLD+1] = CreatePen( PS_SOLID, 2, crBlack ); + pens[PEN_BOLDWHITE] = CreatePen( PS_SOLID, 2, crWhite ); + pens[PEN_BOLDBLACK] = CreatePen( PS_SOLID, 2, crBlack ); hbrHist[0] = CreateBrush( BS_SOLID, crWhite ); hbrHist[1] = CreateBrush( BS_SOLID, crBlack ); hbrHist[2] = CreateBrush( BS_SOLID, GetSysColor( COLOR_3DFACE ) ); // background diff --git a/xevalgraph.c b/xevalgraph.c index 6430471..95e10c1 100644 --- a/xevalgraph.c +++ b/xevalgraph.c @@ -112,7 +112,7 @@ static GC hbrHist[3]; // [HGM] front-end, added as wrapper to avoid use of LineTo and MoveToEx in other routines (so they can be back-end) void -DrawSegment (int x, int y, int *lastX, int *lastY, int penType) +DrawSegment (int x, int y, int *lastX, int *lastY, enum PEN penType) { static int curX, curY; @@ -181,8 +181,8 @@ InitializeEvalGraph (Option *opt) pens[PEN_BLACK] = CreateGC(1, "black", "black", LineSolid); pens[PEN_DOTTED] = CreateGC(1, "#A0A0A0", "#A0A0A0", LineOnOffDash); pens[PEN_BLUEDOTTED] = CreateGC(1, "#0000FF", "#0000FF", LineOnOffDash); - pens[PEN_BOLD] = CreateGC(3, crWhite, crWhite, LineSolid); - pens[PEN_BOLD+1] = CreateGC(3, crBlack, crBlack, LineSolid); + pens[PEN_BOLDWHITE] = CreateGC(3, crWhite, crWhite, LineSolid); + pens[PEN_BOLDBLACK] = CreateGC(3, crBlack, crBlack, LineSolid); hbrHist[0] = CreateGC(3, crWhite, crWhite, LineSolid); hbrHist[1] = CreateGC(3, crBlack, crBlack, LineSolid); hbrHist[2] = CreateGC(3, "#E0E0F0", "#E0E0F0", LineSolid);; // background (a bit blueish, for contrst with yellow curve)