mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
ScatterCtrl_Demo: New interface
git-svn-id: svn://ultimatepp.org/upp/trunk@6048 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
45eba9181a
commit
ff83c18bdd
6 changed files with 54 additions and 32 deletions
|
|
@ -14,7 +14,7 @@ using namespace Upp;
|
|||
#include <Draw/iml_header.h>
|
||||
|
||||
|
||||
struct ScatterDemo : ParentCtrl {
|
||||
struct ScatterDemo : StaticRect {
|
||||
virtual void Init() {};
|
||||
virtual ScatterCtrl &Scatter() = 0;
|
||||
};
|
||||
|
|
@ -184,7 +184,9 @@ class ScatterCtrl_Demo : public WithScatterCtrl_Demo<TopWindow> {
|
|||
|
||||
public:
|
||||
ScatterCtrl_Demo();
|
||||
TabPie tabPie;
|
||||
|
||||
private:
|
||||
void Preview();
|
||||
void SavePNG();
|
||||
void SaveJPG();
|
||||
|
|
@ -194,7 +196,9 @@ public:
|
|||
void CopyClipboard();
|
||||
void SetMode();
|
||||
|
||||
TabPie tabPie;
|
||||
void OnSel();
|
||||
|
||||
Vector<StaticRect *> examplesRects;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
LAYOUT(ScatterCtrl_Demo, 624, 392)
|
||||
ITEM(TabCtrl, tab, HSizePosZ(12, 12).VSizePosZ(52, 12))
|
||||
ITEM(Button, bPreview, SetLabel(t_("Print Preview")).LeftPosZ(12, 80).TopPosZ(12, 24))
|
||||
ITEM(Button, bSavePNG, SetLabel(t_("Save as PNG")).LeftPosZ(204, 88).TopPosZ(12, 24))
|
||||
ITEM(Button, bSaveJPG, SetLabel(t_("Save as JPEG")).LeftPosZ(300, 84).TopPosZ(12, 24))
|
||||
ITEM(Button, bSaveEMF, SetLabel(t_("Save as EMF")).LeftPosZ(392, 80).TopPosZ(12, 24))
|
||||
ITEM(Button, bCopyClipboard, SetLabel(t_("Copy to Clipboard")).LeftPosZ(100, 96).TopPosZ(12, 24))
|
||||
ITEM(DropList, paintMode, LeftPosZ(484, 128).TopPosZ(24, 19))
|
||||
ITEM(Label, dv___7, SetLabel(t_("Painting Mode")).LeftPosZ(484, 128).TopPosZ(4, 19))
|
||||
LAYOUT(ScatterCtrl_Demo, 624, 352)
|
||||
ITEM(Button, bPreview, SetLabel(t_("Print Preview")).LeftPosZ(4, 88).BottomPosZ(4, 20))
|
||||
ITEM(Button, bSavePNG, SetLabel(t_("Save as PNG")).LeftPosZ(4, 88).BottomPosZ(28, 20))
|
||||
ITEM(Button, bSaveJPG, SetLabel(t_("Save as JPEG")).LeftPosZ(96, 80).BottomPosZ(28, 20))
|
||||
ITEM(Button, bSaveEMF, SetLabel(t_("Save as EMF")).LeftPosZ(108, 68).BottomPosZ(52, 20))
|
||||
ITEM(Button, bCopyClipboard, SetLabel(t_("Copy to Clipboard")).LeftPosZ(4, 100).BottomPosZ(52, 20))
|
||||
ITEM(DropList, paintMode, LeftPosZ(4, 172).BottomPosZ(77, 19))
|
||||
ITEM(Label, dv___6, SetLabel(t_("Painting Mode")).LeftPosZ(4, 172).BottomPosZ(97, 19))
|
||||
ITEM(ArrayCtrl, examplesList, LeftPosZ(4, 168).VSizePosZ(28, 124))
|
||||
ITEM(Label, dv___8, SetLabel(t_("Choose example")).LeftPosZ(4, 152).TopPosZ(4, 21))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(Tab1, 380, 292)
|
||||
|
|
@ -70,7 +71,7 @@ LAYOUT(Tab11, 504, 468)
|
|||
END_LAYOUT
|
||||
|
||||
LAYOUT(TabPie, 536, 440)
|
||||
ITEM(PieCtrl, chart, SetLegendBackColor(Color(229, 229, 229)).SetLegendHeight(80).SetTitle(t_("Average Weather")).SetFrame(ThinInsetFrame()).HSizePosZ(8, 12).VSizePosZ(40, 12))
|
||||
ITEM(PieCtrl, chart, SetLegendHeight(80).SetLegendBackColor(Color(229, 229, 229)).SetTitle(t_("Average Weather")).SetFrame(ThinInsetFrame()).HSizePosZ(8, 12).VSizePosZ(40, 12))
|
||||
ITEM(Label, dv___1, SetLabel(t_(" EXPERIMENTAL")).SetFrame(ThinInsetFrame()).LeftPosZ(8, 84).TopPosZ(8, 24))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -33,24 +33,31 @@ bool CompareExamples(Example &a, Example &b) {return a.index < b.index;}
|
|||
GUI_APP_MAIN
|
||||
{
|
||||
Sort(Examples(), CompareExamples);
|
||||
for (int i = 0; i < Examples().GetCount(); ++i)
|
||||
Examples()[i].ctrl()->Init();
|
||||
|
||||
ScatterCtrl_Demo demo;
|
||||
|
||||
demo.tabPie.Init();
|
||||
demo.Run();
|
||||
ScatterCtrl_Demo().Run();
|
||||
}
|
||||
|
||||
ScatterCtrl_Demo::ScatterCtrl_Demo()
|
||||
{
|
||||
CtrlLayout(*this, "Scatter Test");
|
||||
|
||||
for (int i = 0; i < Examples().GetCount(); ++i)
|
||||
tab.Add(*(Examples()[i].ctrl()), Examples()[i].name);
|
||||
|
||||
tab.Add(tabPie, "Pie chart");
|
||||
for (int i = 0; i < Examples().GetCount(); ++i)
|
||||
Examples()[i].ctrl()->Init();
|
||||
|
||||
examplesList.AddColumn("Example name");
|
||||
for (int i = 0; i < Examples().GetCount(); ++i) {
|
||||
examplesList.Add(Examples()[i].name);
|
||||
Add((*(Examples()[i].ctrl())).HSizePosZ(180, 4).VSizePosZ(4, 8));
|
||||
examplesRects.Add(Examples()[i].ctrl());
|
||||
}
|
||||
examplesList.Add("Pie chart");
|
||||
tabPie.Init();
|
||||
Add(tabPie.HSizePosZ(180, 4).VSizePosZ(4, 8));
|
||||
examplesRects.Add(&tabPie);
|
||||
|
||||
for (int i = 0; i < examplesRects.GetCount(); ++i)
|
||||
examplesRects[i]->Hide();
|
||||
|
||||
bPreview <<= THISBACK(Preview);
|
||||
bSavePNG <<= THISBACK(SavePNG);
|
||||
bSaveJPG <<= THISBACK(SaveJPG);
|
||||
|
|
@ -70,14 +77,27 @@ ScatterCtrl_Demo::ScatterCtrl_Demo()
|
|||
paintMode.SetData(ScatterDraw::MD_ANTIALIASED);
|
||||
SetMode();
|
||||
|
||||
examplesList.WhenSel = THISBACK(OnSel);
|
||||
examplesList.Select(0, false);
|
||||
OnSel();
|
||||
|
||||
Sizeable().Zoomable().Icon(MyImages::i1());
|
||||
}
|
||||
|
||||
void ScatterCtrl_Demo::OnSel()
|
||||
{
|
||||
for (int i = 0; i < examplesRects.GetCount(); ++i)
|
||||
examplesRects[i]->Hide();
|
||||
if (examplesList.GetCursor() < 0)
|
||||
return;
|
||||
examplesRects[examplesList.GetCursor()]->Show();
|
||||
}
|
||||
|
||||
void ScatterCtrl_Demo::Preview()
|
||||
{
|
||||
Report r;
|
||||
|
||||
const Drawing &w = Examples()[tab.Get()].ctrl()->Scatter().GetDrawing();
|
||||
const Drawing &w = Examples()[examplesList.GetCursor()].ctrl()->Scatter().GetDrawing();
|
||||
r.Landscape();
|
||||
Size pageSize = r.GetPageSize();
|
||||
r.DrawDrawing(0, 0, pageSize.cx, pageSize.cy, w);
|
||||
|
|
@ -87,14 +107,14 @@ void ScatterCtrl_Demo::Preview()
|
|||
|
||||
void ScatterCtrl_Demo::SavePNG()
|
||||
{
|
||||
int ntab = tab.Get();
|
||||
int ntab = examplesList.GetCursor();
|
||||
|
||||
Examples()[ntab].ctrl()->Scatter().SaveToFile(Format("scatter%d.png", ntab));
|
||||
}
|
||||
|
||||
void ScatterCtrl_Demo::SaveJPG()
|
||||
{
|
||||
int ntab = tab.Get();
|
||||
int ntab = examplesList.GetCursor();
|
||||
|
||||
Examples()[ntab].ctrl()->Scatter().SaveToFile(Format("scatter%d.jpg", ntab));
|
||||
}
|
||||
|
|
@ -102,7 +122,7 @@ void ScatterCtrl_Demo::SaveJPG()
|
|||
#ifdef PLATFORM_WIN32
|
||||
void ScatterCtrl_Demo::SaveEMF()
|
||||
{
|
||||
int ntab = tab.Get();
|
||||
int ntab = examplesList.GetCursor();
|
||||
|
||||
Examples()[ntab].ctrl()->Scatter().SaveAsMetafile(Format("scatter%d.emf", ntab));
|
||||
}
|
||||
|
|
@ -110,7 +130,7 @@ void ScatterCtrl_Demo::SaveEMF()
|
|||
|
||||
void ScatterCtrl_Demo::CopyClipboard()
|
||||
{
|
||||
Examples()[tab.Get()].ctrl()->Scatter().SaveToClipboard();
|
||||
Examples()[examplesList.GetCursor()].ctrl()->Scatter().SaveToClipboard();
|
||||
}
|
||||
|
||||
void ScatterCtrl_Demo::SetMode()
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void Tab1::Init()
|
|||
scatter.AddSeries(s5).Legend("Series 5").PlotStyle<BarSeriesPlot>(barWidth).Dash("").NoMark().Fill();
|
||||
|
||||
scatter.SetRange(60, 50).SetMajorUnits(10, 10);
|
||||
scatter.ShowInfo().ShowContextMenu().ShowPropertiesDlg().SetPopText("h", "v", "v2");
|
||||
scatter.ShowInfo().ShowContextMenu().ShowPropertiesDlg().SetPopText("h", "v", "v2").SetMouseHandling(true, true);
|
||||
}
|
||||
|
||||
ScatterDemo *Construct1()
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ void Tab8::Init()
|
|||
{
|
||||
CtrlLayout(*this);
|
||||
HSizePos().VSizePos();
|
||||
scatter.SetRange(13, 50, 20);
|
||||
scatter.SetMajorUnits(1, 10);
|
||||
scatter.SetXYMin(0,-20, 1000);
|
||||
scatter.SetRange(13, 50, 20).SetMajorUnits(1, 10).SetXYMin(0,-20, 1000);
|
||||
scatter.SetMouseHandling(true, true);
|
||||
|
||||
s3 <<Pointf(1,-12)<<Pointf(2,-17)<<Pointf(3,-13)<<Pointf(4,15)<<Pointf(5,18)<<Pointf(6,25)<<Pointf(7,27)<<Pointf(8,20)<<Pointf(9,5)<<Pointf(10,-10)<<Pointf(11,24)<<Pointf(12,17);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
void TabPie::Init()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
HSizePos().VSizePos();
|
||||
|
||||
chart.ShowPercent();
|
||||
chart.AddCategory("Sunny", 8, ::Color(90, 150, 255));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue