merged 2.2 branch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2000-07-15 19:51:35 +00:00
parent 8a693e6e04
commit f6bcfd974e
1835 changed files with 237729 additions and 67990 deletions

View File

@@ -1005,7 +1005,10 @@ void wxPostScriptDC::SetFont( const wxFont& font )
fprintf( m_pstream, buffer );
fprintf( m_pstream, " findfont\n" );
fprintf( m_pstream, "%f scalefont setfont\n", YLOG2DEVREL(m_font.GetPointSize() * 1000) / 1000.0F);
sprintf( buffer, "%f scalefont setfont\n", YLOG2DEVREL(m_font.GetPointSize() * 1000) / 1000.0F);
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
// this is a hack - we must scale font size (in pts) according to m_scaleY but
// YLOG2DEVREL works with wxCoord type (int or longint). Se we first convert font size
// to 1/1000th of pt and then back.
@@ -1021,11 +1024,18 @@ void wxPostScriptDC::SetPen( const wxPen& pen )
m_pen = pen;
#ifdef __WXMSW__
fprintf( m_pstream, "%d setlinewidth\n", XLOG2DEVREL(m_pen.GetWidth()) );
#else
fprintf( m_pstream, "%d setlinewidth\n", XLOG2DEVREL(m_pen.GetWidth()) );
#endif
{
char buffer[100];
#ifdef __WXMSW__
sprintf( buffer, "%f setlinewidth\n", XLOG2DEVREL(1000 * m_pen.GetWidth()) / 1000.0f );
#else
sprintf( buffer, "%f setlinewidth\n", XLOG2DEVREL(1000 * m_pen.GetWidth()) / 1000.0f );
#endif
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
}
/*
Line style - WRONG: 2nd arg is OFFSET
@@ -1085,10 +1095,14 @@ void wxPostScriptDC::SetPen( const wxPen& pen )
double redPS = (double)(red) / 255.0;
double bluePS = (double)(blue) / 255.0;
double greenPS = (double)(green) / 255.0;
fprintf( m_pstream,
char buffer[100];
sprintf( buffer,
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
m_currentRed = red;
m_currentBlue = blue;
@@ -1129,9 +1143,13 @@ void wxPostScriptDC::SetBrush( const wxBrush& brush )
double bluePS = (double)(blue) / 255.0;
double greenPS = (double)(green) / 255.0;
fprintf( m_pstream,
char buffer[100];
sprintf( buffer,
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
m_currentRed = red;
m_currentBlue = blue;
@@ -1175,9 +1193,13 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
double bluePS = (double)(blue) / 255.0;
double greenPS = (double)(green) / 255.0;
fprintf( m_pstream,
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
char buffer[100];
sprintf( buffer,
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
m_currentRed = red;
m_currentBlue = blue;
@@ -1228,17 +1250,21 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
if (m_font.GetUnderlined())
{
wxCoord uy = (wxCoord)(y + size - m_underlinePosition);
char buffer[100];
fprintf( m_pstream,
sprintf( buffer,
"gsave\n"
"%d %d moveto\n"
"%d setlinewidth\n"
"%f setlinewidth\n"
"%d %d lineto\n"
"stroke\n"
"grestore\n",
XLOG2DEV(x), YLOG2DEV(uy),
(wxCoord)m_underlineThickness,
m_underlineThickness,
XLOG2DEV(x + text_w), YLOG2DEV(uy) );
for (i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
}
CalcBoundingBox( x, y );
@@ -1283,9 +1309,13 @@ void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord
double bluePS = (double)(blue) / 255.0;
double greenPS = (double)(green) / 255.0;
fprintf( m_pstream,
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
char buffer[100];
sprintf( buffer,
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
m_currentRed = red;
m_currentBlue = blue;
@@ -1300,7 +1330,13 @@ void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord
// FIXME only correct for 90 degrees
fprintf(m_pstream, "%d %d moveto\n",
XLOG2DEV((wxCoord)(x + size)), YLOG2DEV(by) );
fprintf(m_pstream, "%.8f rotate\n", angle);
char buffer[100];
sprintf(buffer, "%.8f rotate\n", angle);
int i;
for (i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf(m_pstream, buffer);
/* I don't know how to write char to a stream, so I use a mini string */
char tmpbuf[2];
@@ -1309,7 +1345,6 @@ void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord
fprintf( m_pstream, "(" );
const wxWX2MBbuf textbuf = text.mb_str();
int len = strlen(textbuf);
int i;
for (i = 0; i < len; i++)
{
int c = (unsigned char) textbuf[i];
@@ -1333,24 +1368,32 @@ void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord
}
fprintf( m_pstream, ") show\n" );
fprintf( m_pstream, "%.8f rotate\n", -angle );
sprintf( buffer, "%.8f rotate\n", -angle );
for (i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
if (m_font.GetUnderlined())
{
wxCoord uy = (wxCoord)(y + size - m_underlinePosition);
wxCoord w, h;
char buffer[100];
GetTextExtent(text, &w, &h);
fprintf( m_pstream,
sprintf( buffer,
"gsave\n"
"%d %d moveto\n"
"%ld setlinewidth\n"
"%f setlinewidth\n"
"%d %d lineto\n"
"stroke\n"
"grestore\n",
XLOG2DEV(x), YLOG2DEV(uy),
(long)m_underlineThickness,
m_underlineThickness,
XLOG2DEV(x + w), YLOG2DEV(uy) );
for (i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
}
CalcBoundingBox( x, y );
@@ -1538,7 +1581,7 @@ bool wxPostScriptDC::StartDoc( const wxString& message )
if (!m_pstream)
{
wxMessageBox( _("Cannot open file for PostScript printing!"), _("Error"), wxOK );
wxLogError( _("Cannot open file for PostScript printing!"));
m_ok = FALSE;
return FALSE;
}
@@ -1755,7 +1798,12 @@ void wxPostScriptDC::StartPage()
// fprintf( m_pstream, "90 rotate llx neg ury nef translate\n" );
}
fprintf( m_pstream, "%.8f %.8f scale\n", scale_x, scale_y );
char buffer[100];
sprintf( buffer, "%.8f %.8f scale\n", scale_x, scale_y );
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
fprintf( m_pstream, "%d %d translate\n", translate_x, translate_y );
}
@@ -2071,18 +2119,19 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string,
lastWidths[220] = lastWidths['U']; // <20>
lastWidths[252] = lastWidths['u']; // <20>
lastWidths[223] = lastWidths[251]; // <20>
}
/* JC: calculate UnderlineThickness/UnderlinePosition */
{
/* JC: calculate UnderlineThickness/UnderlinePosition */
// VS: dirty, but is there any better solution?
double *pt;
pt = (double*) &m_underlinePosition;
*pt = UnderlinePosition * fontToUse->GetPointSize() / 1000.0f;
*pt = YLOG2DEVREL(UnderlinePosition * fontToUse->GetPointSize()) / 1000.0f;
pt = (double*) &m_underlineThickness;
*pt = UnderlineThickness * fontToUse->GetPointSize() / 1000.0f * m_scaleFactor;
*pt = YLOG2DEVREL(UnderlineThickness * fontToUse->GetPointSize()) / 1000.0f;
}
/* 3. now the font metrics are read in, calc size this
/ is done by adding the widths of the characters in the
/ string. they are given in 1/1000 of the size! */