From 2d6e3ada45871489f79c813ffad610951f7b5978 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 17 Feb 2009 11:49:01 +0000 Subject: [PATCH] Mirrors upptst git-svn-id: svn://ultimatepp.org/upp/trunk@874 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- upptst/Mirrors/Mirrors.upp | 11 ++++++++ upptst/Mirrors/init | 6 ++++ upptst/Mirrors/main.cpp | 56 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 upptst/Mirrors/Mirrors.upp create mode 100644 upptst/Mirrors/init create mode 100644 upptst/Mirrors/main.cpp diff --git a/upptst/Mirrors/Mirrors.upp b/upptst/Mirrors/Mirrors.upp new file mode 100644 index 000000000..2f95bc283 --- /dev/null +++ b/upptst/Mirrors/Mirrors.upp @@ -0,0 +1,11 @@ +uses + CtrlLib, + Report, + Painter; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/upptst/Mirrors/init b/upptst/Mirrors/init new file mode 100644 index 000000000..e018374b0 --- /dev/null +++ b/upptst/Mirrors/init @@ -0,0 +1,6 @@ +#ifndef _Mirrors_icpp_init_stub +#define _Mirrors_icpp_init_stub +#include "CtrlLib/init" +#include "Report/init" +#include "Painter/init" +#endif diff --git a/upptst/Mirrors/main.cpp b/upptst/Mirrors/main.cpp new file mode 100644 index 000000000..a24f01379 --- /dev/null +++ b/upptst/Mirrors/main.cpp @@ -0,0 +1,56 @@ +#include +#include +#include + +using namespace Upp; + +GUI_APP_MAIN +{ + Font fnt = Arial(200); + Size isz = GetTextSize("M", fnt); + String letters = "sSzZEeDNB12345679kKrRLCc"; + Report r; + Size page = r.GetPageSize(); +// r.DrawText(0, 0, letters, fnt); + for(int y = 0; y + isz.cy < page.cy; y += 3 * isz.cy / 2) + for(int x = 0; x < page.cx; x += 3 * isz.cx / 2) { + int ch = letters[Random(letters.GetCount())]; + PaintingPainter gw(isz.cx, isz.cy); + gw.Begin(); + if(Random(4) == 0) { + gw.Translate(isz.cx, 0); + gw.Scale(-1, 1); + } + gw.Character((isz.cx - fnt.Info()[ch]) / 2, 0, ch, fnt).Fill(Black()); +// gw.Rectangle(0, 0, isz.cx, isz.cy).Stroke(5, LtGray()); + gw.End(); + r.DrawPainting(x, y, isz.cx, isz.cy, gw); + } + r.NewPage(); + String pairs = "BNDH"; + for(int y = 0; y + isz.cy < page.cy; y += 3 * isz.cy / 2) + for(int x = 0; x < page.cx; x += 3 * isz.cx) { + int ch = pairs[Random(pairs.GetCount())]; + int cl = ToLower(ch); + if(Random(3) == 0) + cl = ToLower(pairs[Random(pairs.GetCount())]); + r.DrawText(x, y, String(ch, 1) + String(cl, 1), fnt); + } + r.NewPage(); + for(int i = 0; i < 10; i++) { + int a, b; + do { + a = Random(50) + 1; + b = Random(50) + 1; + } + while(a + b < 0 || a + b > 50); + r.DrawText(10, 10 + isz.cy * 2 * i, Format("%d + %d = ", a, b), fnt); + do { + a = Random(30) + 1; + b = Random(20) + 1; + } + while(a - b < 1); + r.DrawText(2000, 10 + isz.cy * 2 * i, Format("%d - %d = ", a, b), fnt); + } + Perform(r); +}