• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
8 #ifndef Window_mac_DEFINED
9 #define Window_mac_DEFINED
10 
11 #include "src/core/SkTDynamicHash.h"
12 #include "tools/sk_app/Window.h"
13 
14 #import <Cocoa/Cocoa.h>
15 
16 namespace sk_app {
17 
18 class Window_mac : public Window {
19 public:
Window_mac()20     Window_mac()
21             : INHERITED()
22             , fWindow(nil) {}
~Window_mac()23     ~Window_mac() override {
24         this->closeWindow();
25     }
26 
27     bool initWindow();
28 
29     void setTitle(const char*) override;
30     void show() override;
31 
32     bool attach(BackendType) override;
33 
onInval()34     void onInval() override {}
35 
36     static void PaintWindows();
37 
GetKey(const Window_mac & w)38     static const NSInteger& GetKey(const Window_mac& w) {
39         return w.fWindowNumber;
40     }
41 
Hash(const NSInteger & windowNumber)42     static uint32_t Hash(const NSInteger& windowNumber) {
43         return windowNumber;
44     }
45 
window()46     NSWindow* window() { return fWindow; }
47     void closeWindow();
48 
49 private:
50     NSWindow*    fWindow;
51     NSInteger    fWindowNumber;
52 
53     static SkTDynamicHash<Window_mac, NSInteger> gWindowMap;
54 
55     typedef Window INHERITED;
56 };
57 
58 }   // namespace sk_app
59 
60 #endif
61