gzdoom/libraries/ZWidget/include/zwidget/widgets/listview/listview.h
2024-01-05 16:43:56 +01:00

38 lines
873 B
C++

#pragma once
#include "../../core/widget.h"
#include <vector>
#include <functional>
class Scrollbar;
class ListView : public Widget
{
public:
ListView(Widget* parent = nullptr);
void AddItem(const std::string& text);
int GetSelectedItem() const { return selectedItem; }
void SetSelectedItem(int index);
void ScrollToItem(int index);
void Activate();
std::function<void()> OnActivated;
protected:
void OnPaint(Canvas* canvas) override;
void OnPaintFrame(Canvas* canvas) override;
void OnMouseDown(const Point& pos, int key) override;
void OnMouseDoubleclick(const Point& pos, int key) override;
void OnMouseWheel(const Point& pos, EInputKey key) override;
void OnKeyDown(EInputKey key) override;
void OnGeometryChanged() override;
void OnScrollbarScroll();
Scrollbar* scrollbar = nullptr;
std::vector<std::string> items;
int selectedItem = 0;
};