diff --git a/uppsrc/CtrlLib/Ctrl.lay b/uppsrc/CtrlLib/Ctrl.lay index 0aad9157a..1fa81f368 100644 --- a/uppsrc/CtrlLib/Ctrl.lay +++ b/uppsrc/CtrlLib/Ctrl.lay @@ -1,8 +1,8 @@ -LAYOUT(EditStringLayout, 376, 62) - ITEM(Label, lbl, SetLabel(t_("Test")).LeftPosZ(4, 116).TopPosZ(4, 19)) - ITEM(EditString, text, HSizePosZ(124, 4).TopPosZ(4, 19)) - ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(80, 60).BottomPosZ(4, 22)) - ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22)) +LAYOUT(EditStringLayout, 392, 62) + ITEM(Label, lbl, SetLabel(t_("Test")).LeftPosZ(4, 128).TopPosZ(8, 19)) + ITEM(EditString, text, HSizePosZ(136, 4).TopPosZ(8, 19)) + ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(64, 92).BottomPosZ(6, 20)) + ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 64).BottomPosZ(6, 20)) END_LAYOUT LAYOUT(EditIntLayout, 236, 62) diff --git a/uppsrc/CtrlLib/CtrlUtil.cpp b/uppsrc/CtrlLib/CtrlUtil.cpp index 6ef2ca277..a9dd1aada 100644 --- a/uppsrc/CtrlLib/CtrlUtil.cpp +++ b/uppsrc/CtrlLib/CtrlUtil.cpp @@ -132,6 +132,11 @@ void DelayCallback::Invoke() { SetTimeCallback(delay, target, this); } +void sSyncLabel(Label *lbl, const char *label, EditString *text) +{ + lbl->SetLabel(String().Cat() << label << " (" << text->GetLength() << "/" << text->GetMaxLength() << ")"); +} + bool EditText(String& s, const char *title, const char *label, int (*f)(int), int maxlen) { WithEditStringLayout dlg; @@ -139,7 +144,10 @@ bool EditText(String& s, const char *title, const char *label, int (*f)(int), in dlg.lbl = label; dlg.text = s.ToWString(); dlg.text.SetFilter(f); - if(maxlen) dlg.text.MaxLen(maxlen); + if(maxlen) { + dlg.text.MaxLen(maxlen); + dlg.text <<= callback3(sSyncLabel, &dlg.lbl, label, &dlg.text); + } if(dlg.Execute() == IDOK) { s = dlg.text; return true; diff --git a/uppsrc/Draw/Display.cpp b/uppsrc/Draw/Display.cpp index 067efd3bc..9c010cfa4 100644 --- a/uppsrc/Draw/Display.cpp +++ b/uppsrc/Draw/Display.cpp @@ -15,7 +15,12 @@ AttrText::operator Value() const AttrText::AttrText(const Value& v) { - *this = ValueTo(v); + if(IsString(v)) { + Init(); + text = v; + } + else + *this = ValueTo(v); } void AttrText::Init() diff --git a/uppsrc/Draw/src.tpp/Display$en-us.tpp b/uppsrc/Draw/src.tpp/Display$en-us.tpp index 0c99cd619..a5cf552a9 100644 --- a/uppsrc/Draw/src.tpp/Display$en-us.tpp +++ b/uppsrc/Draw/src.tpp/Display$en-us.tpp @@ -237,7 +237,8 @@ SetImage([@(0.0.255) const]_[_^Image^ Image][@(0.0.255) `&]_[@3 m], [@(0.0.255) [s4;%- &] [s5;:AttrText`:`:AttrText`(const Value`&`):%- [* AttrText]([@(0.0.255) const]_[_^Value^ Val ue][@(0.0.255) `&]_[*@3 v])&] -[s2; Converts Value to AttrText.&] +[s2; Converts Value to AttrText. Value can be either of AttrText +type, or IsString type.&] [s3; &] [s4;%- &] [s5;:AttrText`:`:AttrText`(const char`*`):%- [* AttrText]([@(0.0.255) const]_[@(0.0.255) ch