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 "SkSurfaceProps.h"
18 #include "SkTDArray.h"
20 #ifdef SK_BUILD_FOR_WINCEx
23 //#define USE_GX_SCREEN
28 class SkWindow : public SkView {
33 SkSurfaceProps getSurfaceProps() const { return fSurfaceProps; }
34 void setSurfaceProps(const SkSurfaceProps& props) {
35 fSurfaceProps = props;
38 const SkBitmap& getBitmap() const { return fBitmap; }
40 void setColorType(SkColorType);
41 void resize(int width, int height, SkColorType = kUnknown_SkColorType);
43 bool isDirty() const { return !fDirtyRgn.isEmpty(); }
44 bool update(SkIRect* updateArea);
45 // does not call through to onHandleInval(), but does force the fDirtyRgn
46 // to be wide open. Call before update() to ensure we redraw everything.
48 // return the bounds of the dirty/inval rgn, or [0,0,0,0] if none
49 const SkIRect& getDirtyBounds() const { return fDirtyRgn.getBounds(); }
51 bool handleClick(int x, int y, Click::State, void* owner, unsigned modi = 0);
52 bool handleChar(SkUnichar);
53 bool handleKey(SkKey);
54 bool handleKeyUp(SkKey);
56 void addMenu(SkOSMenu*);
57 const SkTDArray<SkOSMenu*>* getMenus() { return &fMenus; }
59 const char* getTitle() const { return fTitle.c_str(); }
60 void setTitle(const char title[]);
62 const SkMatrix& getMatrix() const { return fMatrix; }
63 void setMatrix(const SkMatrix&);
64 void preConcat(const SkMatrix&);
65 void postConcat(const SkMatrix&);
67 virtual SkSurface* createSurface();
69 virtual void onPDFSaved(const char title[], const char desc[],
72 virtual bool onEvent(const SkEvent&);
73 virtual bool onDispatchClick(int x, int y, Click::State, void* owner, unsigned modi);
74 // called if part of our bitmap is invalidated
75 virtual void onHandleInval(const SkIRect&);
76 virtual bool onHandleChar(SkUnichar);
77 virtual bool onHandleKey(SkKey);
78 virtual bool onHandleKeyUp(SkKey);
79 virtual void onAddMenu(const SkOSMenu*) {};
80 virtual void onUpdateMenu(const SkOSMenu*) {};
81 virtual void onSetTitle(const char title[]) {}
83 // overrides from SkView
84 virtual bool handleInval(const SkRect*);
85 virtual bool onGetFocusView(SkView** focus) const;
86 virtual bool onSetFocusView(SkView* focus);
89 SkSurfaceProps fSurfaceProps;
90 SkColorType fColorType;
94 SkTDArray<Click*> fClicks; // to track clicks
96 SkTDArray<SkOSMenu*> fMenus;
104 typedef SkView INHERITED;
107 ////////////////////////////////////////////////////////////////////////////////
109 #if defined(SK_BUILD_FOR_NACL)
110 #include "SkOSWindow_NaCl.h"
111 #elif defined(SK_BUILD_FOR_MAC)
112 #include "SkOSWindow_Mac.h"
113 #elif defined(SK_BUILD_FOR_WIN)
114 #include "SkOSWindow_Win.h"
115 #elif defined(SK_BUILD_FOR_ANDROID)
116 #include "SkOSWindow_Android.h"
117 #elif defined(SK_BUILD_FOR_UNIX)
118 #include "SkOSWindow_Unix.h"
119 #elif defined(SK_BUILD_FOR_SDL)
120 #include "SkOSWindow_SDL.h"
121 #elif defined(SK_BUILD_FOR_IOS)
122 #include "SkOSWindow_iOS.h"