Added support for building on a Windows system using MinGW/MSYS.

After building and installing all the dependencies I used these commands,
in MSYS, to build, install and run:

    export set CPATH=/usr/local/include
    export set LIBRARY_PATH=/usr/local/bin:/usr/local/lib
    make win32
    make install-win32
    tuxpaint
This commit is contained in:
John Popplewell 2005-02-26 02:26:40 +00:00
parent e1ce8e1ddb
commit 778bd2f897
4 changed files with 264 additions and 252 deletions

167
Makefile
View file

@ -22,6 +22,7 @@ PKG_ROOT=
# Program: # Program:
BIN_PREFIX=$(PKG_ROOT)/$(PREFIX)/bin BIN_PREFIX=$(PKG_ROOT)/$(PREFIX)/bin
EXE_EXT=
# Data: # Data:
@ -144,6 +145,22 @@ beos:
ARCH_HEADERS="src/BeOS_Print.h" \ ARCH_HEADERS="src/BeOS_Print.h" \
ARCH_LIBS="obj/BeOS_print.o" ARCH_LIBS="obj/BeOS_print.o"
# "make win32" builds the program for Windows using MinGW/MSYS
win32:
make \
PREFIX=/usr/local \
BIN_PREFIX=$(PREFIX)/bin \
EXE_EXT=.exe \
DATA_PREFIX=$(PREFIX)/share/tuxpaint/ \
DOC_PREFIX=$(PREFIX)/share/doc/tuxpaint/ \
MAN_PREFIX=$(PREFIX)/share/man/ \
ICON_PREFIX=./ \
X11_ICON_PREFIX=./ \
LOCALE_PREFIX=$(PREFIX)/share/locale/ \
CONFDIR=$(PREFIX)/etc/tuxpaint \
ARCH_LINKS="-lintl-3 -lpng12 -lwinspool" \
ARCH_HEADERS="src/win32_print.h" \
ARCH_LIBS="obj/win32_print.o"
# "make install" installs all of the various parts # "make install" installs all of the various parts
# (depending on the *PREFIX variables at the top, you probably need # (depending on the *PREFIX variables at the top, you probably need
@ -172,6 +189,30 @@ install: install-bin install-data install-man install-doc \
@echo @echo
# "make private-win32" installs all of the various parts for MinGW
install-private-win32: install-bin install-data install-man install-doc \
install-icon install-gettext install-importscript \
install-default-config install-example-stamps \
install-example-starters
@echo
@echo "--------------------------------------------------------------"
@echo
@echo "All done!"
@echo "Now you can type the command 'tuxpaint' to run the program!!!"
@echo
@echo "For more information, see the 'tuxpaint' man page,"
@echo "run 'tuxpaint --usage' or see $(DOC_PREFIX)README.txt"
@echo
@echo "Visit Tux Paint's home page for more information, updates"
@echo "and to learn how you can help out!"
@echo
@echo " http://www.newbreedsoftware.com/tuxpaint/"
@echo
@echo "Enjoy!"
@echo
# "make install-beos" installs Tux Paint, but using BeOS settings # "make install-beos" installs Tux Paint, but using BeOS settings
install-beos: install-beos:
@ -182,7 +223,7 @@ install-beos:
DOC_PREFIX=./docs/ \ DOC_PREFIX=./docs/ \
MAN_PREFIX=./src/ \ MAN_PREFIX=./src/ \
CONFDIR=./src/ \ CONFDIR=./src/ \
ICON_PREFIX=./ ICON_PREFIX=./ \
X11_ICON_PREFIX=./ \ X11_ICON_PREFIX=./ \
LOCALE_PREFIX=/boot/home/config/share/locale/ \ LOCALE_PREFIX=/boot/home/config/share/locale/ \
CFLAGS="-O1 -funroll-loops -fomit-frame-pointer -pipe -Wall" \ CFLAGS="-O1 -funroll-loops -fomit-frame-pointer -pipe -Wall" \
@ -192,6 +233,22 @@ install-beos:
ARCH_HEADERS="src/BeOS_Print.h" \ ARCH_HEADERS="src/BeOS_Print.h" \
ARCH_LIBS="obj/BeOS_print.o" ARCH_LIBS="obj/BeOS_print.o"
# "make install-win32" installs Tux Paint, but using MinGW/MSYS settings
install-win32:
make install-private-win32 \
PREFIX=/usr/local \
BIN_PREFIX=$(PREFIX)/bin \
EXE_EXT=.exe \
DATA_PREFIX=$(PREFIX)/share/tuxpaint/ \
DOC_PREFIX=$(PREFIX)/share/doc/tuxpaint/ \
MAN_PREFIX=$(PREFIX)/share/man/ \
ICON_PREFIX=./ \
X11_ICON_PREFIX=./ \
LOCALE_PREFIX=$(PREFIX)/share/locale/ \
CONFDIR=$(PREFIX)/etc/tuxpaint \
ARCH_LINKS="-lintl-3 -lpng12 -lwinspool" \
ARCH_HEADERS="src/win32_print.h" \
ARCH_LIBS="obj/win32_print.o"
# "make clean" deletes the program, the compiled objects and the # "make clean" deletes the program, the compiled objects and the
# built man page (returns to factory archive, pretty much...) # built man page (returns to factory archive, pretty much...)
@ -421,7 +478,7 @@ install-bin:
@echo "...Installing program itself..." @echo "...Installing program itself..."
@install -d $(BIN_PREFIX) @install -d $(BIN_PREFIX)
@cp tuxpaint $(BIN_PREFIX) @cp tuxpaint $(BIN_PREFIX)
@chmod a+rx,g-w,o-w $(BIN_PREFIX)/tuxpaint @chmod a+rx,g-w,o-w $(BIN_PREFIX)/tuxpaint$(EXE_EXT)
# Install the import script: # Install the import script:
@ -779,6 +836,12 @@ obj/BeOS_Print.o: src/BeOS_Print.cpp obj src/BeOS_print.h
@$(CC) $(CFLAGS) $(SDL_CFLAGS) $(DEFS) \ @$(CC) $(CFLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/BeOS_print.cpp -o obj/BeOS_print.o -c src/BeOS_print.cpp -o obj/BeOS_print.o
obj/win32_print.o: src/win32_print.c obj src/win32_print.h
@echo
@echo "...Compiling win32 print support..."
@$(CC) $(CFLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/win32_print.c -o obj/win32_print.o
# Build the translation files for gettext # Build the translation files for gettext
@ -841,203 +904,203 @@ trans:
trans/af.mo: src/po/af.po trans/af.mo: src/po/af.po
@echo " af_ZA ...Afrikaans..." @echo " af_ZA ...Afrikaans..."
@msgfmt src/po/af.po -o trans/af.mo @msgfmt -o trans/af.mo src/po/af.po
trans/be.mo: src/po/be.po trans/be.mo: src/po/be.po
@echo " be_BY ...Belarusian..." @echo " be_BY ...Belarusian..."
@msgfmt src/po/be.po -o trans/be.mo @msgfmt -o trans/be.mo src/po/be.po
trans/bg.mo: src/po/bg.po trans/bg.mo: src/po/bg.po
@echo " bg_BG ...Bulgarian..." @echo " bg_BG ...Bulgarian..."
@msgfmt src/po/bg.po -o trans/bg.mo @msgfmt -o trans/bg.mo src/po/bg.po
trans/br.mo: src/po/br.po trans/br.mo: src/po/br.po
@echo " br_FR ...Breton..." @echo " br_FR ...Breton..."
@msgfmt src/po/br.po -o trans/br.mo @msgfmt -o trans/br.mo src/po/br.po
trans/ca.mo: src/po/ca.po trans/ca.mo: src/po/ca.po
@echo " ca_ES ...Catalan..." @echo " ca_ES ...Catalan..."
@msgfmt src/po/ca.po -o trans/ca.mo @msgfmt -o trans/ca.mo src/po/ca.po
trans/cy.mo: src/po/cy.po trans/cy.mo: src/po/cy.po
@echo " cy_GB ...Welsh..." @echo " cy_GB ...Welsh..."
@msgfmt src/po/cy.po -o trans/cy.mo @msgfmt -o trans/cy.mo src/po/cy.po
trans/cs.mo: src/po/cs.po trans/cs.mo: src/po/cs.po
@echo " cs_CZ ...Czech..." @echo " cs_CZ ...Czech..."
@msgfmt src/po/cs.po -o trans/cs.mo @msgfmt -o trans/cs.mo src/po/cs.po
trans/da.mo: src/po/da.po trans/da.mo: src/po/da.po
@echo " da_DK ...Danish..." @echo " da_DK ...Danish..."
@msgfmt src/po/da.po -o trans/da.mo @msgfmt -o trans/da.mo src/po/da.po
trans/de.mo: src/po/de.po trans/de.mo: src/po/de.po
@echo " de_DE ...German..." @echo " de_DE ...German..."
@msgfmt src/po/de.po -o trans/de.mo @msgfmt -o trans/de.mo src/po/de.po
trans/et.mo: src/po/et.po trans/et.mo: src/po/et.po
@echo " et_EE ...Estonian..." @echo " et_EE ...Estonian..."
@msgfmt src/po/et.po -o trans/et.mo @msgfmt -o trans/et.mo src/po/et.po
trans/el.mo: src/po/el.po trans/el.mo: src/po/el.po
@echo " el_GR ...Greek..." @echo " el_GR ...Greek..."
@msgfmt src/po/el.po -o trans/el.mo @msgfmt -o trans/el.mo src/po/el.po
trans/en_gb.mo: src/po/en_gb.po trans/en_gb.mo: src/po/en_gb.po
@echo " en_GB ...British English..." @echo " en_GB ...British English..."
@msgfmt src/po/en_gb.po -o trans/en_gb.mo @msgfmt -o trans/en_gb.mo src/po/en_gb.po
trans/es.mo: src/po/es.po trans/es.mo: src/po/es.po
@echo " es_ES ...Spanish..." @echo " es_ES ...Spanish..."
@msgfmt src/po/es.po -o trans/es.mo @msgfmt -o trans/es.mo src/po/es.po
trans/eu.mo: src/po/eu.po trans/eu.mo: src/po/eu.po
@echo " eu_ES ...Basque..." @echo " eu_ES ...Basque..."
@msgfmt src/po/eu.po -o trans/eu.mo @msgfmt -o trans/eu.mo src/po/eu.po
trans/fi.mo: src/po/fi.po trans/fi.mo: src/po/fi.po
@echo " fi_FI ...Finnish..." @echo " fi_FI ...Finnish..."
@msgfmt src/po/fi.po -o trans/fi.mo @msgfmt -o trans/fi.mo src/po/fi.po
trans/fr.mo: src/po/fr.po trans/fr.mo: src/po/fr.po
@echo " fr_FR ...French..." @echo " fr_FR ...French..."
@msgfmt src/po/fr.po -o trans/fr.mo @msgfmt -o trans/fr.mo src/po/fr.po
trans/ga.mo: src/po/ga.po trans/ga.mo: src/po/ga.po
@echo " ga_IE ...Gaelic..." @echo " ga_IE ...Gaelic..."
@msgfmt src/po/ga.po -o trans/ga.mo @msgfmt -o trans/ga.mo src/po/ga.po
trans/gl.mo: src/po/gl.po trans/gl.mo: src/po/gl.po
@echo " gl_ES ...Galician..." @echo " gl_ES ...Galician..."
@msgfmt src/po/gl.po -o trans/gl.mo @msgfmt -o trans/gl.mo src/po/gl.po
trans/he.mo: src/po/he.po trans/he.mo: src/po/he.po
@echo " he_IL ...Hebrew..." @echo " he_IL ...Hebrew..."
@msgfmt src/po/he.po -o trans/he.mo @msgfmt -o trans/he.mo src/po/he.po
trans/hi.mo: src/po/hi.po trans/hi.mo: src/po/hi.po
@echo " hi_IN ...Hindi..." @echo " hi_IN ...Hindi..."
@msgfmt src/po/hi.po -o trans/hi.mo @msgfmt -o trans/hi.mo src/po/hi.po
trans/hr.mo: src/po/hr.po trans/hr.mo: src/po/hr.po
@echo " hr_HR ...Croatian..." @echo " hr_HR ...Croatian..."
@msgfmt src/po/hr.po -o trans/hr.mo @msgfmt -o trans/hr.mo src/po/hr.po
trans/hu.mo: src/po/hu.po trans/hu.mo: src/po/hu.po
@echo " hu_HU ...Hungarian..." @echo " hu_HU ...Hungarian..."
@msgfmt src/po/hu.po -o trans/hu.mo @msgfmt -o trans/hu.mo src/po/hu.po
trans/tlh.mo: src/po/tlh.po trans/tlh.mo: src/po/tlh.po
@echo " tlh ...Klingon (Romanized)..." @echo " tlh ...Klingon (Romanized)..."
@msgfmt src/po/tlh.po -o trans/tlh.mo @msgfmt -o trans/tlh.mo src/po/tlh.po
trans/id.mo: src/po/id.po trans/id.mo: src/po/id.po
@echo " id_ID ...Indonesian..." @echo " id_ID ...Indonesian..."
@msgfmt src/po/id.po -o trans/id.mo @msgfmt -o trans/id.mo src/po/id.po
trans/is.mo: src/po/is.po trans/is.mo: src/po/is.po
@echo " is_IS ...Icelandic..." @echo " is_IS ...Icelandic..."
@msgfmt src/po/is.po -o trans/is.mo @msgfmt -o trans/is.mo src/po/is.po
trans/it.mo: src/po/it.po trans/it.mo: src/po/it.po
@echo " it_IT ...Italian..." @echo " it_IT ...Italian..."
@msgfmt src/po/it.po -o trans/it.mo @msgfmt -o trans/it.mo src/po/it.po
trans/ja.mo: src/po/ja.po trans/ja.mo: src/po/ja.po
@echo " ja_JP ...Japanese..." @echo " ja_JP ...Japanese..."
@msgfmt src/po/ja.po -o trans/ja.mo @msgfmt -o trans/ja.mo src/po/ja.po
trans/ko.mo: src/po/ko.po trans/ko.mo: src/po/ko.po
@echo " ko_KR ...Korean..." @echo " ko_KR ...Korean..."
@msgfmt src/po/ko.po -o trans/ko.mo @msgfmt -o trans/ko.mo src/po/ko.po
trans/lt.mo: src/po/lt.po trans/lt.mo: src/po/lt.po
@echo " lt_LT ...Lithuanian..." @echo " lt_LT ...Lithuanian..."
@msgfmt src/po/lt.po -o trans/lt.mo @msgfmt -o trans/lt.mo src/po/lt.po
trans/ms.mo: src/po/ms.po trans/ms.mo: src/po/ms.po
@echo " ms_MY ...Malay..." @echo " ms_MY ...Malay..."
@msgfmt src/po/ms.po -o trans/ms.mo @msgfmt -o trans/ms.mo src/po/ms.po
trans/nl.mo: src/po/nl.po trans/nl.mo: src/po/nl.po
@echo " nl_NL ...Dutch..." @echo " nl_NL ...Dutch..."
@msgfmt src/po/nl.po -o trans/nl.mo @msgfmt -o trans/nl.mo src/po/nl.po
trans/nb.mo: src/po/nb.po trans/nb.mo: src/po/nb.po
@echo " nb_NO ...Norwegian Bokmal..." @echo " nb_NO ...Norwegian Bokmal..."
@msgfmt src/po/nb.po -o trans/nb.mo @msgfmt -o trans/nb.mo src/po/nb.po
trans/nn.mo: src/po/nn.po trans/nn.mo: src/po/nn.po
@echo " nn_NO ...Norwegian Nynorsk..." @echo " nn_NO ...Norwegian Nynorsk..."
@msgfmt src/po/nn.po -o trans/nn.mo @msgfmt -o trans/nn.mo src/po/nn.po
trans/pl.mo: src/po/pl.po trans/pl.mo: src/po/pl.po
@echo " pl_PL ...Polish..." @echo " pl_PL ...Polish..."
@msgfmt src/po/pl.po -o trans/pl.mo @msgfmt -o trans/pl.mo src/po/pl.po
trans/pt_pt.mo: src/po/pt_pt.po trans/pt_pt.mo: src/po/pt_pt.po
@echo " pt_PT ...Portuguese..." @echo " pt_PT ...Portuguese..."
@msgfmt src/po/pt_pt.po -o trans/pt_pt.mo @msgfmt -o trans/pt_pt.mo src/po/pt_pt.po
trans/pt_br.mo: src/po/pt_br.po trans/pt_br.mo: src/po/pt_br.po
@echo " pt_BR ...Brazilian Portuguese..." @echo " pt_BR ...Brazilian Portuguese..."
@msgfmt src/po/pt_br.po -o trans/pt_br.mo @msgfmt -o trans/pt_br.mo src/po/pt_br.po
trans/ro.mo: src/po/ro.po trans/ro.mo: src/po/ro.po
@echo " ro_RO ...Romanian..." @echo " ro_RO ...Romanian..."
@msgfmt src/po/ro.po -o trans/ro.mo @msgfmt -o trans/ro.mo src/po/ro.po
trans/ru.mo: src/po/ru.po trans/ru.mo: src/po/ru.po
@echo " ru_RU ...Russian..." @echo " ru_RU ...Russian..."
@msgfmt src/po/ru.po -o trans/ru.mo @msgfmt -o trans/ru.mo src/po/ru.po
trans/sk.mo: src/po/sk.po trans/sk.mo: src/po/sk.po
@echo " sk_SK ...Slovak..." @echo " sk_SK ...Slovak..."
@msgfmt src/po/sk.po -o trans/sk.mo @msgfmt -o trans/sk.mo src/po/sk.po
trans/sl.mo: src/po/sl.po trans/sl.mo: src/po/sl.po
@echo " sl_SI ...Slovenian..." @echo " sl_SI ...Slovenian..."
@msgfmt src/po/sl.po -o trans/sl.mo @msgfmt -o trans/sl.mo src/po/sl.po
trans/sq.mo: src/po/sq.po trans/sq.mo: src/po/sq.po
@echo " sq_AL ...Albanian..." @echo " sq_AL ...Albanian..."
@msgfmt src/po/sq.po -o trans/sq.mo @msgfmt -o trans/sq.mo src/po/sq.po
trans/sr.mo: src/po/sr.po trans/sr.mo: src/po/sr.po
@echo " sr_YU ...Serbian..." @echo " sr_YU ...Serbian..."
@msgfmt src/po/sr.po -o trans/sr.mo @msgfmt -o trans/sr.mo src/po/sr.po
trans/sv.mo: src/po/sv.po trans/sv.mo: src/po/sv.po
@echo " sv_SE ...Swedish..." @echo " sv_SE ...Swedish..."
@msgfmt src/po/sv.po -o trans/sv.mo @msgfmt -o trans/sv.mo src/po/sv.po
trans/sw.mo: src/po/sw.po trans/sw.mo: src/po/sw.po
@echo " sw_TZ ...Swahili..." @echo " sw_TZ ...Swahili..."
@msgfmt src/po/sw.po -o trans/sw.mo @msgfmt -o trans/sw.mo src/po/sw.po
trans/ta.mo: src/po/ta.po trans/ta.mo: src/po/ta.po
@echo " ta_IN ...Tamil..." @echo " ta_IN ...Tamil..."
@msgfmt src/po/ta.po -o trans/ta.mo @msgfmt -o trans/ta.mo src/po/ta.po
trans/tr.mo: src/po/tr.po trans/tr.mo: src/po/tr.po
@echo " tr_TR ...Turkish..." @echo " tr_TR ...Turkish..."
@msgfmt src/po/tr.po -o trans/tr.mo @msgfmt -o trans/tr.mo src/po/tr.po
trans/vi.mo: src/po/vi.po trans/vi.mo: src/po/vi.po
@echo " vi_VN ...Vietnamese..." @echo " vi_VN ...Vietnamese..."
@msgfmt src/po/vi.po -o trans/vi.mo @msgfmt -o trans/vi.mo src/po/vi.po
trans/wa.mo: src/po/wa.po trans/wa.mo: src/po/wa.po
@echo " wa_BE ...Walloon..." @echo " wa_BE ...Walloon..."
@msgfmt src/po/wa.po -o trans/wa.mo @msgfmt -o trans/wa.mo src/po/wa.po
trans/zh_cn.mo: src/po/zh_cn.po trans/zh_cn.mo: src/po/zh_cn.po
@echo " zh_CN ...Chinese..." @echo " zh_CN ...Chinese..."
@msgfmt src/po/zh_cn.po -o trans/zh_cn.mo @msgfmt -o trans/zh_cn.mo src/po/zh_cn.po
trans/zh_tw.mo: src/po/zh_tw.po trans/zh_tw.mo: src/po/zh_tw.po
@echo " zh_TW ...Chinese..." @echo " zh_TW ...Chinese..."
@msgfmt src/po/zh_tw.po -o trans/zh_tw.mo @msgfmt -o trans/zh_tw.mo src/po/zh_tw.po

View file

@ -41,6 +41,9 @@
// plan to rip this out as soon as it is considered stable // plan to rip this out as soon as it is considered stable
//#define THREADED_FONTS //#define THREADED_FONTS
#define FORKED_FONTS #define FORKED_FONTS
#ifdef WIN32
#undef FORKED_FONTS
#endif
/* Method for printing images: */ /* Method for printing images: */
@ -159,16 +162,6 @@ static scaleparams scaletable[] = {
#include <wctype.h> #include <wctype.h>
#endif #endif
#ifdef WIN32_OLD
/* The following are required by libintl.h, so must be defined first: */
#define LC_MESSAGES 1729
#define HAVE_LC_MESSAGES 1
#define ENABLE_NLS 1
#define HAVE_LOCALE_H 1
#define HAVE_GETTEXT 1
#define HAVE_DCGETTEXT 1
#endif
#include <libintl.h> #include <libintl.h>
#ifndef gettext_noop #ifndef gettext_noop
#define gettext_noop(String) String #define gettext_noop(String) String
@ -187,8 +180,6 @@ static scaleparams scaletable[] = {
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef WIN32 #ifndef WIN32
#include <unistd.h> #include <unistd.h>
#include <dirent.h> #include <dirent.h>
@ -211,38 +202,15 @@ typedef struct safer_dirent {
extern WrapperData macosx; extern WrapperData macosx;
#endif #endif
#else #else
#include "win32_dirent.h"
#include <unistd.h>
#include <dirent.h>
#include <malloc.h>
#include "win32_print.h" #include "win32_print.h"
#include <io.h> #include <io.h>
#include <direct.h> #include <direct.h>
/* Enables win32 apps to get a GNU compatible locale string */
extern char* g_win32_getlocale(void);
/* Set this to 0 during developement and testing in Visual-Studio
Set this to 1 to make the final executable */
#if 1
#define DOC_PREFIX "docs/"
#define DATA_PREFIX "data/"
#define LOCALEDIR "locale"
#else
#define DOC_PREFIX "../../docs/"
#define DATA_PREFIX "../../data/"
#define LOCALEDIR "../../locale"
#endif /* 1/0 */
#define mkdir(path,access) _mkdir(path) #define mkdir(path,access) _mkdir(path)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define snprintf _snprintf
#define S_ISDIR(i) ((i&_S_IFDIR)!=0)
#define alloca _alloca
#endif /* WIN32 */ #endif /* WIN32 */
@ -250,7 +218,7 @@ extern char* g_win32_getlocale(void);
#include <sys/stat.h> #include <sys/stat.h>
#include "SDL.h" #include "SDL.h"
#ifndef _SDL_H #if !defined(_SDL_H)
#error "---------------------------------------------------" #error "---------------------------------------------------"
#error "If you installed SDL from a package, be sure to get" #error "If you installed SDL from a package, be sure to get"
#error "the development package, as well!" #error "the development package, as well!"
@ -259,30 +227,26 @@ extern char* g_win32_getlocale(void);
#endif #endif
#include "SDL_image.h" #include "SDL_image.h"
#ifndef _SDL_IMAGE_H #if !defined(_SDL_IMAGE_H) && !defined(_IMG_h)
#ifndef _IMG_h
#error "---------------------------------------------------" #error "---------------------------------------------------"
#error "If you installed SDL_image from a package, be sure" #error "If you installed SDL_image from a package, be sure"
#error "to get the development package, as well!" #error "to get the development package, as well!"
#error "(e.g., 'libsdl-image1.2-devel.rpm')" #error "(e.g., 'libsdl-image1.2-devel.rpm')"
#error "---------------------------------------------------" #error "---------------------------------------------------"
#endif #endif
#endif
#include "SDL_ttf.h" #include "SDL_ttf.h"
#ifndef _SDL_TTF_h #if !defined(_SDL_TTF_H) && !defined(_SDLttf_h)
#ifndef _SDLttf_h
#error "---------------------------------------------------" #error "---------------------------------------------------"
#error "If you installed SDL_ttf from a package, be sure" #error "If you installed SDL_ttf from a package, be sure"
#error "to get the development package, as well!" #error "to get the development package, as well!"
#error "(e.g., 'libsdl-ttf1.2-devel.rpm')" #error "(e.g., 'libsdl-ttf1.2-devel.rpm')"
#error "---------------------------------------------------" #error "---------------------------------------------------"
#endif #endif
#endif
#ifndef NOSOUND #ifndef NOSOUND
#include "SDL_mixer.h" #include "SDL_mixer.h"
#ifndef _MIXER_H_ #if !defined(_SDL_MIXER_H) && !defined(_MIXER_H_)
#error "---------------------------------------------------" #error "---------------------------------------------------"
#error "If you installed SDL_mixer from a package, be sure" #error "If you installed SDL_mixer from a package, be sure"
#error "to get the development package, as well!" #error "to get the development package, as well!"
@ -389,7 +353,6 @@ static void win32_perror(const char * const str)
#endif #endif
#ifndef WIN32
#ifdef __GNUC__ #ifdef __GNUC__
// This version has strict type checking for safety. // This version has strict type checking for safety.
// See the "unnecessary" pointer comparison. (from Linux) // See the "unnecessary" pointer comparison. (from Linux)
@ -407,7 +370,6 @@ static void win32_perror(const char * const str)
#define min(a,b) (((a) < (b)) ? (a) : (b)) #define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b))
#endif #endif
#endif
#define clamp(lo,value,hi) (min(max(value,lo),hi)) #define clamp(lo,value,hi) (min(max(value,lo),hi))
@ -718,25 +680,12 @@ static void set_current_language(void)
lang = LANG_EN; lang = LANG_EN;
#ifndef WIN32
loc = setlocale(LC_MESSAGES, NULL); loc = setlocale(LC_MESSAGES, NULL);
if (loc != NULL) if (loc != NULL)
{ {
if (strstr(loc, "LC_MESSAGES") != NULL) if (strstr(loc, "LC_MESSAGES") != NULL)
loc = getenv("LANG"); loc = getenv("LANG");
} }
#else
loc = getenv("LANGUAGE");
if (!loc)
{
loc = g_win32_getlocale();
if (loc)
{
snprintf(str, sizeof(str), "LANGUAGE=%s", loc);
putenv(strdup(str));
}
}
#endif
debug(loc); debug(loc);
@ -15123,7 +15072,7 @@ static int charsize(char c)
str[0] = c; str[0] = c;
str[1] = '\0'; str[1] = '\0';
TTF_SizeUNICODE(fonts[cur_font], str, &w, &h); TTF_SizeUNICODE(getfonthandle(cur_font), str, &w, &h);
return w; return w;
} }

View file

@ -23,14 +23,14 @@
/* Oct. 07, 2003 - added banding support */ /* Oct. 07, 2003 - added banding support */
/* - prints using 24-bit (not 32-bit) bitmap */ /* - prints using 24-bit (not 32-bit) bitmap */
#include <windows.h>
#include "SDL_syswm.h" #include "SDL_syswm.h"
#include "win32_print.h" #include "win32_print.h"
#include "resource.h"
#define NOREF(x) ((x)=(x)) #define NOREF(x) ((x)=(x))
#define GETHINST(hWnd) ((HINSTANCE)GetWindowLong( hWnd, GWL_HINSTANCE )) #define GETHINST(hWnd) ((HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE))
#define MIR( id ) (MAKEINTRESOURCE( id )) #define MIR(id) (MAKEINTRESOURCE(id))
static PRINTDLG global_pd = { static PRINTDLG global_pd = {
@ -42,11 +42,11 @@ static PRINTDLG global_pd = {
0xFFFF, 0xFFFF,
0xFFFF, 0xFFFF,
1, 1,
NULL, 0, 0, 0, 0, 0, 0, 0, 0,
}; };
static SDL_Surface *make24bitDIB( SDL_Surface *surf ) static SDL_Surface *make24bitDIB(SDL_Surface *surf)
{ {
SDL_PixelFormat pixfmt; SDL_PixelFormat pixfmt;
SDL_Surface *surf24; SDL_Surface *surf24;
@ -55,7 +55,7 @@ static SDL_Surface *make24bitDIB( SDL_Surface *surf )
Uint32 linesize; Uint32 linesize;
int i; int i;
memset( &pixfmt, 0, sizeof(pixfmt) ); memset(&pixfmt, 0, sizeof(pixfmt));
pixfmt.palette = NULL; pixfmt.palette = NULL;
pixfmt.BitsPerPixel = 24; pixfmt.BitsPerPixel = 24;
pixfmt.BytesPerPixel= 3; pixfmt.BytesPerPixel= 3;
@ -74,47 +74,47 @@ static SDL_Surface *make24bitDIB( SDL_Surface *surf )
pixfmt.colorkey = 0; pixfmt.colorkey = 0;
pixfmt.alpha = 0; pixfmt.alpha = 0;
surf24 = SDL_ConvertSurface( surf, &pixfmt, SDL_SWSURFACE ); surf24 = SDL_ConvertSurface(surf, &pixfmt, SDL_SWSURFACE);
surfDIB = SDL_CreateRGBSurface( SDL_SWSURFACE, surf24->w, surf24->h, 24, 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 linesize = surf24->w * 3; // Flip top2bottom
dst = surfDIB->pixels; dst = surfDIB->pixels;
src = ((Uint8*)surf24->pixels)+((surf24->h-1)*surf24->pitch); src = ((Uint8*)surf24->pixels)+((surf24->h-1)*surf24->pitch);
for ( i = 0; i < surf24->h; ++i ) for (i = 0; i < surf24->h; ++i)
{ {
memcpy( dst, src, linesize ); memcpy(dst, src, linesize);
src -= surf24->pitch; src -= surf24->pitch;
dst += surfDIB->pitch; dst += surfDIB->pitch;
} }
SDL_FreeSurface( surf24 ); // Free temp surface SDL_FreeSurface(surf24); // Free temp surface
return surfDIB; return surfDIB;
} }
/* returns 0 if failed */ /* returns 0 if failed */
static int GetDefaultPrinterStrings( char *device, char *driver, char *output ) static int GetDefaultPrinterStrings(char *device, char *driver, char *output)
{ {
const char *section = "windows";
const char *key = "device";
const char *def = "NODEFAULTPRINTER";
char buff[MAX_PATH]; char buff[MAX_PATH];
char *section = "windows";
char *key = "device";
char *def = "NODEFAULTPRINTER";
char *dev,*drv,*out; char *dev,*drv,*out;
if ( !GetProfileString( section, key, def, buff, sizeof(buff) ) ) if (!GetProfileString(section, key, def, buff, sizeof(buff)))
return 0; return 0;
if ( strcmp( buff, def ) == 0 ) if (strcmp(buff, def) == 0)
return 0; return 0;
if ( ((dev = strtok( buff, "," )) != NULL) && if (((dev = strtok(buff, "," )) != NULL) &&
((drv = strtok( NULL, ", ")) != NULL) && ((drv = strtok(NULL, ", ")) != NULL) &&
((out = strtok( NULL, ", ")) != NULL) ) ((out = strtok(NULL, ", ")) != NULL))
{ {
if ( device ) strcpy( device, dev ); if (device) strcpy(device, dev);
if ( driver ) strcpy( driver, drv ); if (driver) strcpy(driver, drv);
if ( output ) strcpy( output, out ); if (output) strcpy(output, out);
return 1; return 1;
} }
return 0; return 0;
@ -122,7 +122,7 @@ static int GetDefaultPrinterStrings( char *device, char *driver, char *output )
#define dmDeviceNameSize 32 #define dmDeviceNameSize 32
static HANDLE LoadCustomPrinterHDEVMODE( HWND hWnd, const char *filepath ) static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
{ {
char device[MAX_PATH]; char device[MAX_PATH];
HANDLE hPrinter = NULL; HANDLE hPrinter = NULL;
@ -134,151 +134,151 @@ static HANDLE LoadCustomPrinterHDEVMODE( HWND hWnd, const char *filepath )
int block_size; int block_size;
int block_read; int block_read;
if ( (fp = fopen( filepath, "rb" )) == NULL ) if ((fp = fopen(filepath, "rb")) == NULL)
return NULL; return NULL;
if ( fread( device, 1, dmDeviceNameSize, fp ) != dmDeviceNameSize ) if (fread(device, 1, dmDeviceNameSize, fp) != dmDeviceNameSize)
goto err_exit; goto err_exit;
if (!OpenPrinter( device, &hPrinter, NULL )) if (!OpenPrinter(device, &hPrinter, NULL))
return NULL; return NULL;
sizeof_devmode = (int)DocumentProperties( hWnd, hPrinter, device, sizeof_devmode = (int)DocumentProperties(hWnd, hPrinter, device,
NULL, NULL, 0 ); NULL, NULL, 0);
if ( !sizeof_devmode ) if (!sizeof_devmode)
goto err_exit; goto err_exit;
hDevMode = GlobalAlloc( GHND, sizeof_devmode ); hDevMode = GlobalAlloc(GHND, sizeof_devmode);
if ( !hDevMode ) if (!hDevMode)
goto err_exit; goto err_exit;
devmode = (DEVMODE*)GlobalLock( hDevMode ); devmode = (DEVMODE*)GlobalLock(hDevMode);
if ( !devmode ) if (!devmode)
goto err_exit; goto err_exit;
res = DocumentProperties( hWnd, hPrinter, device, devmode, NULL, res = DocumentProperties(hWnd, hPrinter, device, devmode, NULL,
DM_OUT_BUFFER); DM_OUT_BUFFER);
if ( res != IDOK ) if (res != IDOK)
goto err_exit; goto err_exit;
block_size = devmode->dmSize + devmode->dmDriverExtra; block_size = devmode->dmSize + devmode->dmDriverExtra;
block_read = fread( devmode, 1, block_size, fp ); block_read = fread(devmode, 1, block_size, fp);
if ( block_size != block_read ) if (block_size != block_read)
goto err_exit; goto err_exit;
fclose(fp); fclose(fp);
res = DocumentProperties( hWnd, hPrinter, device, devmode, devmode, res = DocumentProperties(hWnd, hPrinter, device, devmode, devmode,
DM_IN_BUFFER|DM_OUT_BUFFER); DM_IN_BUFFER|DM_OUT_BUFFER);
if ( res != IDOK ) if (res != IDOK)
goto err_exit; goto err_exit;
GlobalUnlock( hDevMode ); GlobalUnlock(hDevMode);
ClosePrinter( hPrinter ); ClosePrinter(hPrinter);
return hDevMode; return hDevMode;
err_exit: err_exit:
if ( fp ) fclose( fp ); if (fp) fclose(fp);
if ( devmode ) GlobalUnlock( hDevMode ); if (devmode) GlobalUnlock(hDevMode);
if ( hDevMode ) GlobalFree( hDevMode ); if (hDevMode) GlobalFree(hDevMode);
if ( hPrinter ) ClosePrinter( hPrinter ); if (hPrinter) ClosePrinter(hPrinter);
return NULL; 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; FILE *fp = NULL;
NOREF(hWnd); NOREF(hWnd);
if ( (fp = fopen( filepath, "wb" )) != NULL ) if ((fp = fopen(filepath, "wb")) != NULL)
{ {
DEVMODE *devmode = (DEVMODE*)GlobalLock( hDevMode ); DEVMODE *devmode = (DEVMODE*)GlobalLock(hDevMode);
int block_size = devmode->dmSize + devmode->dmDriverExtra; int block_size = devmode->dmSize + devmode->dmDriverExtra;
int block_written; int block_written;
char devname[dmDeviceNameSize]; char devname[dmDeviceNameSize];
strcpy( devname, (const char*)devmode->dmDeviceName ); strcpy(devname, (const char*)devmode->dmDeviceName);
fwrite( devname, 1, sizeof(devname), fp ); fwrite(devname, 1, sizeof(devname), fp);
block_written = fwrite( devmode, 1, block_size, fp ); block_written = fwrite(devmode, 1, block_size, fp);
GlobalUnlock( hDevMode ); GlobalUnlock(hDevMode);
fclose( fp ); fclose(fp);
return block_size == block_written; return block_size == block_written;
} }
return 0; return 0;
} }
static HDC GetCustomPrinterDC( HWND hWnd, const char *printcfg, int show ) static HDC GetCustomPrinterDC(HWND hWnd, const char *printcfg, int show)
{ {
global_pd.hwndOwner = hWnd; global_pd.hwndOwner = hWnd;
global_pd.hDC = NULL; global_pd.hDC = NULL;
global_pd.hDevNames = NULL; global_pd.hDevNames = NULL;
if ( global_pd.hDevMode == NULL ) if (global_pd.hDevMode == NULL)
{ {
global_pd.hDevMode = LoadCustomPrinterHDEVMODE( hWnd, printcfg ); global_pd.hDevMode = LoadCustomPrinterHDEVMODE(hWnd, printcfg);
} }
if ( show ) if (show)
{ {
if ( PrintDlg( &global_pd ) ) if (PrintDlg(&global_pd))
{ {
SaveCustomPrinterHDEVMODE( hWnd, printcfg, global_pd.hDevMode ); SaveCustomPrinterHDEVMODE(hWnd, printcfg, global_pd.hDevMode);
return global_pd.hDC; return global_pd.hDC;
} }
return NULL; return NULL;
} }
{ {
DEVMODE *devmode = (DEVMODE*)GlobalLock( global_pd.hDevMode ); 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 ); GlobalUnlock(global_pd.hDevMode);
} }
return global_pd.hDC; return global_pd.hDC;
} }
static HDC GetDefaultPrinterDC( void ) static HDC GetDefaultPrinterDC(void)
{ {
char device[MAX_PATH],driver[MAX_PATH],output[MAX_PATH]; char device[MAX_PATH],driver[MAX_PATH],output[MAX_PATH];
if ( GetDefaultPrinterStrings( device, driver, output ) ) if (GetDefaultPrinterStrings(device, driver, output))
return CreateDC( driver, device, output, NULL ); return CreateDC(driver, device, output, NULL);
return NULL; return NULL;
} }
static HDC GetPrinterDC( HWND hWnd, const char *printcfg, int show ) static HDC GetPrinterDC(HWND hWnd, const char *printcfg, int show)
{ {
if ( !printcfg ) return GetDefaultPrinterDC(); if (!printcfg) return GetDefaultPrinterDC();
return GetCustomPrinterDC( hWnd, printcfg, show ); return GetCustomPrinterDC(hWnd, printcfg, show);
} }
static int IsBandingRequired( HDC hPrinter ) static int IsBandingRequired(HDC hPrinter)
{ {
OSVERSIONINFO osvi; OSVERSIONINFO osvi;
int indata = NEXTBAND; int indata = NEXTBAND;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if ( GetVersionEx( &osvi ) && (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) ) 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; return 0;
} }
int IsPrinterAvailable( void ) int IsPrinterAvailable(void)
{ {
return (GetDefaultPrinterStrings( NULL, NULL, NULL ) != 0); return (GetDefaultPrinterStrings(NULL, NULL, NULL) != 0);
} }
const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialog ) const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog)
{ {
char *res = NULL; const char *res = NULL;
HWND hWnd; HWND hWnd;
DOCINFO di; DOCINFO di;
int nError; int nError;
@ -297,15 +297,15 @@ const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialo
HDC hdcMem = NULL; HDC hdcMem = NULL;
SDL_VERSION(&wminfo.version); SDL_VERSION(&wminfo.version);
if ( !SDL_GetWMInfo( &wminfo ) ) if (!SDL_GetWMInfo(&wminfo))
return "win32_print: SDL_GetWMInfo() failed."; return "win32_print: SDL_GetWMInfo() failed.";
hWnd = wminfo.window; hWnd = wminfo.window;
hDCprinter = GetPrinterDC( hWnd, printcfg, showdialog ); hDCprinter = GetPrinterDC(hWnd, printcfg, showdialog);
if ( !hDCprinter ) if (!hDCprinter)
return "win32_print: GetPrinterDC() failed."; return "win32_print: GetPrinterDC() failed.";
EnableWindow( hWnd, FALSE ); EnableWindow(hWnd, FALSE);
di.cbSize = sizeof(DOCINFO); di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "Tux Paint"; di.lpszDocName = "Tux Paint";
@ -313,14 +313,14 @@ const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialo
di.lpszDatatype = (LPTSTR)NULL; di.lpszDatatype = (LPTSTR)NULL;
di.fwType = 0; di.fwType = 0;
nError = StartDoc( hDCprinter, &di ); nError = StartDoc(hDCprinter, &di);
if ( nError == SP_ERROR ) if (nError == SP_ERROR)
{ {
res = "win32_print: StartDoc() failed."; res = "win32_print: StartDoc() failed.";
goto error; goto error;
} }
nError = StartPage( hDCprinter ); nError = StartPage(hDCprinter);
if (nError <= 0) if (nError <= 0)
{ {
res = "win32_print: StartPage() failed."; res = "win32_print: StartPage() failed.";
@ -329,14 +329,14 @@ const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialo
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
surf24 = make24bitDIB( surf ); surf24 = make24bitDIB(surf);
if ( !surf24 ) if (!surf24)
{ {
res = "win32_print: make24bitDIB() failed."; res = "win32_print: make24bitDIB() failed.";
goto error; goto error;
} }
memset( &bmih,0, sizeof(bmih) ); memset(&bmih, 0, sizeof(bmih));
bmih.biSize = sizeof(bmih); bmih.biSize = sizeof(bmih);
bmih.biPlanes = 1; bmih.biPlanes = 1;
bmih.biCompression = BI_RGB; bmih.biCompression = BI_RGB;
@ -344,25 +344,25 @@ const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialo
bmih.biWidth = surf24->w; bmih.biWidth = surf24->w;
bmih.biHeight = surf24->h; bmih.biHeight = surf24->h;
GetClientRect( hWnd, &rc ); GetClientRect(hWnd, &rc);
subscalerx = (float)rc.right/surf24->w; subscalerx = (float)rc.right/surf24->w;
subscalery = (float)rc.bottom/surf24->h; subscalery = (float)rc.bottom/surf24->h;
subscaler = subscalery; subscaler = subscalery;
if ( subscalerx < subscalery ) if (subscalerx < subscalery)
subscaler = subscalerx; subscaler = subscalerx;
hDCwindow = GetDC( hWnd ); hDCwindow = GetDC(hWnd);
if ( !hDCwindow ) if (!hDCwindow)
{ {
res = "win32_print: failed to get window DC."; res = "win32_print: failed to get window DC.";
goto error; goto error;
} }
fLogPelsX1 = (float)GetDeviceCaps(hDCwindow, LOGPIXELSX); fLogPelsX1 = GetDeviceCaps(hDCwindow, LOGPIXELSX);
fLogPelsY1 = (float)GetDeviceCaps(hDCwindow, LOGPIXELSY); fLogPelsY1 = GetDeviceCaps(hDCwindow, LOGPIXELSY);
ReleaseDC( hWnd, hDCwindow ); ReleaseDC(hWnd, hDCwindow);
fLogPelsX2 = (float)GetDeviceCaps(hDCprinter, LOGPIXELSX); fLogPelsX2 = GetDeviceCaps(hDCprinter, LOGPIXELSX);
fLogPelsY2 = (float)GetDeviceCaps(hDCprinter, LOGPIXELSY); fLogPelsY2 = GetDeviceCaps(hDCprinter, LOGPIXELSY);
if (fLogPelsX1 > fLogPelsX2) if (fLogPelsX1 > fLogPelsX2)
fScaleX = (fLogPelsX1/fLogPelsX2); fScaleX = (fLogPelsX1/fLogPelsX2);
@ -390,24 +390,24 @@ const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialo
goto error; goto error;
} }
if ( IsBandingRequired( hDCprinter ) ) if (IsBandingRequired(hDCprinter))
{ {
RECT rcBand = { 0 }; RECT rcBand = { 0, 0, 0, 0 };
RECT rcPrinter; RECT rcPrinter;
RECT rcImage; 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 ); SetRect(&rcImage, 0, 0, bmih.biWidth, bmih.biHeight);
while ( Escape(hDCprinter, NEXTBAND, 0, NULL, &rcBand) ) while (Escape(hDCprinter, NEXTBAND, 0, NULL, &rcBand))
{ {
if ( IsRectEmpty( &rcBand) ) break; if (IsRectEmpty(&rcBand)) break;
if ( IntersectRect( &rcBand, &rcBand, &rcPrinter ) ) if (IntersectRect(&rcBand, &rcBand, &rcPrinter))
{ {
rcImage.top = (int)(0.5f+(float)rcBand.top/fScaleX); rcImage.top = (int)(0.5f+(float)rcBand.top/fScaleX);
rcImage.bottom = (int)(0.5f+(float)rcBand.bottom/fScaleX); rcImage.bottom = (int)(0.5f+(float)rcBand.bottom/fScaleX);
SetStretchBltMode( hDCprinter, COLORONCOLOR ); SetStretchBltMode(hDCprinter, COLORONCOLOR);
nError = StretchDIBits(hDCprinter, rcBand.left, rcBand.top, nError = StretchDIBits(hDCprinter, rcBand.left, rcBand.top,
rcBand.right - rcBand.left, rcBand.right - rcBand.left,
rcBand.bottom - rcBand.top, rcBand.bottom - rcBand.top,
@ -416,7 +416,7 @@ const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialo
rcImage.bottom - rcImage.top, rcImage.bottom - rcImage.top,
surf24->pixels, (BITMAPINFO*)&bmih, surf24->pixels, (BITMAPINFO*)&bmih,
DIB_RGB_COLORS, SRCCOPY); DIB_RGB_COLORS, SRCCOPY);
if ( nError == GDI_ERROR ) if (nError == GDI_ERROR)
{ {
res = "win32_print: StretchDIBits() failed."; res = "win32_print: StretchDIBits() failed.";
goto error; goto error;
@ -426,7 +426,7 @@ const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialo
} }
else else
{ {
if ( hDCCaps & RC_STRETCHDIB ) if (hDCCaps & RC_STRETCHDIB)
{ {
SetStretchBltMode(hDCprinter, COLORONCOLOR); SetStretchBltMode(hDCprinter, COLORONCOLOR);
@ -436,7 +436,7 @@ const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialo
0, 0, bmih.biWidth, bmih.biHeight, 0, 0, bmih.biWidth, bmih.biHeight,
surf24->pixels, (BITMAPINFO*)&bmih, surf24->pixels, (BITMAPINFO*)&bmih,
DIB_RGB_COLORS, SRCCOPY); DIB_RGB_COLORS, SRCCOPY);
if ( nError == GDI_ERROR ) if (nError == GDI_ERROR)
{ {
res = "win32_print: StretchDIBits() failed."; res = "win32_print: StretchDIBits() failed.";
goto error; goto error;
@ -451,22 +451,22 @@ const char *SurfacePrint( SDL_Surface *surf, const char *printcfg, int showdialo
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
nError = EndPage( hDCprinter ); nError = EndPage(hDCprinter);
if ( nError <= 0 ) if (nError <= 0)
{ {
res = "win32_print: EndPage() failed."; res = "win32_print: EndPage() failed.";
goto error; goto error;
} }
EndDoc( hDCprinter ); EndDoc(hDCprinter);
error: error:
if ( hdcMem ) DeleteDC( hdcMem ); if (hdcMem) DeleteDC(hdcMem);
if ( hbm ) DeleteObject( hbm ); if (hbm) DeleteObject(hbm);
if ( surf24 ) SDL_FreeSurface( surf24 ); if (surf24) SDL_FreeSurface(surf24);
EnableWindow( hWnd, TRUE ); EnableWindow(hWnd, TRUE);
DeleteDC( hDCprinter ); DeleteDC(hDCprinter);
return res; return res;
} }

View file

@ -1,22 +1,22 @@
/* win32_print.h */ /* win32_print.h */
/* printing support for Tux Paint */ /* printing support for Tux Paint */
/* John Popplewell <john@johnnypops.demon.co.uk> */ /* John Popplewell <john@johnnypops.demon.co.uk> */
/* Sept. 30, 2002 - Oct. 1, 2002 */ /* Sept. 30, 2002 - Oct. 1, 2002 */
#ifndef __WIN32_PRINT_H__ #ifndef __WIN32_PRINT_H__
#define __WIN32_PRINT_H__ #define __WIN32_PRINT_H__
#ifndef _SDL_H #ifndef _SDL_H
#include "SDL.h" #include "SDL.h"
#endif #endif
/* if printcfg is NULL, uses the default printer */ /* if printcfg is NULL, uses the default printer */
extern const char *SurfacePrint( SDL_Surface *surf, extern const char *SurfacePrint( SDL_Surface *surf,
const char *printcfg, const char *printcfg,
int showdialog ); int showdialog );
extern int IsPrinterAvailable( void ); extern int IsPrinterAvailable( void );
#endif #endif