m_pageNumber = 0;
- m_clipping = FALSE;
+ m_clipping = false;
m_underlinePosition = 0.0;
m_underlineThickness = 0.0;
m_pageNumber = 0;
- m_clipping = FALSE;
+ m_clipping = false;
m_underlinePosition = 0.0;
m_underlineThickness = 0.0;
m_printData = printData;
- m_ok = TRUE;
+ m_ok = true;
}
wxPostScriptDC::~wxPostScriptDC ()
{
wxPrintDialogData ddata( data );
wxPrintDialog dialog( parent, &data );
- dialog.GetPrintDialogData().SetSetupDialog(TRUE);
+ dialog.GetPrintDialogData().SetSetupDialog(true);
if (dialog.ShowModal() != wxID_OK)
{
- m_ok = FALSE;
- return FALSE;
+ m_ok = false;
+ return false;
}
data = dialog.GetPrintDialogData().GetPrintData();
}
- return TRUE;
+ return true;
}
#endif
wxDC::DoSetClippingRegion(x, y, w, h);
- m_clipping = TRUE;
+ m_clipping = true;
PsPrintf( wxT("gsave\n newpath\n")
wxT("%d %d moveto\n")
if (m_clipping)
{
- m_clipping = FALSE;
+ m_clipping = false;
PsPrint( "grestore\n" );
}
bool wxPostScriptDC::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style))
{
wxFAIL_MSG( wxT("wxPostScriptDC::FloodFill not implemented.") );
- return FALSE;
+ return false;
}
bool wxPostScriptDC::DoGetPixel (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour * WXUNUSED(col)) const
{
wxFAIL_MSG( wxT("wxPostScriptDC::GetPixel not implemented.") );
- return FALSE;
+ return false;
}
void wxPostScriptDC::DoCrossHair (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
wxT("%d %d moveto\n"),
LogicalToDeviceX(points[0].x+xoffset),
LogicalToDeviceY(points[0].y+yoffset) );
-
+
for (i = 1; i < n; i++)
{
PsPrintf( wxT("%d %d lineto\n"),
LogicalToDeviceX(points[i].x+xoffset),
LogicalToDeviceY(points[i].y+yoffset) );
}
-
+
PsPrint( "stroke\n" );
}
void wxPostScriptDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y )
{
- DrawBitmap( icon, x, y, TRUE );
+ DrawBitmap( icon, x, y, true );
}
/* this has to be char, not wxChar */
// We may legitimately call SetFont before BeginDoc
if (!m_pstream)
return;
-
+
PsPrint( name );
PsPrint( " reencodeISO def\n" );
PsPrint( name );
PsPrint( " findfont\n" );
-
+
char buffer[100];
sprintf( buffer, "%f scalefont setfont\n", LogicalToDeviceYRel(m_font.GetPointSize() * 1000) / 1000.0F);
// this is a hack - we must scale font size (in pts) according to m_scaleY but
double redPS = (double)(red) / 255.0;
double bluePS = (double)(blue) / 255.0;
double greenPS = (double)(green) / 255.0;
-
+
char buffer[100];
sprintf( buffer,
"%.8f %.8f %.8f setrgbcolor\n",
if (buffer[i] == ',') buffer[i] = '.';
PsPrint( buffer );
-
+
m_currentRed = red;
m_currentBlue = blue;
m_currentGreen = green;
redPS, greenPS, bluePS );
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
-
+
PsPrint( buffer );
m_currentRed = red;
#endif
+
+#if wxUSE_PANGO
+static void InitializePangoContext(PangoContext *context)
+{
+#ifdef __WXGTK__
+ pango_context_set_base_dir(context,
+ gtk_widget_get_default_direction() == GTK_TEXT_DIR_LTR ?
+ PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
+ pango_context_set_language(context, gtk_get_default_language());
+#else
+ // FIXME: assuming LTR is incorrect!
+ pango_context_set_base_dir(context, PANGO_DIRECTION_LTR);
+ wxString lang = wxLocale::GetCanonicalName();
+ pango_context_set_language(context,
+ pango_language_from_string(lang::ToAscii()));
+#endif
+}
+#endif
+
void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
int ps_dpi = 72;
int pango_dpi = 600;
PangoContext *context = pango_ft2_get_context ( pango_dpi, pango_dpi );
+
+ InitializePangoContext(context);
double scale = (double)pango_dpi / (double)ps_dpi;
scale /= m_userScaleY;
- pango_context_set_language (context, pango_language_from_string ("en_US"));
- pango_context_set_base_dir (context, PANGO_DIRECTION_LTR );
-
pango_context_set_font_description (context, m_font.GetNativeFontInfo()->description );
PangoLayout *layout = pango_layout_new (context);
PsPrintf( wxT("%d %d moveto\n"), LogicalToDeviceX(x), LogicalToDeviceY(by) );
PsPrint( "(" );
-
+
const wxWX2MBbuf textbuf = text.mb_str();
size_t len = strlen(textbuf);
size_t i;
PsPrint(c);
}
}
-
+
PsPrint( ") show\n" );
-
+
if (m_font.GetUnderlined())
{
wxCoord uy = (wxCoord)(y + size - m_underlinePosition);
PsPrintf( wxT("%d %d moveto\n"),
LogicalToDeviceX(x), LogicalToDeviceY(y));
-
+
char buffer[100];
sprintf(buffer, "%.8f rotate\n", angle);
size_t i;
if (buffer[i] == ',') buffer[i] = '.';
}
PsPrint( buffer);
-
+
PsPrint( "(" );
const wxWX2MBbuf textbuf = text.mb_str();
size_t len = strlen(textbuf);
PsPrint(c);
}
}
-
+
PsPrint( ") show\n" );
-
+
sprintf( buffer, "%.8f rotate\n", -angle );
for (i = 0; i < 100; i++)
{
if (buffer[i] == ',') buffer[i] = '.';
}
PsPrint( buffer );
-
+
if (m_font.GetUnderlined())
{
wxCoord uy = (wxCoord)(y + size - m_underlinePosition);
}
PsPrint( buffer );
}
-
+
CalcBoundingBox( x, y );
CalcBoundingBox( x + size * text.Length() * 2/3 , y );
}
bool wxPostScriptDC::StartDoc( const wxString& message )
{
- wxCHECK_MSG( m_ok, FALSE, wxT("invalid postscript dc") );
+ wxCHECK_MSG( m_ok, false, wxT("invalid postscript dc") );
if ( m_printData.GetPrintMode() != wxPRINT_MODE_STREAM )
{
- if (m_printData.GetFilename() == wxT(""))
+ if (m_printData.GetFilename() == wxEmptyString)
{
wxString filename = wxGetTempFileName( wxT("ps") );
m_printData.SetFilename(filename);
if (!m_pstream)
{
wxLogError( _("Cannot open file for PostScript printing!"));
- m_ok = FALSE;
- return FALSE;
+ m_ok = false;
+ return false;
}
}
- m_ok = TRUE;
+ m_ok = true;
m_title = message;
PsPrint( "%!PS-Adobe-2.0\n" );
PsPrintf( wxT("%%%%Title: %s\n"), m_title.c_str() );
- PsPrint( "%%Creator: wxWindows PostScript renderer\n" );
+ PsPrint( "%%Creator: wxWidgets PostScript renderer\n" );
PsPrintf( wxT("%%%%CreationDate: %s\n"), wxNow().c_str() );
if (m_printData.GetOrientation() == wxLANDSCAPE)
PsPrint( "%%Orientation: Landscape\n" );
wxPageNumber = 1;
m_pageNumber = 1;
- return TRUE;
+ return true;
}
void wxPostScriptDC::EndDoc ()
if (m_clipping)
{
- m_clipping = FALSE;
+ m_clipping = false;
PsPrint( "grestore\n" );
}
command += wxT(" ");
command += m_printData.GetFilename();
- wxExecute( command, TRUE );
+ wxExecute( command, true );
wxRemoveFile( m_printData.GetFilename() );
}
#endif
wxCoord xsrc, wxCoord ysrc,
int rop, bool WXUNUSED(useMask), wxCoord WXUNUSED(xsrcMask), wxCoord WXUNUSED(ysrcMask) )
{
- wxCHECK_MSG( m_ok, FALSE, wxT("invalid postscript dc") );
+ wxCHECK_MSG( m_ok, false, wxT("invalid postscript dc") );
- wxCHECK_MSG( source, FALSE, wxT("invalid source dc") );
+ wxCHECK_MSG( source, false, wxT("invalid source dc") );
/* blit into a bitmap */
wxBitmap bitmap( (int)fwidth, (int)fheight );
/* draw bitmap. scaling and positioning is done there */
DrawBitmap( bitmap, xdest, ydest );
- return TRUE;
+ return true;
}
wxCoord wxPostScriptDC::GetCharHeight() const
int pango_dpi = 600;
PangoContext *context = pango_ft2_get_context ( pango_dpi, pango_dpi );
+ InitializePangoContext(context);
+
double scale = pango_dpi / wx_dpi;
scale /= m_userScaleY;
- pango_context_set_language (context, pango_language_from_string ("en_US"));
- pango_context_set_base_dir (context, PANGO_DIRECTION_LTR );
-
PangoLayout *layout = pango_layout_new (context);
PangoFontDescription *desc = fontToUse->GetNativeFontInfo()->description;
const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
#endif
pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data ));
- PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
PangoRectangle rect;
- pango_layout_line_get_extents(line, NULL, &rect);
+ pango_layout_get_extents(layout, NULL, &rect);
- if (x) (*x) = (wxCoord) ( rect.width / PANGO_SCALE / scale );
- if (y) (*y) = (wxCoord) ( rect.height / PANGO_SCALE / scale );
+ if (x) (*x) = (wxCoord) ( PANGO_PIXELS(rect.width) / scale );
+ if (y) (*y) = (wxCoord) ( PANGO_PIXELS(rect.height) / scale );
if (descent)
{
- // Do something about metrics here
- (*descent) = 0;
+ PangoLayoutIter *iter = pango_layout_get_iter(layout);
+ int baseline = pango_layout_iter_get_baseline(iter);
+ pango_layout_iter_free(iter);
+ *descent = wxCoord(*y - PANGO_PIXELS(baseline) / scale);
}
if (externalLeading) (*externalLeading) = 0; // ??
/
/ example:
/
- / wxPostScriptDC dc(NULL, TRUE);
+ / wxPostScriptDC dc(NULL, true);
/ if (dc.Ok()){
/ wxSetAFMPath("d:\\wxw161\\afm\\");
/ dc.StartDoc("Test");
{
wxInitializePrintSetupData();
- return TRUE;
+ return true;
}
void wxPostScriptModule::OnExit()
{
- wxInitializePrintSetupData(FALSE);
+ wxInitializePrintSetupData(false);
}
#endif
// WXWIN_COMPATIBILITY_2_2