diff --git a/uppsrc/CtrlLib/Ctrl.lay b/uppsrc/CtrlLib/Ctrl.lay index 968e3ac99..03986025a 100644 --- a/uppsrc/CtrlLib/Ctrl.lay +++ b/uppsrc/CtrlLib/Ctrl.lay @@ -5,6 +5,20 @@ LAYOUT(EditStringLayout, 236, 62) ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22)) END_LAYOUT +LAYOUT(EditIntLayout, 236, 62) + ITEM(Label, lbl, SetLabel(t_("Test")).LeftPosZ(4, 68).TopPosZ(4, 19)) + ITEM(EditInt, number, HSizePosZ(68, 4).TopPosZ(4, 19)) + ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(80, -10).BottomPosZ(4, 22)) + ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22)) +END_LAYOUT + +LAYOUT(EditDoubleLayout, 236, 62) + ITEM(Label, lbl, SetLabel(t_("Test")).LeftPosZ(4, 68).TopPosZ(4, 19)) + ITEM(EditDouble, number, HSizePosZ(68, 4).TopPosZ(4, 19)) + ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(80, -10).BottomPosZ(4, 22)) + ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22)) +END_LAYOUT + LAYOUT(ProgressLayout, 320, 72) ITEM(Button, stop, SetLabel(t_("Cancel")).HCenterPosZ(68, 0).BottomPosZ(4, 24)) UNTYPED(pi, HSizePosZ(4, 4).TopPosZ(28, 12)) diff --git a/uppsrc/CtrlLib/CtrlUtil.cpp b/uppsrc/CtrlLib/CtrlUtil.cpp index 919fe0f58..f2befdb98 100644 --- a/uppsrc/CtrlLib/CtrlUtil.cpp +++ b/uppsrc/CtrlLib/CtrlUtil.cpp @@ -172,6 +172,34 @@ bool EditText(WString& s, const char *title, const char *label, int maxlen) return EditText(s, title, label, CharFilterUnicode, maxlen); } +bool EditNumber(int& n, const char *title, const char *label, int min, int max, bool notnull) +{ + WithEditIntLayout dlg; + CtrlLayoutOKCancel(dlg, title); + dlg.lbl = label; + dlg.number <<= n; + dlg.number.MinMax(min, max); + if(dlg.Execute() == IDOK) { + n = ~dlg.number; + return true; + } + return false; +} + +bool EditNumber(int& n, const char *title, const char *label, double min, double max, bool notnull) +{ + WithEditDoubleLayout dlg; + CtrlLayoutOKCancel(dlg, title); + dlg.lbl = label; + dlg.number <<= n; + dlg.number.MinMax(min, max); + if(dlg.Execute() == IDOK) { + n = ~dlg.number; + return true; + } + return false; +} + Callback CtrlRetriever::operator<<=(Callback cb) { for(int i = 0; i < item.GetCount(); i++) { diff --git a/uppsrc/CtrlLib/CtrlUtil.h b/uppsrc/CtrlLib/CtrlUtil.h index f03c7e878..92871a123 100644 --- a/uppsrc/CtrlLib/CtrlUtil.h +++ b/uppsrc/CtrlLib/CtrlUtil.h @@ -9,6 +9,9 @@ bool EditText(String& s, const char *title, const char *label, int maxlen = 0); bool EditText(WString& s, const char *title, const char *label, int (*filter)(int), int maxlen = 0); bool EditText(WString& s, const char *title, const char *label, int maxlen = 0); +bool EditNumber(int& n, const char *title, const char *label, int min = INT_MIN, int max = INT_MAX, bool notnull = false); +bool EditNumber(double& n, const char *title, const char *label, double min = DBL_MIN, double max = DBL_MAX, bool notnull = false); + void Show2(Ctrl& ctrl1, Ctrl& ctrl, bool show = true); void Hide2(Ctrl& ctrl1, Ctrl& ctrl);