application.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #if defined(Hiro_Application)
  2. struct Application {
  3. Application() = delete;
  4. static auto abort() -> void;
  5. static auto doMain() -> void;
  6. static auto exit() -> void;
  7. static auto font() -> Font;
  8. static auto locale() -> Locale&;
  9. static auto modal() -> bool;
  10. static auto name() -> string;
  11. static auto onMain(const function<void ()>& callback = {}) -> void;
  12. static auto run() -> void;
  13. static auto scale() -> float;
  14. static auto scale(float value) -> float;
  15. static auto pendingEvents() -> bool;
  16. static auto processEvents() -> void;
  17. static auto quit() -> void;
  18. static auto screenSaver() -> bool;
  19. static auto setFont(const Font& font = {}) -> void;
  20. static auto setName(const string& name = "") -> void;
  21. static auto setScale(float scale = 1.0) -> void;
  22. static auto setScreenSaver(bool screenSaver = true) -> void;
  23. static auto setToolTips(bool toolTips = true) -> void;
  24. static auto toolTips() -> bool;
  25. static auto unscale(float value) -> float;
  26. struct Cocoa {
  27. static auto doAbout() -> void;
  28. static auto doActivate() -> void;
  29. static auto doPreferences() -> void;
  30. static auto doQuit() -> void;
  31. static auto onAbout(const function<void ()>& callback = {}) -> void;
  32. static auto onActivate(const function<void ()>& callback = {}) -> void;
  33. static auto onPreferences(const function<void ()>& callback = {}) -> void;
  34. static auto onQuit(const function<void ()>& callback = {}) -> void;
  35. };
  36. struct Namespace : Locale::Namespace {
  37. Namespace(const string& value) : Locale::Namespace(Application::locale(), value) {}
  38. };
  39. //private:
  40. struct State {
  41. Font font;
  42. bool initialized = false;
  43. Locale locale;
  44. int modal = 0;
  45. string name;
  46. function<void ()> onMain;
  47. bool quit = false;
  48. float scale = 1.0;
  49. bool screenSaver = true;
  50. bool toolTips = true;
  51. struct Cocoa {
  52. function<void ()> onAbout;
  53. function<void ()> onActivate;
  54. function<void ()> onPreferences;
  55. function<void ()> onQuit;
  56. } cocoa;
  57. };
  58. static auto initialize() -> void;
  59. static auto state() -> State&;
  60. };
  61. #endif