2 * Copyright 2006 The Android Open Source Project
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkWindow_DEFINED
9 #define SkWindow_DEFINED
17 #include "SkTDArray.h"
19 #ifdef SK_BUILD_FOR_WINCEx
22 //#define USE_GX_SCREEN
27 class SkWindow : public SkView {
32 const SkBitmap& getBitmap() const { return fBitmap; }
34 void setColorType(SkColorType);
35 void resize(int width, int height, SkColorType = kUnknown_SkColorType);
37 bool isDirty() const { return !fDirtyRgn.isEmpty(); }
38 bool update(SkIRect* updateArea);
39 // does not call through to onHandleInval(), but does force the fDirtyRgn
40 // to be wide open. Call before update() to ensure we redraw everything.
42 // return the bounds of the dirty/inval rgn, or [0,0,0,0] if none
43 const SkIRect& getDirtyBounds() const { return fDirtyRgn.getBounds(); }
45 bool handleClick(int x, int y, Click::State, void* owner, unsigned modi = 0);
46 bool handleChar(SkUnichar);
47 bool handleKey(SkKey);
48 bool handleKeyUp(SkKey);
50 void addMenu(SkOSMenu*);
51 const SkTDArray<SkOSMenu*>* getMenus() { return &fMenus; }
53 const char* getTitle() const { return fTitle.c_str(); }
54 void setTitle(const char title[]);
56 const SkMatrix& getMatrix() const { return fMatrix; }
57 void setMatrix(const SkMatrix&);
58 void preConcat(const SkMatrix&);
59 void postConcat(const SkMatrix&);
61 virtual SkSurface* createSurface();
63 virtual void onPDFSaved(const char title[], const char desc[],
66 virtual bool onEvent(const SkEvent&);
67 virtual bool onDispatchClick(int x, int y, Click::State, void* owner, unsigned modi);
68 // called if part of our bitmap is invalidated
69 virtual void onHandleInval(const SkIRect&);
70 virtual bool onHandleChar(SkUnichar);
71 virtual bool onHandleKey(SkKey);
72 virtual bool onHandleKeyUp(SkKey);
73 virtual void onAddMenu(const SkOSMenu*) {};
74 virtual void onUpdateMenu(const SkOSMenu*) {};
75 virtual void onSetTitle(const char title[]) {}
77 // overrides from SkView
78 virtual bool handleInval(const SkRect*);
79 virtual bool onGetFocusView(SkView** focus) const;
80 virtual bool onSetFocusView(SkView* focus);
83 SkColorType fColorType;
87 SkTDArray<Click*> fClicks; // to track clicks
89 SkTDArray<SkOSMenu*> fMenus;
97 typedef SkView INHERITED;
100 ////////////////////////////////////////////////////////////////////////////////
102 #if defined(SK_BUILD_FOR_NACL)
103 #include "SkOSWindow_NaCl.h"
104 #elif defined(SK_BUILD_FOR_MAC)
105 #include "SkOSWindow_Mac.h"
106 #elif defined(SK_BUILD_FOR_WIN)
107 #include "SkOSWindow_Win.h"
108 #elif defined(SK_BUILD_FOR_ANDROID)
109 #include "SkOSWindow_Android.h"
110 #elif defined(SK_BUILD_FOR_UNIX)
111 #include "SkOSWindow_Unix.h"
112 #elif defined(SK_BUILD_FOR_SDL)
113 #include "SkOSWindow_SDL.h"
114 #elif defined(SK_BUILD_FOR_IOS)
115 #include "SkOSWindow_iOS.h"