⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gprint.cpp

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    }    gs_lgp->gnome_print_job_close( job );    if (m_native_preview)    {        const wxCharBuffer title(wxGTK_CONV_SYS(_("Print preview")));        GtkWidget *preview = gs_lgp->gnome_print_job_preview_new                                     (                                        job,                                        (const guchar *)title.data()                                     );        gtk_widget_show(preview);    }    else    {        gs_lgp->gnome_print_job_print( job );    }    g_object_unref (job);    delete dc;    return (sm_lastError == wxPRINTER_NO_ERROR);}wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent ){    wxGnomePrintDialog dialog( parent, &m_printDialogData );    int ret = dialog.ShowModal();    if (ret == wxID_CANCEL)    {        sm_lastError = wxPRINTER_CANCELLED;        return NULL;    }    m_native_preview = ret == wxID_PREVIEW;    m_printDialogData = dialog.GetPrintDialogData();    return new wxGnomePrintDC( this );}bool wxGnomePrinter::Setup( wxWindow *parent ){    return false;}//-----------------------------------------------------------------------------// wxGnomePrintDC//-----------------------------------------------------------------------------IMPLEMENT_CLASS(wxGnomePrintDC, wxDC)wxGnomePrintDC::wxGnomePrintDC( wxGnomePrinter *printer ){    m_printer = printer;    m_gpc = printer->GetPrintContext();    m_job = NULL; // only used and destroyed when created with wxPrintData    m_layout = gs_lgp->gnome_print_pango_create_layout( m_gpc );    m_fontdesc = pango_font_description_from_string( "Sans 12" );    m_context = NULL;    m_currentRed = 0;    m_currentBlue = 0;    m_currentGreen = 0;    m_signX =  1;  // default x-axis left to right    m_signY = -1;  // default y-axis bottom up -> top down        GetSize( NULL, &m_deviceOffsetY );}wxGnomePrintDC::wxGnomePrintDC( const wxPrintData& data ){    m_printer = NULL;    m_printData = data;    wxGnomePrintNativeData *native =        (wxGnomePrintNativeData*) m_printData.GetNativeData();    GnomePrintJob *job = gs_lgp->gnome_print_job_new( native->GetPrintConfig() );    m_gpc = gs_lgp->gnome_print_job_get_context (job);    m_job = job; // only used and destroyed when created with wxPrintData    m_layout = gs_lgp->gnome_print_pango_create_layout( m_gpc );    m_fontdesc = pango_font_description_from_string( "Sans 12" );    m_context = NULL;    m_currentRed = 0;    m_currentBlue = 0;    m_currentGreen = 0;    m_signX =  1;  // default x-axis left to right    m_signY = -1;  // default y-axis bottom up -> top down            GetSize( NULL, &m_deviceOffsetY );}wxGnomePrintDC::~wxGnomePrintDC(){    if (m_job)        g_object_unref (m_job);}bool wxGnomePrintDC::IsOk() const{    return true;}bool wxGnomePrintDC::DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style ){    return false;}bool wxGnomePrintDC::DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const{    return false;}void wxGnomePrintDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2){    if  (m_pen.GetStyle() == wxTRANSPARENT) return;    SetPen( m_pen );    gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(x1), YLOG2DEV(y1) );    gs_lgp->gnome_print_lineto ( m_gpc, XLOG2DEV(x2), YLOG2DEV(y2) );    gs_lgp->gnome_print_stroke ( m_gpc);    CalcBoundingBox( x1, y1 );    CalcBoundingBox( x2, y2 );}void wxGnomePrintDC::DoCrossHair(wxCoord x, wxCoord y){}void wxGnomePrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc){    double dx = x1 - xc;    double dy = y1 - yc;    double radius = sqrt((double)(dx*dx+dy*dy));    double alpha1, alpha2;    if (x1 == x2 && y1 == y2)    {        alpha1 = 0.0;        alpha2 = 360.0;    }    else    if (radius == 0.0)    {        alpha1 = alpha2 = 0.0;    }    else    {        alpha1 = (x1 - xc == 0) ?            (y1 - yc < 0) ? 90.0 : -90.0 :            -atan2(double(y1-yc), double(x1-xc)) * RAD2DEG;        alpha2 = (x2 - xc == 0) ?            (y2 - yc < 0) ? 90.0 : -90.0 :            -atan2(double(y2-yc), double(x2-xc)) * RAD2DEG;        while (alpha1 <= 0)   alpha1 += 360;        while (alpha2 <= 0)   alpha2 += 360; // adjust angles to be between        while (alpha1 > 360)  alpha1 -= 360; // 0 and 360 degree        while (alpha2 > 360)  alpha2 -= 360;    }    if (m_brush.GetStyle() != wxTRANSPARENT)    {        SetBrush( m_brush );        gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc) );        gs_lgp->gnome_print_arcto( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL((int)radius), alpha1, alpha2, 0 );        gs_lgp->gnome_print_fill( m_gpc );    }    if (m_pen.GetStyle() != wxTRANSPARENT)    {        SetPen (m_pen);        gs_lgp->gnome_print_newpath( m_gpc );        gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc) );        gs_lgp->gnome_print_arcto( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL((int)radius), alpha1, alpha2, 0 );        gs_lgp->gnome_print_closepath( m_gpc );        gs_lgp->gnome_print_stroke( m_gpc );    }    CalcBoundingBox (x1, y1);    CalcBoundingBox (x2, y2);    CalcBoundingBox (xc, yc);}void wxGnomePrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea){    x += w/2;    y += h/2;    int xx = XLOG2DEV(x);    int yy = YLOG2DEV(y);    gs_lgp->gnome_print_gsave( m_gpc );    gs_lgp->gnome_print_translate( m_gpc, xx, yy );    double scale = (double)YLOG2DEVREL(h) / (double) XLOG2DEVREL(w);    gs_lgp->gnome_print_scale( m_gpc, 1.0, scale );    xx = 0;    yy = 0;    if (m_brush.GetStyle () != wxTRANSPARENT)    {        SetBrush( m_brush );        gs_lgp->gnome_print_moveto ( m_gpc, xx, yy );        gs_lgp->gnome_print_arcto( m_gpc, xx, yy,            XLOG2DEVREL(w)/2, sa, ea, 0 );        gs_lgp->gnome_print_moveto ( m_gpc, xx, yy );        gs_lgp->gnome_print_fill( m_gpc );    }    if (m_pen.GetStyle () != wxTRANSPARENT)    {        SetPen (m_pen);        gs_lgp->gnome_print_arcto( m_gpc, xx, yy,            XLOG2DEVREL(w)/2, sa, ea, 0 );        gs_lgp->gnome_print_stroke( m_gpc );    }    gs_lgp->gnome_print_grestore( m_gpc );    CalcBoundingBox( x, y );    CalcBoundingBox( x+w, y+h );}void wxGnomePrintDC::DoDrawPoint(wxCoord x, wxCoord y){}void wxGnomePrintDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset){    if (m_pen.GetStyle() == wxTRANSPARENT) return;    if (n <= 0) return;    SetPen (m_pen);    int i;    for ( i =0; i<n ; i++ )        CalcBoundingBox( points[i].x+xoffset, points[i].y+yoffset);    gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(points[0].x+xoffset), YLOG2DEV(points[0].y+yoffset) );    for (i = 1; i < n; i++)        gs_lgp->gnome_print_lineto ( m_gpc, XLOG2DEV(points[i].x+xoffset), YLOG2DEV(points[i].y+yoffset) );    gs_lgp->gnome_print_stroke ( m_gpc);}void wxGnomePrintDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle){    if (n==0) return;    if (m_brush.GetStyle () != wxTRANSPARENT)    {        SetBrush( m_brush );        int x = points[0].x + xoffset;        int y = points[0].y + yoffset;        CalcBoundingBox( x, y );        gs_lgp->gnome_print_newpath( m_gpc );        gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );        int i;        for (i = 1; i < n; i++)        {            int x = points[i].x + xoffset;            int y = points[i].y + yoffset;            gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );            CalcBoundingBox( x, y );        }        gs_lgp->gnome_print_closepath( m_gpc );        gs_lgp->gnome_print_fill( m_gpc );    }    if (m_pen.GetStyle () != wxTRANSPARENT)    {        SetPen (m_pen);        int x = points[0].x + xoffset;        int y = points[0].y + yoffset;        gs_lgp->gnome_print_newpath( m_gpc );        gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );        int i;        for (i = 1; i < n; i++)        {            int x = points[i].x + xoffset;            int y = points[i].y + yoffset;            gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );            CalcBoundingBox( x, y );        }        gs_lgp->gnome_print_closepath( m_gpc );        gs_lgp->gnome_print_stroke( m_gpc );    }}void wxGnomePrintDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle){    wxDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle );}void wxGnomePrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height){    if (m_brush.GetStyle () != wxTRANSPARENT)    {        SetBrush( m_brush );        gs_lgp->gnome_print_newpath( m_gpc );        gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );        gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) );        gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) );        gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) );        gs_lgp->gnome_print_closepath( m_gpc );        gs_lgp->gnome_print_fill( m_gpc );        CalcBoundingBox( x, y );        CalcBoundingBox( x + width, y + height );    }    if (m_pen.GetStyle () != wxTRANSPARENT)    {        SetPen (m_pen);        gs_lgp->gnome_print_newpath( m_gpc );        gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );        gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) );        gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) );        gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) );        gs_lgp->gnome_print_closepath( m_gpc );        gs_lgp->gnome_print_stroke( m_gpc );        CalcBoundingBox( x, y );        CalcBoundingBox( x + width, y + height );    }}void wxGnomePrintDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius){    wxCoord rad = (wxCoord) radius;    if (m_brush.GetStyle() != wxTRANSPARENT)    {        SetBrush(m_brush);        gs_lgp->gnome_print_newpath(m_gpc);        gs_lgp->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));        gs_lgp->gnome_print_curveto(m_gpc,                                    XLOG2DEV(x + rad),YLOG2DEV(y),                                    XLOG2DEV(x),YLOG2DEV(y),                                    XLOG2DEV(x),YLOG2DEV(y + rad));        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad));        gs_lgp->gnome_print_curveto(m_gpc,                                    XLOG2DEV(x),YLOG2DEV(y + height - rad),                                    XLOG2DEV(x),YLOG2DEV(y + height),                                    XLOG2DEV(x + rad),YLOG2DEV(y + height));        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width - rad),YLOG2DEV(y + height));        gs_lgp->gnome_print_curveto(m_gpc,                                    XLOG2DEV(x + width - rad),YLOG2DEV(y + height),                                    XLOG2DEV(x + width),YLOG2DEV(y + height),                                    XLOG2DEV(x + width),YLOG2DEV(y + height - rad));        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width),YLOG2DEV(y + rad));        gs_lgp->gnome_print_curveto(m_gpc,                                    XLOG2DEV(x + width),YLOG2DEV(y + rad),                                    XLOG2DEV(x + width),YLOG2DEV(y),                                    XLOG2DEV(x + width - rad),YLOG2DEV(y));        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));        gs_lgp->gnome_print_closepath(m_gpc);        gs_lgp->gnome_print_fill(m_gpc);        CalcBoundingBox(x,y);        CalcBoundingBox(x+width,y+height);    }    if (m_pen.GetStyle() != wxTRANSPARENT)    {        SetPen(m_pen);        gs_lgp->gnome_print_newpath(m_gpc);        gs_lgp->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));        gs_lgp->gnome_print_curveto(m_gpc,                                    XLOG2DEV(x + rad),YLOG2DEV(y),                                    XLOG2DEV(x),YLOG2DEV(y),                                    XLOG2DEV(x),YLOG2DEV(y + rad));        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad));        gs_lgp->gnome_print_curveto(m_gpc,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -