From bc04ccb372ba39ed0848308dd1df4ba0cd1d953f Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 3 May 2010 08:48:05 +0000 Subject: [PATCH] upptst: CharMetrics test git-svn-id: svn://ultimatepp.org/upp/trunk@2352 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- upptst/CharMetrics/CharMetrics.upp | 11 ++++++++ upptst/CharMetrics/main.cpp | 45 ++++++++++++++++++++++++++++++ upptst/Clipboard/Clipboard.upp | 9 ++++++ upptst/Clipboard/main.cpp | 19 +++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 upptst/CharMetrics/CharMetrics.upp create mode 100644 upptst/CharMetrics/main.cpp create mode 100644 upptst/Clipboard/Clipboard.upp create mode 100644 upptst/Clipboard/main.cpp diff --git a/upptst/CharMetrics/CharMetrics.upp b/upptst/CharMetrics/CharMetrics.upp new file mode 100644 index 000000000..f50db781f --- /dev/null +++ b/upptst/CharMetrics/CharMetrics.upp @@ -0,0 +1,11 @@ +description "Testing corectness of character metrics\377"; + +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/upptst/CharMetrics/main.cpp b/upptst/CharMetrics/main.cpp new file mode 100644 index 000000000..96cd7e589 --- /dev/null +++ b/upptst/CharMetrics/main.cpp @@ -0,0 +1,45 @@ +#include + +using namespace Upp; + +struct MyApp : TopWindow { + DropList fontlist; + + void Paint(Draw& w) { + w.DrawRect(GetSize(), White); + int y = 50; + for(int p = 32; p < 8192; p += 64) { + Font fnt(~fontlist, 30); + FontInfo fi = fnt.Info(); + int x = 0; + for(int ch = p; ch < p + 64; ch++) { + int width = fi[ch]; + w.DrawRect(x, y, width - 1, fi.GetAscent(), Color(255, 255, 200)); + w.DrawRect(x, y + fi.GetAscent(), width - 1, fi.GetDescent(), Color(255, 200, 255)); + w.DrawRect(x + width - 1, y, 1, fi.GetHeight(), Black()); + w.DrawText(x, y, WString(ch, 1), fnt); + x += width; + } + y += fi.GetHeight() + 20; + } + } + + void NewFont() { + Refresh(); + } + + typedef MyApp CLASSNAME; + + MyApp() { + for(int i = 0; i < Font::GetFaceCount(); i++) + fontlist.Add(i, Font::GetFaceName(i)); + Add(fontlist.TopPos(0, MINSIZE).LeftPosZ(0, 200)); + fontlist <<= 0; + fontlist <<= THISBACK(NewFont); + } +}; + +GUI_APP_MAIN +{ + MyApp().Sizeable().Run(); +} diff --git a/upptst/Clipboard/Clipboard.upp b/upptst/Clipboard/Clipboard.upp new file mode 100644 index 000000000..5872304d3 --- /dev/null +++ b/upptst/Clipboard/Clipboard.upp @@ -0,0 +1,9 @@ +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/upptst/Clipboard/main.cpp b/upptst/Clipboard/main.cpp new file mode 100644 index 000000000..e49256e95 --- /dev/null +++ b/upptst/Clipboard/main.cpp @@ -0,0 +1,19 @@ +#include + +using namespace Upp; + +GUI_APP_MAIN +{ + Progress pi("%d"); + for(;;) { + if(pi.StepCanceled()) + break; + WString txt = AsString(Random()).ToWString(); + ClearClipboard(); + AppendClipboardText(txt.ToString()); + WriteClipboardUnicodeText(txt); + WString txt2 = ReadClipboardUnicodeText(); + DDUMP(txt2); + ASSERT(txt == txt2); + } +}