Example #1
0
void TestPageTextInfo::testPageNumber()
{
    KWPageManager manager;
    QCOMPARE(manager.pageCount(), 0);

    KWPage page1 = manager.appendPage();
    KWPage page2 = manager.appendPage();
    KWPage page3 = manager.appendPage();
    KWPage page4 = manager.appendPage();
    KWPage page5 = manager.appendPage();

    KWPageStyle style2("foo");
    manager.addPageStyle(style2);
    KWPage page40 = manager.appendPage(style2);
    QCOMPARE(page40.pageNumber(), 6);
    page40.setPageNumber(40);
    QCOMPARE(page5.pageNumber(), 5);
    QCOMPARE(page40.pageNumber(), 40);
    KWPage page41 = manager.appendPage();
    QCOMPARE(page41.pageNumber(), 41);

    KWPageTextInfo info1(page1);
    QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 0), 1);
    QCOMPARE(info1.pageNumber(KoTextPage::PreviousPage, 0), -1);
    QCOMPARE(info1.pageNumber(KoTextPage::NextPage, 0), 2);

    QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 4), 5);
    QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 5), -1);
    QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 40), 41);
    QCOMPARE(info1.pageNumber(KoTextPage::PreviousPage, 1), -1);
    QCOMPARE(info1.pageNumber(KoTextPage::NextPage, 3), 5);
    QCOMPARE(info1.pageNumber(KoTextPage::NextPage, 4), -1);

    KWPageTextInfo info2(page2);
    QCOMPARE(info2.pageNumber(KoTextPage::CurrentPage, 0), 2);
    QCOMPARE(info2.pageNumber(KoTextPage::PreviousPage, 0), 1);
    QCOMPARE(info2.pageNumber(KoTextPage::NextPage, 0), 3);

    KWPageTextInfo info3(page5);
    QCOMPARE(info3.pageNumber(KoTextPage::CurrentPage, 0), 5);
    QCOMPARE(info3.pageNumber(KoTextPage::PreviousPage, 0), 4);
    QCOMPARE(info3.pageNumber(KoTextPage::NextPage, 0), 40);

    KWPageTextInfo info40(page40);
    QCOMPARE(info40.pageNumber(KoTextPage::CurrentPage, 0), 40);
    QCOMPARE(info40.pageNumber(KoTextPage::PreviousPage, 0), 5);
    QCOMPARE(info40.pageNumber(KoTextPage::NextPage, 0), 41);

    KWPageTextInfo info41(page41);
    QCOMPARE(info41.pageNumber(KoTextPage::CurrentPage, 0), 41);
    QCOMPARE(info41.pageNumber(KoTextPage::PreviousPage, 0), 40);
    QCOMPARE(info41.pageNumber(KoTextPage::NextPage, 0), -1);
}
void TestFrameLayout::testCreateNewFrameForPage()
{
    QFETCH(QStringList, pages);
    QFETCH(int, frameSetType);
    QFETCH(int, pageNumber);
    QFETCH(int, expectedFrameCount);

    QHash<QString, KWPageStyle> styles;
    KWPageStyle style1("style1");
    style1.setHeaderPolicy(Words::HFTypeNone);
    style1.setHasMainTextFrame(true);
    style1.setFooterPolicy(Words::HFTypeNone);
    styles.insert(style1.name(), style1);

    KWPageStyle style2("style2");
    style2.setHeaderPolicy(Words::HFTypeEvenOdd);
    style2.setHasMainTextFrame(true);
    style2.setFooterPolicy(Words::HFTypeUniform);
    styles.insert(style2.name(), style2);

    KWPageStyle style3("style3"); // weird
    style3.setHeaderPolicy(Words::HFTypeEvenOdd);
    style3.setHasMainTextFrame(false);
    style3.setFooterPolicy(Words::HFTypeUniform);
    styles.insert(style3.name(), style3);

    KWPageStyle style4("style4");
    style4.setHeaderPolicy(Words::HFTypeUniform);
    style4.setHasMainTextFrame(true);
    style4.setFooterPolicy(Words::HFTypeEvenOdd);
    KoColumns columns;
    columns.count = 2;
    columns.gapWidth = 4;
    style4.setColumns(columns);
    styles.insert(style4.name(), style4);

    KWPageStyle style5("style5"); // blank
    style5.setHeaderPolicy(Words::HFTypeNone);
    style5.setHasMainTextFrame(false);
    style5.setFooterPolicy(Words::HFTypeNone);
    style5.setColumns(columns);
    styles.insert(style5.name(), style5);

    KWPageManager manager;
    foreach (const QString &styleName, pages) {
        QVERIFY(styles.contains(styleName));
        manager.appendPage(styles[styleName]);
    }
void TestPageCommands::testPageSpread()
{
    // setup a doc with multiple pages like;
    //   1: S1, 2: S1, 3: S1, 4: S2, 5: S1, 6:S2, 7: S2

    KWDocument document;
    KWPageManager *manager = document.pageManager();

    KWPageStyle style("pagestyle1");
    KoPageLayout lay = style.pageLayout();
    lay.width = 300;
    lay.height = 500;
    style.setPageLayout(lay);

    KWPageStyle style2("pagestyle2");
    lay = style.pageLayout();
    lay.width = 400;
    lay.height = 400;
    style2.setPageLayout(lay);
    KWPage p1 = manager->appendPage(style);
    KWPage p2 = manager->appendPage(style);
    KWPage p3 = manager->appendPage(style);
    KWPage p4 = manager->appendPage(style2);
    KWPage p5 = manager->appendPage(style);
    KWPage p6 = manager->appendPage(style2);
    KWPage p7 = manager->appendPage(style2);

    KWFrameSet *fs = new KWFrameSet();
    for (int i = 1; i <= manager->pageCount(); ++i) {
        // create one frame per page. Positioned relative to the top of the page.
        KWPage page = manager->page(i);
        QVERIFY(page.isValid());
        MockShape *shape = new MockShape();
        new KWFrame(shape, fs);
        shape->setPosition(QPointF(-10, page.offsetInDocument() + 10));
    }
    document.addFrameSet(fs);

    // when changing S1 from normal to pagespread I expect
    //  page 1 to stay the same.
    //  page 2 to become a pagespread
    //  page 3 to be deleted
    //  page 4 to stay the same.
    //  page 5 to become a page spread and gets pageNumber 6
    //  page 6 to become page 7 and become a Right page
    //  page 7 to become page 8 and become a Left page
    //  there will be a new KWPage for page 5
    // all frames to be moved so they are still at the same relative location
    // to their original page' top

    KWPageStyle style3("dummy");
    lay.leftMargin = -1;
    lay.rightMargin = -1;
    lay.pageEdge = 7;
    lay.bindingSide = 13;
    style2.setPageLayout(lay);
    KWPageStylePropertiesCommand cmd(&document, style, style3);
    cmd.redo();

    QCOMPARE(manager->pageCount(), 7);
QEXPECT_FAIL("", "Not done yet", Abort);
    QCOMPARE(p1.height(), 500.);
    QCOMPARE(p1.width(), 300.);
    QCOMPARE(p1.pageSide(), KWPage::Right);
    QCOMPARE(p1.pageNumber(), 1);
    QCOMPARE(p2.height(), 500.);
    QCOMPARE(p2.width(), 600.);
    QCOMPARE(p2.pageSide(), KWPage::PageSpread);
    QCOMPARE(p2.pageNumber(), 2);
    QVERIFY(!p3.isValid());
    QCOMPARE(p4.pageSide(), KWPage::Left);
    QCOMPARE(p4.width(), 300.);
    QCOMPARE(p4.height(), 500.);
    QCOMPARE(p4.pageNumber(), 4);
    QCOMPARE(p5.width(), 600.);
    QCOMPARE(p5.height(), 500.);
    QCOMPARE(p5.pageSide(), KWPage::PageSpread);
    QCOMPARE(p5.pageNumber(), 6);
    QCOMPARE(p6.pageSide(), KWPage::Right);
    QCOMPARE(p6.width(), 400.);
    QCOMPARE(p6.pageNumber(), 7);
    QCOMPARE(p7.pageSide(), KWPage::Left);
    QCOMPARE(p7.width(), 400.);
    QCOMPARE(p7.pageNumber(), 8);

    KWPage newPage5 = manager->page(5);
    QCOMPARE(newPage5.pageStyle(), style);
    QCOMPARE(newPage5.width(), 400.);
    QCOMPARE(newPage5.height(), 400.);
    QCOMPARE(newPage5.pageSide(), KWPage::Left);

    QCOMPARE(fs->frames()[0]->shape()->position(), QPointF(-10, 10));
    // TODO figure out what the actual numbers should be below
    QCOMPARE(fs->frames()[1]->shape()->position(), QPointF(-10, 10));
    QCOMPARE(fs->frames()[2]->shape()->position(), QPointF(-10, 10));
    QCOMPARE(fs->frames()[3]->shape()->position(), QPointF(-10, 10));
    QCOMPARE(fs->frames()[4]->shape()->position(), QPointF(-10, 10));
    QCOMPARE(fs->frames()[5]->shape()->position(), QPointF(-10, 10));
    QCOMPARE(fs->frames()[6]->shape()->position(), QPointF(-10, 10));
}
void TestPageCommands::testPageStylePropertiesCommand2()
{
    /*
      make setup where multiple, interspaced pages use the style we want to change.
      add some frames.
      check if the frames moved properly when the page gets a new size
      check that all pages got their new size
      check that the name of the style did not change
    */
    KWDocument document;
    KWPageManager *manager = document.pageManager();

    KWPageStyle style("pagestyle1");
    KoPageLayout lay = style.pageLayout();
    lay.width = 300;
    lay.height = 500;
    style.setPageLayout(lay);

    KWPageStyle style2("pagestyle2");
    lay = style.pageLayout();
    lay.width = 400;
    lay.height = 400;
    style2.setPageLayout(lay);
    KWPage p1 = manager->appendPage(style2);
    KWPage p2 = manager->appendPage(style);
    KWPage p3 = manager->appendPage(style);
    KWPage p4 = manager->appendPage(style2);
    KWPage p5 = manager->appendPage(style2);
    KWPage p6 = manager->appendPage(style);
    KWPage p7 = manager->appendPage(style);
    KWPage p8 = manager->appendPage(style);
    KWPage p9 = manager->appendPage(style2);
    QCOMPARE(manager->pageCount(), 9);

    KWFrameSet *fs = new KWFrameSet();
    for (int i = 1; i <= manager->pageCount(); ++i) {
        // create one frame per page. Positioned relative to the top of the page.
        KWPage page = manager->page(i);
        QVERIFY(page.isValid());
        MockShape *shape = new MockShape();
        new KWFrame(shape, fs);
        shape->setPosition(QPointF(-10, page.offsetInDocument() + 10));
    }
    document.addFrameSet(fs);

    // lets prepare to change the style to a new page size.
    KWPageStyle newStyle("foo");
    lay = newStyle.pageLayout();
    lay.width = 350;
    lay.height = 1000;
    newStyle.setPageLayout(lay);

    KWPageStylePropertiesCommand command(&document, style, newStyle);

    // nothing happens in constructor before redo;
    for (int i = 1; i <= manager->pageCount(); ++i) {
        KWPage page = manager->page(i);
        QVERIFY(page.height() <= 500); // not 1000 yet
        QVERIFY(page.isValid());
        KoShape *shape = fs->frames().at(i-1)->shape();
        QCOMPARE(shape->position(), QPointF(-10, page.offsetInDocument() + 10));
    }

    const qreal lastPageOffset = p9.offsetInDocument();

    command.redo();
    QCOMPARE(manager->pageCount(), 9);
    QCOMPARE(p1.height(), 400.);
    QCOMPARE(p4.height(), 400.);
    QCOMPARE(p5.height(), 400.);
    QCOMPARE(p9.height(), 400.);
    QCOMPARE(p2.height(), 1000.);
    QCOMPARE(p3.height(), 1000.);
    QCOMPARE(p6.height(), 1000.);
    QCOMPARE(p7.height(), 1000.);
    QCOMPARE(p8.height(), 1000.);
    QCOMPARE(lastPageOffset + 2500, p9.offsetInDocument());
    for (int i = 1; i <= manager->pageCount(); ++i) {
        KWPage page = manager->page(i);
        QVERIFY(page.isValid());
        KoShape *shape = fs->frames().at(i-1)->shape();
        QCOMPARE(shape->position(), QPointF(-10, page.offsetInDocument() + 10));
    }
}
void TestPageCommands::testPageStylePropertiesCommand() // basic properties change
{
    KWDocument document;
    KWPageManager *manager = document.pageManager();

    KWPageStyle style("pagestyle1");
    KoPageLayout oldLayout;
    oldLayout.format = KoPageFormat::IsoA4Size;
    oldLayout.width = 101;
    oldLayout.height = 102;
    oldLayout.leftMargin = -1;
    oldLayout.rightMargin = -1;
    oldLayout.pageEdge = 7;
    oldLayout.bindingSide = 13;
    style.setPageLayout(oldLayout);

    KoColumns oldColumns;
    oldColumns.count = 4;
    oldColumns.gapWidth = 21;
    style.setColumns(oldColumns);
    KWPage page1 = manager->appendPage(style);
    page1.setDirectionHint(KoText::LeftRightTopBottom);

    QCOMPARE(page1.pageNumber(), 1);
    QCOMPARE(page1.width(), 101.);
    QCOMPARE(page1.height(), 102.);
    QCOMPARE(page1.leftMargin(), 13.); // its a right-sided page
    QCOMPARE(page1.pageEdgeMargin(), 7.);
    QCOMPARE(page1.directionHint(), KoText::LeftRightTopBottom);
    QCOMPARE(page1.pageStyle().columns().count, 4);
    QCOMPARE(page1.pageSide(), KWPage::Right);

    // new ;)
    KWPageStyle style2("pagestyle2");
    KoPageLayout newLayout;
    newLayout.width = 401;
    newLayout.height = 405;
    newLayout.leftMargin = 11;
    newLayout.rightMargin = 18;
    newLayout.pageEdge = -1;
    newLayout.bindingSide = -1;
    style2.setPageLayout(newLayout);
    KoColumns newColumns;
    newColumns.count = 2;
    newColumns.columnData.append(ColumnDatum(1.0, 2.0, 1.0, 1.0, 25));
    newColumns.columnData.append(ColumnDatum(1.0, 1.0, 1.0, 1.0, 50));
    style2.setColumns(newColumns);
    style2.setDirection(KoText::RightLeftTopBottom);

    KWPageStylePropertiesCommand command1(&document, style, style2);

    // nothing changed before the redo
    QCOMPARE(page1.width(), 101.);
    QCOMPARE(page1.height(), 102.);
    QCOMPARE(page1.leftMargin(), 13.); // its a right-sided page
    QCOMPARE(page1.pageEdgeMargin(), 7.);
    QCOMPARE(page1.directionHint(), KoText::LeftRightTopBottom);

    // redo
    command1.redo();
    QCOMPARE(page1.pageStyle().name(), QString("pagestyle1")); // name didn't change
    QCOMPARE(page1.width(), 401.);
    QCOMPARE(page1.height(), 405.);
    QCOMPARE(page1.leftMargin(), 11.);
    QCOMPARE(page1.pageEdgeMargin(), -1.); // its a right-sided page
    QCOMPARE(page1.pageStyle().direction(), KoText::RightLeftTopBottom);
    QCOMPARE(page1.directionHint(), KoText::LeftRightTopBottom);
    page1.setDirectionHint(KoText::InheritDirection); // reset to what the style says
    QCOMPARE(page1.directionHint(), KoText::RightLeftTopBottom);
    QCOMPARE(style.pageLayout().width, 401.); // style changed
    QCOMPARE(page1.pageStyle().columns().count, 2);
    QCOMPARE(page1.pageNumber(), 1);
    QCOMPARE(page1.pageSide(), KWPage::Right);

    QCOMPARE(manager->pageCount(), 1);
    QVERIFY(manager->page(1).isValid());
    QVERIFY(!manager->page(2).isValid());

    KWPage page2 = manager->appendPage(style);
    QCOMPARE(manager->pageCount(), 2);
    QVERIFY(manager->page(1).isValid());
    QVERIFY(manager->page(2).isValid());
    QVERIFY(!manager->page(3).isValid());
    QCOMPARE(page2.pageNumber(), 2);
    QCOMPARE(page2.pageSide(), KWPage::Left);

    // undo
    command1.undo();
    QCOMPARE(page1.pageStyle().name(), QString("pagestyle1")); // name didn't change
    QCOMPARE(page1.width(), 101.);
    QCOMPARE(page1.height(), 102.);
    QCOMPARE(page1.leftMargin(), 13.);
    QCOMPARE(page1.directionHint(), KoText::AutoDirection);
    QCOMPARE(style.pageLayout().width, 101.);
    QCOMPARE(page1.pageStyle().columns().count, 4);
    QCOMPARE(page1.pageNumber(), 1);
    QCOMPARE(page1.pageSide(), KWPage::Right);
    QCOMPARE(manager->pageCount(), 2);
    QVERIFY(manager->page(1).isValid());
    QVERIFY(manager->page(2).isValid());
    QVERIFY(!manager->page(3).isValid());
    QCOMPARE(page2.pageNumber(), 2);
    QCOMPARE(page2.pageSide(), KWPage::Left);
    QCOMPARE(page2.width(), 101.); // same style
    QCOMPARE(page2.height(), 102.);
    QCOMPARE(page2.leftMargin(), 7.);
    QCOMPARE(page2.directionHint(), KoText::AutoDirection);
}
Example #6
0
void
drawing()
{
  wxPdfDocument pdf;
  pdf.SetFont(wxT("Helvetica"), wxT(""), 10);

  wxImage pattern1(wxT("pattern1.png"));
  wxImage pattern2(wxT("pattern2.png"));
  pdf.AddPattern(wxT("pattern1"), pattern1, 5, 5);
  pdf.AddPattern(wxT("pattern2"), pattern2, 10, 10);

  pdf.AddPage();

  wxPdfArrayDouble dash1;
  dash1.Add(3.5);
  dash1.Add(7.0);
  dash1.Add(1.75);
  dash1.Add(3.5);
  wxPdfLineStyle style(0.5, wxPDF_LINECAP_BUTT, wxPDF_LINEJOIN_MITER, dash1, 3.5, wxColour(255, 0, 0));

  wxPdfArrayDouble dash2;
  wxPdfLineStyle style2(0.5, wxPDF_LINECAP_BUTT, wxPDF_LINEJOIN_MITER, dash2, 0., wxColour(255, 0, 0));

  wxPdfArrayDouble dash3;
  dash3.Add(0.7);
  dash3.Add(3.5);
  wxPdfLineStyle style3(1.0, wxPDF_LINECAP_ROUND, wxPDF_LINEJOIN_ROUND, dash3, 0., wxColour(255, 0, 0));
  
  wxPdfLineStyle style4(0.5, wxPDF_LINECAP_BUTT, wxPDF_LINEJOIN_MITER, dash1, 3.5, wxColour(255, 0, 0));
  
  wxPdfArrayDouble dash5;
  wxPdfLineStyle style5(0.25, wxPDF_LINECAP_BUTT, wxPDF_LINEJOIN_MITER, dash5, 0., wxColour(0, 0, 0));

  wxPdfArrayDouble dash6;
  dash6.Add(3.5);
  dash6.Add(3.5);
  wxPdfLineStyle style6(0.5, wxPDF_LINECAP_BUTT, wxPDF_LINEJOIN_MITER, dash6, 0., wxColour(0, 255, 0));

  wxPdfArrayDouble dash7;
  wxPdfLineStyle style7(2.5, wxPDF_LINECAP_BUTT, wxPDF_LINEJOIN_MITER, dash7, 3.5, pdf.GetPatternColour(wxT("pattern1")) /*wxColour(200, 200, 0)*/);

  wxPdfArrayDouble dash8;
  wxPdfLineStyle style8(0.5, wxPDF_LINECAP_BUTT, wxPDF_LINEJOIN_MITER, dash8, 0., wxColour(0, 0, 0));

  // Line
  pdf.Text(5, 7, wxT("Line examples"));
  pdf.SetLineStyle(style);
  pdf.Line(5, 10, 80, 30);
  pdf.SetLineStyle(style2);
  pdf.Line(5, 10, 5, 30);
  pdf.SetLineStyle(style3);
  pdf.Line(5, 10, 80, 10);

  // Rect
  pdf.Text(100, 7, wxT("Rectangle examples"));
  pdf.SetLineStyle(style5);
  pdf.SetFillColour(wxColour(220, 220, 200));
  pdf.Rect(100, 10, 40, 20, wxPDF_STYLE_FILLDRAW);
  pdf.SetLineStyle(style3);
  pdf.Rect(145, 10, 40, 20, wxPDF_STYLE_DRAW);

  // Curve
  pdf.Text(5, 37, wxT("Curve examples"));
  pdf.SetLineStyle(style6);
  pdf.Curve(5, 40, 30, 55, 70, 45, 60, 75, wxPDF_STYLE_DRAW);
  pdf.Curve(80, 40, 70, 75, 150, 45, 100, 75, wxPDF_STYLE_FILL);
  pdf.SetFillColour(wxColour(200, 220, 200));
  pdf.Curve(140, 40, 150, 55, 180, 45, 200, 75, wxPDF_STYLE_FILLDRAW);

  // Circle and ellipse
  pdf.Text(5, 82, wxT("Circle and ellipse examples"));
  pdf.SetLineStyle(style5);
  pdf.Circle(25,105,20);
  pdf.SetLineStyle(style6);
  pdf.Circle(25,105,10, 90, 180, wxPDF_STYLE_DRAW);
  pdf.Circle(25,105,10, 270, 360, wxPDF_STYLE_FILL);
  pdf.Circle(25,105,10, 270, 360, wxPDF_STYLE_DRAWCLOSE);

  pdf.SetLineStyle(style5);
  pdf.Ellipse(100,105,40,20);
  pdf.SetLineStyle(style6);
  pdf.Ellipse(100,105,20,10, 0, 90, 180, wxPDF_STYLE_DRAW);
  pdf.Ellipse(100,105,20,10, 0, 270, 360, wxPDF_STYLE_FILLDRAW);

  pdf.SetLineStyle(style5);
  pdf.Ellipse(175,105,30,15, 45);
  pdf.SetLineStyle(style6);
  pdf.Ellipse(175,105,15,7.50, 45, 90, 180, wxPDF_STYLE_DRAW);
  pdf.SetFillColour(wxColour(220, 200, 200));
  pdf.Ellipse(175,105,15,7.50, 45, 270, 360, wxPDF_STYLE_FILL);

  // Polygon
  pdf.Text(5, 132, wxT("Polygon examples"));
  pdf.SetLineStyle(style8);

  wxPdfArrayDouble x1, y1;
  x1.Add(5);  y1.Add(135);
  x1.Add(45); y1.Add(135);
  x1.Add(15); y1.Add(165);
  pdf.Polygon(x1, y1);

  wxPdfArrayDouble x2, y2;
  x2.Add(60); y2.Add(135);
  x2.Add(80); y2.Add(135);
  x2.Add(80); y2.Add(155);
  x2.Add(70); y2.Add(165);
  x2.Add(50); y2.Add(155);
  pdf.SetLineStyle(style6);
  pdf.Polygon(x2, y2, wxPDF_STYLE_FILLDRAW);

  wxPdfArrayDouble x3, y3;
  x3.Add(120); y3.Add(135);
  x3.Add(140); y3.Add(135);
  x3.Add(150); y3.Add(155);
  x3.Add(110); y3.Add(155);
  pdf.SetLineStyle(style7);
  pdf.Polygon(x3, y3, wxPDF_STYLE_DRAW);

  wxPdfArrayDouble x4, y4;
  x4.Add(160); y4.Add(135);
  x4.Add(190); y4.Add(155);
  x4.Add(170); y4.Add(155);
  x4.Add(200); y4.Add(160);
  x4.Add(160); y4.Add(165);
  pdf.SetLineStyle(style6);
  //pdf.SetFillColour(wxColour(220, 220, 220));
  pdf.SetFillPattern(wxT("pattern2"));
  pdf.Polygon(x4, y4, wxPDF_STYLE_FILLDRAW);

  // Regular polygon
  pdf.Text(5, 172, wxT("Regular polygon examples"));
  pdf.SetLineStyle(style5);
  pdf.SetFillColour(wxColour(220, 220, 220));
  pdf.RegularPolygon(20, 190, 15, 6, 0, 1, wxPDF_STYLE_FILL);
  pdf.RegularPolygon(55, 190, 15, 6);
  pdf.SetLineStyle(style7);
  pdf.RegularPolygon(55, 190, 10, 6, 45, 0, wxPDF_STYLE_FILLDRAW);
  pdf.SetLineStyle(style5);
  pdf.SetFillColour(wxColour(200, 220, 200));
  pdf.RegularPolygon(90, 190, 15, 3, 0, 1, wxPDF_STYLE_FILLDRAW,
                                           wxPDF_STYLE_FILL, wxPdfLineStyle(), wxColour(255, 200, 200));
  pdf.RegularPolygon(125, 190, 15, 4, 30, 1, wxPDF_STYLE_DRAW, wxPDF_STYLE_DRAW, style6);
  pdf.RegularPolygon(160, 190, 15, 10);

  // Star polygon
  pdf.Text(5, 212, wxT("Star polygon examples"));
  pdf.SetLineStyle(style5);
  pdf.StarPolygon(20, 230, 15, 20, 3, 0, 1, wxPDF_STYLE_FILL);
  pdf.StarPolygon(55, 230, 15, 12, 5);
  pdf.SetLineStyle(style7);
  pdf.StarPolygon(55, 230, 7, 12, 5, 45, 0, wxPDF_STYLE_FILLDRAW);
  pdf.SetLineStyle(style5);
  pdf.SetFillColour(wxColour(220, 220, 200));
  pdf.StarPolygon(90, 230, 15, 20, 6, 0, 1, wxPDF_STYLE_FILLDRAW,
                                            wxPDF_STYLE_FILL, wxPdfLineStyle(), wxColour(255, 200, 200));
  pdf.StarPolygon(125, 230, 15, 5, 2, 30, 1, wxPDF_STYLE_DRAW, wxPDF_STYLE_DRAW, style6);
  pdf.StarPolygon(160, 230, 15, 10, 3);
  pdf.StarPolygon(160, 230, 7, 50, 26);

  // Rounded rectangle
  pdf.Text(5, 252, wxT("Rounded rectangle examples"));
  pdf.SetLineStyle(style8);
  pdf.RoundedRect(5, 255, 40, 30, 3.50, wxPDF_CORNER_ALL, wxPDF_STYLE_FILLDRAW);
  pdf.RoundedRect(50, 255, 40, 30, 6.50, wxPDF_CORNER_TOP_LEFT);
  pdf.SetLineStyle(style6);
  pdf.RoundedRect(95, 255, 40, 30, 10.0, wxPDF_CORNER_ALL, wxPDF_STYLE_DRAW);
  pdf.SetFillColour(wxColour(200, 200, 200));
  pdf.RoundedRect(140, 255, 40, 30, 8.0, wxPDF_CORNER_TOP_RIGHT | wxPDF_CORNER_BOTTOM_RIGHT, wxPDF_STYLE_FILLDRAW);

  pdf.AddPage();

  pdf.SetFont(wxT("Helvetica"), wxT("B"), 20);
  pdf.SetLineWidth(1);

  pdf.SetDrawColour(50, 0, 0, 0);
  pdf.SetFillColour(100, 0, 0, 0);
  pdf.SetTextColour(100, 0, 0, 0);
  pdf.Rect(10, 10, 20, 20, wxPDF_STYLE_FILLDRAW);
  pdf.Text(10, 40, wxT("Cyan"));

  pdf.SetDrawColour(0, 50, 0, 0);
  pdf.SetFillColour(0, 100, 0, 0);
  pdf.SetTextColour(0, 100, 0, 0);
  pdf.Rect(40, 10, 20, 20, wxPDF_STYLE_FILLDRAW);
  pdf.Text(40, 40, wxT("Magenta"));

  pdf.SetDrawColour(0, 0, 50, 0);
  pdf.SetFillColour(0, 0, 100, 0);
  pdf.SetTextColour(0, 0, 100, 0);
  pdf.Rect(70, 10, 20, 20, wxPDF_STYLE_FILLDRAW);
  pdf.Text(70, 40, wxT("Yellow"));

  pdf.SetDrawColour(0, 0, 0, 50);
  pdf.SetFillColour(0, 0, 0, 100);
  pdf.SetTextColour(0, 0, 0, 100);
  pdf.Rect(100, 10, 20, 20, wxPDF_STYLE_FILLDRAW);
  pdf.Text(100, 40, wxT("Black"));

  pdf.SetDrawColour(128, 0, 0);
  pdf.SetFillColour(255, 0, 0);
  pdf.SetTextColour(255, 0, 0);
  pdf.Rect(10, 50, 20, 20, wxPDF_STYLE_FILLDRAW);
  pdf.Text(10, 80, wxT("Red"));

  pdf.SetDrawColour(0, 127, 0);
  pdf.SetFillColour(0, 255, 0);
  pdf.SetTextColour(0, 255, 0);
  pdf.Rect(40, 50, 20, 20, wxPDF_STYLE_FILLDRAW);
  pdf.Text(40, 80, wxT("Green"));

  pdf.SetDrawColour(0, 0, 127);
  pdf.SetFillColour(0, 0, 255);
  pdf.SetTextColour(0, 0, 255);
  pdf.Rect(70, 50, 20, 20, wxPDF_STYLE_FILLDRAW);
  pdf.Text(70, 80, wxT("Blue"));

  pdf.SetDrawColour(127);
  pdf.SetFillColour(0);
  pdf.SetTextColour(0);
  pdf.Rect(10, 90, 20, 20, wxPDF_STYLE_FILLDRAW);
  pdf.Text(10, 120, wxT("Gray"));

  pdf.AddSpotColour(wxT("PANTONE 404 CVC"), 0, 9.02, 23.14, 56.08);
  pdf.SetFillColour(wxString(wxT("PANTONE 404 CVC")));
  pdf.Rect(10, 130, 20, 20, wxPDF_STYLE_FILL);
  pdf.Text(10, 160, wxT("PANTONE 404 CVC"));

  pdf.SetLineWidth(0.2);
  pdf.SetFont(wxT("Helvetica"), wxT(""), 48);
  pdf.SetTextRenderMode(wxPDF_TEXT_RENDER_FILLSTROKE);
  pdf.SetDrawColour(31);
  pdf.SetTextPattern(wxT("pattern2"));
  pdf.Text(10, 200, wxT("Text with Pattern"));
  pdf.SetTextRenderMode();
  pdf.SetTextColour(0);

  pdf.AddPage();
  pdf.SetFont(wxT("Helvetica"), wxT(""), 10);
  pdf.SetLineWidth(0.2);
  pdf.SetDrawColour(0);

  pdf.Curve(25, 40, 50, 55, 90, 45, 80, 75, wxPDF_STYLE_DRAW);
  wxPdfShape shape1;
  shape1.MoveTo(25,40);
  shape1.CurveTo(50, 55, 90, 45, 80, 75);
  pdf.ShapedText(shape1, wxT("This is a simple text string along a shaped line."));

  pdf.Curve(80, 175, 90, 145, 50, 155, 25, 140, wxPDF_STYLE_DRAW);
  wxPdfShape shape2;
  shape2.MoveTo(80, 175);
  shape2.CurveTo(90, 145, 50, 155, 25, 140);
  pdf.ShapedText(shape2, wxT("This is a simple text string along a shaped line."));

  pdf.Curve(125, 40, 150, 55, 190, 45, 180, 75, wxPDF_STYLE_DRAW);
  wxPdfShape shape3;
  shape3.MoveTo(125,40);
  shape3.CurveTo(150, 55, 190, 45, 180, 75);
  pdf.ShapedText(shape3, wxT("Repeat me! "), wxPDF_SHAPEDTEXTMODE_REPEAT);

  wxPdfShape shape4;
  shape4.MoveTo(125, 130);
  shape4.LineTo(150, 130);
  shape4.LineTo(150, 150);
  shape4.ClosePath();
  shape4.MoveTo(125, 175);
  shape4.CurveTo(150, 145, 190, 155, 180, 140);
  pdf.Shape(shape4, wxPDF_STYLE_FILL | wxPDF_STYLE_DRAWCLOSE);

  pdf.AddPage();
  pdf.SetFont(wxT("Helvetica"), wxT(""), 10);

  static double pi = 4. * atan(1.0);

  pdf.Text(130, 40, wxT("Closed Bezier spline"));
  wxPdfArrayDouble xp, yp;
  int nseg = 10;
  double radius = 30;
  double step = 2 * pi / nseg;
  int i;
  for (i = 0; i < nseg; ++i)
  {
    double angle = i * step;
    xp.Add(20 + radius * (sin(angle) + 1));
    yp.Add(20 + radius * (cos(angle) + 1));
    pdf.Marker(xp[i], yp[i], wxPDF_MARKER_CIRCLE, 2.0);
  }
  pdf.ClosedBezierSpline(xp, yp, wxPDF_STYLE_DRAW);

  pdf.Text(130, 120, wxT("Bezier spline for Sine function"));
  // Sinus points in [0,2PI].
	// Fill point array with scaled in X,Y Sin values in [0, PI].
  wxPdfArrayDouble xpSin, ypSin;
  double scaleX = 20;
  double scaleY = 20;
  step = 2 * pi / nseg;
  for (i = 0; i < nseg; ++i)
  {
    double angle = i * step;
    xpSin.Add(20 + scaleX * angle);
    ypSin.Add(100 + scaleY * (1 - sin(angle)));
    pdf.Marker(xpSin[i], ypSin[i], wxPDF_MARKER_CIRCLE, 2.0);
  }
  pdf.BezierSpline(xpSin, ypSin, wxPDF_STYLE_DRAW);

  pdf.Text(130, 180, wxT("Bezier spline for Runge function"));
  wxPdfArrayDouble xpRunge, ypRunge;
  step = 2.0 / (nseg - 1);
  for (i = 0; i < nseg; ++i)
  {
    double xstep = -1 + i * step;
    xpRunge.Add(20 + scaleX * (xstep+1));
    ypRunge.Add(160 + scaleY * (1 - 1 / (1 + 25 * xstep * xstep)));
    pdf.Marker(xpRunge[i], ypRunge[i], wxPDF_MARKER_CIRCLE, 2.0);
  }
  pdf.BezierSpline(xpRunge, ypRunge, wxPDF_STYLE_DRAW);

  pdf.Text(130, 240, wxT("Bezier spline for arc from 0 to 270 degree"));
  wxPdfArrayDouble xpArc, ypArc;
  step = 270.0 / (nseg - 1);
  for (i = 0; i < nseg; ++i)
  {
    double angle = pi * i * step / 180;
    xpArc.Add(20 + scaleX * (cos(angle) + 1));
    ypArc.Add(220 + scaleY * (sin(angle) + 1));
    pdf.Marker(xpArc[i], ypArc[i], wxPDF_MARKER_CIRCLE, 2.0);
  }
  pdf.BezierSpline(xpArc, ypArc, wxPDF_STYLE_DRAW);

  pdf.SaveAsFile(wxT("drawing.pdf"));
}