DropChoice: RdOnlyDrop

git-svn-id: svn://ultimatepp.org/upp/trunk@7763 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-10-09 15:45:09 +00:00
parent f7c3bf2f7d
commit 668dce6e94
3 changed files with 13 additions and 4 deletions

View file

@ -13,6 +13,7 @@ DropChoice::DropChoice() {
dropwidth = 0;
appending = false;
updownkeys = true;
rodrop = false;
}
void DropChoice::EnableDrop(bool b)
@ -26,7 +27,7 @@ void DropChoice::PseudoPush()
}
void DropChoice::Drop() {
if(!owner || owner->IsReadOnly() || list.GetCount() == 0 && !WhenDrop) return;
if(!owner || owner->IsReadOnly() && !rodrop || list.GetCount() == 0 && !WhenDrop) return;
WhenDrop();
if(dropfocus)
owner->SetWantFocus();
@ -36,12 +37,12 @@ void DropChoice::Drop() {
}
void DropChoice::Select() {
if(!owner || owner->IsReadOnly()) return;
if(!owner || owner->IsReadOnly() && !rodrop) return;
WhenSelect();
}
Value DropChoice::Get() const {
if(!owner || owner->IsReadOnly()) return Value();
if(!owner || owner->IsReadOnly() && !rodrop) return Value();
int c = list.GetCursor();
if(c < 0) return Value();
return list.Get(c, 0);
@ -49,7 +50,7 @@ Value DropChoice::Get() const {
int DropChoice::GetIndex() const
{
if(!owner || owner->IsReadOnly()) return -1;
if(!owner || owner->IsReadOnly() && !rodrop) return -1;
return list.GetCursor();
}

View file

@ -161,6 +161,7 @@ protected:
bool dropfocus;
bool always_drop;
bool updownkeys;
bool rodrop;
void Select();
void Drop();
@ -200,6 +201,7 @@ public:
DropChoice& SetDropLines(int n) { list.SetDropLines(n); return *this; }
DropChoice& Appending() { appending = true; return *this; }
DropChoice& AlwaysDrop(bool e = true);
DropChoice& RdOnlyDrop(bool e = true) { rodrop = e; return *this; }
DropChoice& NoDropFocus() { dropfocus = false; return *this; }
DropChoice& DropWidth(int w) { dropwidth = w; return *this; }
@ -264,6 +266,7 @@ public:
WithDropChoice& SetDisplay(const Display& d, int lcy) { select.SetDisplay(d, lcy); return *this; }
WithDropChoice& SetConvert(const Convert& d) { select.SetConvert(d); return *this; }
WithDropChoice& AlwaysDrop(bool b = true) { select.AlwaysDrop(b); return *this; }
WithDropChoice& RdOnlyDrop(bool b = true) { select.RdOnlyDrop(b); return *this; }
WithDropChoice& WithWheel(bool b = true) { withwheel = b; return *this; }
WithDropChoice& NoWithWheel() { return WithWheel(false); }
WithDropChoice& DropWidth(int w) { select.DropWidth(w); return *this; }

View file

@ -127,6 +127,11 @@ hoice][@(0.0.255) `&]_[* SetDisplay]([@(0.0.255) const]_[_^Display^ Display][@(0
(client code can fill it using WhenDrop callback).&]
[s3; &]
[s4; &]
[s5;:WithDropChoice`:`:RdOnlyDrop`(bool`): [_^WithDropChoice^ WithDropChoice][@(0.0.255) `&
]_[* RdOnlyDrop]([@(0.0.255) bool]_[*@3 b]_`=_[@(0.0.255) true])&]
[s2;%% If active, allows changing value even by drop even if ReadOnly.&]
[s3;%% &]
[s4; &]
[s5;:WithDropChoice`:`:WithWheel`(bool`): [_^WithDropChoice^ WithDropChoice][@(0.0.255) `&
]_[* WithWheel]([@(0.0.255) bool]_[*@3 b]_`=_[@(0.0.255) true])&]
[s2;%% Widget reacts to mousewheel. This is active by default.&]