2019-02-28 10:57:09 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-02-28 21:30:17 +01:00
|
|
|
#include <LibGUI/GTableModel.h>
|
2019-02-28 10:57:09 +01:00
|
|
|
#include <LibGUI/GWidget.h>
|
|
|
|
|
#include <AK/Function.h>
|
|
|
|
|
#include <AK/HashMap.h>
|
|
|
|
|
|
|
|
|
|
class GScrollBar;
|
|
|
|
|
|
|
|
|
|
class GTableView : public GWidget {
|
|
|
|
|
public:
|
|
|
|
|
explicit GTableView(GWidget* parent);
|
|
|
|
|
virtual ~GTableView() override;
|
|
|
|
|
|
|
|
|
|
virtual int header_height() const { return 16; }
|
|
|
|
|
virtual int item_height() const { return 16; }
|
|
|
|
|
|
|
|
|
|
void set_model(OwnPtr<GTableModel>&&);
|
|
|
|
|
GTableModel* model() { return m_model.ptr(); }
|
|
|
|
|
const GTableModel* model() const { return m_model.ptr(); }
|
|
|
|
|
|
|
|
|
|
void did_update_model();
|
|
|
|
|
|
2019-02-28 17:58:53 +01:00
|
|
|
int content_width() const;
|
|
|
|
|
int horizontal_padding() const { return m_horizontal_padding; }
|
|
|
|
|
|
2019-02-28 10:57:09 +01:00
|
|
|
private:
|
2019-02-28 21:30:17 +01:00
|
|
|
virtual void model_notification(const GModelNotification&);
|
|
|
|
|
|
2019-02-28 10:57:09 +01:00
|
|
|
virtual void paint_event(GPaintEvent&) override;
|
|
|
|
|
virtual void resize_event(GResizeEvent&) override;
|
|
|
|
|
virtual void mousedown_event(GMouseEvent&) override;
|
|
|
|
|
|
2019-02-28 17:58:53 +01:00
|
|
|
void update_scrollbar_ranges();
|
2019-02-28 10:57:09 +01:00
|
|
|
int item_count() const;
|
|
|
|
|
Rect row_rect(int item_index) const;
|
|
|
|
|
|
2019-02-28 17:58:53 +01:00
|
|
|
GScrollBar* m_vertical_scrollbar { nullptr };
|
|
|
|
|
GScrollBar* m_horizontal_scrollbar { nullptr };
|
2019-02-28 10:57:09 +01:00
|
|
|
OwnPtr<GTableModel> m_model;
|
2019-02-28 17:58:53 +01:00
|
|
|
int m_horizontal_padding { 5 };
|
2019-02-28 10:57:09 +01:00
|
|
|
};
|