The R Project SVN R

Rev

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

Rev 12976 Rev 27946
Line 86... Line 86...
86
       cppix = 25.40 * devicewidth(NULL) / devicewidthmm(NULL);
86
       cppix = 25.40 * devicewidth(NULL) / devicewidthmm(NULL);
87
       ppix  = 100 * devicepixelsx(NULL);
87
       ppix  = 100 * devicepixelsx(NULL);
88
       cppiy = 25.40 * deviceheight(NULL) / deviceheightmm(NULL);
88
       cppiy = 25.40 * deviceheight(NULL) / deviceheightmm(NULL);
89
       ppiy = 100 * devicepixelsy(NULL);
89
       ppiy = 100 * devicepixelsy(NULL);
90
    }
90
    }
-
 
91
    /* This is all very peculiar. We would really like to create 
-
 
92
       a metafile measured in some snesible units, but it seems 
-
 
93
       we get it in units of 0.01mm *on the current screen* with
-
 
94
       horizontal and vertical resolution set for that screen.
-
 
95
       And of course Windows is famous for getting screen sizes wrong.
-
 
96
    */
91
 
97
 
92
    wr.left = 0;
98
    wr.left = 0;
93
    wr.top =  0 ;
99
    wr.top =  0 ;
94
    wr.right =  (ppix * width) / cppix ;
100
    wr.right =  (ppix * width) / cppix ;
95
    wr.bottom = (ppiy * height) / cppiy ;
101
    wr.bottom = (ppiy * height) / cppiy ;
96
 
102
 
-
 
103
    /* Here the size is in 0.01mm units */
97
    hDC = CreateEnhMetaFile(NULL, strlen(name) ? name : NULL, &wr, 
104
    hDC = CreateEnhMetaFile(NULL, strlen(name) ? name : NULL, &wr, 
98
			    "GraphApp\0\0");
105
			    "GraphApp\0\0");
99
    if ( !hDC ) {
106
    if ( !hDC ) {
100
	R_ShowMessage("Unable to create metafile");
107
	R_ShowMessage("Unable to create metafile");
101
	return NULL;
108
	return NULL;
Line 104... Line 111...
104
    if ( !obj ) {
111
    if ( !obj ) {
105
	R_ShowMessage("Insufficient memory to create metafile");
112
	R_ShowMessage("Insufficient memory to create metafile");
106
	DeleteEnhMetaFile(CloseEnhMetaFile(hDC));
113
	DeleteEnhMetaFile(CloseEnhMetaFile(hDC));
107
	return NULL;
114
	return NULL;
108
    }
115
    }
-
 
116
    /* In looks like Windows rounds up the width and height, so we
-
 
117
       do too.  1 out is common, but 2 out has been seen.
-
 
118
       This is needed to get complete painting of the background.
-
 
119
    */
109
    obj->rect = rect(0, 0, (ppix * width)/2540, (ppiy * height)/2540);
120
    obj->rect = rect(0, 0, 2+(ppix * width)/2540, 2+(ppiy * height)/2540);
110
    obj->depth = GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES);
121
    obj->depth = GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES);
111
    obj->die = private_delmetafile;
122
    obj->die = private_delmetafile;
112
    obj->drawstate = copydrawstate();
123
    obj->drawstate = copydrawstate();
113
    obj->drawstate->dest = obj;
124
    obj->drawstate->dest = obj;
114
    settext(obj, name ? name : "");
125
    settext(obj, name ? name : "");