From ec6ed6959b0b470c4f7f40a69a88229ede94eaf4 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 28 Jan 2010 23:19:40 +0000 Subject: [PATCH] syncing uppdev git-svn-id: svn://ultimatepp.org/upp/trunk@1976 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppdev/CoWork/CoWork.upp | 12 ++ uppdev/CoWork/Img.iml | 30 +++++ uppdev/CoWork/init | 4 + uppdev/CoWork/main.cpp | 244 +++++++++++++++++++++++++++++++++++++ uppdev/Reports/Reports.upp | 24 ++-- uppdev/Reports/init | 6 + uppdev/Reports/main.cpp | 27 +--- 7 files changed, 311 insertions(+), 36 deletions(-) create mode 100644 uppdev/CoWork/CoWork.upp create mode 100644 uppdev/CoWork/Img.iml create mode 100644 uppdev/CoWork/init create mode 100644 uppdev/CoWork/main.cpp create mode 100644 uppdev/Reports/init diff --git a/uppdev/CoWork/CoWork.upp b/uppdev/CoWork/CoWork.upp new file mode 100644 index 000000000..f6b60c0f8 --- /dev/null +++ b/uppdev/CoWork/CoWork.upp @@ -0,0 +1,12 @@ +description "Using CoWork for loop parallelisation\377"; + +uses + CtrlLib; + +file + Img.iml, + main.cpp; + +mainconfig + "" = "GUI MT"; + diff --git a/uppdev/CoWork/Img.iml b/uppdev/CoWork/Img.iml new file mode 100644 index 000000000..a35814b25 --- /dev/null +++ b/uppdev/CoWork/Img.iml @@ -0,0 +1,30 @@ +PREMULTIPLIED +IMAGE_ID(dfmaudio) + +IMAGE_BEGIN_DATA +IMAGE_DATA(120,156,237,220,109,110,212,48,20,134,209,110,133,197,32,22,197,34,250,139,245,130,16,26,49,74,51,19,251,38,142,63) +IMAGE_DATA(238,121,165,231,127,11,167,142,51,130,126,124,126,124,126,164,218,183,31,63,187,103,115,236,232,239,241,251,175,223,77,99) +IMAGE_DATA(105,190,245,178,194,209,124,27,209,202,89,75,214,118,51,154,169,117,100,215,110,118,43,17,71,22,223,10,231,203,89,67) +IMAGE_DATA(86,183,108,102,142,28,217,241,178,123,97,167,126,204,188,247,99,95,183,210,179,201,218,239,241,115,180,130,23,118,238,219) +IMAGE_DATA(74,231,12,59,247,109,69,47,189,203,240,78,207,205,125,118,86,243,195,205,253,142,102,223,170,119,155,81,91,197,15,55) +IMAGE_DATA(253,253,204,54,102,250,55,163,157,204,110,44,190,172,102,216,57,183,236,110,216,137,141,155,57,26,241,29,140,155,57,26) +IMAGE_DATA(237,51,68,103,206,124,141,96,135,155,121,235,233,39,243,187,248,10,245,178,195,204,26,245,180,211,251,123,31,45,123,61) +IMAGE_DATA(207,41,118,34,227,134,157,232,152,89,187,86,119,31,231,205,250,181,122,239,226,102,253,90,125,222,204,78,142,174,182,227) +IMAGE_DATA(121,149,171,171,236,112,147,175,171,237,244,254,126,196,206,234,217,191,121,94,177,19,25,55,236,68,199,141,30,213,188,183) +IMAGE_DATA(59,115,244,92,205,103,134,220,104,91,137,29,103,142,246,170,177,211,251,107,213,120,177,163,104,236,180,45,235,220,117,216) +IMAGE_DATA(137,140,27,118,162,227,70,71,189,186,239,176,163,163,246,236,120,94,169,164,189,207,120,184,81,105,236,40,218,246,236,97) +IMAGE_DATA(71,53,177,211,166,108,99,135,157,232,184,97,39,58,118,84,211,246,190,211,251,235,209,60,249,125,40,58,19,59,138,198) +IMAGE_DATA(142,162,177,163,104,236,40,26,59,215,151,109,236,176,19,29,59,236,68,199,142,106,115,223,81,52,118,20,141,29,69,99) +IMAGE_DATA(71,209,216,209,153,188,103,93,255,231,153,105,236,176,19,29,59,236,68,199,142,106,115,87,86,52,118,20,205,191,89,86) +IMAGE_DATA(164,173,27,118,84,154,255,83,172,104,236,180,41,219,216,97,39,58,118,216,137,142,29,213,180,119,223,225,71,37,177,163) +IMAGE_DATA(104,126,231,160,34,189,251,93,167,252,232,85,123,110,216,81,73,123,110,60,183,84,18,59,109,203,58,207,45,118,162,99) +IMAGE_DATA(135,157,51,99,71,123,189,187,235,108,237,240,163,231,106,237,240,163,191,189,250,92,199,217,163,163,74,221,184,247,104,207) +IMAGE_DATA(13,59,138,218,169,217,179,29,134,202,51,119,102,118,226,99,135,157,51,227,39,103,145,59,206,145,159,222,223,147,238,115) +IMAGE_DATA(115,133,29,126,114,117,165,155,173,29,126,214,237,234,51,135,159,28,181,114,195,207,250,181,116,195,79,89,246,126,236,176) +IMAGE_DATA(115,102,252,176,19,29,59,243,119,199,29,135,159,245,106,253,94,85,99,135,159,121,234,237,134,159,57,27,197,205,99,91) +IMAGE_DATA(63,12,141,217,104,110,30,227,103,236,70,117,243,60,126,198,109,134,101,246,99,231,151,213,143,93,179,140,126,70,217,232) +IMAGE_DATA(119,155,146,101,244,211,187,25,238,197,165,227,135,155,51,243,14,127,159,153,149,220,60,182,231,135,161,107,221,172,62,126) +IMAGE_DATA(174,55,147,193,205,243,248,185,198,78,214,173,118,6,217,189,91,201,143,245,217,10,126,172,223,188,139,253,47,251,125,38) +IMAGE_DATA(178,87,126,178,88,202,252,254,116,229,178,249,97,166,221,86,117,228,172,185,103,51,159,69,71,207,98,187,111,51,220,141) +IMAGE_DATA(74,190,70,235,183,145,12,49,50,255,74,60,221,145,205,59,86,154,237,15,218,43,36,33,0,0,0,0,0,0,0,0) +IMAGE_END_DATA(800, 1) diff --git a/uppdev/CoWork/init b/uppdev/CoWork/init new file mode 100644 index 000000000..fbf40794e --- /dev/null +++ b/uppdev/CoWork/init @@ -0,0 +1,4 @@ +#ifndef _CoWork_icpp_init_stub +#define _CoWork_icpp_init_stub +#include "CtrlLib/init" +#endif diff --git a/uppdev/CoWork/main.cpp b/uppdev/CoWork/main.cpp new file mode 100644 index 000000000..0ff114a99 --- /dev/null +++ b/uppdev/CoWork/main.cpp @@ -0,0 +1,244 @@ +#include + +#define IMAGECLASS MyImg +#define IMAGEFILE +#include + +using namespace Upp; + +class App : public TopWindow { +public: + typedef App CLASSNAME; + virtual void LeftDown(Point, dword); + virtual void Paint(Draw& w); + +private: + String text; + bool cowork; + int phase; + +/* extra stuff */ + CoWork co; + bool dorun; + + TreeCtrl tGroups2; + void TestDropInsert( int parent, int ii, PasteClip& d ); + void TestDrag(); + void TestTree(); + void DoRefresh(); + void Start(); +/* ...... */ + + void SyncTitle(); + +public: + typedef App CLASSNAME; + + App& Text(const String& t) { text = t; Refresh(); return *this; } + + App(); + + //extra stuff + ~App() { dorun = false; } +}; + + + + +/* extra stuff */ + +void App::Start() +{ + for(int i = 0; i < 10; i++) + { + co & THISBACK(DoRefresh); + } +} + +void App::TestTree() { + + TreeCtrl & tree = tGroups2; + + Vector parent, parent2; + parent.Add(0); + tree.SetRoot(Image(), "The Tree"); + for(int i = 1; i < 100; i++) { + parent.Add(tree.Add(parent[rand() % parent.GetCount()], Image(), + FormatIntRoman(i, true))); + if((rand() & 3) == 0) + tree.Open(parent.Top()); + } + + tree.Open(0); + tree.WhenDropInsert = THISBACK(TestDropInsert); + tree.WhenDrag = THISBACK(TestDrag); + tree.MultiSelect(); +} + +void App::TestDropInsert(int parent, int ii, PasteClip& d) +{ + /* + if(AcceptInternal(d, "mytreedrag")) { + tGroups2.InsertDrop(parent, ii, d); + tGroups2.SetFocus(); + return; + } + if(AcceptText(d)) { + tGroups2.SetCursor(tGroups2.Insert(parent, ii, Image(), GetString(d))); + tGroups2.SetFocus(); + return; + } + */ +} + +void App::TestDrag() +{ + if(tGroups2.DoDragAndDrop(InternalClip(tGroups2, "mytreedrag"), + tGroups2.GetDragSample()) == DND_MOVE) + { + tGroups2.RemoveSelection(); + } + int a = 0; +} + +void App::DoRefresh() +{ + while(dorun) + { + Refresh(); + Sleep(1); + } +} + +/* ..... */ + + +App::App() +{ + SetRect(0,0,472,320); + BackPaint(); + Zoomable().Sizeable(); + cowork = true; + phase = 0; + SyncTitle(); + + /* extra stuff */ + Add(tGroups2.LeftPos(0,100).VSizePos()); + TestTree(); + PostCallback(THISBACK(Start)); + /* ... */ +} + +void App::SyncTitle() +{ + Title(cowork ? "Now using all CPU cores (click the image for single core)" + : "Now using single CPU core (click the image to use all cores)"); +} + +void App::LeftDown(Point, dword) +{ + cowork = !cowork; + SyncTitle(); +} + +void DoLine(RGBA *line, int phase, int y, Size sz) +{ + Point c = sz / 2; //center is rotation point + c = Point( int(sin((double)phase / 131) * c.x/2 + c.x), + int(cos((double)phase / 127) * c.y/2 + c.y) + ); + + int yy = (y - c.y) * (y - c.y); + + for(int x = 0; x < sz.cx; x++) { //for the x points + double d = (x - c.x) * (x - c.x) + yy; + line[x] = + //GrayColor((int)(120 + 120 * sin(d / 1000 - (double)phase / 5))); + Blend(Black, LtBlue, (int)(120 + 120 * sin(d / 3000 - (double)phase / 5))); + } +} + +struct EXT +{ + RGBA *line; + int y; + int phase; + Size sz; + Point c; + Color col; +}; + +void DoLine2(EXT e) +{ + int yy = (e.y - e.c.y) * (e.y - e.c.y); + for(int x = 0; x < e.sz.cx; x++) { //for the x points + double d = (x - e.c.x) * (x - e.c.x) + yy; + e.line[x] = + //GrayColor((int)(120 + 120 * sin(d / 1000 - (double)phase / 5))); + Blend(Black, e.col, (int)(120 + 120 * sin(d / 2000 - (double)e.phase / 5))); + } +} + + +void App::Paint(Draw& w) +{ + Size sz = GetSize(); + ImageBuffer ib(sz); + +/* + if(cowork) { + CoWork co; + for(int y = 0; y < sz.cy; y++) + co & callback4(DoLine, ib[y], phase, y, sz); //calculate each line separately + } + else + for(int y = 0; y < sz.cy; y++) + DoLine(ib[y], phase, y, sz); //calculate each line separately +*/ + +/* + EXT e; + e.phase = phase; + e.sz = sz; + Point c = e.sz / 2; //center is rotation point + //e.col = Color(0, 69, 149); + e.col = HsvColorf((float)(phase%360)/360.0f, 1, 1); + if(1) + { + e.c = Point( int(sin((double)e.phase / 131) * c.x/2 + c.x), + int(cos((double)e.phase / 127) * c.y/2 + c.y) + ); + } + else + e.c = c; + + if(cowork) { + CoWork co; + for(int y = 0; y < sz.cy; y++) + { + e.line = ib[y]; e.y = y; + co & callback1(DoLine2, e); //calculate each line separately + } + } + else + for(int y = 0; y < sz.cy; y++) + { + e.line = ib[y]; e.y = y; + DoLine2(e); //calculate each line separately + } +*/ + w.DrawImage(0, 0, ib); + + const Image & im = MyImg::dfmaudio(); + Size isz = im.GetSize(); + Point pp = isz/2; +// w.DrawImage(e.c.x-pp.x, e.c.y-pp.y, im); + w.DrawImage(0+(phase%200), 0, im); + //Refresh(); // is done in the cowork + phase++; +} + +GUI_APP_MAIN +{ + App().Run(); +} diff --git a/uppdev/Reports/Reports.upp b/uppdev/Reports/Reports.upp index 96afec093..5a7f4c190 100644 --- a/uppdev/Reports/Reports.upp +++ b/uppdev/Reports/Reports.upp @@ -1,11 +1,13 @@ -description "Report example"; - -uses - CtrlLib, - Report; - -file - main.cpp; - -mainconfig - "" = "GUI"; +description "Report example\377"; + +uses + CtrlLib, + Report, + PdfDraw; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/uppdev/Reports/init b/uppdev/Reports/init new file mode 100644 index 000000000..f4738d3a7 --- /dev/null +++ b/uppdev/Reports/init @@ -0,0 +1,6 @@ +#ifndef _Reports_icpp_init_stub +#define _Reports_icpp_init_stub +#include "CtrlLib/init" +#include "Report/init" +#include "PdfDraw/init" +#endif diff --git a/uppdev/Reports/main.cpp b/uppdev/Reports/main.cpp index 49e681316..a276cf899 100644 --- a/uppdev/Reports/main.cpp +++ b/uppdev/Reports/main.cpp @@ -2,33 +2,10 @@ using namespace Upp; -struct TableRowTracer : RichTextLayoutTracer { - VectorMap pgr; - - virtual void TableRow(const Rect& page, PageY y, int, const RichTable&) { - pgr.GetAdd(y.page, 0)++; - } -}; - GUI_APP_MAIN { Report r; - r.Footer("[R1 "); - TableRowTracer t; - r.SetRichTextLayoutTracer(t); - String qtf = "&[R This is a demonstration of [* RichTextLayoutTracer]&&&{{1 Table"; - for(int i = 0; i < 100; i++) - qtf << ":: " << i; - qtf << "}}"; - r.Put(qtf); + r << "@@iml:400*400`CtrlImg:exclamation`"; - Report rr; - for(int i = 0; i < r.GetCount(); i++) { - if(i) - rr.NewPage(); - rr.Footer("[R1 There is " + AsString(t.pgr.Get(i, 0)) + " table rows on this page"); - rr.DrawDrawing(r.GetPageSize(), r[i]); - } - - Perform(rr); + Perform(r); }