CtrlLib: EditNumber

git-svn-id: svn://ultimatepp.org/upp/trunk@6183 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-07-11 11:46:54 +00:00
parent a39af990ac
commit c83c4ded63
3 changed files with 45 additions and 0 deletions

View file

@ -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))

View file

@ -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<TopWindow> 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<TopWindow> 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++) {

View file

@ -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);