| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2019-03-15 14:50:36 +01:00
										 |  |  | class Painter; | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | class GTableView : public GWidget { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     explicit GTableView(GWidget* parent); | 
					
						
							|  |  |  |     virtual ~GTableView() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-15 14:50:36 +01:00
										 |  |  |     int header_height() const { return m_headers_visible ? 16 : 0; } | 
					
						
							|  |  |  |     int item_height() const { return 16; } | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void set_model(OwnPtr<GTableModel>&&); | 
					
						
							|  |  |  |     GTableModel* model() { return m_model.ptr(); } | 
					
						
							|  |  |  |     const GTableModel* model() const { return m_model.ptr(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-15 14:50:36 +01:00
										 |  |  |     bool headers_visible() const { return m_headers_visible; } | 
					
						
							|  |  |  |     void set_headers_visible(bool headers_visible) { m_headers_visible = headers_visible; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  |     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-03-01 13:48:08 +01:00
										 |  |  |     virtual bool accepts_focus() const override { return true; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-01 14:29:34 +01:00
										 |  |  |     Rect visible_content_rect() const; | 
					
						
							|  |  |  |     void scroll_into_view(const GModelIndex&, Orientation); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-03-01 13:48:08 +01:00
										 |  |  |     virtual void keydown_event(GKeyEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-15 14:50:36 +01:00
										 |  |  |     void paint_headers(Painter&); | 
					
						
							| 
									
										
										
										
											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-03-09 13:59:01 +01:00
										 |  |  |     Rect header_rect(int) const; | 
					
						
							|  |  |  |     int column_width(int) const; | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 17:58:53 +01:00
										 |  |  |     GScrollBar* m_vertical_scrollbar { nullptr }; | 
					
						
							|  |  |  |     GScrollBar* m_horizontal_scrollbar { nullptr }; | 
					
						
							| 
									
										
										
										
											2019-03-15 14:50:36 +01:00
										 |  |  |     GWidget* m_corner_widget { 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-03-15 14:50:36 +01:00
										 |  |  |     bool m_headers_visible { true }; | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | }; |