Exemplo n.º 1
0
bool
LprSetupView::UpdateViewData()
{
	if (*fServer->Text() && *fQueue->Text()) {

		try {
			LpsClient lpr(fServer->Text());
			lpr.connect();
		}

		catch (LPSException &err) {
			BAlert *alert = new BAlert("", err.what(), "OK");
			alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
			alert->Go();
			return false;
		}

		fDir->WriteAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, fServer->Text(),
			strlen(fServer->Text()) + 1);
		fDir->WriteAttr(LPR_QUEUE_NAME,  B_STRING_TYPE, 0, fQueue->Text(),
			strlen(fQueue->Text())  + 1);
		return true;
	}

	BAlert *alert = new BAlert("", "Please enter server address and printer"
		"queue name.", "OK");
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
	alert->Go();
	return false;
}
Exemplo n.º 2
0
void t32(int value)
{
	int n,cc;

	cc = lpr(value, &n);

	printf("new: %d cc: %d\n", n, cc);
}
Exemplo n.º 3
0
void NodeImporter::importSeacableLandingPoints() {
    // add submarine cable landingpoints
    std::unique_ptr<LandingPointReader> lpr(new LandingPointReader(_dbFilename));

    while (lpr->hasNext()) {
        SeaCableLandingPoint next = lpr->getNext();
        next.setId(_nodenumber);
        ++_nodenumber;
        GeographicNode_Ptr lp(new SeaCableLandingPoint(next));

        // find nearest node
        GeographicNode_Ptr nnP = findNearest(lp);
        double dist = GeometricHelpers::sphericalDist(lp, nnP);
        if (dist > NodeImporter::DIST_TRESHOLD)
            addNode(lp);
        else {
            CityNode* cnp = dynamic_cast<CityNode*>(nnP.get());
            if (cnp)
                cnp->setSeaCableLandingPoint();
        }
    }
}
Exemplo n.º 4
0
void YZPrinter::doPrint( )
{
    const double fontsize = 10.0;
    PSDoc *doc = PS_new();
    if (!doc)
        return ;
    QByteArray p = m_path.toLatin1();
    PS_open_file(doc, p.data());
    PS_set_info(doc, "Creator", "Yzis");
    PS_set_info(doc, "Author", "");
    PS_set_info(doc, "Title", p.data());
    // Set so it'll fit on both A4 and letter paper;
    // some of us live in the US, with archaic paper sizes. ;-)
    PS_set_info(doc, "BoundingBox", "0 0 596 792");
    int font;
    font = PS_findfont(doc, "Fixed", "", 0);
    dbg() << "findfont returned " << font << endl;
    if ( !font ) return ; //no font => abort

    QPrinter lpr(QPrinter::PrinterResolution);
    QPainter p( &lpr );

    QFont f( "fixed" );
    f.setFixedPitch( true );
    f.setStyleHint( QFont::TypeWriter );
    p.setFont( f );

    unsigned int height = lpr.height();
    unsigned int width = lpr.width();

    unsigned int linespace = p.fontMetrics().lineSpacing();
    unsigned int maxwidth = p.fontMetrics().maxWidth();

    p.end();

    PS_set_value(doc, "leading", linespace);

    unsigned int clipw = width / maxwidth - 1;
    unsigned int cliph = height / linespace - 1;

    unsigned int oldLinesVis = mView->getLinesVisible( );
    unsigned int oldColumnsVis = mView->getColumnsVisible( );

    //should be current's view setting no ? XXX
    bool number = mView->getLocalBooleanOption( "number" );
    unsigned int marginLeft = 0;

    double red, green, blue;

    if ( number ) {
        marginLeft = ( 2 + QString::number( mView->buffer()->lineCount() ).length() );
    }

    YOptionValue* ov_wrap = mView->getLocalOption( "wrap" );
    bool oldWrap = ov_wrap->boolean();
    ov_wrap->setBoolean( true );

    mView->setVisibleArea( clipw - marginLeft, cliph, false );
    unsigned int totalHeight = mView->drawTotalHeight();
    mView->setVisibleArea( clipw - marginLeft, totalHeight, false );
    mView->initDraw( 0, 0, 0, 0 );

    unsigned int lastLineNumber = 0;
    unsigned int pageNumber = 0;

    QRect titleRect( 0, 0, width, linespace + linespace / 2 );

    unsigned int topY = titleRect.height() + linespace;
    unsigned int curY = topY;
    unsigned int curX;

    cliph = ( height - topY ) / linespace;
    int nbPages = totalHeight / cliph + ( totalHeight % cliph ? 1 : 0 );
    PS_begin_page(doc, 596, 792);
    PS_setfont(doc, font, fontsize);
    PS_set_parameter(doc, "hyphenation", "false");
    PS_set_parameter(doc, "linebreak", "true");
    PS_set_parameter(doc, "parbreak", "false");
    PS_set_value(doc, "parindent", 0.0);
    PS_set_value(doc, "numindentlines", 0.0);

    while ( mView->drawNextLine( ) ) {
        if ( curY == topY ) {
            if ( pageNumber ) {
                PS_end_page(doc);
                PS_begin_page(doc, 596, 792);
                PS_setfont(doc, font, fontsize);
                PS_set_value(doc, "leading", linespace);
            }
            ++pageNumber;
            convertColor(Qt::black, red, green, blue);
            PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0);
            QByteArray n = ( ' ' + mView->buffer()->fileName() ).toLatin1();
            PS_show_boxed(doc, n.data(),
                          titleRect.x(), titleRect.y(), titleRect.width(),
                          titleRect.height(), "left", "");
            QByteArray nb = ( QString::number( pageNumber ) + '/' + QString::number( nbPages ) + ' ' ).toLatin1();
            PS_show_boxed(doc,
                          nb.data(),
                          titleRect.x(), titleRect.y(), titleRect.width(),
                          titleRect.height(), "right", "");
        }
        if ( number ) {
            unsigned int lineNumber = mView->drawLineNumber();
            if ( lineNumber != lastLineNumber ) {
                //p.setPen( Qt::gray );
                convertColor(Qt::gray, red, green, blue);
                PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0);
                PS_moveto(doc, 0, curY);
                QByteArray m = QString::number( lineNumber ).rightJustified( marginLeft - 1, ' ' ).toLatin1();
                PS_show(doc, m.data());
                lastLineNumber = lineNumber;
            }
        }
        curX = marginLeft * maxwidth;
        while ( mView->drawNextCol( ) ) {
            QColor c = mView->drawColor( );
            if ( c.isValid() && c != Qt::white )
                convertColor(mView->drawColor(), red, green, blue);
            else
                convertColor(Qt::black, red, green, blue);
            PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0);
            char buf[2] = {
                              0, 0
                          };
            buf[0] = mView->drawChar().toLatin1();
            PS_show_xy(doc, buf, curX, curY);
            curX += mView->drawLength( ) * maxwidth;
        }
        curY += linespace * mView->drawHeight();
        if ( curY >= cliph * linespace + topY ) {
            // draw Rect
            convertColor(Qt::black, red, green, blue);
            PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0);
            PS_rect(doc, 0, 0, width, curY);
            if ( number ) {
                PS_moveto(doc, marginLeft*maxwidth - maxwidth / 2, titleRect.height());
                PS_lineto(doc, marginLeft*maxwidth - maxwidth / 2, curY);
            }
            PS_moveto(doc, titleRect.x(), titleRect.height());
            PS_lineto(doc, titleRect.width(), titleRect.height());
            curY = topY;
        }
    }
    if ( curY != topY ) {
        // draw Rect
        convertColor(Qt::black, red, green, blue);
        PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0);
        PS_rect(doc, 0, 0, width, curY);
        if ( number ) {
            PS_moveto(doc, marginLeft*maxwidth - maxwidth / 2, titleRect.height());
            PS_lineto(doc, marginLeft*maxwidth - maxwidth / 2, curY);
        }
        PS_moveto(doc, titleRect.x(), titleRect.height());
        PS_lineto(doc, titleRect.width(), titleRect.height());
    }
    PS_end_page(doc);
    PS_deletefont(doc, font);
    PS_close(doc);
    PS_delete(doc);
    PS_shutdown();

    ov_wrap->setBoolean( oldWrap );
    mView->setVisibleArea( oldColumnsVis, oldLinesVis, false );
}