| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #include <TurboBadger/tb_select.h>
- #include "UI.h"
- #include "UIEvents.h"
- #include "UISelectList.h"
- using namespace tb;
- namespace Atomic
- {
- UISelectList::UISelectList(Context* context, bool createWidget) : UIWidget(context, false)
- {
- if (createWidget)
- {
- widget_ = new TBSelectList();
- widget_->SetDelegate(this);
- GetSubsystem<UI>()->WrapWidget(this, widget_);
- }
- }
- UISelectList::~UISelectList()
- {
- }
- tb::TBSelectList* UISelectList::GetTBSelectList()
- {
- return (TBSelectList*) widget_;
- }
- void UISelectList::SetFilter(const String& filter)
- {
- if (!widget_)
- return;
- ((TBSelectList*)widget_)->SetFilter(filter.CString());
- }
- void UISelectList::SetValue(int value)
- {
- if (!widget_)
- return;
- ((TBSelectList*)widget_)->SetValue(value);
- }
- int UISelectList::GetValue()
- {
- if (!widget_)
- return 0;
- return ((TBSelectList*)widget_)->GetValue();
- }
- void UISelectList::InvalidateList()
- {
- if (!widget_)
- return;
- return ((TBSelectList*)widget_)->InvalidateList();
- }
- String UISelectList::GetSelectedItemID()
- {
- if (!widget_)
- return "";
- String id_;
- TBID id = ((TBSelectList*)widget_)->GetSelectedItemID();
- GetSubsystem<UI>()->GetTBIDString(id, id_);
- return id_;
- }
- String UISelectList::GetHoverItemID()
- {
- if (!widget_)
- return "";
- if (!TBWidget::hovered_widget)
- return "";
- TBSelectList* select = (TBSelectList*) widget_;
- if (!select->IsAncestorOf(TBWidget::hovered_widget))
- {
- return "";
- }
- String id_;
- GetSubsystem<UI>()->GetTBIDString(TBWidget::hovered_widget->GetID(), id_);
- return id_;
- }
- void UISelectList::SetSource(UISelectItemSource* source)
- {
- if (!widget_)
- return;
- ((TBSelectList*)widget_)->SetSource(source ? source->GetTBItemSource() : NULL);
- }
- bool UISelectList::OnEvent(const tb::TBWidgetEvent &ev)
- {
- return false;
- }
- }
|