The R Project SVN R

Rev

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

Rev 42521 Rev 45017
Line 18... Line 18...
18
 */
18
 */
19
 
19
 
20
/*
20
/*
21
 *  metafile newmetafile(char *name,rect r)
21
 *  metafile newmetafile(char *name,rect r)
22
 *     return a metafile object of 'nominal' size (r.width)x(r.height)
22
 *     return a metafile object of 'nominal' size (r.width)x(r.height)
23
 *     in 0.01mm. Use drawto(...)/drawXXX/gdrawXXX to draw to the 
23
 *     in 0.01mm. Use drawto(...)/drawXXX/gdrawXXX to draw to the
24
 *     metafile. If "name"=="" metafile is in memory.
24
 *     metafile. If "name"=="" metafile is in memory.
25
 *     
25
 *
26
 *  del(metafile)  finalizes/closes the metafile. Closed in memory
26
 *  del(metafile)  finalizes/closes the metafile. Closed in memory
27
 *     metafile are saved to the clipboard.
27
 *     metafile are saved to the clipboard.
28
 *
28
 *
29
*/
29
*/
30
 
30
 
Line 76... Line 76...
76
    metafile obj;
76
    metafile obj;
77
    HDC hDC;
77
    HDC hDC;
78
    RECT wr;
78
    RECT wr;
79
    static double cppix=-1, ppix, cppiy, ppiy;
79
    static double cppix=-1, ppix, cppiy, ppiy;
80
 
80
 
81
    /* 
81
    /*
82
     * In theory, (cppix=ppix) and (cppiy=ppiy). However, we
82
     * In theory, (cppix=ppix) and (cppiy=ppiy). However, we
83
     * use the ratio to adjust the 'reference dimension'
83
     * use the ratio to adjust the 'reference dimension'
84
     * in case.... ("Importing graph in MsWord" thread)
84
     * in case.... ("Importing graph in MsWord" thread)
85
    */
85
     */
86
    if (cppix < 0) {
86
    if (cppix < 0) {
87
       cppix = 25.40 * devicewidth(NULL) / devicewidthmm(NULL);
87
	cppix = 25.40 * devicewidth(NULL) / devicewidthmm(NULL);
88
       ppix  = 100 * devicepixelsx(NULL);
88
	ppix  = 100 * devicepixelsx(NULL);
89
       cppiy = 25.40 * deviceheight(NULL) / deviceheightmm(NULL);
89
	cppiy = 25.40 * deviceheight(NULL) / deviceheightmm(NULL);
90
       ppiy = 100 * devicepixelsy(NULL);
90
	ppiy = 100 * devicepixelsy(NULL);
91
    }
91
    }
92
    /* This is all very peculiar. We would really like to create 
92
    /* This is all very peculiar. We would really like to create
93
       a metafile measured in some sensible units, but it seems 
93
       a metafile measured in some sensible units, but it seems
94
       we get it in units of 0.01mm *on the current screen* with
94
       we get it in units of 0.01mm *on the current screen* with
95
       horizontal and vertical resolution set for that screen.
95
       horizontal and vertical resolution set for that screen.
96
       And of course Windows is famous for getting screen sizes wrong.
96
       And of course Windows is famous for getting screen sizes wrong.
97
    */
97
    */
98
 
98
 
Line 100... Line 100...
100
    wr.top =  0 ;
100
    wr.top =  0 ;
101
    wr.right =  (ppix * width) / cppix ;
101
    wr.right =  (ppix * width) / cppix ;
102
    wr.bottom = (ppiy * height) / cppiy ;
102
    wr.bottom = (ppiy * height) / cppiy ;
103
 
103
 
104
    /* Here the size is in 0.01mm units */
104
    /* Here the size is in 0.01mm units */
105
    hDC = CreateEnhMetaFile(NULL, strlen(name) ? name : NULL, &wr, 
105
    hDC = CreateEnhMetaFile(NULL, strlen(name) ? name : NULL, &wr,
106
			    "GraphApp\0\0");
106
			    "GraphApp\0\0");
107
    if ( !hDC ) {
107
    if ( !hDC ) {
108
	R_ShowMessage(_("Unable to create metafile"));
108
	R_ShowMessage(_("Unable to create metafile"));
109
	return NULL;
109
	return NULL;
110
    }
110
    }