mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
CtrlLib: EditText when maxlen defined displays number of chars, Draw: AttrText now also constructs from text Value
git-svn-id: svn://ultimatepp.org/upp/trunk@6825 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9b3c26fc31
commit
ca8ab8b104
4 changed files with 22 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<TopWindow> 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;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,12 @@ AttrText::operator Value() const
|
|||
|
||||
AttrText::AttrText(const Value& v)
|
||||
{
|
||||
*this = ValueTo<AttrText>(v);
|
||||
if(IsString(v)) {
|
||||
Init();
|
||||
text = v;
|
||||
}
|
||||
else
|
||||
*this = ValueTo<AttrText>(v);
|
||||
}
|
||||
|
||||
void AttrText::Init()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue