📄 gvwinit.c
字号:
p = buf + strlen(buf) - 3;
if (isdigit((int)(p[0])) && (p[1]=='.') && isdigit((int)(p[2]))) {
strcpy(p, verstr);
SetDlgItemTextA(hwnd, IDC_CFG22, buf);
}
}
}
int
config_now(void)
{
BOOL assoc_ps;
BOOL assoc_pdf;
char buf[MAXSTR];
TCHAR wbuf[MAXSTR];
WIZPAGE *page;
FILE *f;
char *p;
/* get info from wizard */
page = find_page_from_id(IDD_CFG2);
option.gsversion = add_gsver(page->hwnd, 0);
GetDlgItemTextA(page->hwnd, IDC_CFG22, buf, sizeof(buf));
if (option.gsversion >= 593) {
sprintf(option.gsdll, "%s\\bin\\%s", buf, GS_DLLNAME);
}
else {
sprintf(option.gsdll, "%s\\%s", buf, GS_DLLNAME);
}
default_gsinclude_from_path(option.gsinclude, buf);
strcpy(option.gsother, "-dNOPLATFONTS ");
GetDlgItemTextA(page->hwnd, IDC_CFG23, buf, sizeof(buf));
if (strlen(buf)) {
strcat(option.gsother, "-sFONTPATH=\042");
strcat(option.gsother, buf);
strcat(option.gsother, "\042");
}
/* check if Ghostscript really has been installed */
/* first look for the DLL */
if ( (f = fopen(option.gsdll, "rb")) == (FILE *)NULL ) {
load_string(IDS_GSNOTINSTALLED, wbuf, sizeof(wbuf)/sizeof(TCHAR)-1);
SetDlgItemText(find_page_from_id(IDD_CFG7)->hwnd, IDC_CFG71,
wbuf);
return 1;
}
fclose(f);
/* next look for gs_init.ps */
strcpy(buf, option.gsinclude);
p = strchr(buf, ';'); /* remove trailing paths */
if (p)
*p = '\0';
strcat(buf, "\\gs_init.ps");
if ( (f = fopen(buf, "rb")) == (FILE *)NULL ) {
load_string(IDS_GSLIBNOTINSTALLED, wbuf, sizeof(wbuf));
SetDlgItemText(find_page_from_id(IDD_CFG7)->hwnd, IDC_CFG71,
wbuf);
return 1;
}
fclose(f);
/* at this stage we don't look for fonts, but maybe we should */
assoc_ps = (BOOL)SendDlgItemMessage(find_page_from_id(IDD_CFG4)->hwnd,
IDC_CFG41, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
assoc_pdf = (BOOL)SendDlgItemMessage(find_page_from_id(IDD_CFG4)->hwnd,
IDC_CFG42, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
if (update_registry(assoc_ps, assoc_pdf)) {
return 1;
}
GetDlgItemTextA(find_page_from_id(IDD_CFG5)->hwnd,
IDC_CFG52, buf, sizeof(buf));
if (SendDlgItemMessage(find_page_from_id(IDD_CFG5)->hwnd,
IDC_CFG51, BM_GETCHECK, (WPARAM)0, (LPARAM)0)
&& gsview_create_objects(buf)) {
return 1;
}
if (SendDlgItemMessage(find_page_from_id(IDD_CFG3)->hwnd,
IDC_CFG32, BM_GETCHECK, (WPARAM)0, (LPARAM)0))
gsview_printer_profiles();
option.configured = TRUE;
write_profile();
return 0;
}
int
config_finish(HWND hwnd)
{
EnableWindow(GetDlgItem(hwnd, IDNEXT), FALSE);
EnableWindow(GetDlgItem(hwnd, IDPREV), FALSE);
EnableWindow(GetDlgItem(hwnd, IDCANCEL), FALSE);
if (config_now())
{ TCHAR buf[MAXSTR];
load_string(IDS_CFG73, buf, sizeof(buf));
SetDlgItemText(find_page_from_id(IDD_CFG7)->hwnd, IDC_CFG70, buf);
}
return 0;
}
#ifdef __BORLANDC__
#pragma argsused
#endif
/* Download GS dialog box */
BOOL CALLBACK _export
DownloadGSDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hDlg, TRUE);
return(TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return(TRUE);
case ID_HELP:
get_help();
return(FALSE);
default:
return(FALSE);
}
}
return(FALSE);
}
int
config_wizard(BOOL bVerbose)
{
/* We don't use a configure wizard anymore - this is done in
* the setup program.
* Instead we have several options:
* 1. GS is installed on hard disk - offer the easy configure
* which relies on the setup program having written entries
* to the registry.
* 2. If GS not installed, or 1. fails, look for
* ..\gsN.NN\bin\gsdll32.dll
* If this exists, configure silently since we are either
* running from CD-ROM or network drive.
* 3. Tell user to download GS
*/
int gscount;
char basedir[MAXSTR];
char gsdir[MAXSTR];
char gsdll[MAXSTR];
int gsver;
char *p;
FILE *f;
/* 1. If GS installed, easy configure */
gscount = 0;
get_gs_versions(&gscount);
if (gscount > 0) {
if (config_easy(bVerbose) == 0)
return 0; /* success */
}
/* 2. GS not installed. Look for GS in adajacent directory */
convert_widechar(basedir, szExePath, sizeof(basedir));
p = strrchr(basedir, '\\'); /* remove trailing backslash */
if (p)
*p = '\0';
p = strrchr(basedir, '\\'); /* remove trailing gsview */
if (p)
*(++p) = '\0';
strcpy(gsdir, basedir);
p = gsdir + strlen(gsdir);
gs_addmess("Ghostscript registry entries not present.\n");
gsver = GS_REVISION;
while (gsver <= GS_REVISION_MAX) {
sprintf(p, "gs%d.%02d", gsver / 100, gsver % 100);
strcpy(gsdll, gsdir);
strcat(gsdll, "\\bin\\gsdll32.dll");
if ( (f = fopen(gsdll, "rb")) != (FILE *)NULL ) {
/* GS DLL exists. Configure GSview */
fclose(f);
gs_addmess("Found ");
gs_addmess(gsdll);
gs_addmess("\n");
option.gsversion = gsver;
strcpy(option.gsdll, gsdll);
sprintf(option.gsinclude, "%s\\lib;%sfonts", gsdir, basedir);
strcpy(option.gsother, "-dNOPLATFONTS -sFONTPATH=\042c:\\psfonts\042");
gsview_printer_profiles();
option.configured = TRUE;
write_profile();
return 0; /* success */
}
gsver++;
}
nHelpTopic = IDS_TOPICDOWNLOAD;
if (DialogBoxParamL(hlanguage, MAKEINTRESOURCE(IDD_DOWNLOAD), hwndimg,
DownloadGSDlgProc, (LPARAM)0)) {
/* download now */
ShellExecute(hwndimg, NULL,
TEXT("http://www.cs.wisc.edu/~ghost/index.htm"),
NULL, NULL, SW_SHOWNORMAL);
}
return 1; /* failed */
}
#ifdef __BORLANDC__
#pragma argsused /* ignore warning for next function */
#endif
/* Modeless Dialog Box */
BOOL CALLBACK _export
CfgMainDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_INITDIALOG:
/* create child dialog windows */
{
WIZPAGE *page;
TCHAR buf[MAXSTR];
TCHAR gsdir[MAXSTR];
int i;
for (page=pages; page->id; page++) {
page->hwnd = CreateDialogParamL(hlanguage,
MAKEINTRESOURCE(page->id), hwnd, CfgChildDlgProc,
(LPARAM)NULL);
ShowWindow(page->hwnd, SW_HIDE);
}
ShowWindow(pages[0].hwnd, SW_SHOW);
SetFocus(GetDlgItem(pages[0].hwnd, IDNEXT));
SendDlgItemMessage(pages[0].hwnd, IDNEXT, BM_SETSTYLE,
(WPARAM)BS_DEFPUSHBUTTON, TRUE);
hDlgModeless = pages[0].hwnd;
/* initialize GS version */
page = find_page_from_id(IDD_CFG2);
if (page) {
wsprintf(buf, TEXT("%d.%02d"), option.gsversion / 100,
option.gsversion % 100);
SetDlgItemText(page->hwnd, IDC_CFG20, buf);
SetDlgItemText(page->hwnd, IDC_CFG22, szExePath);
SetDlgItemText(page->hwnd, IDC_CFG23, TEXT("c:\\psfonts"));
}
/* assume that GS is in the adjacent directory */
wsprintf(buf, TEXT("%d.%02d"), option.gsversion / 100,
option.gsversion % 100);
lstrcpy(gsdir, szExePath);
/* remove trailing \ */
for (i=lstrlen(gsdir); i>0; i++)
if (gsdir[i] == '\\') {
gsdir[i] = '\0';
break;
}
/* remove trailing gsview */
for (i=lstrlen(gsdir); i>0; i++)
if (gsdir[i] == '\\') {
gsdir[i+1] = '\0';
break;
}
lstrcat(gsdir, TEXT("gs"));
lstrcat(gsdir, buf);
SetDlgItemText(page->hwnd, IDC_CFG22, gsdir);
SetDlgItemText(page->hwnd, IDC_CFG23, TEXT("c:\\psfonts"));
SendDlgItemMessage(find_page_from_id(IDD_CFG3)->hwnd, IDC_CFG32, BM_SETCHECK,
(WPARAM)1, (LPARAM)0);
SendDlgItemMessage(find_page_from_id(IDD_CFG4)->hwnd, IDC_CFG41, BM_SETCHECK,
(WPARAM)1, (LPARAM)0);
SendDlgItemMessage(find_page_from_id(IDD_CFG4)->hwnd, IDC_CFG42, BM_SETCHECK,
(WPARAM)0, (LPARAM)0); /* PDF is NOT the default */
/* program group */
load_string(IDS_PROGMANGROUP4, buf, sizeof(buf));
page = find_page_from_id(IDD_CFG5);
if (page) {
SendDlgItemMessage(page->hwnd, IDC_CFG51, BM_SETCHECK,
(WPARAM)1, (LPARAM)0);
SetDlgItemText(page->hwnd, IDC_CFG52, buf);
}
}
return FALSE; /* we decide the focus */
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
case IDOK:
EnableWindow(hwndimg, TRUE);
DestroyWindow(hwnd);
hDlgModeless = NULL;
post_args();
/* should post message to main window to delete thunks */
return(TRUE);
default:
return(FALSE);
}
case WM_CLOSE:
EnableWindow(hwndimg, TRUE);
DestroyWindow(hwnd);
hDlgModeless = NULL;
post_args();
return TRUE;
}
return FALSE;
}
#ifdef __BORLANDC__
#pragma argsused /* ignore warning for next function */
#endif
/* Modeless Dialog Box */
BOOL CALLBACK _export
CfgChildDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_INITDIALOG:
return( TRUE);
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
case IDNEXT:
next_page(hwnd);
return(TRUE);
case IDPREV:
SendDlgItemMessage(hwnd, IDPREV, BM_SETSTYLE,
(WPARAM)0, TRUE); /* remove default style */
prev_page(hwnd);
return(TRUE);
case IDCANCEL:
{ TCHAR buf[MAXSTR];
load_string(IDS_CFG74, buf, sizeof(buf));
SetDlgItemText(find_page_from_id(IDD_CFG7)->hwnd, IDC_CFG70, buf);
goto_page(hwnd, IDD_CFG7);
}
return(TRUE);
case IDC_CFG20:
if (GetNotification(wParam,lParam) == EN_CHANGE)
{ int ver;
char buf[16];
ver = add_gsver(hwnd, 0);
sprintf(buf, "%d.%02d", ver / 100, ver % 100);
/* don't use touch IDC_CFG20 - this would be recursive */
gsdir_fix(hwnd, buf);
}
return(TRUE);
default:
return(FALSE);
}
case WM_VSCROLL:
{ int ver;
char buf[16];
switch(LOWORD(wParam)) {
case SB_LINEUP:
ver = add_gsver(hwnd, 1);
break;
case SB_LINEDOWN:
ver = add_gsver(hwnd, -1);
break;
default:
ver = add_gsver(hwnd, 0);
break;
}
sprintf(buf, "%d.%02d", ver / 100, ver % 100);
SetDlgItemTextA(hwnd, IDC_CFG20, buf);
}
return TRUE;
case WM_CLOSE:
PostMessage(GetParent(hwnd), WM_COMMAND, (WPARAM)IDCANCEL, (LPARAM)0);
return TRUE;
}
return FALSE;
}
/* In case we have multiple monitors, get the size of the first and
* last displays. This allows us to put dialog boxes on the the
* first display (instead of centred and split across two displays),
* and to put the fullscreen window on the last display.
*/
typedef BOOL (WINAPI
*LUENUMDISPLAYDEVICES)(HDC,DWORD,PDISPLAY_DEVICE,DWORD);
static void
init_displays(void)
{
DISPLAY_DEVICE dd;
DEVMODE dm;
int dev = 0; /* device index */
/* Get the function's address. We could use the new platform SDK, but
* this code also works with the old one and on older Windozes (NT/95)
*/
HINSTANCE huser32=LoadLibrary("user32.dll");
LUENUMDISPLAYDEVICES pEnumDisplayDevices=0;
memset(&dd, 0, sizeof(dd));
dd.cb = sizeof(dd);
/* Defaults if we don't have or support multiple monitors */
number_of_displays = 1;
first_display.left = last_display.left = 0;
first_display.top = last_display.top = 0;
first_display.width = last_display.width = GetSystemMetrics(SM_CXSCREEN);
first_display.height = last_display.height = GetSystemMetrics(SM_CYSCREEN);
if (huser32!=NULL)
pEnumDisplayDevices=(LUENUMDISPLAYDEVICES)
GetProcAddress(huser32,"EnumDisplayDevicesA");
/* If we support multiple monitors, get dimensions of first and last */
if (pEnumDisplayDevices!=NULL) {
number_of_displays = 0;
while ((*pEnumDisplayDevices)(0, dev, &dd, 0)) {
if (!(dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)) {
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
if ((dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) &&
(EnumDisplaySettings(dd.DeviceName,
ENUM_CURRENT_SETTINGS, &dm) == TRUE)) {
EnumDisplaySettings(dd.DeviceName,
ENUM_REGISTRY_SETTINGS, &dm);
last_display.left = dm.dmPosition.x;
last_display.top = dm.dmPosition.y;
last_display.width = dm.dmPelsWidth;
last_display.height = dm.dmPelsHeight;
if (number_of_displays == 0) {
first_display.left = last_display.left;
first_display.top = last_display.top;
first_display.width = last_display.width;
first_display.height = last_display.height;
}
number_of_displays++;
}
}
dev++;
}
}
if (number_of_displays == 0)
number_of_displays = 1;
if (huser32 != NULL)
FreeLibrary(huser32);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -