diff --git a/uppsrc/ScatterCtrl/Data.cpp b/uppsrc/ScatterCtrl/Data.cpp index 8ea55d4c6..f175c4513 100644 --- a/uppsrc/ScatterCtrl/Data.cpp +++ b/uppsrc/ScatterCtrl/Data.cpp @@ -50,7 +50,7 @@ void DataDlg::Init(ScatterCtrl& scatter) } } - tab <<= THISBACK(OnTab); + tab.WhenAction = [=]{OnTab();}; butOK.WhenAction = [=] {Close();}; } @@ -125,7 +125,7 @@ void DataDlg::OnTab() } } } - data.WhenBar = THISBACK(OnArrayBar); + data.WhenBar = [=](Bar &bar) {OnArrayBar(bar);}; } void DataDlg::ArrayCopy() { @@ -178,7 +178,7 @@ void DataDlg::OnArrayBar(Bar &menu) if (index < 0) return; - menu.Add(t_("Select all"), Null, THISBACK(ArraySelect)).Key(K_CTRL_A) + menu.Add(t_("Select all"), Null, [=] {ArraySelect();}).Key(K_CTRL_A) .Help(t_("Select all rows")); ArrayCtrl &data = series[index].data; @@ -187,9 +187,9 @@ void DataDlg::OnArrayBar(Bar &menu) menu.Add(t_("No row selected"), Null, Null).Enable(false).Bold(true); else { menu.Add(Format(t_("Selected %d rows"), count), Null, Null).Enable(false).Bold(true); - menu.Add(t_("Copy"), ScatterImgP::Copy(), THISBACK(ArrayCopy)).Key(K_CTRL_C) + menu.Add(t_("Copy"), ScatterImgP::Copy(), [=] {ArrayCopy();}).Key(K_CTRL_C) .Help(t_("Copy selected rows to clipboard")); - menu.Add(t_("Save to file"), ScatterImgP::Save(), THISBACK1(ArraySaveToFile, Null)).Key(K_CTRL_S) + menu.Add(t_("Save to file"), ScatterImgP::Save(), [=] {ArraySaveToFile(Null);}).Key(K_CTRL_S) .Help(t_("Save to .csv file")); } } diff --git a/uppsrc/ScatterCtrl/PieCtrl.cpp b/uppsrc/ScatterCtrl/PieCtrl.cpp index d0c61dfd4..d860dd8ae 100644 --- a/uppsrc/ScatterCtrl/PieCtrl.cpp +++ b/uppsrc/ScatterCtrl/PieCtrl.cpp @@ -54,14 +54,14 @@ void PieCtrl::Paint(Draw& w) } void PieCtrl::RightDown(Point, dword) { - MenuBar::Execute(THISBACK(ContextMenu)); + MenuBar::Execute([=](Bar& bar){ContextMenu(bar);}); } void PieCtrl::ContextMenu(Bar& bar) { - bar.Add(t_("Copy"), PieImg::Copy(), THISBACK1(SaveToClipboard, false)).Key(K_CTRL_C) + bar.Add(t_("Copy"), PieImg::Copy(), [=] {SaveToClipboard(false);}).Key(K_CTRL_C) .Help(t_("Copy image to clipboard")); - bar.Add(t_("Save to file"), PieImg::Save(), THISBACK1(SaveToFile, Null)).Key(K_CTRL_S) + bar.Add(t_("Save to file"), PieImg::Save(), [=] {SaveToFile(Null);}).Key(K_CTRL_S) .Help(t_("Save image to file")); } @@ -85,7 +85,7 @@ void PieCtrl::SaveToFile(String fileName) fileToSave.ClearTypes(); fileToSave.Type(Format(t_("%s file"), "JPEG"), "*.jpg"); fileToSave.Type(Format(t_("%s file"), "PNG"), "*.png"); - fileToSave.type.WhenAction = THISBACK(OnFileToSave); + fileToSave.type.WhenAction = [=] {OnFileToSave();}; if(!fileToSave.ExecuteSaveAs(t_("Saving plot to PNG or JPEG file"))) { Exclamation(t_("Plot has not been saved")); return; diff --git a/uppsrc/ScatterCtrl/PieCtrl.h b/uppsrc/ScatterCtrl/PieCtrl.h index b98fda4b3..b6e6d5e71 100644 --- a/uppsrc/ScatterCtrl/PieCtrl.h +++ b/uppsrc/ScatterCtrl/PieCtrl.h @@ -10,7 +10,6 @@ namespace Upp { class PieCtrl: public StaticRect, public PieDraw { public: - typedef PieCtrl CLASSNAME; PieCtrl(); void Paint(Draw& w); diff --git a/uppsrc/ScatterCtrl/Processing.cpp b/uppsrc/ScatterCtrl/Processing.cpp index a31d73545..78dabe381 100644 --- a/uppsrc/ScatterCtrl/Processing.cpp +++ b/uppsrc/ScatterCtrl/Processing.cpp @@ -23,7 +23,7 @@ void PropertiesDlg::Init(ScatterCtrl& scatter) tab.Add(general, t_("General")); OnTab(); - tab <<= THISBACK(OnTab); + tab.WhenAction = [=]{OnTab();}; butOK.WhenAction = [=] {Close();}; } @@ -76,7 +76,7 @@ void ProcessingDlg::Init(ScatterCtrl& scatter) } if (list.list.GetCount() > 0) list.list.SetCursor(0); - list.list.WhenSel = THISBACK(UpdateFields); + list.list.WhenSel = [=] {UpdateFields();}; UpdateFields(); right.butOK.WhenAction = [=] {Close();}; @@ -126,45 +126,45 @@ ProcessingTab::ProcessingTab() tab.Add(splitterTabOp.SizePos(), t_("Operations")); tab.Add(splitterTabBestFit.SizePos(), t_("Best fit")); tab.Add(splitterTabHist.SizePos(), t_("Histogram")); - tab.WhenSet = THISBACK(OnSet); + tab.WhenSet = [=] {OnSet();}; - tabFreqRight.butFFT.WhenAction = THISBACK(OnFFT); + tabFreqRight.butFFT.WhenAction = [=] {OnFFT();}; tabFreqRight.opXAxis = 0; - tabFreqRight.opXAxis.WhenAction = THISBACK(OnFFT); - tabFreqRight.type.WhenAction = THISBACK(OnFFT); + tabFreqRight.opXAxis.WhenAction = [=] {OnFFT();}; + tabFreqRight.type.WhenAction = [=] {OnFFT();}; tabFreqRight.type = 0; for (int i = 0; i < DataSource::GetFFTWindowCount(); ++i) tabFreqRight.window.Add(InitCaps(DataSource::GetFFTWindowStr(i))); tabFreqRight.window.SetIndex(1); - tabFreqRight.window.WhenAction = THISBACK(OnFFT); + tabFreqRight.window.WhenAction = [=] {OnFFT();}; tabFreqRight.num <<= 1; tabFreqRight.overlapping <<= 0.1; tabFitRight.opSeries = true; - tabFitRight.opSeries.WhenAction = THISBACK(OnOp); - tabFitRight.opAverage.WhenAction = THISBACK(OnOp); - tabFitRight.opLinear.WhenAction = THISBACK(OnOp); - tabFitRight.opCuadratic.WhenAction = THISBACK(OnOp); - tabFitRight.opCubic.WhenAction = THISBACK(OnOp); - tabFitRight.opSinus.WhenAction = THISBACK(OnOp); - tabFitRight.opSinusTend.WhenAction = THISBACK(OnOp); - tabFitRight.opSpline.WhenAction = THISBACK(OnOp); - tabFitRight.opDerivative.WhenAction = THISBACK(OnOp); - tabFitRight.derOrder.WhenAction = THISBACK(OnOp); - tabFitRight.derAccuracy.WhenAction = THISBACK(OnOp); - tabFitRight.opSG.WhenAction = THISBACK(OnOp); - tabFitRight.sgOrder.WhenAction = THISBACK(OnOp); - tabFitRight.sgSize.WhenAction = THISBACK(OnOp); - tabFitRight.sgDeg.WhenAction = THISBACK(OnOp); - tabFitRight.opMax.WhenAction = THISBACK(OnOp); - tabFitRight.opMin.WhenAction = THISBACK(OnOp); - tabFitRight.opMovAvg.WhenAction = THISBACK(OnOp); - tabFitRight.opSecAvg.WhenAction = THISBACK(OnOp); - tabFitRight.opCumAvg.WhenAction = THISBACK(OnOp); - tabFitRight.butAutoSensSector.WhenAction = THISBACK(OnAutoSensSector); - tabFitRight.width.WhenLostFocus = THISBACK(OnUpdateSensitivity); - tabFitRight.width.WhenAction = THISBACK(OnUpdateSensitivity); + tabFitRight.opSeries.WhenAction = [=] {OnOp();}; + tabFitRight.opAverage.WhenAction = [=] {OnOp();}; + tabFitRight.opLinear.WhenAction = [=] {OnOp();}; + tabFitRight.opCuadratic.WhenAction = [=] {OnOp();}; + tabFitRight.opCubic.WhenAction = [=] {OnOp();}; + tabFitRight.opSinus.WhenAction = [=] {OnOp();}; + tabFitRight.opSinusTend.WhenAction = [=] {OnOp();}; + tabFitRight.opSpline.WhenAction = [=] {OnOp();}; + tabFitRight.opDerivative.WhenAction = [=] {OnOp();}; + tabFitRight.derOrder.WhenAction = [=] {OnOp();}; + tabFitRight.derAccuracy.WhenAction = [=] {OnOp();}; + tabFitRight.opSG.WhenAction = [=] {OnOp();}; + tabFitRight.sgOrder.WhenAction = [=] {OnOp();}; + tabFitRight.sgSize.WhenAction = [=] {OnOp();}; + tabFitRight.sgDeg.WhenAction = [=] {OnOp();}; + tabFitRight.opMax.WhenAction = [=] {OnOp();}; + tabFitRight.opMin.WhenAction = [=] {OnOp();}; + tabFitRight.opMovAvg.WhenAction = [=] {OnOp();}; + tabFitRight.opSecAvg.WhenAction = [=] {OnOp();}; + tabFitRight.opCumAvg.WhenAction = [=] {OnOp();}; + tabFitRight.butAutoSensSector.WhenAction = [=] {OnAutoSensSector();}; + tabFitRight.width.WhenLostFocus = [=] {OnUpdateSensitivity();}; + tabFitRight.width.WhenAction = [=] {OnUpdateSensitivity();}; tabFitRight.opDerivative.Tip(t_("Numerical derivative including derivative order and accuracy (related to window size)")); tabFitRight.derOrder <<= 1; @@ -181,11 +181,11 @@ ProcessingTab::ProcessingTab() tabFitRight.sgDeg <<= 3; tabFitRight.sgDeg.Tip(t_("Polynomial degree")); tabFitRight.numDecimals <<= 3; - tabFitRight.numDecimals.WhenAction = THISBACK(UpdateEquations); - tabFitRight.showEquation.WhenAction = THISBACK(OnShowEquation); + tabFitRight.numDecimals.WhenAction = [=] {UpdateEquations();}; + tabFitRight.showEquation.WhenAction = [=] {OnShowEquation();}; - tabOpRight.xLow.WhenLostFocus = THISBACK(OnOperation); - tabOpRight.xHigh.WhenLostFocus = THISBACK(OnOperation); + tabOpRight.xLow.WhenLostFocus = [=] {OnOperation();}; + tabOpRight.xHigh.WhenLostFocus = [=] {OnOperation();}; tabBestFitRight.coefficients = 0; tabBestFitRight.coefficients.Tip(t_("To show real equation coefficients with different precisions or just in text")); @@ -197,7 +197,7 @@ ProcessingTab::ProcessingTab() tabBestFitRight.gridTrend.AddColumn(t_("Equation"), 30); tabBestFitRight.gridTrend.AddColumn(t_("R2"), 5); tabBestFitRight.gridTrend.SetLineCy(EditField::GetStdHeight()).MultiSelect(); - tabBestFitRight.gridTrend.WhenBar = THISBACK(OnArrayBar); + tabBestFitRight.gridTrend.WhenBar = [=](Bar &menu) {OnArrayBar(menu);}; tabBestFitRight.gridTrend.Sort(r2Compare); for (int i = 0; i < ExplicitEquation::GetEquationCount(); ++i) equationTypes.Add(ExplicitEquation::Create(i)); @@ -205,13 +205,13 @@ ProcessingTab::ProcessingTab() equationTypes.Add(userEquation); tabBestFitRight.butFit.Tip(t_("It tries to fit the series with the supported equations")); - tabBestFitRight.butFit.WhenPush = THISBACK(OnFit); + tabBestFitRight.butFit.WhenPush = [=] {OnFit();}; tabHistRight.axis.Add(t_("X")); tabHistRight.axis.Add(t_("Y")); tabHistRight.axis.SetIndex(1); - tabHistRight.axis.WhenAction = THISBACK(OnSet); - tabHistRight.butHist <<= THISBACK(OnHist); + tabHistRight.axis.WhenAction = [=] {OnSet();}; + tabHistRight.butHist.WhenAction = [=] {OnHist();}; tabHistRight.numVals <<= 30; tabHistRight.valNormalize <<= 100; tabHistRight.opStaggered <<= true; @@ -239,8 +239,8 @@ void ProcessingTab::ArraySelect() { } void ProcessingTab::OnArrayBar(Bar &menu) { - menu.Add(t_("Select all"), Null, THISBACK(ArraySelect)).Key(K_CTRL_A).Help(t_("Select all rows")); - menu.Add(t_("Copy"), ScatterImgP::Copy(), THISBACK(ArrayCopy)).Key(K_CTRL_C).Help(t_("Copy selected rows")); + menu.Add(t_("Select all"), Null, [=] {ArraySelect();}).Key(K_CTRL_A).Help(t_("Select all rows")); + menu.Add(t_("Copy"), ScatterImgP::Copy(), [=] {ArrayCopy();}).Key(K_CTRL_C).Help(t_("Copy selected rows")); } void ProcessingTab::OnFit() { diff --git a/uppsrc/ScatterCtrl/Properties.cpp b/uppsrc/ScatterCtrl/Properties.cpp index 67de8a363..6ae1d8a53 100644 --- a/uppsrc/ScatterCtrl/Properties.cpp +++ b/uppsrc/ScatterCtrl/Properties.cpp @@ -63,30 +63,30 @@ void MeasuresTab::Init(ScatterCtrl& scatter) } dashStyle <<= DashStyle::TypeName(id); - xMin.WhenEnter = THISBACK(Change); - xMax.WhenEnter = THISBACK(Change); - yMin.WhenEnter = THISBACK(Change); - yMax.WhenEnter = THISBACK(Change); - yMin2.WhenEnter = THISBACK(Change); - yMax2.WhenEnter = THISBACK(Change); - xMinUnit.WhenEnter = THISBACK(Change); - yMinUnit.WhenEnter = THISBACK(Change); - xMajorUnit.WhenEnter = THISBACK(Change); - yMajorUnit.WhenEnter = THISBACK(Change); + xMin.WhenEnter = [=]{Change();}; + xMax.WhenEnter = [=]{Change();}; + yMin.WhenEnter = [=]{Change();}; + yMax.WhenEnter = [=]{Change();}; + yMin2.WhenEnter = [=]{Change();}; + yMax2.WhenEnter = [=]{Change();}; + xMinUnit.WhenEnter = [=]{Change();}; + yMinUnit.WhenEnter = [=]{Change();}; + xMajorUnit.WhenEnter = [=]{Change();}; + yMajorUnit.WhenEnter = [=]{Change();}; - opAttachX.WhenAction = THISBACK(Change); - opAttachY.WhenAction = THISBACK(Change); - opReticleX.WhenAction = THISBACK(Change); - opReticleY.WhenAction = THISBACK(Change); - opReticleY2.WhenAction = THISBACK(Change); - opReticleXNumbers.WhenAction = THISBACK(Change); - opReticleYNumbers.WhenAction = THISBACK(Change); - opReticleY2Numbers.WhenAction = THISBACK(Change); - reticlethickness <<= THISBACK(Change); + opAttachX.WhenAction = [=]{Change();}; + opAttachY.WhenAction = [=]{Change();}; + opReticleX.WhenAction = [=]{Change();}; + opReticleY.WhenAction = [=]{Change();}; + opReticleY2.WhenAction = [=]{Change();}; + opReticleXNumbers.WhenAction = [=]{Change();}; + opReticleYNumbers.WhenAction = [=]{Change();}; + opReticleY2Numbers.WhenAction = [=]{Change();}; + reticlethickness.WhenAction = [=]{Change();}; - linecolor <<= THISBACK(Change); - linethickness <<= THISBACK(Change); - dashStyle.WhenAction = THISBACK(Change); + linecolor.WhenAction = [=]{Change();}; + linethickness.WhenAction = [=]{Change();}; + dashStyle.WhenAction = [=]{Change();}; Change(); } @@ -140,31 +140,31 @@ void TextsTab::Init(ScatterCtrl& scatter) pscatter = &scatter; title <<= scatter.GetTitle(); - title <<= THISBACK(Change); + title.WhenAction = [=]{Change();}; xLabel <<= scatter.GetLabelX(); - xLabel <<= THISBACK(Change); + xLabel.WhenAction = [=]{Change();}; yLabel <<= scatter.GetLabelY(); - yLabel <<= THISBACK(Change); + yLabel.WhenAction = [=]{Change();}; yLabel2 <<= scatter.GetLabelY2(); - yLabel2 <<= THISBACK(Change); + yLabel2.WhenAction = [=]{Change();}; backcolor <<= scatter.GetPlotAreaColor(); - backcolor <<= THISBACK(Change); + backcolor.WhenAction = [=]{Change();}; leftMargin <<= scatter.GetPlotAreaLeftMargin(); - leftMargin <<= THISBACK(Change); + leftMargin.WhenAction = [=]{Change();}; rightMargin <<= scatter.GetPlotAreaRightMargin(); - rightMargin <<= THISBACK(Change); + rightMargin.WhenAction = [=]{Change();}; topMargin <<= scatter.GetPlotAreaTopMargin(); - topMargin <<= THISBACK(Change); + topMargin.WhenAction = [=]{Change();}; bottomMargin <<= scatter.GetPlotAreaBottomMargin(); - bottomMargin <<= THISBACK(Change); + bottomMargin.WhenAction = [=]{Change();}; butFontTitle.SetImage(ScatterImgP::ColorA); - butFontTitle <<= THISBACK(OnFontTitle); + butFontTitle.WhenAction = [=]{Change();}; colorTitle <<= scatter.GetTitleColor(); - colorTitle <<= THISBACK(Change); + colorTitle.WhenAction = [=]{Change();}; butFontLabel.SetImage(ScatterImgP::ColorA); - butFontLabel <<= THISBACK(OnFontLabel); + butFontLabel.WhenAction = [=]{OnFontLabel();}; colorLabel <<= scatter.GetLabelsColor(); - colorLabel <<= THISBACK(Change); + colorLabel.WhenAction = [=]{Change();}; Change(); } @@ -173,7 +173,7 @@ void TextsTab::OnFontTitle() { FontSelect fontSelect; fontSelect.Set(pscatter->GetTitleFont()); - fontSelect.WhenAction = THISBACK(OnChangeFontTitle); + fontSelect.WhenAction = [=](Font f) {OnChangeFontTitle(f);}; fontSelect.Execute(butFontTitle); } @@ -186,7 +186,7 @@ void TextsTab::OnFontLabel() { FontSelect fontSelect; fontSelect.Set(pscatter->GetLabelsFont()); - fontSelect.WhenAction = THISBACK(OnChangeFontLabel); + fontSelect.WhenAction = [=](Font f) {OnChangeFontLabel(f);}; fontSelect.Execute(butFontLabel); } @@ -217,35 +217,35 @@ void LegendTab::Init(ScatterCtrl& scatter) pscatter = &scatter; showLegend <<= scatter.GetShowLegend(); - showLegend <<= THISBACK(Change); + showLegend.WhenAction = [=] {Change();}; legendPosition <<= (scatter.GetLegendAnchor() == ScatterDraw::TOP ? 0 : 1); - legendPosition <<= THISBACK(Change); + legendPosition.WhenAction = [=] {Change();}; switch(scatter.GetLegendAnchor()) { case ScatterDraw::LEFT_TOP: legendAnchorLT = true; break; case ScatterDraw::RIGHT_TOP: legendAnchorRT = true; break; case ScatterDraw::LEFT_BOTTOM: legendAnchorLB = true; break; case ScatterDraw::RIGHT_BOTTOM: legendAnchorRB = true; break; } - legendAnchorLT <<= THISBACK1(ChangeAnchor, &legendAnchorLT); - legendAnchorRT <<= THISBACK1(ChangeAnchor, &legendAnchorRT); - legendAnchorLB <<= THISBACK1(ChangeAnchor, &legendAnchorLB); - legendAnchorRB <<= THISBACK1(ChangeAnchor, &legendAnchorRB); + legendAnchorLT.WhenAction = [&] {ChangeAnchor(&legendAnchorLT);}; + legendAnchorRT.WhenAction = [&] {ChangeAnchor(&legendAnchorRT);}; + legendAnchorLB.WhenAction = [&] {ChangeAnchor(&legendAnchorLB);}; + legendAnchorRB.WhenAction = [&] {ChangeAnchor(&legendAnchorRB);}; fillColor <<= scatter.GetLegendFillColor(); - fillColor <<= THISBACK(Change); + fillColor.WhenAction = [=] {Change();}; borderColor <<= scatter.GetLegendBorderColor(); - borderColor <<= THISBACK(Change); + borderColor.WhenAction = [=] {Change();}; Point p = scatter.GetLegendPos(); tableHoriz <<= p.x; - tableHoriz <<= THISBACK(Change); + tableHoriz.WhenAction = [=] {Change();}; tableVert <<= p.y; - tableVert <<= THISBACK(Change); + tableVert.WhenAction = [=] {Change();}; numCols <<= scatter.GetLegendNumCols(); - numCols <<= THISBACK(Change); + numCols.WhenAction = [=] {Change();}; rowSpacing <<= scatter.GetLegendRowSpacing(); - rowSpacing <<= THISBACK(Change); + rowSpacing.WhenAction = [=] {Change();}; Change(); } @@ -317,26 +317,26 @@ void GeneralTab::Init(ScatterCtrl& scatter) dropResolution.Add(ScatterDraw::MD_ANTIALIASED, t_("Painter Antialiased")); dropResolution.Add(ScatterDraw::MD_SUBPIXEL, t_("Painter Subpixel")); dropResolution = scatter.GetMode(); - dropResolution <<= THISBACK(Change); + dropResolution.WhenAction = [=] {Change();}; dropRotate.Clear(); dropRotate.Add(ScatterCtrl::Angle_0, t_("0º")); dropRotate.Add(ScatterCtrl::Angle_90, t_("90º")); dropRotate.Add(ScatterCtrl::Angle_180, t_("180º")); dropRotate.Add(ScatterCtrl::Angle_270, t_("270º")); dropRotate = scatter.GetRotate(); - dropRotate <<= THISBACK(Change); + dropRotate.WhenAction = [=] {Change();}; editWidth <<= scatter.GetSaveSize().cx; editHeight <<= scatter.GetSaveSize().cy; opResponsive <<= scatter.ScatterDraw::IsResponsive(); editSensitivity <<= scatter.ScatterDraw::GetResponsivenessFactor(); editJpgQ <<= scatter.GetJPGQuality(); - editWidth <<= THISBACK(Change); - editHeight <<= THISBACK(Change); - opResponsive <<= THISBACK(Change); - editSensitivity <<= THISBACK(Change); - editJpgQ <<= THISBACK(Change); + editWidth.WhenAction = [=] {Change();}; + editHeight.WhenAction = [=] {Change();}; + opResponsive.WhenAction = [=] {Change();}; + editSensitivity.WhenAction = [=] {Change();}; + editJpgQ.WhenAction = [=] {Change();}; - butApplyToAll <<= THISBACK(ChangeAll); + butApplyToAll.WhenAction = [=] {ChangeAll();}; Change(); } @@ -398,12 +398,12 @@ void SeriesTab::Init0() for(int i = 0; i < scatter.GetCount(); i++) left.list.Add(scatter.GetLegend(i)); left.list.SetCursor(0); - left.list.WhenSel = THISBACK(UpdateFields); - left.butMoveUp <<= THISBACK(OnMoveUp); + left.list.WhenSel = [=] {UpdateFields();}; + left.butMoveUp.WhenAction = [=] {OnMoveUp();}; left.butMoveUp.SetImage(ScatterImgP::UpArrow); - left.butMoveDown <<= THISBACK(OnMoveDown); + left.butMoveDown.WhenAction = [=] {OnMoveDown();}; left.butMoveDown.SetImage(ScatterImgP::DownArrow); - left.butDelete <<= THISBACK(OnDelete); + left.butDelete.WhenAction = [=] {OnDelete();}; right.marktype.Clear(); @@ -418,24 +418,24 @@ void SeriesTab::Init0() UpdateFields(); - right.linecolor <<= THISBACK(Change); - right.fillcolor <<= THISBACK(Change); - right.visible <<= THISBACK(Change); - right.dashStyle.WhenAction = THISBACK(Change); - right.linethickness <<= THISBACK(Change); + right.linecolor.WhenAction = [=] {Change();}; + right.fillcolor.WhenAction = [=] {Change();}; + right.visible.WhenAction = [=] {Change();}; + right.dashStyle.WhenAction = [=] {Change();}; + right.linethickness.WhenAction = [=] {Change();}; - right.markstyle.WhenAction = THISBACK(Change); - right.markcolor <<= THISBACK(Change); - right.markwidth <<= THISBACK(Change); - right.marktype.WhenAction = THISBACK(Change); + right.markstyle.WhenAction = [=] {Change();}; + right.markcolor.WhenAction = [=] {Change();}; + right.markwidth.WhenAction = [=] {Change();}; + right.marktype.WhenAction = [=] {Change();}; - right.showLegend <<= THISBACK(Change); + right.showLegend.WhenAction = [=] {Change();}; - right.unitsY <<= THISBACK(Change); - right.unitsX <<= THISBACK(Change); + right.unitsY.WhenAction = [=] {Change();}; + right.unitsX.WhenAction = [=] {Change();}; - right.name <<= THISBACK(Change); - right.primary <<= THISBACK(Change); + right.name.WhenAction = [=] {Change();}; + right.primary.WhenAction = [=] {Change();}; right.name.SetFocus(); } diff --git a/uppsrc/ScatterCtrl/Properties.h b/uppsrc/ScatterCtrl/Properties.h index c2b11bfdd..136b383a1 100644 --- a/uppsrc/ScatterCtrl/Properties.h +++ b/uppsrc/ScatterCtrl/Properties.h @@ -12,7 +12,6 @@ namespace Upp { class FontSelect : public WithFontSelector { -typedef FontSelect CLASSNAME; public: Event WhenAction; @@ -20,11 +19,11 @@ public: CtrlLayoutExit(*this, t_("Font")); FrameLess(true); - face.WhenAction = THISBACK(Select); - height.WhenAction = THISBACK(Select); - bold.WhenAction = THISBACK(Select); - italic.WhenAction = THISBACK(Select); - naa.WhenAction = THISBACK(Select); + face.WhenAction = [=]{Select();}; + height.WhenAction = [=]{Select();}; + bold.WhenAction = [=]{Select();}; + italic.WhenAction = [=]{Select();}; + naa.WhenAction = [=]{Select();}; face.Clear(); Upp::Index fni; for(int i = 0; i < Font::GetFaceCount(); i++) { @@ -91,8 +90,6 @@ private: class MeasuresTab : public WithMeasures { public: - typedef MeasuresTab CLASSNAME; - void Init(ScatterCtrl &scatter); void Change(); @@ -102,8 +99,6 @@ private: class TextsTab : public WithTexts { public: - typedef TextsTab CLASSNAME; - void Init(ScatterCtrl &scatter); void DoShowText(); @@ -119,8 +114,6 @@ private: class LegendTab : public WithLegend { public: - typedef LegendTab CLASSNAME; - void Init(ScatterCtrl &scatter); private: @@ -132,8 +125,6 @@ private: class SeriesTab : public Splitter { public: - typedef SeriesTab CLASSNAME; - SeriesTab() : dashCount(DashStyle::GetCount()) {} virtual ~SeriesTab() noexcept {DashStyle::UnregisterFrom(dashCount);} void Init(ScatterCtrl& scatter); @@ -157,8 +148,6 @@ private: class GeneralTab : public WithGeneral { public: - typedef GeneralTab CLASSNAME; - void Init(ScatterCtrl &scatter); private: @@ -170,8 +159,6 @@ private: class DataDlg : public WithData { public: - typedef DataDlg CLASSNAME; - void Init(ScatterCtrl& scatter); virtual ~DataDlg() noexcept {}; @@ -204,8 +191,6 @@ private: class PropertiesDlg : public WithProperties { public: - typedef PropertiesDlg CLASSNAME; - void Init(ScatterCtrl& scatter); virtual ~PropertiesDlg() noexcept {}; @@ -229,8 +214,6 @@ private: class ProcessingTab : public WithProcessingTab { public: - typedef ProcessingTab CLASSNAME; - ProcessingTab(); virtual ~ProcessingTab() noexcept {}; @@ -301,8 +284,6 @@ private: class ProcessingDlg : public TopWindow { public: - typedef ProcessingDlg CLASSNAME; - void Init(ScatterCtrl& scatter); virtual ~ProcessingDlg() noexcept {}; diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.cpp b/uppsrc/ScatterCtrl/ScatterCtrl.cpp index 194c16584..c3aa06cc9 100644 --- a/uppsrc/ScatterCtrl/ScatterCtrl.cpp +++ b/uppsrc/ScatterCtrl/ScatterCtrl.cpp @@ -92,7 +92,7 @@ String FixPathName(const String &path) { CtrlScroll::CtrlScroll() { AddFrame(scroll); scroll.AutoHide(); - scroll.WhenScroll = THISBACK(OnScroll); + scroll.WhenScroll = [=]{OnScroll();}; hsizepos = vsizepos = false; } @@ -177,7 +177,7 @@ void ScatterCtrl::LoadControl() { fs.ActiveType(idt); fs.ActiveDir(GetFileFolder(defaultDataFile)); - fs.type.WhenAction = THISBACK1(OnTypeDataFile, &fs); + fs.type.WhenAction = [&] {OnTypeDataFile(&fs);}; if(!fs.ExecuteOpen(t_("Loading plot data from file"))) { Exclamation(t_("Plot has not been loaded")); return; @@ -240,7 +240,7 @@ void ScatterCtrl::SaveControl() { fs.ActiveType(idt); fs.ActiveDir(GetFileFolder(defaultDataFile)); - fs.type.WhenAction = THISBACK1(OnTypeDataFile, &fs); + fs.type.WhenAction = [&] {OnTypeDataFile(&fs);}; if(!fs.ExecuteSaveAs(t_("Saving plot data to file"))) { Exclamation(t_("Plot has not been saved")); return; @@ -267,7 +267,7 @@ void ScatterCtrl::Paint0(Draw& w, const Size &sz) { } if (!IsNull(highlight_0) && !highlighting) { highlighting = true; - SetTimeCallback(-200, THISBACK(TimerCallback)); + SetTimeCallback(-200, [=] {TimerCallback();}); } TimeStop t; lastRefresh0_ms = GetTickCount(); @@ -552,7 +552,7 @@ void ScatterCtrl::DoMouseAction(bool down, Point pt, ScatterAction action, int w case ZOOM_WINDOW: ZoomWindow(down, pt); break; case CONTEXT_MENU: if(showContextMenu && !down) - MenuBar::Execute(THISBACK(ContextMenu)); + MenuBar::Execute([=](Bar& bar) {ContextMenu(bar);}); break; case NO_ACTION: case SCROLL_LEFT: @@ -969,25 +969,25 @@ void ScatterCtrl::ContextMenu(Bar& bar) if (mouseHandlingX || mouseHandlingY) { bar.Add(t_("Fit to data"), ScatterImg::ShapeHandles(), [=]{ZoomToFit(mouseHandlingX, mouseHandlingY, 0.);}).Key(K_CTRL_F) .Help(t_("Zoom to fit visible all data")); - bar.Add(t_("Zoom +"), ScatterImg::ZoomPlus(), THISBACK3(Zoom, 1/1.2, true, mouseHandlingY)).Key(K_CTRL|K_ADD) + bar.Add(t_("Zoom +"), ScatterImg::ZoomPlus(), [=] {Zoom(1/1.2, true, mouseHandlingY);}).Key(K_CTRL|K_ADD) .Help(t_("Zoom in (closer)")); - bar.Add(t_("Zoom -"), ScatterImg::ZoomMinus(), THISBACK3(Zoom, 1.2, true, mouseHandlingY)).Key(K_CTRL|K_SUBTRACT) + bar.Add(t_("Zoom -"), ScatterImg::ZoomMinus(), [=] {Zoom(1.2, true, mouseHandlingY);}).Key(K_CTRL|K_SUBTRACT) .Help(t_("Zoom out (away)")); } - bar.Add(t_("Attach X axis"), Null, THISBACK(ChangeMouseHandlingX)).Check(!mouseHandlingX) + bar.Add(t_("Attach X axis"), Null, [=] {ChangeMouseHandlingX();}).Check(!mouseHandlingX) .Help(t_("Fix X axis so no zoom or scroll is possible")); if (mouseHandlingX) { - bar.Add(t_("Scroll Left"), ScatterImg::LeftArrow(), THISBACK2(ScatterDraw::Scroll, 0.2, 0)).Key(K_CTRL_LEFT) + bar.Add(t_("Scroll Left"), ScatterImg::LeftArrow(), [=] {ScatterDraw::Scroll(0.2, 0);}).Key(K_CTRL_LEFT) .Help(t_("Scrolls plot to the left")); - bar.Add(t_("Scroll Right"),ScatterImg::RightArrow(), THISBACK2(ScatterDraw::Scroll, -0.2, 0)).Key(K_CTRL_RIGHT) + bar.Add(t_("Scroll Right"),ScatterImg::RightArrow(), [=] {ScatterDraw::Scroll(-0.2, 0);}).Key(K_CTRL_RIGHT) .Help(t_("Scrolls plot to the right")); } - bar.Add(t_("Attach Y axis"), Null, THISBACK(ChangeMouseHandlingY)).Check(!mouseHandlingY) + bar.Add(t_("Attach Y axis"), Null, [=] {ChangeMouseHandlingY();}).Check(!mouseHandlingY) .Help(t_("Fix Y axis so no zoom or scroll is possible")); if (mouseHandlingY) { - bar.Add(t_("Scroll Up"), ScatterImg::UpArrow(), THISBACK2(ScatterDraw::Scroll, 0, -0.2)).Key(K_CTRL_UP) + bar.Add(t_("Scroll Up"), ScatterImg::UpArrow(), [=] {ScatterDraw::Scroll(0, -0.2);}).Key(K_CTRL_UP) .Help(t_("Scrolls plot up")); - bar.Add(t_("Scroll Down"), ScatterImg::DownArrow(), THISBACK2(ScatterDraw::Scroll, 0, 0.2)).Key(K_CTRL_DOWN) + bar.Add(t_("Scroll Down"), ScatterImg::DownArrow(), [=] {ScatterDraw::Scroll(0, 0.2);}).Key(K_CTRL_DOWN) .Help(t_("Scrolls plot down")); } if (mouseHandlingX || mouseHandlingY) @@ -996,16 +996,16 @@ void ScatterCtrl::ContextMenu(Bar& bar) if (showPropDlg) #endif { - bar.Add(t_("Properties"), ScatterImg::Gear(), THISBACK1(DoShowEditDlg, 0)).Key(K_CTRL_P) + bar.Add(t_("Properties"), ScatterImg::Gear(), [=] {DoShowEditDlg(0);}).Key(K_CTRL_P) .Help(t_("Plot properties dialog")); - bar.Add(t_("View Data"), ScatterImg::Database(), THISBACK(DoShowData)).Key(K_CTRL_D) + bar.Add(t_("View Data"), ScatterImg::Database(), [=] {DoShowData();}).Key(K_CTRL_D) .Help(t_("Raw data table")); } #ifndef _DEBUG if (showProcessDlg) #endif { - bar.Add(t_("Data Analysis"), ScatterImg::chart_curve_edit(), THISBACK(DoProcessing)).Key(K_SHIFT_P) + bar.Add(t_("Data Analysis"), ScatterImg::chart_curve_edit(), [=] {DoProcessing();}).Key(K_SHIFT_P) .Help(t_("Data processing dialog")); } #ifndef _DEBUG @@ -1014,9 +1014,9 @@ void ScatterCtrl::ContextMenu(Bar& bar) { bar.Separator(); } - bar.Add(t_("Copy image"), ScatterImg::Copy(), THISBACK1(SaveToClipboard, false)).Key(K_CTRL_C) + bar.Add(t_("Copy image"), ScatterImg::Copy(), [=] {SaveToClipboard(false);}).Key(K_CTRL_C) .Help(t_("Copy image to clipboard")); - bar.Add(t_("Save image"), ScatterImg::Save(), THISBACK1(SaveToFile, Null)).Key(K_CTRL_S) + bar.Add(t_("Save image"), ScatterImg::Save(), [=] {SaveToFile(Null);}).Key(K_CTRL_S) .Help(t_("Save image to file")); #ifndef _DEBUG if (showLoadData || showSaveData) @@ -1024,8 +1024,8 @@ void ScatterCtrl::ContextMenu(Bar& bar) { bar.Separator(); } - bar.Add(t_("Load plot"), THISBACK(LoadControl)).Help(t_("Load plot from file")); - bar.Add(t_("Save plot"), THISBACK(SaveControl)).Help(t_("Save plot to file")); + bar.Add(t_("Load plot"), [=] {LoadControl();}).Help(t_("Load plot from file")); + bar.Add(t_("Save plot"), [=] {SaveControl();}).Help(t_("Save plot to file")); } void ScatterCtrl::OnTypeImage(FileSel *_fs) @@ -1070,7 +1070,7 @@ void ScatterCtrl::SaveToFile(String fileName) fs.ActiveType(idt); fs.ActiveDir(GetFileFolder(defaultFileNamePlot)); - fs.type.WhenAction = THISBACK1(OnTypeImage, &fs); + fs.type.WhenAction = [&] {OnTypeImage(&fs);}; if(!fs.ExecuteSaveAs(t_("Saving plot image to file"))) { Exclamation(t_("Plot has not been saved")); return; @@ -1183,7 +1183,7 @@ ScatterCtrl::ScatterCtrl() { Add(processButton.RightPosZ(posx, buttonWidthProcess).TopPosZ(0, buttonHeight)); processButton.Show(false); processButton.SetImage(ScatterImg::chart_curve_edit()).SetLabel(t_("Data Analysis")); - processButton.WhenAction = THISBACK(DoProcessing); + processButton.WhenAction = [=] {DoProcessing();}; processButton.Tip(t_("Data processing dialog")); posx += buttonWidthProcess; @@ -1191,7 +1191,7 @@ ScatterCtrl::ScatterCtrl() { Add(dataButton.RightPosZ(posx, buttonWidthData).TopPosZ(0, buttonHeight)); dataButton.Show(false); dataButton.SetImage(ScatterImg::Database()).SetLabel(t_("View Data")); - dataButton.WhenAction = THISBACK(DoShowData); + dataButton.WhenAction = [=] {DoShowData();}; dataButton.Tip(t_("Show raw data table")); posx += buttonWidthData; @@ -1199,7 +1199,7 @@ ScatterCtrl::ScatterCtrl() { Add(propertiesButton.RightPosZ(posx, buttonWidthProperties).TopPosZ(0, buttonHeight)); propertiesButton.Show(false); propertiesButton.SetImage(ScatterImg::Gear()).SetLabel(t_("Properties")); - propertiesButton.WhenAction = THISBACK1(DoShowEditDlg, 0); + propertiesButton.WhenAction = [=] {DoShowEditDlg(0);}; propertiesButton.Tip(t_("Plot properties dialog")); AddMouseBehavior(false, false, false, true , false, 0, false, ScatterCtrl::SHOW_COORDINATES); diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.h b/uppsrc/ScatterCtrl/ScatterCtrl.h index b03dc28bb..bddf8b1e4 100644 --- a/uppsrc/ScatterCtrl/ScatterCtrl.h +++ b/uppsrc/ScatterCtrl/ScatterCtrl.h @@ -14,7 +14,7 @@ namespace Upp { class EditDoubleLostFocus : public EditDouble { public: - Callback WhenLostFocus; + Event<> WhenLostFocus; virtual void LostFocus() { WhenLostFocus(); @@ -26,7 +26,6 @@ typedef WithSpin EditDoubleLostFocusSpin; class CtrlScroll : public StaticRect { public: - typedef CtrlScroll CLASSNAME; CtrlScroll(); CtrlScroll &AddPane(Ctrl& c, bool scrollH = true, bool scrollV = true); @@ -164,8 +163,6 @@ public: class ScatterCtrl : public Ctrl, public ScatterDraw { public: - typedef ScatterCtrl CLASSNAME; - ScatterCtrl(); virtual ~ScatterCtrl() noexcept {RemoveInstance(this);}; @@ -192,7 +189,7 @@ public: enum MouseAction {NONE, LEFT_DOWN, LEFT_UP, LEFT_DOUBLE, LEFT_MOVE, MIDDLE_DOWN, MIDDLE_UP, MIDDLE_MOVE, RIGHT_DOWN, RIGHT_UP, RIGHT_MOVE}; - Callback3 WhenMouseClick; + Function WhenMouseClick; struct KeyBehavior { KeyBehavior(bool _ctrl, bool _alt, bool _shift, int _key, bool _isVirtualKey, ScatterAction _action) : @@ -496,8 +493,6 @@ void ScatterCtrl::SetDrawing(T& w, const Size &sz, bool ctrl) { class ScatterWindow : public TopWindow { public: - typedef ScatterWindow CLASSNAME; - ScatterWindow() { Sizeable().Zoomable(); Add(scatter.SizePos()); diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.upp b/uppsrc/ScatterCtrl/ScatterCtrl.upp index 11de9b8f1..2b699b88d 100644 --- a/uppsrc/ScatterCtrl/ScatterCtrl.upp +++ b/uppsrc/ScatterCtrl/ScatterCtrl.upp @@ -11,8 +11,8 @@ file ScatterCtrl.cpp, ScatterCtrl.h, ScatterCtrlX.cpp, - Properties.cpp, Processing.cpp, + Properties.cpp, Properties.h, Data.cpp, PopUpText.cpp,