Ran source code through "indent -nbfda -npcs -npsl -bli0".
This commit is contained in:
parent
51355bce43
commit
7716a05281
38 changed files with 10816 additions and 10710 deletions
|
|
@ -9,7 +9,7 @@ http://www.newbreedsoftware.com/tuxpaint/
|
|||
$Id$
|
||||
|
||||
|
||||
2006.August.26 (0.9.16)
|
||||
2006.August.27 (0.9.16)
|
||||
* Interface improvements:
|
||||
-----------------------
|
||||
* Modified "Text" tool so that it correctly handles the 16-bit unicode
|
||||
|
|
@ -143,6 +143,8 @@ $Id$
|
|||
|
||||
* Compiling, porting and packaging updates:
|
||||
-----------------------------------------
|
||||
* Ran source code through "indent -nbfda -npcs -npsl -bli0".
|
||||
|
||||
* "DESTDIR" patch is no longer needed.
|
||||
TOYAMA Shin-ichi <shin1@wmail.plala.or.jp>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,21 +23,21 @@
|
|||
/* Jan. 17, 2003 */
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
#ifndef __BEOS_PRINT_H__
|
||||
#define __BEOS_PRINT_H__
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern "C"
|
||||
{
|
||||
|
||||
#endif /*
*/
|
||||
extern int SurfacePrint(SDL_Surface * surf);
|
||||
extern int IsPrinterAvailable();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*
*/
|
||||
|
||||
#endif
|
||||
#endif /*
*/
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
/* What colors are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
COLOR_BLACK,
|
||||
COLOR_DARKGREY,
|
||||
COLOR_LIGHTGREY,
|
||||
|
|
|
|||
|
|
@ -150,4 +150,3 @@
|
|||
#undef CLOCK_ASM
|
||||
#define CLOCK_ASM(x) x=42
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
#define DEBUG
|
||||
|
||||
//#define DEBUG
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@
|
|||
|
||||
///////////////// directory walking callers and callbacks //////////////////
|
||||
|
||||
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned i)
|
||||
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||
unsigned dirlen, tp_ftw_str * files, unsigned i)
|
||||
{
|
||||
dirlen = dirlen;
|
||||
|
||||
|
|
@ -37,7 +38,8 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, uns
|
|||
if (cp)
|
||||
{
|
||||
// need gcc 3.4 for the restrict in this location
|
||||
const char * /*restrict*/ const suffixes[] = {"ttc", "dfont", "pfa", "pfb", "otf", "ttf",};
|
||||
const char * /*restrict */ const suffixes[] =
|
||||
{ "ttc", "dfont", "pfa", "pfb", "otf", "ttf", };
|
||||
int j = sizeof suffixes / sizeof suffixes[0];
|
||||
while (j--)
|
||||
{
|
||||
|
|
@ -74,7 +76,8 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, uns
|
|||
#ifdef DEBUG
|
||||
int numfaces = TTF_FontFaces(font);
|
||||
if (numfaces != 1)
|
||||
printf("Found %d faces in %s, %s, %s\n", numfaces, files[i].str, family, style);
|
||||
printf("Found %d faces in %s, %s, %s\n", numfaces, files[i].str,
|
||||
family, style);
|
||||
#endif
|
||||
|
||||
// First, the blacklist. We list font families that can crash Tux Paint
|
||||
|
|
@ -88,23 +91,19 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, uns
|
|||
// translated. Otherwise, only Line X should be translated and the
|
||||
// ASCII-only fonts should be given bad scores in the scoring code below.
|
||||
// (the best scores going to fonts that support both)
|
||||
if
|
||||
(
|
||||
strcmp("Zapfino",family) && strcmp("Elvish Ring NFI",family)
|
||||
&&
|
||||
(
|
||||
(charset_works(font, gettext("qx")) && charset_works(font, gettext("QX"))) // Line X
|
||||
||
|
||||
(charset_works(font, gettext("qy")) && charset_works(font, gettext("QY"))) // Line Y
|
||||
)
|
||||
)
|
||||
if (strcmp("Zapfino", family) && strcmp("Elvish Ring NFI", family) && ((charset_works(font, gettext("qx")) && charset_works(font, gettext("QX"))) // Line X
|
||||
|| (charset_works(font, gettext("qy")) && charset_works(font, gettext("QY"))) // Line Y
|
||||
))
|
||||
{
|
||||
if (num_font_styles == num_font_styles_max)
|
||||
{
|
||||
num_font_styles_max = num_font_styles_max * 5 / 4 + 30;
|
||||
user_font_styles = realloc(user_font_styles, num_font_styles_max * sizeof *user_font_styles);
|
||||
user_font_styles =
|
||||
realloc(user_font_styles,
|
||||
num_font_styles_max * sizeof *user_font_styles);
|
||||
}
|
||||
user_font_styles[num_font_styles] = malloc(sizeof *user_font_styles[num_font_styles]);
|
||||
user_font_styles[num_font_styles] =
|
||||
malloc(sizeof *user_font_styles[num_font_styles]);
|
||||
user_font_styles[num_font_styles]->directory = strdup(dir);
|
||||
user_font_styles[num_font_styles]->filename = files[i].str; // steal it (mark NULL below)
|
||||
user_font_styles[num_font_styles]->family = strdup(family);
|
||||
|
|
@ -127,7 +126,8 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, uns
|
|||
{
|
||||
#if 0
|
||||
// THREADED_FONTS
|
||||
printf("Font is too defective: %s, %s, %s\n", files[i].str, family, style);
|
||||
printf("Font is too defective: %s, %s, %s\n", files[i].str, family,
|
||||
style);
|
||||
#endif
|
||||
}
|
||||
TTF_CloseFont(font);
|
||||
|
|
@ -154,9 +154,11 @@ int compare_ftw_str(const void *v1, const void *v2)
|
|||
return -strcmp(s1, s2);
|
||||
}
|
||||
|
||||
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen, int rsrc,
|
||||
void (*fn)(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned count)
|
||||
)
|
||||
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen,
|
||||
int rsrc, void (*fn) (SDL_Surface * screen,
|
||||
const char *restrict const dir,
|
||||
unsigned dirlen, tp_ftw_str * files,
|
||||
unsigned count))
|
||||
{
|
||||
DIR *d;
|
||||
unsigned num_file_names = 0;
|
||||
|
|
@ -289,11 +291,11 @@ void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen, int
|
|||
qsort(dir_names, num_dir_names, sizeof *dir_names, compare_ftw_str);
|
||||
while (num_dir_names--)
|
||||
{
|
||||
memcpy(dir+dirlen, dir_names[num_dir_names].str, dir_names[num_dir_names].len+1);
|
||||
memcpy(dir + dirlen, dir_names[num_dir_names].str,
|
||||
dir_names[num_dir_names].len + 1);
|
||||
tp_ftw(screen, dir, dirlen + dir_names[num_dir_names].len, rsrc, fn);
|
||||
free(dir_names[num_dir_names].str);
|
||||
}
|
||||
free(dir_names);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,17 +17,21 @@
|
|||
|
||||
#define TP_FTW_PATHSIZE 400
|
||||
|
||||
typedef struct tp_ftw_str {
|
||||
typedef struct tp_ftw_str
|
||||
{
|
||||
char *str;
|
||||
unsigned char len;
|
||||
// unsigned char is_rsrc;
|
||||
} tp_ftw_str;
|
||||
|
||||
|
||||
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned i);
|
||||
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||
unsigned dirlen, tp_ftw_str * files, unsigned i);
|
||||
int compare_ftw_str(const void *v1, const void *v2);
|
||||
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen, int rsrc,
|
||||
void (*fn)(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned count));
|
||||
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen,
|
||||
int rsrc, void (*fn) (SDL_Surface * screen,
|
||||
const char *restrict const dir,
|
||||
unsigned dirlen, tp_ftw_str * files,
|
||||
unsigned count));
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ static int colors_close(SDL_Surface * canvas, Uint32 c1, Uint32 c2)
|
|||
#ifdef LOW_QUALITY_FLOOD_FILL
|
||||
return (c1 == c2);
|
||||
#else
|
||||
Uint8 r1, g1, b1,
|
||||
r2, g2, b2;
|
||||
Uint8 r1, g1, b1, r2, g2, b2;
|
||||
|
||||
if (c1 == c2)
|
||||
{
|
||||
|
|
@ -80,16 +79,18 @@ static int colors_close(SDL_Surface * canvas, Uint32 c1, Uint32 c2)
|
|||
|
||||
/* Flood fill! */
|
||||
|
||||
void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr)
|
||||
void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y,
|
||||
Uint32 cur_colr, Uint32 old_colr)
|
||||
{
|
||||
int fillL, fillR, i, in_line;
|
||||
static unsigned char prog_anim;
|
||||
Uint32 (*getpixel)(SDL_Surface *, int, int) = getpixels[canvas->format->BytesPerPixel];
|
||||
void (*putpixel)(SDL_Surface *, int, int, Uint32) = putpixels[canvas->format->BytesPerPixel];
|
||||
Uint32(*getpixel) (SDL_Surface *, int, int) =
|
||||
getpixels[canvas->format->BytesPerPixel];
|
||||
void (*putpixel) (SDL_Surface *, int, int, Uint32) =
|
||||
putpixels[canvas->format->BytesPerPixel];
|
||||
|
||||
|
||||
if (cur_colr == old_colr ||
|
||||
colors_close(canvas, cur_colr, old_colr))
|
||||
if (cur_colr == old_colr || colors_close(canvas, cur_colr, old_colr))
|
||||
return;
|
||||
|
||||
|
||||
|
|
@ -113,7 +114,8 @@ void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uin
|
|||
putpixel(canvas, fillL, y, cur_colr);
|
||||
fillL--;
|
||||
|
||||
in_line = (fillL < 0) ? 0 : colors_close(canvas, getpixel(canvas, fillL, y),
|
||||
in_line =
|
||||
(fillL < 0) ? 0 : colors_close(canvas, getpixel(canvas, fillL, y),
|
||||
old_colr);
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +131,8 @@ void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uin
|
|||
fillR++;
|
||||
|
||||
in_line = (fillR >= canvas->w) ? 0 : colors_close(canvas, getpixel(canvas,
|
||||
fillR, y),
|
||||
fillR,
|
||||
y),
|
||||
old_colr);
|
||||
}
|
||||
|
||||
|
|
@ -143,8 +146,8 @@ void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uin
|
|||
if (y > 0 && colors_close(canvas, getpixel(canvas, i, y - 1), old_colr))
|
||||
do_flood_fill(screen, canvas, i, y - 1, cur_colr, old_colr);
|
||||
|
||||
if (y < canvas->h && colors_close(canvas, getpixel(canvas, i, y + 1), old_colr))
|
||||
if (y < canvas->h
|
||||
&& colors_close(canvas, getpixel(canvas, i, y + 1), old_colr))
|
||||
do_flood_fill(screen, canvas, i, y + 1, cur_colr, old_colr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "SDL.h"
|
||||
|
||||
void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr);
|
||||
void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y,
|
||||
Uint32 cur_colr, Uint32 old_colr);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
85
src/fonts.c
85
src/fonts.c
|
|
@ -84,7 +84,8 @@ TTF_Font *BUGFIX_TTF_OpenFont206(const char * const file, int ptsize)
|
|||
printf("Loading font: %s\n", file);
|
||||
#endif
|
||||
|
||||
if ((fp = fopen(file, "rb")) == NULL) return NULL;
|
||||
if ((fp = fopen(file, "rb")) == NULL)
|
||||
return NULL;
|
||||
fclose(fp);
|
||||
|
||||
#undef TTF_OpenFont
|
||||
|
|
@ -105,8 +106,7 @@ TTF_Font *try_alternate_font(int size)
|
|||
if ((p = strrchr(prefix, '_')) != NULL)
|
||||
{
|
||||
*p = 0;
|
||||
snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf",
|
||||
DATA_PREFIX, prefix);
|
||||
snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf", DATA_PREFIX, prefix);
|
||||
|
||||
return TTF_OpenFont(str, size);
|
||||
}
|
||||
|
|
@ -169,7 +169,9 @@ void reliable_write(int fd, const void *buf, size_t count)
|
|||
case EAGAIN:
|
||||
case ENOSPC:
|
||||
; // satisfy a C syntax abomination
|
||||
p = (struct pollfd){fd, POLLOUT, 0};
|
||||
p = (struct pollfd)
|
||||
{
|
||||
fd, POLLOUT, 0};
|
||||
poll(&p, 1, -1); // try not to burn CPU time
|
||||
// FALL THROUGH
|
||||
case EINTR:
|
||||
|
|
@ -178,7 +180,8 @@ void reliable_write(int fd, const void *buf, size_t count)
|
|||
}
|
||||
buf += rc;
|
||||
count -= rc;
|
||||
} while(count);
|
||||
}
|
||||
while (count);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -196,7 +199,9 @@ void reliable_read(int fd, void *buf, size_t count)
|
|||
return;
|
||||
case EAGAIN:
|
||||
; // satisfy a C syntax abomination
|
||||
p = (struct pollfd){fd, POLLIN, 0};
|
||||
p = (struct pollfd)
|
||||
{
|
||||
fd, POLLIN, 0};
|
||||
poll(&p, 1, -1); // try not to burn CPU time
|
||||
// FALL THROUGH
|
||||
case EINTR:
|
||||
|
|
@ -207,7 +212,8 @@ void reliable_read(int fd, void *buf, size_t count)
|
|||
break; // EOF. Better not happen before the end!
|
||||
buf += rc;
|
||||
count -= rc;
|
||||
} while(count);
|
||||
}
|
||||
while (count);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -245,17 +251,23 @@ void run_font_scanner(SDL_Surface * screen)
|
|||
{
|
||||
char *s;
|
||||
s = user_font_families[i]->directory;
|
||||
if(s) size += strlen(s);
|
||||
if (s)
|
||||
size += strlen(s);
|
||||
s = user_font_families[i]->family;
|
||||
if(s) size += strlen(s);
|
||||
if (s)
|
||||
size += strlen(s);
|
||||
s = user_font_families[i]->filename[0];
|
||||
if(s) size += strlen(s);
|
||||
if (s)
|
||||
size += strlen(s);
|
||||
s = user_font_families[i]->filename[1];
|
||||
if(s) size += strlen(s);
|
||||
if (s)
|
||||
size += strlen(s);
|
||||
s = user_font_families[i]->filename[2];
|
||||
if(s) size += strlen(s);
|
||||
if (s)
|
||||
size += strlen(s);
|
||||
s = user_font_families[i]->filename[3];
|
||||
if(s) size += strlen(s);
|
||||
if (s)
|
||||
size += strlen(s);
|
||||
size += 6; // for '\0' on each of the above
|
||||
}
|
||||
size += 2; // for 2-byte font count
|
||||
|
|
@ -353,7 +365,8 @@ void receive_some_font_info(SDL_Surface * screen)
|
|||
}
|
||||
rc = read(font_socket_fd, buf + buf_fill, buf_size - buf_fill);
|
||||
#ifdef DEBUG
|
||||
printf("read: fd=%d buf_fill=%u buf_size=%u rc=%ld\n", font_socket_fd, buf_fill, buf_size, rc);
|
||||
printf("read: fd=%d buf_fill=%u buf_size=%u rc=%ld\n", font_socket_fd,
|
||||
buf_fill, buf_size, rc);
|
||||
#endif
|
||||
|
||||
if (rc == -1)
|
||||
|
|
@ -364,7 +377,9 @@ printf("read: fd=%d buf_fill=%u buf_size=%u rc=%ld\n", font_socket_fd, buf_fill,
|
|||
return;
|
||||
case EAGAIN:
|
||||
; // satisfy a C syntax abomination
|
||||
p = (struct pollfd){font_socket_fd, POLLIN, 0};
|
||||
p = (struct pollfd)
|
||||
{
|
||||
font_socket_fd, POLLIN, 0};
|
||||
show_progress_bar(screen);
|
||||
poll(&p, 1, 29); // try not to burn CPU time
|
||||
continue;
|
||||
|
|
@ -692,7 +707,8 @@ void parse_font_style(style_info *si)
|
|||
si->boldness = 1;
|
||||
|
||||
// we'll count both TrueType and OpenType
|
||||
si->truetype = !!strcasestr(si->filename,".ttf") || !!strcasestr(si->filename,".otf");
|
||||
si->truetype = !!strcasestr(si->filename, ".ttf")
|
||||
|| !!strcasestr(si->filename, ".otf");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -758,7 +774,8 @@ printf(" %s\n", base[i]->style);
|
|||
boldmid = boldcounts[boldmin + 1] ? boldmin + 1 : boldmin + 2;
|
||||
|
||||
i = 3;
|
||||
while(i--){
|
||||
while (i--)
|
||||
{
|
||||
if (base[i]->boldness == boldmin)
|
||||
zmin = base[i]->italic;
|
||||
if (base[i]->boldness == boldmid)
|
||||
|
|
@ -813,7 +830,9 @@ printf(" %s\n", base[i]->style);
|
|||
if (num_font_families == num_font_families_max)
|
||||
{
|
||||
num_font_families_max = num_font_families_max * 5 / 4 + 30;
|
||||
user_font_families = realloc(user_font_families, num_font_families_max * sizeof *user_font_families);
|
||||
user_font_families =
|
||||
realloc(user_font_families,
|
||||
num_font_families_max * sizeof *user_font_families);
|
||||
}
|
||||
|
||||
fi = calloc(1, sizeof *fi);
|
||||
|
|
@ -829,7 +848,8 @@ printf(" %s\n", base[i]->style);
|
|||
{
|
||||
#if 0
|
||||
// THREADED_FONTS
|
||||
printf("too many boldness levels, discarding: %s, %s\n", base[i]->family, base[i]->style);
|
||||
printf("too many boldness levels, discarding: %s, %s\n",
|
||||
base[i]->family, base[i]->style);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
|
@ -839,9 +859,11 @@ printf(" %s\n", base[i]->style);
|
|||
{
|
||||
#if 0
|
||||
// THREADED_FONTS
|
||||
printf("duplicates, discarding: %s, %s\n", base[i]->family, base[i]->style);
|
||||
printf("duplicates, discarding: %s, %s\n", base[i]->family,
|
||||
base[i]->style);
|
||||
printf("b %d, spot %d\n", b, spot);
|
||||
printf("occupancy %p %p %p %p\n", fi->filename[0], fi->filename[1], fi->filename[2], fi->filename[3]);
|
||||
printf("occupancy %p %p %p %p\n", fi->filename[0], fi->filename[1],
|
||||
fi->filename[2], fi->filename[3]);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
|
@ -901,7 +923,8 @@ void groupfonts(void)
|
|||
while (i--)
|
||||
parse_font_style(user_font_styles[i]);
|
||||
|
||||
qsort(user_font_styles, num_font_styles, sizeof user_font_styles[0], compar_fontgroup);
|
||||
qsort(user_font_styles, num_font_styles, sizeof user_font_styles[0],
|
||||
compar_fontgroup);
|
||||
//printf("groupfonts() qsort(user_font_styles...)\n");
|
||||
//fflush(stdout);
|
||||
|
||||
|
|
@ -933,7 +956,8 @@ void groupfonts(void)
|
|||
free(user_font_styles);
|
||||
user_font_styles = NULL; // just to catch bugs
|
||||
|
||||
qsort(user_font_families, num_font_families, sizeof user_font_families[0], compar_fontkiller);
|
||||
qsort(user_font_families, num_font_families, sizeof user_font_families[0],
|
||||
compar_fontkiller);
|
||||
//printf(stderr, "groupfonts() qsort(user_font_families 1...)\n");
|
||||
//fflush(stdout);
|
||||
low = 0;
|
||||
|
|
@ -946,13 +970,15 @@ void groupfonts(void)
|
|||
{
|
||||
if (++high >= num_font_families)
|
||||
break;
|
||||
if(strcmp(user_font_families[low]->family,user_font_families[high]->family))
|
||||
if (strcmp
|
||||
(user_font_families[low]->family, user_font_families[high]->family))
|
||||
break;
|
||||
}
|
||||
dupe_markdown_range(user_font_families + low, high - low);
|
||||
low = high;
|
||||
}
|
||||
qsort(user_font_families, num_font_families, sizeof user_font_families[0], compar_fontscore);
|
||||
qsort(user_font_families, num_font_families, sizeof user_font_families[0],
|
||||
compar_fontscore);
|
||||
//printf("groupfonts() qsort(user_font_families 2...)\n");
|
||||
//fflush(stdout);
|
||||
if (user_font_families[0]->score < 0)
|
||||
|
|
@ -961,7 +987,8 @@ void groupfonts(void)
|
|||
// THREADED_FONTS
|
||||
printf("Trim starting with %d families\n", num_font_families);
|
||||
#endif
|
||||
while(num_font_families>1 && user_font_families[num_font_families-1]->score < 0)
|
||||
while (num_font_families > 1
|
||||
&& user_font_families[num_font_families - 1]->score < 0)
|
||||
{
|
||||
i = --num_font_families;
|
||||
free(user_font_families[i]->directory);
|
||||
|
|
@ -1034,7 +1061,8 @@ void loadfonts(SDL_Surface * screen, const char * const dir)
|
|||
int was_bad_font;
|
||||
|
||||
// see if two font surfaces are the same
|
||||
int do_surfcmp(const SDL_Surface *const *const v1, const SDL_Surface *const *const v2)
|
||||
int do_surfcmp(const SDL_Surface * const *const v1,
|
||||
const SDL_Surface * const *const v2)
|
||||
{
|
||||
const SDL_Surface *const s1 = *v1;
|
||||
const SDL_Surface *const s2 = *v2;
|
||||
|
|
@ -1047,7 +1075,8 @@ int do_surfcmp(const SDL_Surface *const *const v1, const SDL_Surface *const *con
|
|||
printf("s1==s2?\n");
|
||||
return 0;
|
||||
}
|
||||
if(!s1 || !s2 || !s1->w || !s2->w || !s1->h || !s2->h || !s1->format || !s2->format)
|
||||
if (!s1 || !s2 || !s1->w || !s2->w || !s1->h || !s2->h || !s1->format
|
||||
|| !s2->format)
|
||||
{
|
||||
was_bad_font = 1;
|
||||
return 0;
|
||||
|
|
|
|||
15
src/fonts.h
15
src/fonts.h
|
|
@ -79,12 +79,15 @@ extern unsigned text_size;
|
|||
// commonly hinted sizes seem to be: 9, 10, 12, 14, 18, 20 (less so), 24
|
||||
// reasonable: 9,12,18... and 10,14,18...
|
||||
static int text_sizes[] = { 9, 12, 18, 24, 36, 48,
|
||||
56, 64, 96, 112, 128, 160}; // point sizes
|
||||
56, 64, 96, 112, 128, 160
|
||||
}; // point sizes
|
||||
|
||||
#define MIN_TEXT_SIZE 0u
|
||||
#define MAX_TEXT_SIZE (sizeof text_sizes / sizeof text_sizes[0] - 1)
|
||||
|
||||
// for sorting through the font files at startup
|
||||
typedef struct style_info {
|
||||
typedef struct style_info
|
||||
{
|
||||
char *filename;
|
||||
char *directory;
|
||||
char *family; // name like "FooCorp Thunderstruck"
|
||||
|
|
@ -96,7 +99,8 @@ typedef struct style_info {
|
|||
} style_info;
|
||||
|
||||
// user's notion of a font
|
||||
typedef struct family_info {
|
||||
typedef struct family_info
|
||||
{
|
||||
char *directory;
|
||||
char *family;
|
||||
char *filename[4];
|
||||
|
|
@ -125,10 +129,9 @@ void groupfonts(void);
|
|||
TTF_Font *getfonthandle(int desire);
|
||||
void loadfonts(SDL_Surface * screen, const char *const dir);
|
||||
|
||||
int do_surfcmp(const SDL_Surface *const *const v1, const SDL_Surface *const *const v2);
|
||||
int do_surfcmp(const SDL_Surface * const *const v1,
|
||||
const SDL_Surface * const *const v2);
|
||||
int surfcmp(const void *s1, const void *s2);
|
||||
int charset_works(TTF_Font * font, const char *s);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -96,4 +96,3 @@ char * get_fname(const char * const name)
|
|||
|
||||
return strdup(f);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,4 +11,3 @@ char * get_fname(const char * const name);
|
|||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
20
src/i18n.c
20
src/i18n.c
|
|
@ -347,9 +347,7 @@ void show_lang_usage(FILE * f, const char * const prg)
|
|||
{
|
||||
fprintf(f,
|
||||
"\n"
|
||||
"Usage: %s [--lang LANGUAGE]\n"
|
||||
"\n"
|
||||
"LANGUAGE may be one of:\n"
|
||||
"Usage: %s [--lang LANGUAGE]\n" "\n" "LANGUAGE may be one of:\n"
|
||||
/* C */ " english american-english\n"
|
||||
/* af */ " afrikaans\n"
|
||||
/* sq */ " albanian\n"
|
||||
|
|
@ -357,7 +355,8 @@ void show_lang_usage(FILE * f, const char * const prg)
|
|||
/* eu */ " basque euskara\n"
|
||||
/* be */ " belarusian bielaruskaja\n"
|
||||
/* nb */ " bokmal\n"
|
||||
/* pt_BR */ " brazilian brazilian-portuguese portugues-brazilian\n"
|
||||
/* pt_BR */
|
||||
" brazilian brazilian-portuguese portugues-brazilian\n"
|
||||
/* br */ " breton brezhoneg\n"
|
||||
/* en_GB */ " british british-english\n"
|
||||
/* bg_BG */ " bulgarian\n"
|
||||
|
|
@ -392,7 +391,8 @@ void show_lang_usage(FILE * f, const char * const prg)
|
|||
/* ku */ " kurdish\n"
|
||||
/* lt */ " lithuanian lietuviu\n"
|
||||
/* ms */ " malay\n"
|
||||
/* es_MX */ " mexican mexican-spanish espanol-mejicano\n"
|
||||
/* es_MX */
|
||||
" mexican mexican-spanish espanol-mejicano\n"
|
||||
/* nn */ " norwegian nynorsk norsk\n"
|
||||
/* pl */ " polish polski\n"
|
||||
/* pt_PT */ " portuguese portugues\n"
|
||||
|
|
@ -414,8 +414,7 @@ void show_lang_usage(FILE * f, const char * const prg)
|
|||
/* vi */ " vietnamese\n"
|
||||
/* wa */ " walloon walon\n"
|
||||
/* cy */ " welsh cymraeg\n"
|
||||
"\n",
|
||||
prg);
|
||||
"\n", prg);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -490,9 +489,7 @@ void show_locale_usage(FILE * f, const char * const prg)
|
|||
" uk_UA (Ukrainian)\n"
|
||||
" vi_VN (Vietnamese)\n"
|
||||
" wa_BE (Walloon)\n"
|
||||
" cy_GB (Welsh Cymraeg)\n"
|
||||
"\n",
|
||||
prg);
|
||||
" cy_GB (Welsh Cymraeg)\n" "\n", prg);
|
||||
}
|
||||
|
||||
void setup_language(const char *const prg)
|
||||
|
|
@ -512,7 +509,8 @@ void setup_language(const char * const prg)
|
|||
|
||||
if (langstr != NULL)
|
||||
{
|
||||
int i = sizeof language_to_locale_array / sizeof language_to_locale_array[0];
|
||||
int i =
|
||||
sizeof language_to_locale_array / sizeof language_to_locale_array[0];
|
||||
const char *locale = NULL;
|
||||
|
||||
while (i--)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
/* Possible languages: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
LANG_AF, /* Afrikaans */
|
||||
LANG_AR, /* Arabic */
|
||||
LANG_BE, /* Belarusian */
|
||||
|
|
@ -89,7 +90,8 @@ enum {
|
|||
|
||||
/* Types: */
|
||||
|
||||
typedef struct language_to_locale_struct {
|
||||
typedef struct language_to_locale_struct
|
||||
{
|
||||
const char *language;
|
||||
const char *locale;
|
||||
} language_to_locale_struct;
|
||||
|
|
@ -119,4 +121,3 @@ void do_locale_option(const char * const arg);
|
|||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@
|
|||
#include "SDL.h"
|
||||
|
||||
const char *SurfacePrint(SDL_Surface * surface, int showDialog);
|
||||
|
||||
|
||||
|
|
|
|||
13
src/magic.h
13
src/magic.h
|
|
@ -30,7 +30,8 @@
|
|||
|
||||
/* What tools are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
MAGIC_FILL,
|
||||
MAGIC_GRASS,
|
||||
|
||||
|
|
@ -143,14 +144,17 @@ const char * const magic_tips[NUM_MAGICS] = {
|
|||
gettext_noop("Click and move to fade the colors."),
|
||||
gettext_noop("Click and move to darken the colors."),
|
||||
|
||||
gettext_noop("Click and move the mouse around to turn the picture into a chalk drawing."),
|
||||
gettext_noop
|
||||
("Click and move the mouse around to turn the picture into a chalk drawing."),
|
||||
gettext_noop("Click and move the mouse around to make the picture blocky."),
|
||||
|
||||
gettext_noop("Click and move the mouse around to draw a negative."),
|
||||
gettext_noop("Click and move the mouse around to change the picture’s color."),
|
||||
gettext_noop
|
||||
("Click and move the mouse around to change the picture’s color."),
|
||||
|
||||
gettext_noop("Click and move the mouse around to make the picture drip."),
|
||||
gettext_noop("Click and move the mouse around to turn the picture into a cartoon."),
|
||||
gettext_noop
|
||||
("Click and move the mouse around to turn the picture into a cartoon."),
|
||||
|
||||
gettext_noop("Click to make a mirror image."),
|
||||
gettext_noop("Click to flip the picture upside-down."),
|
||||
|
|
@ -222,4 +226,3 @@ const int rainbow_hexes[NUM_RAINBOW_COLORS][3] = {
|
|||
{255, 0, 128},
|
||||
{255, 0, 64}
|
||||
};
|
||||
|
||||
|
|
|
|||
23
src/pixels.c
23
src/pixels.c
|
|
@ -37,7 +37,9 @@ void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
|||
Uint8 *p;
|
||||
|
||||
/* Assuming the X/Y values are within the bounds of this surface... */
|
||||
if (likely( likely((unsigned)x<(unsigned)surface->w) && likely((unsigned)y<(unsigned)surface->h) ))
|
||||
if (likely
|
||||
(likely((unsigned) x < (unsigned) surface->w)
|
||||
&& likely((unsigned) y < (unsigned) surface->h)))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */
|
||||
|
|
@ -58,7 +60,9 @@ void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
|||
Uint8 *p;
|
||||
|
||||
/* Assuming the X/Y values are within the bounds of this surface... */
|
||||
if (likely( likely((unsigned)x<(unsigned)surface->w) && likely((unsigned)y<(unsigned)surface->h) ))
|
||||
if (likely
|
||||
(likely((unsigned) x < (unsigned) surface->w)
|
||||
&& likely((unsigned) y < (unsigned) surface->h)))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */
|
||||
|
|
@ -79,7 +83,9 @@ void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
|||
Uint8 *p;
|
||||
|
||||
/* Assuming the X/Y values are within the bounds of this surface... */
|
||||
if (likely( likely((unsigned)x<(unsigned)surface->w) && likely((unsigned)y<(unsigned)surface->h) ))
|
||||
if (likely
|
||||
(likely((unsigned) x < (unsigned) surface->w)
|
||||
&& likely((unsigned) y < (unsigned) surface->h)))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */
|
||||
|
|
@ -112,7 +118,9 @@ void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
|||
Uint8 *p;
|
||||
|
||||
/* Assuming the X/Y values are within the bounds of this surface... */
|
||||
if (likely( likely((unsigned)x<(unsigned)surface->w) && likely((unsigned)y<(unsigned)surface->h) ))
|
||||
if (likely
|
||||
(likely((unsigned) x < (unsigned) surface->w)
|
||||
&& likely((unsigned) y < (unsigned) surface->h)))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */
|
||||
|
|
@ -239,10 +247,11 @@ Uint32 getpixel32(SDL_Surface * surface, int x, int y)
|
|||
return *(Uint32 *) p; // 32-bit display
|
||||
}
|
||||
|
||||
void (*putpixels[])(SDL_Surface *, int, int, Uint32) = {
|
||||
void (*putpixels[]) (SDL_Surface *, int, int, Uint32) =
|
||||
{
|
||||
putpixel8, putpixel8, putpixel16, putpixel24, putpixel32};
|
||||
|
||||
|
||||
Uint32 (*getpixels[])(SDL_Surface *, int, int) = {
|
||||
Uint32(*getpixels[])(SDL_Surface *, int, int) =
|
||||
{
|
||||
getpixel8, getpixel8, getpixel16, getpixel24, getpixel32};
|
||||
|
||||
|
|
|
|||
|
|
@ -47,4 +47,3 @@ Uint32 getpixel32(SDL_Surface * surface, int x, int y);
|
|||
extern Uint32(*getpixels[]) (SDL_Surface *, int, int);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ Mix_Chunk * sounds[NUM_SOUNDS];
|
|||
int mute, use_sound;
|
||||
int old_sound[4] = { -1, -1, -1, -1 };
|
||||
|
||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y)
|
||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x,
|
||||
int y)
|
||||
{
|
||||
#ifndef NOSOUND
|
||||
int left, dist;
|
||||
|
|
@ -59,4 +60,3 @@ void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
extern Mix_Chunk *sounds[NUM_SOUNDS];
|
||||
extern int mute, use_sound;
|
||||
|
||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y);
|
||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x,
|
||||
int y);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -70,4 +70,3 @@ void show_progress_bar(SDL_Surface * screen)
|
|||
/* FIXME: RESURRECT THIS (bjk 2006.02.18) */
|
||||
//eat_sdl_events();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,4 +39,3 @@ extern int progress_bar_disabled, prog_bar_ctr;
|
|||
void show_progress_bar(SDL_Surface * screen);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -43,5 +43,3 @@ unsigned char linear_to_sRGB (float linear)
|
|||
}
|
||||
return linear_to_sRGB_table[slot];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -306,10 +306,8 @@ static const unsigned char linear_to_sRGB_table[4096] =
|
|||
"\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
|
||||
"\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
|
||||
"\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
;
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff";
|
||||
|
||||
unsigned char linear_to_sRGB(float linear) FUNCTION;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
16
src/shapes.h
16
src/shapes.h
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
/* What shapes are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
SHAPE_SQUARE,
|
||||
SHAPE_SQUARE_FILL,
|
||||
SHAPE_RECTANGLE,
|
||||
|
|
@ -178,16 +179,20 @@ const char * const shape_tips[NUM_SHAPES] = {
|
|||
gettext_noop("A square is a rectangle with four equal sides."),
|
||||
gettext_noop("A rectangle has four sides and four right angles."),
|
||||
gettext_noop("A rectangle has four sides and four right angles."),
|
||||
gettext_noop("A circle is a curve where all points have the same distance from the centre."),
|
||||
gettext_noop("A circle is a curve where all points have the same distance from the centre."),
|
||||
gettext_noop
|
||||
("A circle is a curve where all points have the same distance from the centre."),
|
||||
gettext_noop
|
||||
("A circle is a curve where all points have the same distance from the centre."),
|
||||
gettext_noop("An ellipse is a stretched circle."),
|
||||
gettext_noop("An ellipse is a stretched circle."),
|
||||
gettext_noop("A triangle has three sides."),
|
||||
gettext_noop("A triangle has three sides."),
|
||||
gettext_noop("A pentagon has five sides."),
|
||||
gettext_noop("A pentagon has five sides."),
|
||||
gettext_noop("A rhombus has four equal sides, and opposite sides are parallel."),
|
||||
gettext_noop("A rhombus has four equal sides, and opposite sides are parallel.")
|
||||
gettext_noop
|
||||
("A rhombus has four equal sides, and opposite sides are parallel."),
|
||||
gettext_noop
|
||||
("A rhombus has four equal sides, and opposite sides are parallel.")
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -209,4 +214,3 @@ const char * const shape_img_fnames[NUM_SHAPES] = {
|
|||
DATA_PREFIX "images/shapes/diamond.png",
|
||||
DATA_PREFIX "images/shapes/diamond_f.png"
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@
|
|||
|
||||
#define SND_NONE -1
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
SND_HARP, /* Begin / New */
|
||||
SND_CLICK, /* Tool selections */
|
||||
SND_BLEEP, /* Selector selection */
|
||||
|
|
@ -136,4 +137,3 @@ static const char * sound_fnames[NUM_SOUNDS] = {
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
/* What tuxes are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TUX_DEFAULT,
|
||||
TUX_KISS,
|
||||
TUX_BORED,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@
|
|||
|
||||
/* What titles are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TITLE_NONE,
|
||||
TITLE_NOCOLORS,
|
||||
TITLE_TOOLS,
|
||||
|
|
@ -45,4 +46,3 @@ const char * const title_names[NUM_TITLES] = {
|
|||
gettext_noop("Letters"),
|
||||
gettext_noop("Magic")
|
||||
};
|
||||
|
||||
|
|
|
|||
10
src/tools.h
10
src/tools.h
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
/* What tools are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TOOL_BRUSH,
|
||||
TOOL_STAMP,
|
||||
TOOL_LINES,
|
||||
|
|
@ -63,8 +64,10 @@ const char * const tool_tips[NUM_TOOLS] = {
|
|||
gettext_noop("Pick a color and a brush shape to draw with."),
|
||||
gettext_noop("Pick a picture to stamp around your drawing."),
|
||||
gettext_noop("Click to start drawing a line. Let go to complete it."),
|
||||
gettext_noop("Pick a shape. Click to pick the center, drag, then let go when it is the size you want. Move around to rotate it, and click to draw it."),
|
||||
gettext_noop("Choose a style of text. Click on your drawing and you can start typing."),
|
||||
gettext_noop
|
||||
("Pick a shape. Click to pick the center, drag, then let go when it is the size you want. Move around to rotate it, and click to draw it."),
|
||||
gettext_noop
|
||||
("Choose a style of text. Click on your drawing and you can start typing."),
|
||||
gettext_noop("Pick a magical effect to use on your drawing!"),
|
||||
/* Undo */ gettext_noop("Undo!"),
|
||||
/* Redo */ gettext_noop("Redo!"),
|
||||
|
|
@ -120,4 +123,3 @@ const int tool_tux[NUM_TOOLS] = {
|
|||
TUX_GREAT,
|
||||
TUX_DEFAULT
|
||||
};
|
||||
|
||||
|
|
|
|||
1216
src/tuxpaint.c
1216
src/tuxpaint.c
File diff suppressed because it is too large
Load diff
|
|
@ -29,46 +29,42 @@
|
|||
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "win32_dirent.h"
|
||||
#include "debug.h"
|
||||
|
||||
DIR * opendir(const char *pSpec)
|
||||
{
|
||||
char pathname[MAX_PATH + 2];
|
||||
DIR * pDir = calloc(1, sizeof(DIR));
|
||||
|
||||
if ( !pDir ) return NULL;
|
||||
if (!pDir)
|
||||
return NULL;
|
||||
strcpy(pathname, pSpec);
|
||||
strcat(pathname, "/*");
|
||||
pDir->hFind = FindFirstFile(pathname, &pDir->wfd);
|
||||
if (pDir->hFind == INVALID_HANDLE_VALUE)
|
||||
|
||||
{
|
||||
free(pDir);
|
||||
pDir = NULL;
|
||||
}
|
||||
return pDir;
|
||||
}
|
||||
|
||||
|
||||
void closedir(DIR * pDir)
|
||||
{
|
||||
assert(pDir != NULL);
|
||||
free(pDir);
|
||||
}
|
||||
|
||||
|
||||
struct dirent *readdir(struct DIR *pDir)
|
||||
}
struct dirent *readdir(struct DIR *pDir)
|
||||
{
|
||||
assert(pDir != NULL);
|
||||
if (pDir->hFind)
|
||||
|
||||
{
|
||||
strcpy(pDir->de.d_name, (const char *) pDir->wfd.cFileName);
|
||||
if (!FindNextFile(pDir->hFind, &pDir->wfd))
|
||||
|
||||
{
|
||||
FindClose(pDir->hFind);
|
||||
pDir->hFind = NULL;
|
||||
|
|
@ -77,59 +73,56 @@ struct dirent *readdir(struct DIR *pDir)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int alphasort(const void *a, const void *b)
|
||||
{
|
||||
return(strcmp((*(const struct dirent **)a)->d_name, (*(const struct dirent **)b)->d_name));
|
||||
}
|
||||
|
||||
|
||||
static int addToList( int i, struct dirent ***namelist, struct dirent *entry )
|
||||
return (strcmp
|
||||
((*(const struct dirent **) a)->d_name,
|
||||
(*(const struct dirent **) b)->d_name));
|
||||
}
static int addToList(int i, struct dirent ***namelist,
|
||||
struct dirent *entry)
|
||||
{
|
||||
int size;
|
||||
struct dirent *block;
|
||||
|
||||
*namelist = (struct dirent**)realloc( (void*)(*namelist), (size_t)((i+1)*sizeof(struct dirent*)) );
|
||||
if ( *namelist == NULL ) return -1;
|
||||
|
||||
size = (((char*)&entry->d_name)-((char*)entry))+strlen(entry->d_name)+1;
|
||||
*namelist =
|
||||
(struct dirent **) realloc((void *) (*namelist),
|
||||
(size_t) ((i + 1) * sizeof(struct dirent *)));
|
||||
if (*namelist == NULL)
|
||||
return -1;
|
||||
size =
|
||||
(((char *) &entry->d_name) - ((char *) entry)) + strlen(entry->d_name) +
|
||||
1;
|
||||
block = (struct dirent *) malloc(size);
|
||||
|
||||
if ( block == NULL ) return -1;
|
||||
|
||||
if (block == NULL)
|
||||
return -1;
|
||||
(*namelist)[i] = block;
|
||||
memcpy(block, entry, size);
|
||||
|
||||
return ++i;
|
||||
}
|
||||
|
||||
|
||||
int scandir( const char *dir, struct dirent ***namelist, selectCB select, comparCB compar)
|
||||
int scandir(const char *dir, struct dirent ***namelist, selectCB select,
|
||||
comparCB compar)
|
||||
{
|
||||
DIR * pDir;
|
||||
int count;
|
||||
struct dirent *entry;
|
||||
|
||||
assert((dir != NULL) && (namelist != NULL));
|
||||
|
||||
pDir = opendir(dir);
|
||||
|
||||
if ( !pDir ) return -1;
|
||||
|
||||
if (!pDir)
|
||||
return -1;
|
||||
count = 0;
|
||||
while ((entry = readdir(pDir)) != NULL)
|
||||
|
||||
{
|
||||
if (select == NULL || (select != NULL && select(entry)))
|
||||
if ((count = addToList(count, namelist, entry)) < 0)
|
||||
break;
|
||||
}
|
||||
closedir(pDir);
|
||||
if ( count <= 0 ) return -1;
|
||||
|
||||
if (count <= 0)
|
||||
return -1;
|
||||
if (compar != NULL)
|
||||
qsort( (void *)(*namelist), (size_t)count, sizeof(struct dirent *), compar );
|
||||
|
||||
qsort((void *) (*namelist), (size_t) count, sizeof(struct dirent *),
|
||||
compar);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
/* */
|
||||
/****************************************************/
|
||||
/* $Id$ */
|
||||
|
||||
typedef long BOOL;
|
||||
typedef unsigned int DWORD;
|
||||
typedef wchar_t TCHAR;
|
||||
|
|
@ -17,13 +16,11 @@ typedef void* HANDLE;
|
|||
#define MAX_PATH 256
|
||||
#define INVALID_HANDLE_VALUE ((HANDLE)(-1))
|
||||
#define WINAPI __stdcall
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwLowDateTime;
|
||||
DWORD dwHighDateTime;
|
||||
} FILETIME;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwFileAttributes;
|
||||
|
|
@ -38,45 +35,39 @@ typedef struct
|
|||
TCHAR cAlternateFileName[14];
|
||||
} WIN32_FIND_DATA;
|
||||
|
||||
|
||||
#define FindFirstFile FindFirstFileA
|
||||
#define FindNextFile FindNextFileA
|
||||
#define FindClose FindClose
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern "C"
|
||||
{
|
||||
|
||||
#endif /*
*/
|
||||
extern HANDLE WINAPI FindFirstFile(const char *, WIN32_FIND_DATA *);
|
||||
extern BOOL WINAPI FindNextFile(HANDLE, WIN32_FIND_DATA *);
|
||||
extern BOOL WINAPI FindClose(HANDLE);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*
*/
|
||||
struct dirent
|
||||
{
|
||||
char d_name[MAX_PATH];
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WIN32_FIND_DATA wfd;
|
||||
HANDLE hFind;
|
||||
struct dirent de;
|
||||
} DIR;
|
||||
|
||||
|
||||
extern DIR *opendir(const char *pSpec);
|
||||
extern void closedir(DIR * pDir);
|
||||
extern struct dirent *readdir(struct DIR *pDir);
|
||||
|
||||
typedef int (*selectCB) (const struct dirent *);
|
||||
typedef int (*comparCB) (const void *, const void *);
|
||||
|
||||
extern int alphasort(const void *a, const void *b);
|
||||
extern int scandir( const char *dir, struct dirent ***namelist, selectCB select, comparCB compar);
|
||||
extern int scandir(const char *dir, struct dirent ***namelist,
|
||||
selectCB select, comparCB compar);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ static SDL_Surface *make24bitDIB(SDL_Surface *surf)
|
|||
|
||||
surf24 = SDL_ConvertSurface(surf, &pixfmt, SDL_SWSURFACE);
|
||||
surfDIB = SDL_CreateRGBSurface(SDL_SWSURFACE, surf24->w, surf24->h, 24,
|
||||
pixfmt.Rmask, pixfmt.Gmask, pixfmt.Bmask, pixfmt.Amask);
|
||||
pixfmt.Rmask, pixfmt.Gmask, pixfmt.Bmask,
|
||||
pixfmt.Amask);
|
||||
|
||||
linesize = surf24->w * 3; // Flip top2bottom
|
||||
dst = surfDIB->pixels;
|
||||
|
|
@ -115,9 +116,12 @@ static int GetDefaultPrinterStrings(char *device, char *driver, char *output)
|
|||
((drv = strtok(NULL, ", ")) != NULL) &&
|
||||
((out = strtok(NULL, ", ")) != NULL))
|
||||
{
|
||||
if (device) strcpy(device, dev);
|
||||
if (driver) strcpy(driver, drv);
|
||||
if (output) strcpy(output, out);
|
||||
if (device)
|
||||
strcpy(device, dev);
|
||||
if (driver)
|
||||
strcpy(driver, drv);
|
||||
if (output)
|
||||
strcpy(output, out);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -181,15 +185,20 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
|
|||
return hDevMode;
|
||||
|
||||
err_exit:
|
||||
if (fp) fclose(fp);
|
||||
if (devmode) GlobalUnlock(hDevMode);
|
||||
if (hDevMode) GlobalFree(hDevMode);
|
||||
if (hPrinter) ClosePrinter(hPrinter);
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
if (devmode)
|
||||
GlobalUnlock(hDevMode);
|
||||
if (hDevMode)
|
||||
GlobalFree(hDevMode);
|
||||
if (hPrinter)
|
||||
ClosePrinter(hPrinter);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath, HANDLE hDevMode)
|
||||
static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath,
|
||||
HANDLE hDevMode)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
|
|
@ -236,7 +245,8 @@ static HDC GetCustomPrinterDC(HWND hWnd, const char *printcfg, int show)
|
|||
{
|
||||
DEVMODE *devmode = (DEVMODE *) GlobalLock(global_pd.hDevMode);
|
||||
|
||||
global_pd.hDC = CreateDC(NULL, (const char*)devmode->dmDeviceName, NULL, devmode);
|
||||
global_pd.hDC =
|
||||
CreateDC(NULL, (const char *) devmode->dmDeviceName, NULL, devmode);
|
||||
GlobalUnlock(global_pd.hDevMode);
|
||||
}
|
||||
return global_pd.hDC;
|
||||
|
|
@ -256,7 +266,8 @@ static HDC GetDefaultPrinterDC(void)
|
|||
|
||||
static HDC GetPrinterDC(HWND hWnd, const char *printcfg, int show)
|
||||
{
|
||||
if (!printcfg) return GetDefaultPrinterDC();
|
||||
if (!printcfg)
|
||||
return GetDefaultPrinterDC();
|
||||
return GetCustomPrinterDC(hWnd, printcfg, show);
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +279,8 @@ static int IsBandingRequired(HDC hPrinter)
|
|||
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (GetVersionEx(&osvi) && (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT))
|
||||
return Escape(hPrinter, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&indata, NULL);
|
||||
return Escape(hPrinter, QUERYESCSUPPORT, sizeof(int), (LPCSTR) & indata,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +291,8 @@ int IsPrinterAvailable(void)
|
|||
}
|
||||
|
||||
|
||||
const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog)
|
||||
const char *SurfacePrint(SDL_Surface * surf, const char *printcfg,
|
||||
int showdialog)
|
||||
{
|
||||
const char *res = NULL;
|
||||
HWND hWnd;
|
||||
|
|
@ -399,12 +412,14 @@ const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog
|
|||
RECT rcPrinter;
|
||||
RECT rcImage;
|
||||
|
||||
SetRect(&rcPrinter, xLeft, yTop, (int)(fScaleX*bmih.biWidth), (int)(fScaleY*bmih.biHeight));
|
||||
SetRect(&rcPrinter, xLeft, yTop, (int) (fScaleX * bmih.biWidth),
|
||||
(int) (fScaleY * bmih.biHeight));
|
||||
SetRect(&rcImage, 0, 0, bmih.biWidth, bmih.biHeight);
|
||||
|
||||
while (Escape(hDCprinter, NEXTBAND, 0, NULL, &rcBand))
|
||||
{
|
||||
if (IsRectEmpty(&rcBand)) break;
|
||||
if (IsRectEmpty(&rcBand))
|
||||
break;
|
||||
if (IntersectRect(&rcBand, &rcBand, &rcPrinter))
|
||||
{
|
||||
rcImage.top = (int) (0.5f + (float) rcBand.top / fScaleX);
|
||||
|
|
@ -464,9 +479,12 @@ const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog
|
|||
EndDoc(hDCprinter);
|
||||
|
||||
error:
|
||||
if (hdcMem) DeleteDC(hdcMem);
|
||||
if (hbm) DeleteObject(hbm);
|
||||
if (surf24) SDL_FreeSurface(surf24);
|
||||
if (hdcMem)
|
||||
DeleteDC(hdcMem);
|
||||
if (hbm)
|
||||
DeleteObject(hbm);
|
||||
if (surf24)
|
||||
SDL_FreeSurface(surf24);
|
||||
|
||||
EnableWindow(hWnd, TRUE);
|
||||
DeleteDC(hDCprinter);
|
||||
|
|
@ -477,7 +495,8 @@ error:
|
|||
/*
|
||||
Read access to Windows Registry
|
||||
*/
|
||||
static HRESULT ReadRegistry(const char *key, const char *option, char *value, int size)
|
||||
static HRESULT ReadRegistry(const char *key, const char *option, char *value,
|
||||
int size)
|
||||
{
|
||||
LONG res;
|
||||
HKEY hKey = NULL;
|
||||
|
|
@ -485,13 +504,16 @@ static HRESULT ReadRegistry(const char *key, const char *option, char *value, in
|
|||
res = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey);
|
||||
if (res != ERROR_SUCCESS)
|
||||
goto err_exit;
|
||||
res = RegQueryValueEx(hKey, option, NULL, NULL, (LPBYTE)value, (LPDWORD)&size);
|
||||
res =
|
||||
RegQueryValueEx(hKey, option, NULL, NULL, (LPBYTE) value,
|
||||
(LPDWORD) & size);
|
||||
if (res != ERROR_SUCCESS)
|
||||
goto err_exit;
|
||||
res = ERROR_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
if (hKey) RegCloseKey(hKey);
|
||||
if (hKey)
|
||||
RegCloseKey(hKey);
|
||||
return HRESULT_FROM_WIN32(res);
|
||||
}
|
||||
|
||||
|
|
@ -520,7 +542,8 @@ char *GetDefaultSaveDir(const char *suffix)
|
|||
{
|
||||
char prefix[MAX_PATH];
|
||||
char path[2 * MAX_PATH];
|
||||
const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
||||
const char *key =
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
||||
const char *option = "AppData";
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
|
|
@ -541,7 +564,8 @@ char *GetDefaultSaveDir(const char *suffix)
|
|||
char *GetSystemFontDir(void)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
||||
const char *key =
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
||||
const char *option = "Fonts";
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
|
|
@ -552,5 +576,3 @@ char *GetSystemFontDir(void)
|
|||
}
|
||||
return strdup("C:\\WINDOWS\\FONTS");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
/* if printcfg is NULL, uses the default printer */
|
||||
extern const char *SurfacePrint(SDL_Surface * surf,
|
||||
const char *printcfg,
|
||||
int showdialog );
|
||||
const char *printcfg, int showdialog);
|
||||
extern int IsPrinterAvailable(void);
|
||||
|
||||
/* additional windows functions requiring <windows.h> */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue