yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 1 | #import <UIKit/UIKit.h> |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 2 | #include "SkCanvas.h" |
yangsu@google.com | 2e20c24 | 2011-07-07 19:26:42 +0000 | [diff] [blame] | 3 | #include "SkGraphics.h" |
yangsu@google.com | e938b19 | 2011-08-02 13:23:15 +0000 | [diff] [blame] | 4 | #import "SkEventNotifier.h" |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 5 | #include "SkOSMenu.h" |
| 6 | #include "SkTime.h" |
yangsu@google.com | 2e20c24 | 2011-07-07 19:26:42 +0000 | [diff] [blame] | 7 | #include "SkTypes.h" |
yangsu@google.com | c5aeccd | 2011-07-17 14:42:08 +0000 | [diff] [blame] | 8 | #import "SkUIView.h" |
yangsu@google.com | 2e20c24 | 2011-07-07 19:26:42 +0000 | [diff] [blame] | 9 | #include "SkWindow.h" |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 10 | |
| 11 | #define kINVAL_UIVIEW_EventType "inval-uiview" |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 12 | |
| 13 | SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) { |
| 14 | fInvalEventIsPending = false; |
yangsu@google.com | e938b19 | 2011-08-02 13:23:15 +0000 | [diff] [blame] | 15 | fNotifier = [[SkEventNotifier alloc] init]; |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 16 | } |
| 17 | SkOSWindow::~SkOSWindow() { |
yangsu@google.com | e938b19 | 2011-08-02 13:23:15 +0000 | [diff] [blame] | 18 | [(SkEventNotifier*)fNotifier release]; |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | void SkOSWindow::onHandleInval(const SkIRect& r) { |
| 22 | if (!fInvalEventIsPending) { |
| 23 | fInvalEventIsPending = true; |
yangsu@google.com | f3493f0 | 2011-08-08 15:12:05 +0000 | [diff] [blame] | 24 | (new SkEvent(kINVAL_UIVIEW_EventType, this->getSinkID()))->post(); |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 25 | } |
| 26 | } |
| 27 | |
| 28 | bool SkOSWindow::onEvent(const SkEvent& evt) { |
| 29 | if (evt.isType(kINVAL_UIVIEW_EventType)) { |
| 30 | fInvalEventIsPending = false; |
| 31 | const SkIRect& r = this->getDirtyBounds(); |
yangsu@google.com | c5aeccd | 2011-07-17 14:42:08 +0000 | [diff] [blame] | 32 | [(SkUIView*)fHWND postInvalWithRect:&r]; |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 33 | return true; |
| 34 | } |
yangsu@google.com | c5aeccd | 2011-07-17 14:42:08 +0000 | [diff] [blame] | 35 | if ([(SkUIView*)fHWND onHandleEvent:evt]) { |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 36 | return true; |
| 37 | } |
yangsu@google.com | 2e20c24 | 2011-07-07 19:26:42 +0000 | [diff] [blame] | 38 | return this->INHERITED::onEvent(evt); |
| 39 | } |
| 40 | |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 41 | void SkOSWindow::onSetTitle(const char title[]) { |
yangsu@google.com | c5aeccd | 2011-07-17 14:42:08 +0000 | [diff] [blame] | 42 | [(SkUIView*)fHWND setSkTitle:title]; |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 43 | } |
| 44 | |
yangsu@google.com | e938b19 | 2011-08-02 13:23:15 +0000 | [diff] [blame] | 45 | void SkOSWindow::onAddMenu(const SkOSMenu* menu) { |
| 46 | [(SkUIView*)fHWND onAddMenu:menu]; |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 47 | } |
| 48 | |
caryclark@google.com | 867cbd8 | 2012-09-20 15:45:41 +0000 | [diff] [blame] | 49 | void SkOSWindow::onUpdateMenu(SkOSMenu* menu) { |
yangsu@google.com | e938b19 | 2011-08-02 13:23:15 +0000 | [diff] [blame] | 50 | [(SkUIView*)fHWND onUpdateMenu:menu]; |
| 51 | } |
yangsu@google.com | 2e20c24 | 2011-07-07 19:26:42 +0000 | [diff] [blame] | 52 | |
bsalomon@google.com | 1195925 | 2012-04-06 20:13:38 +0000 | [diff] [blame] | 53 | bool SkOSWindow::attach(SkBackEndTypes /* attachType */, |
| 54 | int /* msaaSampleCount */) { |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 55 | bool success = true; |
| 56 | return success; |
| 57 | } |
| 58 | |
robertphillips@google.com | d5b05ef | 2012-04-02 20:19:28 +0000 | [diff] [blame] | 59 | void SkOSWindow::detach() {} |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 60 | |
robertphillips@google.com | d5b05ef | 2012-04-02 20:19:28 +0000 | [diff] [blame] | 61 | void SkOSWindow::present() { |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 62 | } |