GApplication.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include <AK/Badge.h>
  3. #include <AK/HashMap.h>
  4. #include <AK/OwnPtr.h>
  5. #include <LibDraw/Palette.h>
  6. #include <LibGUI/GShortcut.h>
  7. namespace AK {
  8. class SharedBuffer;
  9. }
  10. class CEventLoop;
  11. class GAction;
  12. class GKeyEvent;
  13. class GMenuBar;
  14. class GWindow;
  15. class GWindowServerConnection;
  16. class Palette;
  17. class Point;
  18. class GApplication {
  19. public:
  20. static GApplication& the();
  21. GApplication(int argc, char** argv);
  22. ~GApplication();
  23. int exec();
  24. void quit(int = 0);
  25. void set_menubar(OwnPtr<GMenuBar>&&);
  26. GAction* action_for_key_event(const GKeyEvent&);
  27. void register_global_shortcut_action(Badge<GAction>, GAction&);
  28. void unregister_global_shortcut_action(Badge<GAction>, GAction&);
  29. void show_tooltip(const StringView&, const Point& screen_location);
  30. void hide_tooltip();
  31. bool quit_when_last_window_deleted() const { return m_quit_when_last_window_deleted; }
  32. void set_quit_when_last_window_deleted(bool b) { m_quit_when_last_window_deleted = b; }
  33. void did_create_window(Badge<GWindow>);
  34. void did_delete_last_window(Badge<GWindow>);
  35. const String& invoked_as() const { return m_invoked_as; }
  36. const Vector<String>& args() const { return m_args; }
  37. Palette palette() const { return Palette(*m_palette); }
  38. void set_palette(const Palette&);
  39. void set_system_palette(SharedBuffer&);
  40. private:
  41. OwnPtr<CEventLoop> m_event_loop;
  42. OwnPtr<GMenuBar> m_menubar;
  43. RefPtr<PaletteImpl> m_palette;
  44. RefPtr<PaletteImpl> m_system_palette;
  45. HashMap<GShortcut, GAction*> m_global_shortcut_actions;
  46. class TooltipWindow;
  47. TooltipWindow* m_tooltip_window { nullptr };
  48. bool m_quit_when_last_window_deleted { true };
  49. String m_invoked_as;
  50. Vector<String> m_args;
  51. };