146
145
img = image_find(handle, device);
148
image_delete(img); /* remove from list but don't free */
147
image_delete(img); /* remove from list but don't free */
154
153
/* Device is about to be resized. */
155
154
/* Resize will only occur if this function returns 0. */
156
static int display_presize(void *handle, void *device, int width, int height,
157
int raster, unsigned int format)
155
static int display_presize(void *handle, void *device, int width, int height,
156
int raster, unsigned int format)
159
158
#ifdef DISPLAY_DEBUG
161
160
sprintf(buf, "display_presize(0x%x, 0x%x, width=%d height=%d raster=%d\n\
163
162
handle, device, width, height, raster, format);
164
163
text_puts(tw, buf);
169
168
/* Device has been resized. */
170
169
/* New pointer to raster returned in pimage */
171
static int display_size(void *handle, void *device, int width, int height,
172
int raster, unsigned int format, unsigned char *pimage)
170
static int display_size(void *handle, void *device, int width, int height,
171
int raster, unsigned int format, unsigned char *pimage)
175
174
#ifdef DISPLAY_DEBUG
177
176
sprintf(buf, "display_size(0x%x, 0x%x, width=%d height=%d raster=%d\n\
178
format=%d image=0x%x)\n",
177
format=%d image=0x%x)\n",
179
178
handle, device, width, height, raster, format, pimage);
180
179
text_puts(tw, buf);
229
int display_separation(void *handle, void *device,
228
int display_separation(void *handle, void *device,
230
229
int comp_num, const char *name,
231
230
unsigned short c, unsigned short m,
232
231
unsigned short y, unsigned short k)
235
234
#ifdef DISPLAY_DEBUG
236
fprintf(stdout, "display_separation(0x%x, 0x%x, %d '%s' %d,%d,%d,%d)\n",
237
handle, device, comp_num, name, (int)c, (int)m, (int)y, (int)k);
235
fprintf(stdout, "display_separation(0x%x, 0x%x, %d '%s' %d,%d,%d,%d)\n",
236
handle, device, comp_num, name, (int)c, (int)m, (int)y, (int)k);
239
238
img = image_find(handle, device);
297
295
gsdll.set_display_callback(instance, &display);
299
297
/* insert display device defaults as first arguments */
300
{ int format = DISPLAY_COLORS_NATIVE | DISPLAY_ALPHA_NONE |
301
DISPLAY_DEPTH_1 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
302
HDC hdc = GetDC(NULL); /* get hdc for desktop */
303
int depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
304
sprintf(ddpi, "-dDisplayResolution=%d", GetDeviceCaps(hdc, LOGPIXELSY));
298
{ int format = DISPLAY_COLORS_NATIVE | DISPLAY_ALPHA_NONE |
299
DISPLAY_DEPTH_1 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
300
HDC hdc = GetDC(NULL); /* get hdc for desktop */
301
int depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
302
sprintf(ddpi, "-dDisplayResolution=%d", GetDeviceCaps(hdc, LOGPIXELSY));
305
303
ReleaseDC(NULL, hdc);
307
format = DISPLAY_COLORS_RGB | DISPLAY_UNUSED_LAST |
308
DISPLAY_DEPTH_8 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
309
else if (depth == 16)
310
format = DISPLAY_COLORS_NATIVE | DISPLAY_ALPHA_NONE |
311
DISPLAY_DEPTH_16 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST |
314
format = DISPLAY_COLORS_RGB | DISPLAY_ALPHA_NONE |
315
DISPLAY_DEPTH_8 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
317
format = DISPLAY_COLORS_NATIVE | DISPLAY_ALPHA_NONE |
318
DISPLAY_DEPTH_8 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
320
format = DISPLAY_COLORS_NATIVE | DISPLAY_ALPHA_NONE |
321
DISPLAY_DEPTH_4 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
305
format = DISPLAY_COLORS_RGB | DISPLAY_UNUSED_LAST |
306
DISPLAY_DEPTH_8 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
307
else if (depth == 16)
308
format = DISPLAY_COLORS_NATIVE | DISPLAY_ALPHA_NONE |
309
DISPLAY_DEPTH_16 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST |
312
format = DISPLAY_COLORS_RGB | DISPLAY_ALPHA_NONE |
313
DISPLAY_DEPTH_8 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
315
format = DISPLAY_COLORS_NATIVE | DISPLAY_ALPHA_NONE |
316
DISPLAY_DEPTH_8 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
318
format = DISPLAY_COLORS_NATIVE | DISPLAY_ALPHA_NONE |
319
DISPLAY_DEPTH_4 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST;
322
320
sprintf(dformat, "-dDisplayFormat=%d", format);
324
322
nargc = argc + 2;
424
423
* "arg1 arg2" if called with CreateProcess(NULL, command, ...)
425
424
* "arg2" if called with CreateProcess(command, args, ...)
426
425
* GetCommandLine() returns
427
* ""gswin32c.exe" arg1 arg2"
426
* ""gswin32c.exe" arg1 arg2"
428
427
* if called with CreateProcess(NULL, command, ...)
430
429
* if called with CreateProcess(command, args, ...)
431
* Consequently we must use GetCommandLine()
430
* Consequently we must use GetCommandLine()
432
#ifdef WINDOWS_NO_UNICODE
433
433
p = GetCommandLine();
436
wchar_t *uni = GetCommandLineW();
437
pstart = p = malloc(wchar_to_utf8(NULL, uni));
439
wchar_to_utf8(p, uni);
436
444
args = (char *)malloc(lstrlen(p)+1);
437
445
if (args == (char *)NULL) {
438
fprintf(stdout, "Insufficient memory in WinMain()\n");
446
fprintf(stdout, "Insufficient memory in WinMain()\n");
442
450
/* Parse command line handling quotes. */
445
/* for each argument */
453
/* for each argument */
447
if (argc >= MAXCMDTOKENS - 1)
455
if (argc >= MAXCMDTOKENS - 1)
451
459
while ((*p) && (*p != ' ')) {
453
/* Remove quotes, skipping over embedded spaces. */
454
/* Doesn't handle embedded quotes. */
456
while ((*p) && (*p != '\042'))
461
/* Remove quotes, skipping over embedded spaces. */
462
/* Doesn't handle embedded quotes. */
464
while ((*p) && (*p != '\042'))
467
while ((*p) && (*p == ' '))
468
p++; /* Skip over trailing spaces */
475
while ((*p) && (*p == ' '))
476
p++; /* Skip over trailing spaces */
470
478
argv[argc] = NULL;
480
#ifndef WINDOWS_NO_UNICODE
472
484
if (strlen(argv[0]) == 0) {
473
GetModuleFileName(hInstance, command, sizeof(command)-1);
485
GetModuleFileName(hInstance, command, sizeof(command)-1);
479
490
if (tw == NULL) {
480
MessageBox((HWND)NULL, "Can't create text window",
481
szAppName, MB_OK | MB_ICONSTOP);
491
MessageBox((HWND)NULL, "Can't create text window",
492
szAppName, MB_OK | MB_ICONSTOP);
485
496
/* start up the text window */
486
497
if (!hPrevInstance) {
487
HICON hicon = LoadIcon(hInstance, (LPSTR)MAKEINTRESOURCE(GSTEXT_ICON));
488
text_register_class(tw, hicon);
498
HICON hicon = LoadIcon(hInstance, (LPSTR)MAKEINTRESOURCE(GSTEXT_ICON));
499
text_register_class(tw, hicon);
491
502
text_size(tw, 80, 80);
492
503
text_drag(tw, "(", ") run\r");
493
504
if (win_get_reg_value("Text", winposbuf, &len) == 0) {
494
if (sscanf(winposbuf, "%d %d %d %d", &x, &y, &cx, &cy) == 4)
495
text_setpos(tw, x, y, cx, cy);
505
if (sscanf(winposbuf, "%d %d %d %d", &x, &y, &cx, &cy) == 4)
506
text_setpos(tw, x, y, cx, cy);
498
509
/* create the text window */
499
510
if (text_create(tw, szAppName, cmdShow))
502
513
hwndtext = text_get_handle(tw);
503
514
image_textwindow(hwndtext);
505
516
dll_exit_status = new_main(argc, argv);
507
518
if (dll_exit_status && !tw->quitnow) {
508
/* display error message in text window */
510
text_puts(tw, "\nClose this window with the close button on the title bar or the system menu.\n");
511
if (IsIconic(text_get_handle(tw)))
512
ShowWindow(text_get_handle(tw), SW_SHOWNORMAL);
513
BringWindowToTop(text_get_handle(tw)); /* make text window visible */
514
FlashWindow(text_get_handle(tw), TRUE);
515
/* Wait until error message is read */
516
while (!tw->quitnow && GetMessage(&msg, (HWND)NULL, 0, 0)) {
517
TranslateMessage(&msg);
518
DispatchMessage(&msg);
519
/* display error message in text window */
521
text_puts(tw, "\nClose this window with the close button on the title bar or the system menu.\n");
522
if (IsIconic(text_get_handle(tw)))
523
ShowWindow(text_get_handle(tw), SW_SHOWNORMAL);
524
BringWindowToTop(text_get_handle(tw)); /* make text window visible */
525
FlashWindow(text_get_handle(tw), TRUE);
526
/* Wait until error message is read */
527
while (!tw->quitnow && GetMessage(&msg, (HWND)NULL, 0, 0)) {
528
TranslateMessage(&msg);
529
DispatchMessage(&msg);
522
533
/* Save the text window size */
523
534
if (text_getpos(tw, &x, &y, &cx, &cy) == 0) {
524
sprintf(winposbuf, "%d %d %d %d", x, y, cx, cy);
525
win_set_reg_value("Text", winposbuf);
535
sprintf(winposbuf, "%d %d %d %d", x, y, cx, cy);
536
win_set_reg_value("Text", winposbuf);
528
539
text_destroy(tw);