Window_mac.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright 2016 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef Window_mac_DEFINED
  8. #define Window_mac_DEFINED
  9. #include "src/core/SkTDynamicHash.h"
  10. #include "tools/sk_app/Window.h"
  11. #import <Cocoa/Cocoa.h>
  12. namespace sk_app {
  13. class Window_mac : public Window {
  14. public:
  15. Window_mac()
  16. : INHERITED()
  17. , fWindow(nil) {}
  18. ~Window_mac() override {
  19. this->closeWindow();
  20. }
  21. bool initWindow();
  22. void setTitle(const char*) override;
  23. void show() override;
  24. bool attach(BackendType) override;
  25. void onInval() override {}
  26. static void PaintWindows();
  27. static const NSInteger& GetKey(const Window_mac& w) {
  28. return w.fWindowNumber;
  29. }
  30. static uint32_t Hash(const NSInteger& windowNumber) {
  31. return windowNumber;
  32. }
  33. NSWindow* window() { return fWindow; }
  34. void closeWindow();
  35. private:
  36. NSWindow* fWindow;
  37. NSInteger fWindowNumber;
  38. static SkTDynamicHash<Window_mac, NSInteger> gWindowMap;
  39. typedef Window INHERITED;
  40. };
  41. } // namespace sk_app
  42. #endif