| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/Function.h>
 | 
					
						
							|  |  |  | #include <AK/HashMap.h>
 | 
					
						
							| 
									
										
										
										
											2019-05-28 11:53:16 +02:00
										 |  |  | #include <LibGUI/GAbstractView.h>
 | 
					
						
							|  |  |  | #include <LibGUI/GModel.h>
 | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | class GScrollBar; | 
					
						
							| 
									
										
										
										
											2019-03-15 14:50:36 +01:00
										 |  |  | class Painter; | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-23 02:04:31 +01:00
										 |  |  | class GTableView : public GAbstractView { | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-03-15 21:41:27 +01:00
										 |  |  |     bool alternating_row_colors() const { return m_alternating_row_colors; } | 
					
						
							|  |  |  |     void set_alternating_row_colors(bool b) { m_alternating_row_colors = b; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 17:58:53 +01:00
										 |  |  |     int content_width() const; | 
					
						
							|  |  |  |     int horizontal_padding() const { return m_horizontal_padding; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-01 14:29:34 +01:00
										 |  |  |     void scroll_into_view(const GModelIndex&, Orientation); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-20 13:35:11 +01:00
										 |  |  |     bool is_column_hidden(int) const; | 
					
						
							|  |  |  |     void set_column_hidden(int, bool); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 21:16:41 +02:00
										 |  |  |     Point adjusted_position(const Point&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-19 00:07:33 +02:00
										 |  |  |     virtual Rect content_rect(const GModelIndex&) const override; | 
					
						
							| 
									
										
										
										
											2019-04-18 22:27:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-23 03:53:51 +01:00
										 |  |  |     virtual const char* class_name() const override { return "GTableView"; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2019-03-23 02:04:31 +01:00
										 |  |  |     virtual void did_update_model() override; | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  |     virtual void paint_event(GPaintEvent&) override; | 
					
						
							|  |  |  |     virtual void mousedown_event(GMouseEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-05-04 23:45:31 +02:00
										 |  |  |     virtual void mousemove_event(GMouseEvent&) override; | 
					
						
							|  |  |  |     virtual void mouseup_event(GMouseEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-03-25 01:42:15 +01:00
										 |  |  |     virtual void doubleclick_event(GMouseEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-03-01 13:48:08 +01:00
										 |  |  |     virtual void keydown_event(GKeyEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-05-04 23:45:31 +02:00
										 |  |  |     virtual void leave_event(CEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-05-10 20:26:55 +02:00
										 |  |  |     virtual void context_menu_event(GContextMenuEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-19 00:07:33 +02:00
										 |  |  |     Rect content_rect(int row, int column) const; | 
					
						
							| 
									
										
										
										
											2019-03-15 14:50:36 +01:00
										 |  |  |     void paint_headers(Painter&); | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2019-05-04 23:45:31 +02:00
										 |  |  |     Rect column_resize_grabbable_rect(int) const; | 
					
						
							| 
									
										
										
										
											2019-03-09 13:59:01 +01:00
										 |  |  |     int column_width(int) const; | 
					
						
							| 
									
										
										
										
											2019-03-16 16:03:31 +01:00
										 |  |  |     void update_content_size(); | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 23:45:31 +02:00
										 |  |  |     struct ColumnData { | 
					
						
							|  |  |  |         int width { 0 }; | 
					
						
							|  |  |  |         bool has_initialized_width { false }; | 
					
						
							|  |  |  |         bool visibility { true }; | 
					
						
							| 
									
										
										
										
											2019-05-10 20:26:55 +02:00
										 |  |  |         RetainPtr<GAction> visibility_action; | 
					
						
							| 
									
										
										
										
											2019-05-04 23:45:31 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  |     ColumnData& column_data(int column) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     mutable Vector<ColumnData> m_column_data; | 
					
						
							| 
									
										
										
										
											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-03-15 21:41:27 +01:00
										 |  |  |     bool m_alternating_row_colors { true }; | 
					
						
							| 
									
										
										
										
											2019-05-04 23:45:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool m_in_column_resize { false }; | 
					
						
							|  |  |  |     Point m_column_resize_origin; | 
					
						
							|  |  |  |     int m_column_resize_original_width { 0 }; | 
					
						
							|  |  |  |     int m_resizing_column { -1 }; | 
					
						
							| 
									
										
										
										
											2019-05-10 20:26:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     GMenu& ensure_header_context_menu(); | 
					
						
							|  |  |  |     OwnPtr<GMenu> m_header_context_menu; | 
					
						
							| 
									
										
										
										
											2019-02-28 10:57:09 +01:00
										 |  |  | }; |