| 
									
										
										
										
											2018-10-12 01:03:22 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-20 04:49:48 +01:00
										 |  |  | #include "GObject.h"
 | 
					
						
							| 
									
										
										
										
											2019-01-19 23:49:56 +01:00
										 |  |  | #include <SharedGraphics/Rect.h>
 | 
					
						
							|  |  |  | #include <SharedGraphics/GraphicsBitmap.h>
 | 
					
						
							| 
									
										
										
										
											2018-12-21 02:18:16 +01:00
										 |  |  | #include <AK/AKString.h>
 | 
					
						
							| 
									
										
										
										
											2019-01-27 08:48:34 +01:00
										 |  |  | #include <AK/WeakPtr.h>
 | 
					
						
							| 
									
										
										
										
											2018-10-12 01:03:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-20 05:48:43 +01:00
										 |  |  | class GWidget; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-15 12:14:23 +01:00
										 |  |  | class GWindow : public GObject { | 
					
						
							| 
									
										
										
										
											2018-10-12 01:03:22 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-01-20 05:48:43 +01:00
										 |  |  |     GWindow(GObject* parent = nullptr); | 
					
						
							| 
									
										
										
										
											2019-01-20 04:49:48 +01:00
										 |  |  |     virtual ~GWindow() override; | 
					
						
							| 
									
										
										
										
											2018-10-12 01:03:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-20 05:48:43 +01:00
										 |  |  |     static GWindow* from_window_id(int); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-19 00:01:02 +01:00
										 |  |  |     bool is_modal() const { return m_modal; } | 
					
						
							|  |  |  |     void set_modal(bool); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-17 04:23:54 +01:00
										 |  |  |     void set_double_buffering_enabled(bool); | 
					
						
							| 
									
										
										
										
											2019-02-19 01:42:53 +01:00
										 |  |  |     void set_has_alpha_channel(bool); | 
					
						
							|  |  |  |     void set_opacity(float); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-14 14:21:51 +01:00
										 |  |  |     int window_id() const { return m_window_id; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-26 05:20:32 +01:00
										 |  |  |     String title() const; | 
					
						
							| 
									
										
										
										
											2019-03-19 00:01:02 +01:00
										 |  |  |     void set_title(const String&); | 
					
						
							| 
									
										
										
										
											2018-10-12 01:03:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-24 23:40:12 +01:00
										 |  |  |     int x() const { return rect().x(); } | 
					
						
							|  |  |  |     int y() const { return rect().y(); } | 
					
						
							|  |  |  |     int width() const { return rect().width(); } | 
					
						
							|  |  |  |     int height() const { return rect().height(); } | 
					
						
							| 
									
										
										
										
											2018-10-12 01:03:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-24 23:40:12 +01:00
										 |  |  |     Rect rect() const; | 
					
						
							| 
									
										
										
										
											2019-02-10 14:28:39 +01:00
										 |  |  |     Size size() const { return rect().size(); } | 
					
						
							| 
									
										
										
										
											2019-01-16 13:49:44 +01:00
										 |  |  |     void set_rect(const Rect&); | 
					
						
							| 
									
										
										
										
											2019-02-08 00:14:37 +01:00
										 |  |  |     void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); } | 
					
						
							| 
									
										
										
										
											2018-10-12 01:03:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-24 23:40:12 +01:00
										 |  |  |     Point position() const { return rect().location(); } | 
					
						
							| 
									
										
										
										
											2018-10-12 02:24:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-11 06:09:54 +01:00
										 |  |  |     void move_to(int x, int y) { move_to({ x, y }); } | 
					
						
							|  |  |  |     void move_to(const Point& point) { set_rect({ point, size() }); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-20 04:49:48 +01:00
										 |  |  |     virtual void event(GEvent&) override; | 
					
						
							| 
									
										
										
										
											2018-10-12 01:26:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-16 13:49:44 +01:00
										 |  |  |     bool is_visible() const; | 
					
						
							| 
									
										
										
										
											2019-01-26 21:58:43 +01:00
										 |  |  |     bool is_active() const { return m_is_active; } | 
					
						
							| 
									
										
										
										
											2018-10-14 01:23:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 20:03:52 +01:00
										 |  |  |     void show(); | 
					
						
							|  |  |  |     void hide(); | 
					
						
							| 
									
										
										
										
											2018-10-14 00:21:42 +02:00
										 |  |  |     void close(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-20 07:56:48 +01:00
										 |  |  |     GWidget* main_widget() { return m_main_widget; } | 
					
						
							|  |  |  |     const GWidget* main_widget() const { return m_main_widget; } | 
					
						
							| 
									
										
										
										
											2019-01-20 05:48:43 +01:00
										 |  |  |     void set_main_widget(GWidget*); | 
					
						
							| 
									
										
										
										
											2019-01-26 11:24:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     GWidget* focused_widget() { return m_focused_widget; } | 
					
						
							|  |  |  |     const GWidget* focused_widget() const { return m_focused_widget; } | 
					
						
							| 
									
										
										
										
											2019-01-26 06:39:13 +01:00
										 |  |  |     void set_focused_widget(GWidget*); | 
					
						
							| 
									
										
										
										
											2019-01-20 05:48:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-26 05:20:32 +01:00
										 |  |  |     void update(const Rect& = Rect()); | 
					
						
							| 
									
										
										
										
											2019-01-20 05:48:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-27 08:48:34 +01:00
										 |  |  |     void set_global_cursor_tracking_widget(GWidget*); | 
					
						
							|  |  |  |     GWidget* global_cursor_tracking_widget() { return m_global_cursor_tracking_widget.ptr(); } | 
					
						
							|  |  |  |     const GWidget* global_cursor_tracking_widget() const { return m_global_cursor_tracking_widget.ptr(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-24 15:01:56 +01:00
										 |  |  |     void set_automatic_cursor_tracking_widget(GWidget*); | 
					
						
							|  |  |  |     GWidget* automatic_cursor_tracking_widget() { return m_automatic_cursor_tracking_widget.ptr(); } | 
					
						
							|  |  |  |     const GWidget* automatic_cursor_tracking_widget() const { return m_automatic_cursor_tracking_widget.ptr(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-19 00:01:02 +01:00
										 |  |  |     bool should_exit_event_loop_on_close() const { return m_should_exit_app_on_close; } | 
					
						
							|  |  |  |     void set_should_exit_event_loop_on_close(bool b) { m_should_exit_app_on_close = b; } | 
					
						
							| 
									
										
										
										
											2019-02-05 10:31:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-20 10:12:19 +01:00
										 |  |  |     GWidget* hovered_widget() { return m_hovered_widget.ptr(); } | 
					
						
							|  |  |  |     const GWidget* hovered_widget() const { return m_hovered_widget.ptr(); } | 
					
						
							|  |  |  |     void set_hovered_widget(GWidget*); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-17 04:23:54 +01:00
										 |  |  |     GraphicsBitmap* front_bitmap() { return m_front_bitmap.ptr(); } | 
					
						
							|  |  |  |     GraphicsBitmap* back_bitmap() { return m_back_bitmap.ptr(); } | 
					
						
							| 
									
										
										
										
											2019-02-20 21:59:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-21 00:21:23 +01:00
										 |  |  |     Size size_increment() const { return m_size_increment; } | 
					
						
							|  |  |  |     void set_size_increment(const Size& increment) { m_size_increment = increment; } | 
					
						
							|  |  |  |     Size base_size() const { return m_base_size; } | 
					
						
							|  |  |  |     void set_base_size(const Size& size) { m_base_size = size; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-10 14:28:39 +01:00
										 |  |  |     virtual const char* class_name() const override { return "GWindow"; } | 
					
						
							| 
									
										
										
										
											2019-03-20 22:31:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2019-03-19 02:20:00 +01:00
										 |  |  |     virtual bool is_window() const override final { return true; } | 
					
						
							| 
									
										
										
										
											2019-02-10 14:28:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-17 04:23:54 +01:00
										 |  |  |     Retained<GraphicsBitmap> create_backing_bitmap(const Size&); | 
					
						
							|  |  |  |     void set_current_backing_bitmap(GraphicsBitmap&, bool flush_immediately = false); | 
					
						
							|  |  |  |     void flip(const Rect& dirty_rect); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     RetainPtr<GraphicsBitmap> m_front_bitmap; | 
					
						
							|  |  |  |     RetainPtr<GraphicsBitmap> m_back_bitmap; | 
					
						
							| 
									
										
										
										
											2019-01-30 20:03:52 +01:00
										 |  |  |     int m_window_id { 0 }; | 
					
						
							| 
									
										
										
										
											2019-02-19 01:42:53 +01:00
										 |  |  |     float m_opacity_when_windowless { 1.0f }; | 
					
						
							| 
									
										
										
										
											2019-01-20 05:48:43 +01:00
										 |  |  |     GWidget* m_main_widget { nullptr }; | 
					
						
							| 
									
										
										
										
											2019-01-26 06:39:13 +01:00
										 |  |  |     GWidget* m_focused_widget { nullptr }; | 
					
						
							| 
									
										
										
										
											2019-01-27 08:48:34 +01:00
										 |  |  |     WeakPtr<GWidget> m_global_cursor_tracking_widget; | 
					
						
							| 
									
										
										
										
											2019-03-24 15:01:56 +01:00
										 |  |  |     WeakPtr<GWidget> m_automatic_cursor_tracking_widget; | 
					
						
							| 
									
										
										
										
											2019-02-20 10:12:19 +01:00
										 |  |  |     WeakPtr<GWidget> m_hovered_widget; | 
					
						
							| 
									
										
										
										
											2019-01-30 20:03:52 +01:00
										 |  |  |     Rect m_rect_when_windowless; | 
					
						
							|  |  |  |     String m_title_when_windowless; | 
					
						
							| 
									
										
										
										
											2019-02-10 14:46:43 +01:00
										 |  |  |     Vector<Rect> m_pending_paint_event_rects; | 
					
						
							| 
									
										
										
										
											2019-02-21 00:21:23 +01:00
										 |  |  |     Size m_size_increment; | 
					
						
							|  |  |  |     Size m_base_size; | 
					
						
							| 
									
										
										
										
											2019-02-19 01:42:53 +01:00
										 |  |  |     bool m_is_active { false }; | 
					
						
							| 
									
										
										
										
											2019-02-05 10:31:37 +01:00
										 |  |  |     bool m_should_exit_app_on_close { false }; | 
					
						
							| 
									
										
										
										
											2019-02-19 01:42:53 +01:00
										 |  |  |     bool m_has_alpha_channel { false }; | 
					
						
							| 
									
										
										
										
											2019-03-17 04:23:54 +01:00
										 |  |  |     bool m_double_buffering_enabled { true }; | 
					
						
							| 
									
										
										
										
											2019-03-19 00:01:02 +01:00
										 |  |  |     bool m_modal { false }; | 
					
						
							| 
									
										
										
										
											2019-03-19 00:52:39 +01:00
										 |  |  |     bool m_resizable { true }; | 
					
						
							| 
									
										
										
										
											2018-10-12 01:03:22 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 |