49 if(
const auto p = dynamic_cast<Panel*>(pCon))
58 ListBox::ListBox(
const Rect& r,
const shared_ptr<ListType>&
h)
59 : ScrollableContainer(r),
60 tlContent(Rect(r.GetSize()), h)
64 vsbVertical.GetTrack().GetScroll() += [
this](ScrollEventArgs&& e){
65 tlContent.LocateViewPosition(
SDst(round(e.GetValue())));
67 tlContent.GetViewChanged() += [
this](ViewArgs&& e){
71 tlContent.GetFullViewHeight());
73 SetSizeOf(tlContent, FixLayout(view_arena));
74 if(view_arena.Height > tlContent.GetHeight())
76 vsbVertical.SetSmallDelta(tlContent.GetItemHeight());
77 vsbVertical.SetMaxValue(view_arena.Height
78 - tlContent.GetHeight());
79 vsbVertical.SetLargeDelta(tlContent.GetHeight());
80 vsbVertical.SetValue(tlContent.GetViewPosition());
86 tlContent.RefreshTextState();
90 ListBox::ResizeForPreferred(
const Size& sup,
Size s)
93 s.
Width = tlContent.GetMaxTextWidth()
96 s.
Height = tlContent.GetFullViewHeight();
111 FileBox::FileBox(
const Rect& r)
112 : FileList(),
ListBox(r, GetListPtr())
132 if(FileList::operator=(pth))
145 const auto detacher([
this](UIEventArgs&&){
153 lbContent.GetView().DependencyPtr =
this,
154 FetchEvent<TouchDown>(*this) += [
this](TouchEventArgs&& e){
159 if(
const auto p = dynamic_cast<Panel*>(
164 const SDst h1(max<SPos>(0, pt.Y)), h2(max<SPos>(0, h0 - pt.Y
169 lbContent.ResizeForPreferred(Size(0, max(h1, h2)),
170 Size(GetWidth(), 0));
172 const SDst h(lbContent.GetHeight());
175 pt.Y += h2 < h ? -h : GetHeight();
177 lbContent.AdjustViewLength();
179 const auto idx(lbContent.Find(Text));
182 lbContent.SetSelected(idx);
184 lbContent.ClearSelected();
186 p->Add(lbContent, 224U);
193 FetchEvent<LostFocus>(*this) += detacher,
194 FetchEvent<LostFocus>(lbContent) += detacher,
196 YAssert(e.Value < lbContent.GetList().size(),
197 "Invalid index found.");
199 Text = lbContent.GetList()[e.Value];