diff --git a/bazaar/PainterSvg demo/Examples.h b/bazaar/PainterSvg demo/Examples.h index 1b032622d..ca1ec63c2 100644 --- a/bazaar/PainterSvg demo/Examples.h +++ b/bazaar/PainterSvg demo/Examples.h @@ -1,41 +1,39 @@ -#ifndef _PainterExamples_Examples_h_ -#define _PainterExamples_Examples_h_ - -#include -#include - -using namespace Upp; - -#define LAYOUTFILE -#include - -void RegisterExample(const char *name, void (*ex)(Painter& pw)); - -struct App : TopWindow { - virtual void Paint(Draw& w); - - SplitterFrame split; - ArrayCtrl list; - FrameBottom< WithCtrlLayout > ctrl; - - typedef App CLASSNAME; - - void DoPaint0(Painter& sw); - void DoPaint(Painter& sw); - void Print(); - void Benchmark(); - void Sync(); - void ToSlider(EditDouble *e, SliderCtrl *slider); - void ToEdit(EditDouble *e, SliderCtrl *slider); - void Pair(EditDouble& e, SliderCtrl& slider); - void ToSlider(); - void Reset(); - void Serialize(Stream& s); - - App(); - ~App(); -}; - - - -#endif +#ifndef _PainterExamples_Examples_h_ +#define _PainterExamples_Examples_h_ + +#include +#include + +using namespace Upp; + +#define LAYOUTFILE +#include + +void RegisterExample(const char *name, void (*ex)(Painter& pw)); + +struct App : TopWindow { + virtual void Paint(Draw& w); + + SplitterFrame split; + ArrayCtrl list; + FrameBottom< WithCtrlLayout > ctrl; + + typedef App CLASSNAME; + + void DoPaint0(Painter& sw); + void DoPaint(Painter& sw); + void Print(); + void Benchmark(); + void Sync(); + void ToSlider(EditDouble *e, SliderCtrl *slider); + void ToEdit(EditDouble *e, SliderCtrl *slider); + void Pair(EditDouble& e, SliderCtrl& slider); + void ToSlider(); + void Reset(); + void Serialize(Stream& s); + + App(); + ~App(); +}; + +#endif diff --git a/bazaar/PainterSvg demo/PainterSvg demo.upp b/bazaar/PainterSvg demo/PainterSvg demo.upp index d1bcfdced..96ac8413c 100644 --- a/bazaar/PainterSvg demo/PainterSvg demo.upp +++ b/bazaar/PainterSvg demo/PainterSvg demo.upp @@ -2,12 +2,11 @@ description "Svg Painter demo"; uses CtrlLib, - Painter; + PainterSvg; file - SvgDemo.cpp, - ..\PainterSvg\ParseSvg.cpp, Examples.h, + SvgDemo.cpp, main.cpp, Examples.lay; diff --git a/bazaar/PainterSvg demo/SvgDemo.cpp b/bazaar/PainterSvg demo/SvgDemo.cpp index f1bc92153..c085840fd 100644 --- a/bazaar/PainterSvg demo/SvgDemo.cpp +++ b/bazaar/PainterSvg demo/SvgDemo.cpp @@ -1,28 +1,28 @@ -#include "Examples.h" - -void ParseSVG(Painter& p, const char *svg); - -void SvgDemo(Painter& sw) -{ - String file = "C:\\demo.svg"; - - try { - if (FileExists(file)) - ParseSVG(sw, file); - else { - sw.Scale(1./20); - sw.Text(200, 200, "Please copy the svg file in '" + file + "'", Font(Font::ARIAL, 400)); - sw.Text(200, 700, "or change String file in SvgDemo.cpp", Font(Font::ARIAL, 400)); - sw.Opacity(1); - sw.Stroke(1, Black()); - sw.Fill(Black()); - } - } - catch(XmlError e) { - LOG("SVG XML error: " + e); - } -} - -INITBLOCK { - RegisterExample("Svg demo", SvgDemo); -} +#include "Examples.h" + +void ParseSVG(Painter& p, const char *svg); + +void SvgDemo(Painter& sw) +{ + String file = "C:\\demo.svg"; + + try { + if (FileExists(file)) + ParseSVG(sw, LoadFileBOM(file)); + else { + sw.Scale(1./20); + sw.Text(200, 200, "Please copy the svg file in '" + file + "'", Font(Font::ARIAL, 400)); + sw.Text(200, 700, "or change String file in SvgDemo.cpp", Font(Font::ARIAL, 400)); + sw.Opacity(1); + sw.Stroke(1, Black()); + sw.Fill(Black()); + } + } + catch(XmlError e) { + LOG("SVG XML error: " + e); + } +} + +INITBLOCK { + RegisterExample("Svg demo", SvgDemo); +} diff --git a/bazaar/PainterSvg demo/init b/bazaar/PainterSvg demo/init index 9bfefeb5e..a881f5789 100644 --- a/bazaar/PainterSvg demo/init +++ b/bazaar/PainterSvg demo/init @@ -1,5 +1,5 @@ #ifndef _PainterSvg_demo_icpp_init_stub #define _PainterSvg_demo_icpp_init_stub #include "CtrlLib/init" -#include "Painter/init" +#include "PainterSvg/init" #endif diff --git a/bazaar/PainterSvg/PainterSvg.h b/bazaar/PainterSvg/PainterSvg.h new file mode 100644 index 000000000..3c39e0872 --- /dev/null +++ b/bazaar/PainterSvg/PainterSvg.h @@ -0,0 +1,13 @@ +#ifndef _PainterSvg_PainterSvg_h +#define _PainterSvg_PainterSvg_h + +#include + +NAMESPACE_UPP + +void ParseSVG(Painter& p, const char *svg); + +END_UPP_NAMESPACE + +#endif + diff --git a/bazaar/PainterSvg/PainterSvg.upp b/bazaar/PainterSvg/PainterSvg.upp new file mode 100644 index 000000000..2cc1997f8 --- /dev/null +++ b/bazaar/PainterSvg/PainterSvg.upp @@ -0,0 +1,7 @@ +uses + Painter; + +file + PainterSvg.h, + ParseSvg.cpp; + diff --git a/bazaar/PainterSvg/ParseSvg.cpp b/bazaar/PainterSvg/ParseSvg.cpp index 073acfcf3..e9470f896 100644 --- a/bazaar/PainterSvg/ParseSvg.cpp +++ b/bazaar/PainterSvg/ParseSvg.cpp @@ -1,7 +1,6 @@ -#include -#include +#include "PainterSvg.h" -using namespace Upp; +NAMESPACE_UPP Color GetSvgColor(const char *color); String GetValueStringXml(String str, const char* var); @@ -616,9 +615,7 @@ void ParseG(Painter& p, XmlParser &xp, Svg2DTransform transf, SvgStyle style) } void ParseSVG(Painter& p, const char *svg) { - String strXml = LoadFileBOM(svg); - XmlParser xp(strXml); - + XmlParser xp(svg); while(!xp.IsTag()) xp.Skip(); xp.PassTag("svg"); @@ -633,3 +630,4 @@ void ParseSVG(Painter& p, const char *svg) p.End(); } +END_UPP_NAMESPACE diff --git a/bazaar/PainterSvg/init b/bazaar/PainterSvg/init new file mode 100644 index 000000000..7f97e8d30 --- /dev/null +++ b/bazaar/PainterSvg/init @@ -0,0 +1,4 @@ +#ifndef _PainterSvg_icpp_init_stub +#define _PainterSvg_icpp_init_stub +#include "Painter/init" +#endif diff --git a/bazaar/SvgView/SvgView.upp b/bazaar/SvgView/SvgView.upp new file mode 100644 index 000000000..eb56503ca --- /dev/null +++ b/bazaar/SvgView/SvgView.upp @@ -0,0 +1,15 @@ +description "Simple SVG viewer (PainterSvg demo)"; + +uses + CtrlLib, + plugin\tif, + plugin\jpg, + plugin\gif, + PainterSvg; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/bazaar/SvgView/init b/bazaar/SvgView/init new file mode 100644 index 000000000..d2436c7b5 --- /dev/null +++ b/bazaar/SvgView/init @@ -0,0 +1,8 @@ +#ifndef _SvgView_icpp_init_stub +#define _SvgView_icpp_init_stub +#include "CtrlLib/init" +#include "plugin\tif/init" +#include "plugin\jpg/init" +#include "plugin\gif/init" +#include "PainterSvg/init" +#endif diff --git a/bazaar/SvgView/main.cpp b/bazaar/SvgView/main.cpp new file mode 100644 index 000000000..987327b0b --- /dev/null +++ b/bazaar/SvgView/main.cpp @@ -0,0 +1,132 @@ +#include +#include + +using namespace Upp; + +class SvgView : public TopWindow { +public: + virtual bool Key(dword key, int); + +private: + ImageCtrl img; + FileList files; + Splitter splitter; + String dir; + FrameTop