wxChar userId[256];
wxGetUserId (userId, sizeof (userId) / sizeof (char));
wxChar tmp[256];
- wxStrcpy (tmp, _T("/tmp/preview_"));
+ wxStrcpy (tmp, wxT("/tmp/preview_"));
wxStrcat (tmp, userId);
m_printData.SetFilename(tmp);
#endif
wxChar tmp2[256];
wxStrcpy(tmp2, m_printData.GetFilename());
- wxStrcat (tmp2, _T(".ps"));
+ wxStrcat (tmp2, wxT(".ps"));
m_printData.SetFilename(tmp2);
}
- else if ((m_printData.GetFilename() == _T("")) && (m_printData.GetPrintMode() == wxPRINT_MODE_FILE))
+ else if ((m_printData.GetFilename() == wxT("")) && (m_printData.GetPrintMode() == wxPRINT_MODE_FILE))
{
- wxString file = wxSaveFileSelector (_("PostScript"), _T("ps"));
+ wxString file = wxSaveFileSelector (_("PostScript"), wxT("ps"));
if ( file.IsEmpty() )
{
m_ok = FALSE;
void wxPostScriptDC::SetClippingRegion (long x, long y, long w, long h)
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (m_clipping) return;
void wxPostScriptDC::SetClippingRegion( const wxRegion &WXUNUSED(region) )
{
- wxFAIL_MSG( _T("wxPostScriptDC::SetClippingRegion not implemented.") );
+ wxFAIL_MSG( wxT("wxPostScriptDC::SetClippingRegion not implemented.") );
}
void wxPostScriptDC::DestroyClippingRegion()
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
wxDC::DestroyClippingRegion();
void wxPostScriptDC::Clear()
{
- wxFAIL_MSG( _T("wxPostScriptDC::Clear not implemented.") );
+ wxFAIL_MSG( wxT("wxPostScriptDC::Clear not implemented.") );
}
void wxPostScriptDC::DoFloodFill (long WXUNUSED(x), long WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style))
{
- wxFAIL_MSG( _T("wxPostScriptDC::FloodFill not implemented.") );
+ wxFAIL_MSG( wxT("wxPostScriptDC::FloodFill not implemented.") );
}
bool wxPostScriptDC::DoGetPixel (long WXUNUSED(x), long WXUNUSED(y), wxColour * WXUNUSED(col)) const
{
- wxFAIL_MSG( _T("wxPostScriptDC::GetPixel not implemented.") );
+ wxFAIL_MSG( wxT("wxPostScriptDC::GetPixel not implemented.") );
return FALSE;
}
void wxPostScriptDC::DoCrossHair (long WXUNUSED(x), long WXUNUSED(y))
{
- wxFAIL_MSG( _T("wxPostScriptDC::CrossHair not implemented.") );
+ wxFAIL_MSG( wxT("wxPostScriptDC::CrossHair not implemented.") );
}
void wxPostScriptDC::DoDrawLine (long x1, long y1, long x2, long y2)
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (m_pen.GetStyle() == wxTRANSPARENT) return;
void wxPostScriptDC::DoDrawArc (long x1, long y1, long x2, long y2, long xc, long yc)
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
long dx = x1 - xc;
long dy = y1 - yc;
void wxPostScriptDC::DoDrawEllipticArc(long x,long y,long w,long h,double sa,double ea)
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360;
if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360;
void wxPostScriptDC::DoDrawPoint (long x, long y)
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (m_pen.GetStyle() == wxTRANSPARENT) return;
void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], long xoffset, long yoffset, int WXUNUSED(fillStyle))
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (n <= 0) return;
void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], long xoffset, long yoffset)
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (m_pen.GetStyle() == wxTRANSPARENT) return;
void wxPostScriptDC::DoDrawRectangle (long x, long y, long width, long height)
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (m_brush.GetStyle () != wxTRANSPARENT)
{
void wxPostScriptDC::DoDrawRoundedRectangle (long x, long y, long width, long height, double radius)
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (radius < 0.0)
{
void wxPostScriptDC::DoDrawEllipse (long x, long y, long width, long height)
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (m_brush.GetStyle () != wxTRANSPARENT)
{
void wxPostScriptDC::DoDrawBitmap( const wxBitmap& bitmap, long x, long y, bool WXUNUSED(useMask) )
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (!bitmap.Ok()) return;
void wxPostScriptDC::SetFont( const wxFont& font )
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (!font.Ok()) return;
void wxPostScriptDC::SetPen( const wxPen& pen )
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (!pen.Ok()) return;
void wxPostScriptDC::SetBrush( const wxBrush& brush )
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (!brush.Ok()) return;
void wxPostScriptDC::DoDrawText( const wxString& text, long x, long y )
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
SetFont( m_font );
void wxPostScriptDC::SetLogicalFunction (int WXUNUSED(function))
{
- wxFAIL_MSG( _T("wxPostScriptDC::SetLogicalFunction not implemented.") );
+ wxFAIL_MSG( wxT("wxPostScriptDC::SetLogicalFunction not implemented.") );
}
void wxPostScriptDC::DoDrawSpline( wxList *points )
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
SetPen( m_pen );
void wxPostScriptDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
m_signX = (xLeftRight ? 1 : -1);
m_signY = (yBottomUp ? 1 : -1);
void wxPostScriptDC::SetDeviceOrigin( long x, long y )
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
int h = 0;
int w = 0;
if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4);
+ int w = 595;
+ int h = 842;
if (paper)
{
- if (width) *width = paper->GetSizeDeviceUnits().x;
- if (height) *height = paper->GetSizeDeviceUnits().y;
+ w = paper->GetSizeDeviceUnits().x;
+ h = paper->GetSizeDeviceUnits().y;
}
- else
+
+ if (m_printData.GetOrientation() == wxLANDSCAPE)
{
- if (width) *width = 595;
- if (height) *height = 842;
+ int tmp = w;
+ w = h;
+ h = tmp;
}
+
+ if (width) *width = w;
+ if (height) *height = h;
}
void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const
if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4);
+ int w = 210;
+ int h = 297;
if (paper)
{
- if (width) *width = paper->GetWidth() / 10;
- if (height) *height = paper->GetHeight() / 10;
+ w = paper->GetWidth() / 10;
+ h = paper->GetHeight() / 10;
}
- else
+
+ if (m_printData.GetOrientation() == wxLANDSCAPE)
{
- if (width) *width = 210;
- if (height) *height = 297;
+ int tmp = w;
+ w = h;
+ h = tmp;
}
+
+ if (width) *width = w;
+ if (height) *height = h;
}
// Resolution in pixels per logical inch
bool wxPostScriptDC::StartDoc( const wxString& message )
{
- wxCHECK_MSG( m_ok, FALSE, _T("invalid postscript dc") );
+ wxCHECK_MSG( m_ok, FALSE, wxT("invalid postscript dc") );
if (m_printData.GetFilename() == "")
{
void wxPostScriptDC::EndDoc ()
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
if (m_clipping)
{
m_pstream = fopen( wxConvFile.cWX2MB(header_file) , "w+" );
fprintf( m_pstream, "%%!PS-Adobe-2.0\n" ); // PostScript magic strings
- fprintf( m_pstream, "%%%%Title: %s\n", m_title.mb_str() );
- fprintf( m_pstream, "%%%%Creator: %s\n", wxTheApp->argv[0] );
- fprintf( m_pstream, "%%%%CreationDate: %s\n", wxNow().mb_str() );
+ fprintf( m_pstream, "%%%%Title: %s\n", (const char *)m_title.mb_str() );
+ fprintf( m_pstream, "%%%%Creator: %s\n", (const char*)wxConvCurrent->cWX2MB(wxTheApp->argv[0]) );
+ fprintf( m_pstream, "%%%%CreationDate: %s\n", (const char *)wxNow().mb_str() );
wxChar userID[256];
if ( wxGetEmailAddress(userID, sizeof(userID)) )
{
- fprintf( m_pstream, "%%%%For: %s ", MBSTRINGCAST wxConvCurrent->cWX2MB(userID) );
+ fprintf( m_pstream, "%%%%For: %s ", wxMBSTRINGCAST wxConvCurrent->cWX2MB(userID) );
wxChar userName[245];
if (wxGetUserName(userName, sizeof(userName)))
- fprintf( m_pstream, " (%s)", MBSTRINGCAST wxConvCurrent->cWX2MB(userName) );
+ fprintf( m_pstream, " (%s)", wxMBSTRINGCAST wxConvCurrent->cWX2MB(userName) );
fprintf( m_pstream, "\n" );
}
else if ( wxGetUserName(userID, sizeof(userID)) )
{
- fprintf( m_pstream, "%%%%For: %s\n", MBSTRINGCAST wxConvCurrent->cWX2MB(userID) );;
+ fprintf( m_pstream, "%%%%For: %s\n", wxMBSTRINGCAST wxConvCurrent->cWX2MB(userID) );;
}
// THE FOLLOWING HAS BEEN CONTRIBUTED BY Andy Fyfe <andy@hyperparallel.com>
void wxPostScriptDC::StartPage()
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
fprintf( m_pstream, "%%%%Page: %d\n", wxPageNumber++ );
+ // What is this one supposed to do? RR.
// *m_pstream << "matrix currentmatrix\n";
// Added by Chris Breeze
// transformation and so we need to reset the origin
// (and rotate the page for landscape printing)
-/*
- m_scaleFactor = 1.0;
- m_logicalOriginX = 0;
- m_logicalOriginY = 0;
-*/
// Output scaling
long translate_x, translate_y;
double scale_x, scale_y;
if (m_printData.GetOrientation() == wxLANDSCAPE)
{
-// translate_y -= m_maxY;
-// fprintf( m_pstream, "90 rotate\n" );
-
- printf( "Hi.\n" );
+ int h;
+ GetSize( (int*) NULL, &h );
+ translate_y -= h;
+ fprintf( m_pstream, "90 rotate\n" );
- fprintf( m_pstream, "90 rotate llx neg ury nef translate\n" );
+ // I copied this one from a PostScript tutorial, but to no avail. RR.
+// fprintf( m_pstream, "90 rotate llx neg ury nef translate\n" );
}
-// fprintf( m_pstream, "%.8f %.8f scale\n", scale_x, scale_y );
-// fprintf( m_pstream, "%ld %ld translate\n", translate_x, translate_y );
+ fprintf( m_pstream, "%.8f %.8f scale\n", scale_x, scale_y );
+ fprintf( m_pstream, "%ld %ld translate\n", translate_x, translate_y );
}
void wxPostScriptDC::EndPage ()
{
- wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") );
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
fprintf( m_pstream, "showpage\n" );
}
long xsrc, long ysrc,
int rop, bool WXUNUSED(useMask) )
{
- wxCHECK_MSG( m_ok && m_pstream, FALSE, _T("invalid postscript dc") );
+ wxCHECK_MSG( m_ok && m_pstream, FALSE, wxT("invalid postscript dc") );
- wxCHECK_MSG( source, FALSE, _T("invalid source dc") );
+ wxCHECK_MSG( source, FALSE, wxT("invalid source dc") );
/* blit into a bitmap */
wxBitmap bitmap( (int)fwidth, (int)fheight );
if (!fontToUse) fontToUse = (wxFont*) &m_font;
- wxCHECK_RET( fontToUse, _T("GetTextExtent: no font defined") );
- wxCHECK_RET( x, _T("GetTextExtent: x == NULL") );
- wxCHECK_RET( y, _T("GetTextExtent: y == NULL") );
+ wxCHECK_RET( fontToUse, wxT("GetTextExtent: no font defined") );
+ wxCHECK_RET( x, wxT("GetTextExtent: x == NULL") );
+ wxCHECK_RET( y, wxT("GetTextExtent: y == NULL") );
const wxWX2MBbuf strbuf = string.mb_str();
-#if !USE_AFM_FOR_POSTSCRIPT
+#if !wxUSE_AFM_FOR_POSTSCRIPT
/* Provide a VERY rough estimate (avoid using it).
* Produces accurate results for mono-spaced font
* such as Courier (aka wxMODERN) */
static int lastWeight= INT_MIN;
static int lastDescender = INT_MIN;
static int lastWidths[256]; /* widths of the characters */
+
+ double UnderlinePosition = 0.0;
+ double UnderlineThickness = 0.0;
/* get actual parameters */
const int Family = fontToUse->GetFamily();
if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "TimesBoO";
else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "TimesBo";
else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "TimesO";
- else if name = "TimesRo"; /* no typo */
+ else name = "TimesRo";
}
break;
default:
if (!m_printData.GetFontMetricPath().IsEmpty())
{
- strcpy( afmName, m_printData.GetFontMetricPath().fn_str() )
+ strcpy( afmName, m_printData.GetFontMetricPath().fn_str() );
}
/* 2. open and process the file
FILE *afmFile = fopen(afmName,"r");
#ifdef __UNIX__
- if (afmFile==NULL)
- {
- strcpy( afmName, "/usr/local/share/wx/gs_afm/" );
- strcat(afmName,name);
- strcat(afmName,".afm");
- FILE *afmFile = fopen(afmName,"r");
- }
-
- if (afmFile==NULL)
- {
- strcpy( afmName, "/usr/share/wx/gs_afm/" );
- strcat(afmName,name);
- strcat(afmName,".afm");
- FILE *afmFile = fopen(afmName,"r");
- }
+ if (afmFile==NULL)
+ {
+ strcpy( afmName, "/usr/local/share/wx/afm/" );
+ strcat(afmName,name);
+ strcat(afmName,".afm");
+ afmFile = fopen(afmName,"r");
+ }
+
+ if (afmFile==NULL)
+ {
+ strcpy( afmName, "/usr/share/wx/afm/" );
+ strcat(afmName,name);
+ strcat(afmName,".afm");
+ afmFile = fopen(afmName,"r");
+ }
#endif
if (afmFile==NULL)
}
/* JC: calculate UnderlineThickness/UnderlinePosition */
- m_underlinePosition = m_underlinePosition * fontToUse->GetPointSize() / 1000.0f;
- m_underlineThickness = m_underlineThickness * fontToUse->GetPointSize() / 1000.0f * m_scaleFactor;
+ {
+ // VS: dirty, but is there any better solution?
+ double *pt;
+ pt = (double*) &m_underlinePosition;
+ *pt = UnderlinePosition * fontToUse->GetPointSize() / 1000.0f;
+ pt = (double*) &m_underlineThickness;
+ *pt = UnderlineThickness * fontToUse->GetPointSize() / 1000.0f * m_scaleFactor;
+ }
/* 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! */
- long widthSum=0;
+ double widthSum=0;
long height=Size; /* by default */
unsigned char *p;
for(p=(unsigned char *)strbuf; *p; p++)
if(lastWidths[*p]== INT_MIN)
{
wxLogDebug("GetTextExtent: undefined width for character '%c' (%d)\n", *p,*p);
- widthSum += (long)(lastWidths[' ']/1000.0F * Size); /* assume space */
+ widthSum += /*(long)*/(lastWidths[' ']/1000.0F * Size); /* assume space */
}
else
{
- widthSum += (long)((lastWidths[*p]/1000.0F)*Size);
+ widthSum += /*(long)*/((lastWidths[*p]/1000.0F)*Size);
}
}
/* add descender to height (it is usually a negative value) */
- if (lastDescender!=INT_MIN)
+ if (lastDescender != INT_MIN)
{
height += (long)(((-lastDescender)/1000.0F) * Size); /* MATTHEW: forgot scale */
}
/* return size values */
- *x = widthSum;
+ *x = (long)widthSum;
*y = height;
/* return other parameters */