| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Redistribution and use in source and binary forms, with or without | 
					
						
							|  |  |  |  * modification, are permitted provided that the following conditions are met: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 1. Redistributions of source code must retain the above copyright notice, this | 
					
						
							|  |  |  |  *    list of conditions and the following disclaimer. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 2. Redistributions in binary form must reproduce the above copyright notice, | 
					
						
							|  |  |  |  *    this list of conditions and the following disclaimer in the documentation | 
					
						
							|  |  |  |  *    and/or other materials provided with the distribution. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 
					
						
							|  |  |  |  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
					
						
							|  |  |  |  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 
					
						
							|  |  |  |  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | 
					
						
							|  |  |  |  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
					
						
							|  |  |  |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 
					
						
							|  |  |  |  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 
					
						
							|  |  |  |  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 
					
						
							|  |  |  |  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
					
						
							|  |  |  |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-11 14:43:43 +01:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-03 12:32:15 +01:00
										 |  |  | #include <AK/HashMap.h>
 | 
					
						
							| 
									
										
										
										
											2019-05-28 11:53:16 +02:00
										 |  |  | #include <AK/OwnPtr.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-16 09:17:49 +01:00
										 |  |  | #include <AK/String.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-15 00:10:34 +01:00
										 |  |  | #include <LibCore/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-16 09:17:49 +01:00
										 |  |  | #include <LibGUI/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-06 20:33:02 +01:00
										 |  |  | #include <LibGUI/Shortcut.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-15 00:10:34 +01:00
										 |  |  | #include <LibGfx/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2019-02-11 14:43:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  | namespace GUI { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Application { | 
					
						
							| 
									
										
										
										
											2019-02-11 14:43:43 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  |     static Application& the(); | 
					
						
							|  |  |  |     Application(int argc, char** argv); | 
					
						
							|  |  |  |     ~Application(); | 
					
						
							| 
									
										
										
										
											2019-02-11 14:43:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     int exec(); | 
					
						
							| 
									
										
										
										
											2019-05-08 01:15:41 +02:00
										 |  |  |     void quit(int = 0); | 
					
						
							| 
									
										
										
										
											2019-02-11 14:43:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  |     void set_menubar(OwnPtr<MenuBar>&&); | 
					
						
							|  |  |  |     Action* action_for_key_event(const KeyEvent&); | 
					
						
							| 
									
										
										
										
											2019-03-03 12:32:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  |     void register_global_shortcut_action(Badge<Action>, Action&); | 
					
						
							|  |  |  |     void unregister_global_shortcut_action(Badge<Action>, Action&); | 
					
						
							| 
									
										
										
										
											2019-02-11 14:43:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-06 11:56:38 +01:00
										 |  |  |     void show_tooltip(const StringView&, const Gfx::Point& screen_location); | 
					
						
							| 
									
										
										
										
											2019-04-08 18:58:44 +02:00
										 |  |  |     void hide_tooltip(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-23 18:16:25 +02:00
										 |  |  |     bool quit_when_last_window_deleted() const { return m_quit_when_last_window_deleted; } | 
					
						
							|  |  |  |     void set_quit_when_last_window_deleted(bool b) { m_quit_when_last_window_deleted = b; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  |     void did_create_window(Badge<Window>); | 
					
						
							|  |  |  |     void did_delete_last_window(Badge<Window>); | 
					
						
							| 
									
										
										
										
											2019-07-23 18:16:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-06 22:38:19 +11:00
										 |  |  |     const String& invoked_as() const { return m_invoked_as; } | 
					
						
							|  |  |  |     const Vector<String>& args() const { return m_args; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-15 01:18:12 +01:00
										 |  |  |     Gfx::Palette palette() const; | 
					
						
							|  |  |  |     void set_palette(const Gfx::Palette&); | 
					
						
							| 
									
										
										
										
											2019-12-24 20:57:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void set_system_palette(SharedBuffer&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-11 14:43:43 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |     OwnPtr<Core::EventLoop> m_event_loop; | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  |     OwnPtr<MenuBar> m_menubar; | 
					
						
							| 
									
										
										
										
											2020-02-06 11:56:38 +01:00
										 |  |  |     RefPtr<Gfx::PaletteImpl> m_palette; | 
					
						
							|  |  |  |     RefPtr<Gfx::PaletteImpl> m_system_palette; | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  |     HashMap<Shortcut, Action*> m_global_shortcut_actions; | 
					
						
							| 
									
										
										
										
											2019-04-08 18:58:44 +02:00
										 |  |  |     class TooltipWindow; | 
					
						
							| 
									
										
										
										
											2020-02-15 01:27:37 +01:00
										 |  |  |     RefPtr<TooltipWindow> m_tooltip_window; | 
					
						
							| 
									
										
										
										
											2019-07-23 18:16:25 +02:00
										 |  |  |     bool m_quit_when_last_window_deleted { true }; | 
					
						
							| 
									
										
										
										
											2019-10-06 22:38:19 +11:00
										 |  |  |     String m_invoked_as; | 
					
						
							|  |  |  |     Vector<String> m_args; | 
					
						
							| 
									
										
										
										
											2019-02-11 14:43:43 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |