indent win32_print.c win32_print.h
This commit is contained in:
parent
f8c4dc626c
commit
527de8bee2
2 changed files with 160 additions and 175 deletions
|
|
@ -67,8 +67,7 @@ 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;
|
||||
|
|
@ -101,8 +100,7 @@ static int GetDefaultPrinterStrings(char *device, char *driver, char *output)
|
|||
return 0;
|
||||
|
||||
if (((dev = strtok(buff, ",")) != NULL) &&
|
||||
((drv = strtok(NULL, ", ")) != NULL) &&
|
||||
((out = strtok(NULL, ", ")) != NULL))
|
||||
((drv = strtok(NULL, ", ")) != NULL) && ((out = strtok(NULL, ", ")) != NULL))
|
||||
{
|
||||
if (device)
|
||||
strcpy(device, dev);
|
||||
|
|
@ -138,8 +136,7 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
|
|||
if (!OpenPrinter(device, &hPrinter, NULL))
|
||||
goto err_exit;
|
||||
|
||||
sizeof_devmode = (int) DocumentProperties(hWnd, hPrinter, device,
|
||||
NULL, NULL, 0);
|
||||
sizeof_devmode = (int)DocumentProperties(hWnd, hPrinter, device, NULL, NULL, 0);
|
||||
|
||||
if (!sizeof_devmode)
|
||||
goto err_exit;
|
||||
|
|
@ -152,8 +149,7 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
|
|||
if (!devmode)
|
||||
goto err_exit;
|
||||
|
||||
res = DocumentProperties(hWnd, hPrinter, device, devmode, NULL,
|
||||
DM_OUT_BUFFER);
|
||||
res = DocumentProperties(hWnd, hPrinter, device, devmode, NULL, DM_OUT_BUFFER);
|
||||
if (res != IDOK)
|
||||
goto err_exit;
|
||||
|
||||
|
|
@ -163,8 +159,7 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
|
|||
goto err_exit;
|
||||
fclose(fp);
|
||||
|
||||
res = DocumentProperties(hWnd, hPrinter, device, devmode, devmode,
|
||||
DM_IN_BUFFER | DM_OUT_BUFFER);
|
||||
res = DocumentProperties(hWnd, hPrinter, device, devmode, devmode, DM_IN_BUFFER | DM_OUT_BUFFER);
|
||||
if (res != IDOK)
|
||||
goto err_exit;
|
||||
|
||||
|
|
@ -185,8 +180,7 @@ err_exit:
|
|||
}
|
||||
|
||||
|
||||
static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath,
|
||||
HANDLE hDevMode)
|
||||
static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath, HANDLE hDevMode)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
|
|
@ -198,7 +192,7 @@ static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath,
|
|||
int block_written;
|
||||
char devname[dmDeviceNameSize];
|
||||
|
||||
strcpy(devname, (const char *) devmode->dmDeviceName);
|
||||
strcpy(devname, (const char *)devmode->dmDeviceName);
|
||||
fwrite(devname, 1, sizeof(devname), fp);
|
||||
block_written = fwrite(devmode, 1, block_size, fp);
|
||||
GlobalUnlock(hDevMode);
|
||||
|
|
@ -252,8 +246,7 @@ static int GetCustomPrinterDC(HWND hWnd, const char *printcfg, int show)
|
|||
{
|
||||
DEVMODE *devmode = (DEVMODE *) GlobalLock(pd.hDevMode);
|
||||
|
||||
hDCprinter =
|
||||
CreateDC(NULL, (const char *) devmode->dmDeviceName, NULL, devmode);
|
||||
hDCprinter = CreateDC(NULL, (const char *)devmode->dmDeviceName, NULL, devmode);
|
||||
GlobalUnlock(pd.hDevMode);
|
||||
GlobalFree(pd.hDevMode);
|
||||
}
|
||||
|
|
@ -292,8 +285,7 @@ int IsPrinterAvailable(void)
|
|||
#define STRETCH_TO_FIT 0
|
||||
#define SCALE_TO_FIT 1
|
||||
|
||||
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;
|
||||
|
|
@ -374,8 +366,10 @@ const char *SurfacePrint(SDL_Surface * surf, const char *printcfg,
|
|||
{
|
||||
/* stretches x and y dimensions independently to fit the page */
|
||||
/* doesn't preserve image aspect-ratio */
|
||||
rcDst.top = 0; rcDst.left = 0;
|
||||
rcDst.bottom = pageHeight; rcDst.right = pageWidth;
|
||||
rcDst.top = 0;
|
||||
rcDst.left = 0;
|
||||
rcDst.bottom = pageHeight;
|
||||
rcDst.right = pageWidth;
|
||||
break;
|
||||
}
|
||||
case SCALE_TO_FIT:
|
||||
|
|
@ -393,29 +387,29 @@ const char *SurfacePrint(SDL_Surface * surf, const char *printcfg,
|
|||
if (dW < dH)
|
||||
{
|
||||
width = pageWidth;
|
||||
height = (int)((height * dW * (sY/sX)) + 0.5f);
|
||||
height = (int)((height * dW * (sY / sX)) + 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
width = (int)((width * dH * (sX/sY)) + 0.5f);
|
||||
width = (int)((width * dH * (sX / sY)) + 0.5f);
|
||||
height = pageHeight;
|
||||
}
|
||||
}
|
||||
if (width > pageWidth)
|
||||
{
|
||||
height= height*width/pageWidth;
|
||||
height = height * width / pageWidth;
|
||||
width = pageWidth;
|
||||
}
|
||||
if (height > pageHeight)
|
||||
{
|
||||
width= width*height/pageHeight;
|
||||
width = width * height / pageHeight;
|
||||
height = pageHeight;
|
||||
}
|
||||
|
||||
rcDst.top = 0;
|
||||
rcDst.left = (pageWidth-width)/2;
|
||||
rcDst.bottom = rcDst.top+height;
|
||||
rcDst.right = rcDst.left+width;
|
||||
rcDst.left = (pageWidth - width) / 2;
|
||||
rcDst.bottom = rcDst.top + height;
|
||||
rcDst.right = rcDst.left + width;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -439,8 +433,7 @@ const char *SurfacePrint(SDL_Surface * surf, const char *printcfg,
|
|||
rcDst.right - rcDst.left,
|
||||
rcDst.bottom - rcDst.top,
|
||||
0, 0, bmih.biWidth, bmih.biHeight,
|
||||
surf24->pixels, (BITMAPINFO *) & bmih,
|
||||
DIB_RGB_COLORS, SRCCOPY);
|
||||
surf24->pixels, (BITMAPINFO *) & bmih, DIB_RGB_COLORS, SRCCOPY);
|
||||
if (nError == GDI_ERROR)
|
||||
{
|
||||
res = "win32_print: StretchDIBits() failed.";
|
||||
|
|
@ -482,8 +475,7 @@ 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;
|
||||
|
|
@ -491,9 +483,7 @@ static HRESULT ReadRegistry(const char *key, const char *option, char *value,
|
|||
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;
|
||||
|
|
@ -529,8 +519,7 @@ 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;
|
||||
|
||||
|
|
@ -551,8 +540,7 @@ 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;
|
||||
|
||||
|
|
@ -599,7 +587,7 @@ static int g_bWindowActive = 0;
|
|||
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int bEatKeystroke = 0;
|
||||
KBDLLHOOKSTRUCT *p = (KBDLLHOOKSTRUCT*)lParam;
|
||||
KBDLLHOOKSTRUCT *p = (KBDLLHOOKSTRUCT *) lParam;
|
||||
|
||||
if (nCode < 0 || nCode != HC_ACTION)
|
||||
return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
|
||||
|
|
@ -614,7 +602,7 @@ LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
}
|
||||
|
||||
if(bEatKeystroke)
|
||||
if (bEatKeystroke)
|
||||
return 1;
|
||||
return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
|
@ -640,5 +628,3 @@ void SetActivationState(int state)
|
|||
{
|
||||
g_bWindowActive = state;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@
|
|||
#endif
|
||||
|
||||
/* if printcfg is NULL, uses the default printer */
|
||||
extern const char *SurfacePrint(SDL_Surface * surf,
|
||||
const char *printcfg, int showdialog);
|
||||
extern const char *SurfacePrint(SDL_Surface * surf, 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