CtrlLib: DropChoice FindAdd

git-svn-id: svn://ultimatepp.org/upp/trunk@12258 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2018-09-07 13:17:47 +00:00
parent ea02579b4d
commit c8d0c102a6
3 changed files with 18 additions and 2 deletions

View file

@ -109,11 +109,19 @@ bool DropChoice::DoKey(dword key) {
return false;
}
void DropChoice::Add(const Value& s) {
void DropChoice::Add(const Value& s)
{
list.Add(s);
EnableDrop(true);
}
void DropChoice::FindAdd(const Value& s)
{
if (list.Find(s) < 0)
list.Add(s);
EnableDrop(true);
}
void DropChoice::Remove(int i)
{
list.Remove(i);

View file

@ -181,6 +181,7 @@ public:
void Clear();
void Add(const Value& data);
void FindAdd(const Value& data);
void Set(int i, const Value& data) { list.Set(i, 0, data); }
void Remove(int i);
void SerializeList(Stream& s);
@ -243,6 +244,7 @@ public:
void ClearList() { select.Clear(); }
void AddList(const Value& data) { select.Add(data); }
void FindAddList(const Value& data) { select.FindAdd(data); }
void Set(int i, const Value& data) { select.Set(i, data); }
void Remove(int i) { select.Remove(i); }
void SerializeList(Stream& s) { select.SerializeList(s); }

View file

@ -1,5 +1,4 @@
topic "WithDropChoice";
[2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,0#27521748481378242620020725143825:desc]
[0 $$3,0#96390100711032703541132217272105:end]
@ -9,6 +8,7 @@ topic "WithDropChoice";
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
[b42;2 $$9,9#13035079074754324216151401829390:normal]
[2 $$0,0#00000000000000000000000000000000:Default]
[{_}
[ {{10000@3 [s0; [*@(229)4 WithDropChoice]]}}&]
[s3; &]
@ -48,6 +48,12 @@ onst]_[_^Value^ Value][@(0.0.255) `&]_[*@3 data])&]
[s2;%% Adds [%-*@3 data] to the drop`-down list.&]
[s3;%% &]
[s4; &]
[s5;:Upp`:`:WithDropChoice`:`:FindAddList`(const Upp`:`:Value`&`): [@(0.0.255) void]_[* F
indAddList]([@(0.0.255) const]_[_^Upp`:`:Value^ Value][@(0.0.255) `&]_[*@3 data])&]
[s2;%% Adds [%-*@3 data] to the drop`-down list, by only if it is not
already there.&]
[s3;%% &]
[s4; &]
[s5;:Upp`:`:WithDropChoice`:`:Set`(int`,const Upp`:`:Value`&`): [@(0.0.255) void]_[* Set](
[@(0.0.255) int]_[*@3 i], [@(0.0.255) const]_[_^Upp`:`:Value^ Value][@(0.0.255) `&]_[*@3 data
])&]