From 3db7b0ca8b463ba9bc79b713e1db07fba2a5f0cc Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 16 Sep 2013 08:31:34 +0000 Subject: [PATCH] .upptst: GLDrawTest git-svn-id: svn://ultimatepp.org/upp/trunk@6353 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- upptst/GLDrawTest/GLDrawTest.upp | 12 +++++ upptst/GLDrawTest/init | 6 +++ upptst/GLDrawTest/main.cpp | 83 ++++++++++++++++++++++++++++++++ upptst/GLDrawTest/test.qtf | 68 ++++++++++++++++++++++++++ 4 files changed, 169 insertions(+) create mode 100644 upptst/GLDrawTest/GLDrawTest.upp create mode 100644 upptst/GLDrawTest/init create mode 100644 upptst/GLDrawTest/main.cpp create mode 100644 upptst/GLDrawTest/test.qtf diff --git a/upptst/GLDrawTest/GLDrawTest.upp b/upptst/GLDrawTest/GLDrawTest.upp new file mode 100644 index 000000000..1cfbd5b48 --- /dev/null +++ b/upptst/GLDrawTest/GLDrawTest.upp @@ -0,0 +1,12 @@ +uses + CtrlLib, + GLCtrl, + GLDraw; + +file + main.cpp, + test.qtf; + +mainconfig + "" = "GUI SSE2"; + diff --git a/upptst/GLDrawTest/init b/upptst/GLDrawTest/init new file mode 100644 index 000000000..0054b6888 --- /dev/null +++ b/upptst/GLDrawTest/init @@ -0,0 +1,6 @@ +#ifndef _GLDrawTest_icpp_init_stub +#define _GLDrawTest_icpp_init_stub +#include "CtrlLib/init" +#include "GLCtrl/init" +#include "GLDraw/init" +#endif diff --git a/upptst/GLDrawTest/main.cpp b/upptst/GLDrawTest/main.cpp new file mode 100644 index 000000000..abffdcec2 --- /dev/null +++ b/upptst/GLDrawTest/main.cpp @@ -0,0 +1,83 @@ +#include +#include +#include + +using namespace Upp; + +struct OpenGLExample : GLCtrl { + Point point; + + virtual void GLPaint() { + DLOG("GLPaint"); + Size sz = GetSize(); + + GLDraw w; + + Rect r = Rect(GetSize()).Deflated(20, 20); + + w.InitGL(GetSize()); + + w.DrawRect(sz, LtRed()); + DrawFatFrame(w, r, LtBlue(), 2); + + DrawFatFrame(w, r.Deflated(5), LtBlue(), 2); + + w.DrawRect(100, 100, 2, 2, Blue()); + + w.DrawImage(200, 100, CtrlImg::exclamation()); + w.DrawImage(300, 100, CtrlImg::reporticon()); + w.DrawImage(350, 100, CtrlImg::reporticon(), Blue()); + w.DrawImage(400, 100, CtrlImg::swap_color_cursor()); + + for(int i = 0; i < 16; i++) { + w.DrawImage(50 + 20 * i, 180, CtrlImg::checkers()); + w.DrawImage(50 + 20 * i, 200, CtrlImg::checkers(), Rect(0, 0, i, 16)); + w.DrawImage(50 + 20 * i, 220, CtrlImg::checkers(), Rect(0, 0, 16, i)); + w.DrawImage(50 + 20 * i, 240, CtrlImg::checkers(), Rect(0, 0, i, i)); + w.DrawImage(50 + 20 * i, 260, CtrlImg::checkers(), RectC(i, i, 4, 3)); + } + + w.DrawRect(50, 50, 20, 20, InvertColor()); + w.DrawRect(55, 55, 8, 8, InvertColor()); + + // w.DrawRect(0, 0, sz.cx, sz.cy, SWhite); + w.DrawRect(10, 10, 30, 30, SRed); + w.DrawLine(45, 45, 80, 120, 4, Blue); + w.DrawLine(80, 90, 400, 0, PEN_DASHDOT); + w.DrawEllipse(200, 200, 50, 100, Green); + w.DrawImage(200, 10, CtrlImg::HandCursor()); + const char *text = "This text is centered"; + Size tsz = GetTextSize(text, Arial(25).Bold()); + w.DrawText((sz.cx - tsz.cx) / 2, (sz.cy - tsz.cy) / 2, text, Arial(27).Bold(), SBlue); + w.Clipoff(200, 50, 95, 100); + w.DrawText(0, 80, "CLIPPED", Roman(25)); + w.End(); + + RichText txt = ParseQTF(LoadFile(GetDataFile("test.qtf"))); + DDUMP(txt.GetLength()); + if(1) { + RTIMING("SystemDraw"); + DLOG("---------------------------------------"); + txt.Paint(Zoom(2, 10), w, 20, 20, 500); + } + + GLDraw::ClearCache(); + } + + virtual void MouseMove(Point p, dword) { + point = p; + Refresh(); + } +}; + +GUI_APP_MAIN +{ + Ctrl::GlobalBackPaint(); + TopWindow win; + OpenGLExample gl; + gl.SetFrame(InsetFrame()); + win.Add(gl.HSizePos(10, 10).VSizePos(10, 10)); + win.Sizeable().Zoomable(); + win.Open(); + win.Run(); +} diff --git a/upptst/GLDrawTest/test.qtf b/upptst/GLDrawTest/test.qtf new file mode 100644 index 000000000..09e0394b9 --- /dev/null +++ b/upptst/GLDrawTest/test.qtf @@ -0,0 +1,68 @@ +[ $$0,0#00000000000000000000000000000000:Default] +[*C@3+75 $$1,1#36268203433472503231438721581057:code] +[*/+117 $$2,0#07143242482611002448121871408047:title] +[@(128.0.255)2 $$3,0#65874547464505293575048467215454:QTF Chr] +[{_}%EN-US +[s0; [*4 QTF]&] +[s0;= [*8 QTF]&] +[s0; &] +[s0; QTF is the native format of Ultimate`+`+ rich texts (formatted +texts).&] +[s0; &] +[s0; It is byte oriented format. Bytes with values 2`-31 are ignored. +Other are interpreted as characters or formatting commands.&] +[s0; &] +[s0; Letters ([@4 a]`-[@4 zA]`-[@4 Z]), numbers ([@4 0]`-[@4 9]), space (32) +and characters&] +[s0; &] +[s0; [*@4 . , ; ! ? % ( ) / < > #]&] +[s0; &] +[s0; and bytes [* greater] than 127 are guaranteed to be never used as +command characters (not even in future versions of QTF). Other +characters should be prefixed with escape character `` (reverse +apostrophe). Group of characters can be escaped using byte 1. +Example:&] +[s0; &] +[s1; `\"`\1a`[x`]`\1`[`* bold`]`\"&] +[s0; Normal [* Bold] [/ Italic] [*/ Bold Italic] [_ Underline] [- Stroked]&] +[Rs0; Normal [* Bold] [/ Italic] [*/ Bold Italic] [_ Underline] [- Stroked]&] +[Cs0; Normal [* Bold] [/ Italic] [*/ Bold Italic] [_ Underline] [- Stroked]&] +[s0; Byte 0 represents the end of input sequence.&] +[s0; &] +[s0; Dimension units of QTF are dots `- one dot is defined as 1/600 +of inch.&] +[s0; &] +[s0; Colors are described as either number [@(128.0.255) 0]`-[@(128.0.255) 9], +with meaning&] +[s0; &] +[ {{1000:1000:1000:1000:1000:1000:1000:1000:1000:1000<96;>96;f4; [s0;%- [* 0]] +:: [s0;%- [* 1]] +:: [s0;%- [* 2]] +:: [s0;%- [* 3]] +:: [s0;%- [* 4]] +:: [s0;%- [* 5]] +:: [s0;%- [* 6]] +:: [s0;%- [* 7]] +:: [s0;%- [* 8]] +:: [s0;%- [* 9]] +::l/0r/0t/0b/0@0 [s0; ] +::@1 [s0; ] +::@2 [s0; ] +::@3 [s0; ] +::@4 [s0; ] +::@5 [s0; ] +::@6 [s0; ] +::@7 [s0; ] +::@8 [s0; ] +::@9 [s0; ] +::l/25r/25t/15b/15@2 [s0;%- [1 Black]] +:: [s0; [1 LtGray]] +:: [s0; [1 White]] +:: [s0;%- [1 Red]] +:: [s0;%- [1 Green]] +:: [s0;%- [1 Blue]] +:: [s0;%- [1 LtRed]] +:: [s0;%- [1 WhiteGray]] +:: [s0;%- [1 LtCyan]] +:: [s0;%- [1 Yellow]]}}&] +[s0; &]