Fix issue 57: Missing refresh in the cross points for the 4-point splines.

Also fixed the display of the bottom-right corner of the spline itself.
Grad rectangle: The vector line is now drawn as XOR: dragging it no longer erases the screen.
SFont.c: Only removed TAB characters in source.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@418 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud
2008-12-26 19:38:21 +00:00
parent c55c27bd85
commit df33261b59
3 changed files with 51 additions and 54 deletions

66
SFont.c
View File

@@ -74,7 +74,7 @@ SFont_Font* SFont_InitFont(SDL_Surface* Surface)
Uint32 pink;
if (Surface == NULL)
return NULL;
return NULL;
Font = (SFont_Font *) malloc(sizeof(SFont_Font));
Font->Surface = Surface;
@@ -83,13 +83,13 @@ SFont_Font* SFont_InitFont(SDL_Surface* Surface)
pink = SDL_MapRGB(Surface->format, 255, 0, 255);
while (x < Surface->w) {
if (GetPixel(Surface, x, 0) == pink) {
Font->CharPos[i++]=x;
while((x < Surface->w) && (GetPixel(Surface, x, 0)== pink))
x++;
Font->CharPos[i++]=x;
}
x++;
if (GetPixel(Surface, x, 0) == pink) {
Font->CharPos[i++]=x;
while((x < Surface->w) && (GetPixel(Surface, x, 0)== pink))
x++;
Font->CharPos[i++]=x;
}
x++;
}
Font->MaxPos = x-1;
@@ -107,14 +107,14 @@ void SFont_FreeFont(SFont_Font* FontInfo)
}
void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font,
int x, int y, const char *text)
int x, int y, const char *text)
{
const char* c;
int charoffset;
SDL_Rect srcrect, dstrect;
if(text == NULL)
return;
return;
// these values won't change in the loop
srcrect.y = 1;
@@ -122,23 +122,23 @@ void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font,
srcrect.h = dstrect.h = Font->Surface->h - 1;
for(c = text; *c != '\0' && x <= Surface->w ; c++) {
charoffset = ((int) (*c - 33)) * 2 + 1;
// skip spaces and nonprintable characters
if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
x += Font->CharPos[2]-Font->CharPos[1];
continue;
}
charoffset = ((int) (*c - 33)) * 2 + 1;
// skip spaces and nonprintable characters
if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
x += Font->CharPos[2]-Font->CharPos[1];
continue;
}
srcrect.w = dstrect.w =
(Font->CharPos[charoffset+2] + Font->CharPos[charoffset+1])/2 -
(Font->CharPos[charoffset] + Font->CharPos[charoffset-1])/2;
srcrect.x = (Font->CharPos[charoffset]+Font->CharPos[charoffset-1])/2;
dstrect.x = x - (float)(Font->CharPos[charoffset]
- Font->CharPos[charoffset-1])/2;
srcrect.w = dstrect.w =
(Font->CharPos[charoffset+2] + Font->CharPos[charoffset+1])/2 -
(Font->CharPos[charoffset] + Font->CharPos[charoffset-1])/2;
srcrect.x = (Font->CharPos[charoffset]+Font->CharPos[charoffset-1])/2;
dstrect.x = x - (float)(Font->CharPos[charoffset]
- Font->CharPos[charoffset-1])/2;
SDL_BlitSurface(Font->Surface, &srcrect, Surface, &dstrect);
SDL_BlitSurface(Font->Surface, &srcrect, Surface, &dstrect);
x += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
x += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
}
}
@@ -149,17 +149,17 @@ int SFont_TextWidth(const SFont_Font *Font, const char *text)
int width = 0;
if(text == NULL)
return 0;
return 0;
for(c = text; *c != '\0'; c++) {
charoffset = ((int) *c - 33) * 2 + 1;
// skip spaces and nonprintable characters
charoffset = ((int) *c - 33) * 2 + 1;
// skip spaces and nonprintable characters
if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
width += Font->CharPos[2]-Font->CharPos[1];
continue;
}
width += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
continue;
}
width += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
}
return width;
@@ -171,9 +171,9 @@ int SFont_TextHeight(const SFont_Font* Font)
}
void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font *Font,
int y, const char *text)
int y, const char *text)
{
SFont_Write(Surface, Font, Surface->w/2 - SFont_TextWidth(Font, text)/2,
y, text);
y, text);
}