The R Project SVN R

Rev

Rev 5458 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5458 Rev 6098
Line 55... Line 55...
55
 
55
 
56
static HDC chooseprinter()
56
static HDC chooseprinter()
57
{
57
{
58
    PRINTDLG pd;
58
    PRINTDLG pd;
59
    HDC dc;
59
    HDC dc;
-
 
60
    DWORD rc;
60
    char cwd[MAX_PATH];
61
    char cwd[MAX_PATH];
61
 
62
 
62
    GetCurrentDirectory(MAX_PATH,cwd);
63
    GetCurrentDirectory(MAX_PATH,cwd);
63
 
64
 
64
    pd.lStructSize = sizeof( PRINTDLG );
65
    pd.lStructSize = sizeof( PRINTDLG );
Line 81... Line 82...
81
    pd.hPrintTemplate = (HGLOBAL)0;
82
    pd.hPrintTemplate = (HGLOBAL)0;
82
    pd.hSetupTemplate = (HGLOBAL)0;
83
    pd.hSetupTemplate = (HGLOBAL)0;
83
 
84
 
84
    dc = PrintDlg( &pd ) ? pd.hDC : NULL;
85
    dc = PrintDlg( &pd ) ? pd.hDC : NULL;
85
    SetCurrentDirectory(cwd);
86
    SetCurrentDirectory(cwd);
-
 
87
    if (!dc) {
-
 
88
	rc = CommDlgExtendedError(); /* 0 means user cancelled */
-
 
89
	if (rc) R_ShowMessage("Unable to choose printer");
86
 
90
    }
87
    return dc;
91
    return dc;
88
}
92
}
89
 
93
 
90
 
94
 
91
printer newprinter(double width, double height)
95
printer newprinter(double width, double height)
Line 94... Line 98...
94
    printer obj;
98
    printer obj;
95
    HDC hDC = chooseprinter();
99
    HDC hDC = chooseprinter();
96
    double dd,AL;
100
    double dd,AL;
97
    int ww,hh,x0,y0;
101
    int ww,hh,x0,y0;
98
 
102
 
99
    if ( !hDC) return NULL;
103
    if ( !hDC ) return NULL;
100
    obj = new_object(PrinterObject,(HANDLE) hDC,get_printer_base());
104
    obj = new_object(PrinterObject, (HANDLE) hDC, get_printer_base());
101
    if ( !obj ) {
105
    if ( !obj ) {
102
	R_ShowMessage("Insufficient memory for new printer");
106
	R_ShowMessage("Insufficient memory for new printer");
103
	DeleteDC(hDC);
107
	DeleteDC(hDC);
104
	return NULL;
108
	return NULL;
105
    }
109
    }
Line 112... Line 116...
112
	if (height < 0.1) height = 0.1;
116
	if (height < 0.1) height = 0.1;
113
	dd =  GetDeviceCaps(hDC, HORZSIZE) / width;
117
	dd =  GetDeviceCaps(hDC, HORZSIZE) / width;
114
	AL = (dd < 1.0) ? dd : 1.0;
118
	AL = (dd < 1.0) ? dd : 1.0;
115
	dd = GetDeviceCaps(hDC, VERTSIZE) / height;
119
	dd = GetDeviceCaps(hDC, VERTSIZE) / height;
116
	AL = (dd < AL) ? dd : AL;
120
	AL = (dd < AL) ? dd : AL;
117
	ww = (AL * width) * GetDeviceCaps(hDC,LOGPIXELSX) / 25.4;
121
	ww = (AL * width) * GetDeviceCaps(hDC, LOGPIXELSX) / 25.4;
118
	hh = (AL * height) * GetDeviceCaps(hDC,LOGPIXELSY) / 25.4;
122
	hh = (AL * height) * GetDeviceCaps(hDC, LOGPIXELSY) / 25.4;
119
    }
123
    }
120
    x0 = (GetDeviceCaps(hDC,HORZRES) - ww) / 2;
124
    x0 = (GetDeviceCaps(hDC, HORZRES) - ww) / 2;
121
    y0 = (GetDeviceCaps(hDC,VERTRES) - hh) / 2;
125
    y0 = (GetDeviceCaps(hDC, VERTRES) - hh) / 2;
122
    obj->rect = rect(x0,y0,ww,hh);
126
    obj->rect = rect(x0, y0, ww, hh);
123
    obj->depth = GetDeviceCaps(hDC, BITSPIXEL)*
127
    obj->depth = GetDeviceCaps(hDC, BITSPIXEL)* GetDeviceCaps(hDC, PLANES);
124
	GetDeviceCaps(hDC, PLANES);
-
 
125
    obj->die = private_delprinter;
128
    obj->die = private_delprinter;
126
    obj->drawstate = copydrawstate();
129
    obj->drawstate = copydrawstate();
127
    obj->drawstate->dest = obj;
130
    obj->drawstate->dest = obj;
128
 
131
 
129
    docinfo.cbSize = sizeof(DOCINFO);	/* set this size... */
132
    docinfo.cbSize = sizeof(DOCINFO);	/* set this size... */