📄 gvpprn.c
字号:
{int needed;
char *desc, *p, *q;
/* draw window immediately */
WinShowWindow(hwnd, TRUE);
WinInvalidateRect(hwnd, (PRECTL)NULL, TRUE);
WinUpdateWindow(hwnd);
desc = NULL;
uppname[0] = uppname[1] = '\0';
i = 8192; /* a guess */
if ((ubuf = (char *)malloc(i)) == (char *)NULL) {
play_sound(SOUND_ERROR);
WinPostMsg(hwnd, WM_COMMAND, (MPARAM)DID_CANCEL,
MPFROM2SHORT(CMDSRC_OTHER, TRUE));
return (MRESULT)TRUE; /* no memory */
}
needed = enum_upp_path(option.gsinclude, ubuf, i);
if (needed > i) {
/* our guess wasn't big enough */
free(ubuf);
if ((ubuf = (char *)malloc(needed)) == (char *)NULL) {
play_sound(SOUND_ERROR);
WinPostMsg(hwnd, WM_COMMAND, (MPARAM)DID_CANCEL,
MPFROM2SHORT(CMDSRC_OTHER, TRUE));
return (MRESULT)TRUE; /* no memory */
}
enum_upp_path(option.gsinclude, ubuf, needed);
}
GetUPPname(hwnd, uppname, sizeof(uppname));
WinSendMsg(WinWindowFromID(hwnd, UPP_LIST), LM_DELETEALL,
(MPARAM)0, (MPARAM)0);
for (p = ubuf; *p!='\0'; p += strlen(p) + 1) {
q = p + strlen(p) + 1;
if (strcmp(p, (char *)uppname) == 0)
desc = q;
WinSendMsg( WinWindowFromID(hwnd, UPP_LIST), LM_INSERTITEM,
MPFROMLONG(LIT_SORTASCENDING), MPFROMP(q) );
p = q;
}
if (desc != (LPSTR)NULL) {
i = (int)WinSendMsg( WinWindowFromID(hwnd, UPP_LIST),
LM_SEARCHSTRING,
MPFROM2SHORT(LSS_CASESENSITIVE, LIT_FIRST),
MPFROMP(desc) );
if ((i != LIT_ERROR) && (i != LIT_NONE)) {
WinSendMsg( WinWindowFromID(hwnd, UPP_LIST),
LM_SELECTITEM, MPFROMLONG(i), MPFROMLONG(TRUE) );
WinSendMsg(WinWindowFromID(hwnd, UPP_LIST),
LM_SETTOPINDEX, MPFROMLONG(i), (MPARAM)0);
}
}
WinSetWindowText(WinWindowFromID(hwnd, UPP_NAME), uppname);
WinEnableWindow(WinWindowFromID(hwnd, UPP_LIST), TRUE);
}
return (MRESULT)TRUE;
case ID_HELP:
get_help();
return (MRESULT)TRUE;
case DID_OK:
if (WinQueryWindowText(WinWindowFromID(hwnd, UPP_NAME),
sizeof(uppname)-3, uppname+2)) {
uppname[0] = '"';
uppname[1] = '@';
strcat((char *)uppname, "\042");
WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd,
QW_OWNER), DEVICE_OPTIONS), uppname);
}
if (ubuf)
free(ubuf);
WinDismissDlg(hwnd, DID_OK);
return (MRESULT)TRUE;
case DID_CANCEL:
if (ubuf)
free(ubuf);
WinDismissDlg(hwnd, DID_CANCEL);
return (MRESULT)TRUE;
}
break;
}
return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
/* dialog box for selecting PostScript prolog/epilog and Ctrl+D */
MRESULT EXPENTRY
AdvPSDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
switch (msg) {
case WM_INITDLG:
{
/* for PostScript printers, provide options for sending
* Ctrl+D before and after job, and sending a prolog
* and epilog file.
* These are set using the Advanced button on the Printer
* Setup dialog, only enabled for PostScript printer.
*/
PROFILE *prf;
char buf[MAXSTR];
char section[MAXSTR];
int prectrld=0;
int postctrld=0;
int i = (int)WinSendMsg(
WinWindowFromID(WinQueryWindow(hwnd, QW_OWNER), SPOOL_PORT),
LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), (MPARAM)0);
WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_OWNER), SPOOL_PORT),
LM_QUERYITEMTEXT, MPFROM2SHORT(i, sizeof(section)),
MPFROMP(section));
WinSendMsg( WinWindowFromID(hwnd, ADVPS_PROLOG),
EM_SETTEXTLIMIT, MPFROM2SHORT(MAXSTR, 0), MPFROMLONG(0) );
WinSendMsg( WinWindowFromID(hwnd, ADVPS_EPILOG),
EM_SETTEXTLIMIT, MPFROM2SHORT(MAXSTR, 0), MPFROMLONG(0) );
if ( (prf = profile_open(szIniFile)) != (PROFILE *)NULL ) {
profile_read_string(prf, section, "PreCtrlD", "0", buf,
sizeof(buf)-2);
if (sscanf(buf, "%d", &prectrld) != 1)
prectrld = 0;
WinSendMsg( WinWindowFromID(hwnd, ADVPS_PRECTRLD),
BM_SETCHECK, MPFROMLONG(prectrld ? 1 : 0), MPFROMLONG(0));
profile_read_string(prf, section, "PostCtrlD", "0", buf,
sizeof(buf)-2);
if (sscanf(buf, "%d", &postctrld) != 1)
postctrld = 0;
WinSendMsg( WinWindowFromID(hwnd, ADVPS_POSTCTRLD),
BM_SETCHECK, MPFROMLONG(postctrld ? 1 : 0), MPFROMLONG(0));
profile_read_string(prf, section, "Prolog", "", buf,
sizeof(buf)-2);
WinSetWindowText(WinWindowFromID(hwnd, ADVPS_PROLOG), (PCSZ)buf);
profile_read_string(prf, section, "Epilog", "", buf,
sizeof(buf)-2);
WinSetWindowText(WinWindowFromID(hwnd, ADVPS_EPILOG), (PCSZ)buf);
profile_close(prf);
}
}
break;
case WM_COMMAND:
switch(LOUSHORT(mp1)) {
case ADVPS_PROLOGBROWSE:
{ char buf[MAXSTR];
WinQueryWindowText(WinWindowFromID(hwnd, ADVPS_PROLOG),
sizeof(buf)-1, (PBYTE)buf);
if (get_filename(buf, FALSE, FILTER_ALL,
0, IDS_TOPICPRINT)) {
WinSetWindowText(WinWindowFromID(hwnd,
ADVPS_PROLOG), (PCSZ)buf);
}
}
return (MRESULT)TRUE;
case ADVPS_EPILOGBROWSE:
{ char buf[MAXSTR];
WinQueryWindowText(WinWindowFromID(hwnd, ADVPS_EPILOG),
sizeof(buf)-1, (PBYTE)buf);
if (get_filename(buf, FALSE, FILTER_ALL,
0, IDS_TOPICPRINT)) {
WinSetWindowText(WinWindowFromID(hwnd,
ADVPS_EPILOG), (PCSZ)buf);
}
}
return (MRESULT)TRUE;
case ID_HELP:
get_help();
return (MRESULT)TRUE;
case DID_OK:
{ PROFILE *prf;
int i;
char buf[MAXSTR];
char section[MAXSTR];
i = (int)WinSendMsg(
WinWindowFromID(WinQueryWindow(hwnd, QW_OWNER), SPOOL_PORT),
LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), (MPARAM)0);
WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_OWNER), SPOOL_PORT),
LM_QUERYITEMTEXT, MPFROM2SHORT(i, sizeof(section)),
MPFROMP(section));
if ( (prf = profile_open(szIniFile)) != (PROFILE *)NULL ) {
i = (int)WinSendMsg( WinWindowFromID(hwnd, ADVPS_PRECTRLD),
BM_QUERYCHECK, MPFROMLONG(0), MPFROMLONG(0));
profile_write_string(prf, section, "PreCtrlD",
i ? "1" : "0");
i = (int)WinSendMsg( WinWindowFromID(hwnd, ADVPS_POSTCTRLD),
BM_QUERYCHECK, MPFROMLONG(0), MPFROMLONG(0));
profile_write_string(prf, section, "PostCtrlD",
i ? "1" : "0");
WinQueryWindowText(WinWindowFromID(hwnd, ADVPS_PROLOG),
sizeof(buf)-1, (PBYTE)buf);
profile_write_string(prf, section, "Prolog", buf);
WinQueryWindowText(WinWindowFromID(hwnd, ADVPS_EPILOG),
sizeof(buf)-1, (PBYTE)buf);
profile_write_string(prf, section, "Epilog", buf);
profile_close(prf);
}
}
WinDismissDlg(hwnd, DID_OK);
return (MRESULT)TRUE;
case DID_CANCEL:
WinDismissDlg(hwnd, DID_CANCEL);
return (MRESULT)TRUE;
}
break;
}
return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
void init_fixed_media(HWND hwnd, int id, int fixed_media)
{
char buf[MAXSTR];
// Fill in Page Size combo box
strcpy(buf, "Variable");
load_string(IDS_PAGESIZE_VARIABLE, buf, sizeof(buf));
WinSendMsg( WinWindowFromID(hwnd, id),
LM_INSERTITEM, MPFROMLONG(LIT_END), MPFROMP(buf) );
strcpy(buf, "Fixed");
load_string(IDS_PAGESIZE_FIXED, buf, sizeof(buf));
WinSendMsg( WinWindowFromID(hwnd, id),
LM_INSERTITEM, MPFROMLONG(LIT_END), MPFROMP(buf) );
strcpy(buf, "Shrink");
load_string(IDS_PAGESIZE_SHRINK, buf, sizeof(buf));
WinSendMsg( WinWindowFromID(hwnd, id),
LM_INSERTITEM, MPFROMLONG(LIT_END), MPFROMP(buf) );
WinSendMsg( WinWindowFromID(hwnd, id),
LM_SELECTITEM, MPFROMLONG(fixed_media), MPFROMLONG(TRUE) );
}
char *device_queue_list;
int device_queue_index;
/* dialog box for selecting printer device and resolution */
MRESULT EXPENTRY
DeviceDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
char buf[128];
int idevice;
int i;
char *p;
char *res;
char *s;
int numentry;
char entry[MAXSTR];
struct prop_item_s *proplist;
static BOOL bConvert;
switch (msg) {
case WM_INITDLG:
bConvert = (BOOL)mp2;
WinSendMsg( WinWindowFromID(hwnd, DEVICE_OPTIONS),
EM_SETTEXTLIMIT, MPFROM2SHORT(MAXSTR, 0), MPFROMLONG(0) );
/* fill in device, resolution list boxes */
p = get_devices(bConvert);
res = p; /* save for free() */
idevice = -1;
s = bConvert ? option.convert_device : option.printer_device;
if (strlen(s) == 0)
idevice = 0;
for (numentry=0; p!=(char *)NULL && strlen(p)!=0; numentry++) {
WinSendMsg( WinWindowFromID(hwnd, DEVICE_NAME),
LM_INSERTITEM, MPFROMLONG(LIT_END), MPFROMP(p) );
if (strcmp(p, s) == 0)
idevice = numentry;
p += strlen(p) + 1;
}
if (res)
free(res);
if (idevice < 0)
WinSetWindowText(WinWindowFromID(hwnd, DEVICE_NAME),
(unsigned char *)(s));
else
WinSendMsg( WinWindowFromID(hwnd, DEVICE_NAME),
LM_SELECTITEM, MPFROMLONG(idevice), MPFROMLONG(TRUE) );
/* force update of DEVICE_RES */
s = bConvert ? option.convert_resolution : option.printer_resolution;
WinSendMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DEVICE_NAME, CBN_LBSELECT),
MPFROMLONG(WinWindowFromID(hwnd, DEVICE_NAME)));
i = (int)WinSendMsg( WinWindowFromID(hwnd, DEVICE_RES),
LM_SEARCHSTRING, MPFROM2SHORT(LSS_CASESENSITIVE, LIT_FIRST),
MPFROMP(s) );
if ((i == LIT_ERROR) || (i == LIT_NONE))
WinSetWindowText(WinWindowFromID(hwnd, DEVICE_RES),
(unsigned char *)(s));
else
WinSendMsg( WinWindowFromID(hwnd, DEVICE_RES),
LM_SELECTITEM, MPFROMLONG(i), MPFROMLONG(TRUE) );
if (!bConvert) {
/* fill in queue list box */
p = device_queue_list;
device_queue_index = 0;
i = 0;
if (strlen(p)==0) {
/* no printers, so force Print to File */
option.print_to_file = TRUE;
option.print_method = PRINT_GS;
WinSendMsg( WinWindowFromID(hwnd, SPOOL_TOFILE),
BM_SETCHECK, MPFROMLONG(1), MPFROMLONG(0));
WinEnableWindow(WinWindowFromID(hwnd, SPOOL_TOFILE), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, SPOOL_PORT), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, SPOOL_PORTTEXT), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, DEVICE_PSPRINT), FALSE);
}
while (*p) {
if ( strcmp(p, option.printer_queue) == 0 )
device_queue_index = i;
p += strlen(p)+1; /* skip to queue comment */
if (*p) {
WinSendMsg( WinWindowFromID(hwnd, SPOOL_PORT),
LM_INSERTITEM, MPFROMLONG(LIT_END), MPFROMP(p));
p += strlen(p)+1;
}
i++;
}
if (option.print_method == PRINT_PS) {
WinSendMsg( WinWindowFromID(hwnd, DEVICE_PSPRINT),
BM_SETCHECK, MPFROMLONG(1), MPFROMLONG(0));
WinEnableWindow(WinWindowFromID(hwnd, DEVICE_NAMETEXT), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, DEVICE_NAME), FALSE);
WinSendMsg(hwnd, WM_CONTROL,
MPFROM2SHORT(DEVICE_NAME, CBN_LBSELECT),
MPFROMLONG(WinWindowFromID(hwnd, DEVICE_NAME)));
WinEnableWindow(WinWindowFromID(hwnd, DEVICE_PROP), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, SPOOL_TOFILE), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, DEVICE_OPTIONSTEXT),
FALSE);
WinEnableWindow(WinWindowFromID(hwnd, DEVICE_OPTIONS), FALSE);
WinSendMsg( WinWindowFromID(hwnd, SPOOL_PORT),
LM_SELECTITEM, MPFROMLONG(device_queue_index),
MPFROMLONG(TRUE) );
}
else {
WinEnableWindow(WinWindowFromID(hwnd, DEVICE_ADVPS), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, DEVICE_UNIPRINT), TRUE);
/* set Print to File check box */
if (option.print_to_file) {
WinSendMsg( WinWindowFromID(hwnd, SPOOL_TOFILE),
BM_SETCHECK, MPFROMLONG(1), MPFROMLONG(0));
WinEnableWindow(WinWindowFromID(hwnd, SPOOL_PORT), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, SPOOL_PORTTEXT),
FALSE);
}
else {
WinSendMsg( WinWindowFromID(hwnd, SPOOL_PORT),
LM_SELECTITEM, MPFROMLONG(device_queue_index),
MPFROMLONG(TRUE) );
}
}
}
/* fill in page list box */
if ( (psfile.dsc != (CDSC *)NULL) && (psfile.dsc->page_count != 0)) {
psfile.page_list.current = psfile.pagenum-1;
psfile.page_list.multiple = TRUE;
for (i=0; i< (int)psfile.dsc->page_count; i++)
psfile.page_list.select[i] = FALSE;
psfile.page_list.select[psfile.page_list.current] = TRUE;
psfile.page_list.reverse = option.print_reverse;
PageMultiDlgProc(hwnd, msg, mp1, mp2);
}
else {
psfile.page_list.multiple = FALSE;
WinEnableWindow(WinWindowFromID(hwnd, PAGE_ALL), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, PAGE_ODD), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, PAGE_EVEN), FALSE);
WinEnableWindow(WinWindowFromID(hwnd, PAGE_REVERSE), FALSE);
load_string(IDS_ALL, buf, sizeof(buf));
for (p=buf, i=0; *p; p++) {
if (*p != '~')
buf[i++] = *p;
}
buf[i] = '\0';
WinSendMsg( WinWindowFromID(hwnd, PAGE_LIST),
LM_INSERTITEM, MPFROMLONG(LIT_END), MPFROMP(buf) );
WinEnableWindow(WinWindowFromID(hwnd, PAGE_LIST), FALSE);
}
init_fixed_media(hwnd, DEVICE_FIXEDMEDIA, option.print_fixed_media);
break;
case WM_CONTROL:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -