From d400a792fc40f7edef5f87e2e1ca83ac48662bef Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 31 Mar 2020 15:04:59 +0000 Subject: [PATCH] .examples git-svn-id: svn://ultimatepp.org/upp/trunk@14205 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- examples/GeoFun/GeoFun.cpp | 46 ++++++---------------- examples/GeoFun/GeoFun.h | 6 ++- examples/TextToSvgPath/TextToSvgPath.h | 2 - examples/TextToSvgPath/TextToSvgPath.lay | 12 +++--- examples/TextToSvgPath/ToSvg.cpp | 4 +- examples/TextToSvgPath/main.cpp | 50 ++++++++---------------- 6 files changed, 41 insertions(+), 79 deletions(-) diff --git a/examples/GeoFun/GeoFun.cpp b/examples/GeoFun/GeoFun.cpp index 08135bf03..8cbf3d2d1 100644 --- a/examples/GeoFun/GeoFun.cpp +++ b/examples/GeoFun/GeoFun.cpp @@ -233,7 +233,6 @@ void GeoFun::SaveToAutoCadScript ( String fileName ) fo.Put ( sScr ); fo.Close(); } - } @@ -284,7 +283,6 @@ void GeoFun::SaveToSVG ( String fileName ) fo.Put ( sXML ); fo.Close(); } - } void GeoFun::Print() @@ -309,14 +307,13 @@ void GeoFun::Print() // This function calculates curve data points for display -void GeoFun::PrepareData0() +void GeoFun::PrepareData() { int p, q, pw; double a, b, h ; double x, y; double Period, step, t ; - static int prepd = 0; step = 1.0 ; // value in deg @@ -405,8 +402,6 @@ void GeoFun::PrepareData0() InputPane.RollingRad = "Rolling Radius : " + Format ( "%0.2f", b ) ; -// ShowAnimation = ~InputPane.optAnimate ; - dc1.Zoomed = InputPane.optZoom.GetData(); if ( dc1.Zoomed ) @@ -479,19 +474,14 @@ void GeoFun::PrepareData0() p1.x = dc1.data[0].point[0].x ; p1.y = dc1.data[0].point[0].y ; dc1.data[0].point.Add ( p1 ); - prepd++; -} -void GeoFun::PrepareData() -{ - PrepareData0(); dc1.Refresh(); } + void GeoFun::ShowAnimated() { int MaxCnt = dc1.data[0].point.GetCount(); -// static dword LastTickCount = GetTickCount() ; if ( dc1.ShowAnimation ) { @@ -499,17 +489,17 @@ void GeoFun::ShowAnimated() { dc1.Refresh(); dc1.ShowTo += dc1.AnimSpeed ; + DUMP("Animation"); } else { dc1.ShowAnimation = false ; dc1.ColorFill = ~InputPane.optColorFill ; dc1.Refresh(); + Animate.Kill(); + DUMP("End Animation"); } } - -// RLOG("TickCount - " <<( GetTickCount() - LastTickCount)); -// LastTickCount = GetTickCount(); } void GeoFun::SetAnimation() @@ -518,6 +508,7 @@ void GeoFun::SetAnimation() dc1.ShowTo = 5 ; dc1.ShowAnimation = true ; dc1.ColorFill = false ; + Animate.KillSet(-50, THISBACK(ShowAnimated)); } @@ -525,7 +516,9 @@ void GeoFun::FirstDraw() { First = false ; PrepareData(); - SetTimeCallback ( -30, THISBACK ( ShowAnimated ), 50 ); +// SetTimeCallback ( 1030, THISBACK ( ShowAnimated ), 50 ); +// Animate.KillSet(-50, THISBACK(ShowAnimated)); + DUMP("First Draw"); } @@ -562,7 +555,7 @@ void GeoFun::Layout() { if ( !First ) { - PrepareData0(); + PrepareData(); } TopWindow::Layout(); @@ -570,23 +563,19 @@ void GeoFun::Layout() void GeoFun::About() { - WithAboutLayout dlg; dlg.AboutText = GetTopic ( "topic://GeoFun/app/About$en-us" ).text; CtrlLayoutOK ( dlg, "About" ); dlg.CenterScreen(); dlg.Run(); - } void GeoFun::Help() { - HelpWindow helpme; helpme.GoTo ( "topic://GeoFun/app/Help$en-us" ); helpme.Execute(); - } @@ -598,11 +587,8 @@ void GeoFun::Exit() void GeoFun::SetAnimationSpeed() { dc1.AnimSpeed = InputPane.edAnimSpeed.GetData(); - if ( dc1.AnimSpeed < 1 ) dc1.AnimSpeed = 1; - if ( dc1.AnimSpeed > 20 ) dc1.AnimSpeed = 20; - InputPane.edAnimSpeed.SetData ( dc1.AnimSpeed ); } @@ -637,16 +623,11 @@ void GeoFun::SetCurveType ( int CrvType ) SetCurveTypeMenu ( CrvType ); } -void GeoFun::SetCurveTypeMenu1 ( ) -{ - int CrvType = InputPane.CurveType.GetData(); - SetCurveTypeMenu ( CrvType ); -} void GeoFun::SetCurveTypeMenu ( int CrvType ) { EpiCyclo = HypoCyclo = EpiTroch = HypoTroch = false ; - switch ( CrvType ) + switch ( CrvType ) { case 1 : HypoCyclo = true ; break ; case 2 : EpiTroch = true ; break ; @@ -761,7 +742,7 @@ GeoFun::GeoFun() InputPane.CurveType.SetData ( 2 ); } - InputPane.CurveType.WhenAction << THISBACK (SetCurveTypeMenu1); + InputPane.CurveType.WhenAction << THISBACK1 (SetCurveTypeMenu,(int)InputPane.CurveType.GetData()); InputPane.optGradient.WhenAction << THISBACK ( PrepareData ); InputPane.optColorFill.WhenAction << THISBACK ( PrepareData ); @@ -794,7 +775,6 @@ GUI_APP_MAIN gf.First = true ; String cfgfile = ConfigFile(); - if ( FileExists ( cfgfile ) ) { cfgAvailable = true ; @@ -810,8 +790,6 @@ GUI_APP_MAIN cfgAvailable = false ; } -// gf.Icon(Image::(5555, true), Image::ICON(5555, false)); - gf.Run(); StoreToFile ( gf ); diff --git a/examples/GeoFun/GeoFun.h b/examples/GeoFun/GeoFun.h index 3be489cb5..6430c986b 100644 --- a/examples/GeoFun/GeoFun.h +++ b/examples/GeoFun/GeoFun.h @@ -65,6 +65,8 @@ class GeoFun : public WithGeoFunLayout { Splitter sp1; QtfRichObject qtfim; + + TimeCallback Animate; int ValP, ValQ, PenW, CurvT, GradientY; Color PenC, M1C, M2C, B1C, B2C; @@ -90,7 +92,7 @@ class GeoFun : public WithGeoFunLayout { void OptionZoom(); void PrepareData(); - void PrepareData0(); + void Print(); void SaveToImageFile ( String fileName ); @@ -99,7 +101,7 @@ class GeoFun : public WithGeoFunLayout { void SetAnimation(); void SetAnimationSpeed(); void SetCurveType ( int CrvType ); - void SetCurveTypeMenu1 ( ); + void SetCurveTypeMenu ( int CrvType ); void Serialize ( Stream& s ); void ShowAnimated(); diff --git a/examples/TextToSvgPath/TextToSvgPath.h b/examples/TextToSvgPath/TextToSvgPath.h index 59e38de8a..308dd26b7 100644 --- a/examples/TextToSvgPath/TextToSvgPath.h +++ b/examples/TextToSvgPath/TextToSvgPath.h @@ -19,8 +19,6 @@ struct Preview : Ctrl { struct TextToSvgPathDlg : public WithTextToSvgPathLayout { Preview preview; - - void Render(); TextToSvgPathDlg(); }; diff --git a/examples/TextToSvgPath/TextToSvgPath.lay b/examples/TextToSvgPath/TextToSvgPath.lay index 5a9a44638..56cf4eb7a 100644 --- a/examples/TextToSvgPath/TextToSvgPath.lay +++ b/examples/TextToSvgPath/TextToSvgPath.lay @@ -1,15 +1,15 @@ LAYOUT(TextToSvgPathLayout, 704, 588) ITEM(Label, dv___0, SetLabel(t_("Text")).LeftPosZ(8, 33).TopPosZ(28, 19)) - ITEM(EditString, text, LeftPosZ(44, 652).TopPosZ(28, 19)) + ITEM(EditString, text, HSizePosZ(44, 8).TopPosZ(28, 19)) ITEM(Label, dv___2, SetLabel(t_("Font")).LeftPosZ(8, 33).TopPosZ(4, 19)) ITEM(DropList, face, LeftPosZ(44, 188).TopPosZ(4, 19)) ITEM(Label, dv___4, SetLabel(t_("Height")).LeftPosZ(252, 39).TopPosZ(4, 19)) ITEM(WithDropChoice, height, LeftPosZ(292, 56).TopPosZ(4, 19)) - ITEM(Option, bold, SetLabel(t_("Bold")).LeftPosZ(356, 52).TopPosZ(4, 18)) - ITEM(Option, italic, SetLabel(t_("Italic")).LeftPosZ(408, 52).TopPosZ(4, 18)) - ITEM(LineEdit, svgpath, LeftPosZ(8, 688).TopPosZ(52, 268)) - UNTYPED(preview, LeftPosZ(8, 688).TopPosZ(324, 260)) - ITEM(Button, copy, SetLabel(t_("Copy path to clipboard")).LeftPosZ(568, 128).TopPosZ(4, 20)) + ITEM(Option, bold, SetLabel(t_("Bold")).LeftPosZ(356, 52).TopPosZ(4, 20)) + ITEM(Option, italic, SetLabel(t_("Italic")).LeftPosZ(408, 52).TopPosZ(4, 20)) + ITEM(LineEdit, svgpath, HSizePosZ(8, 8).VSizePosZ(52, 268)) + UNTYPED(preview, HSizePosZ(8, 8).BottomPosZ(4, 260)) + ITEM(Button, copy, SetLabel(t_("Copy path to clipboard")).RightPosZ(8, 128).TopPosZ(4, 20)) ITEM(Option, singleline, SetLabel(t_("Single line")).LeftPosZ(484, 80).TopPosZ(4, 20)) END_LAYOUT diff --git a/examples/TextToSvgPath/ToSvg.cpp b/examples/TextToSvgPath/ToSvg.cpp index 122eaf454..600bfa423 100644 --- a/examples/TextToSvgPath/ToSvg.cpp +++ b/examples/TextToSvgPath/ToSvg.cpp @@ -1,7 +1,7 @@ #include "TextToSvgPath.h" struct TextToSvg : FontGlyphConsumer { - String t; + String t; // here we accumulate the SVG path text void Put(Pointf p); @@ -55,7 +55,7 @@ String TextToSvgPath(double x, double y, const char *text, Font fnt, bool single TextToSvg t; for(const wchar *s = ~ws; *s; s++) { fnt.Render(t, x, y, *s); - x += fnt[*s]; + x += fnt[*s]; // move the reference point if(!singleline) t.t << "\n"; } diff --git a/examples/TextToSvgPath/main.cpp b/examples/TextToSvgPath/main.cpp index f67a8e345..04b989ede 100644 --- a/examples/TextToSvgPath/main.cpp +++ b/examples/TextToSvgPath/main.cpp @@ -10,31 +10,12 @@ void Preview::Paint(Draw& w) TextToSvgPathDlg::TextToSvgPathDlg() { CtrlLayout(*this, "Text to SVG path converter"); - for(Ctrl *q = GetFirstChild(); q; q = q->GetNext()) - if(!dynamic_cast