Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / include / views / SkWindow.h
1 /*
2  * Copyright 2006 The Android Open Source Project
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 SkWindow_DEFINED
9 #define SkWindow_DEFINED
10
11 #include "SkView.h"
12 #include "SkBitmap.h"
13 #include "SkMatrix.h"
14 #include "SkRegion.h"
15 #include "SkEvent.h"
16 #include "SkKey.h"
17 #include "SkTDArray.h"
18
19 #ifdef SK_BUILD_FOR_WINCEx
20     #define SHOW_FPS
21 #endif
22 //#define USE_GX_SCREEN
23
24 class SkSurface;
25 class SkOSMenu;
26
27 class SkWindow : public SkView {
28 public:
29             SkWindow();
30     virtual ~SkWindow();
31
32     const SkBitmap& getBitmap() const { return fBitmap; }
33
34     void    setColorType(SkColorType);
35     void    resize(int width, int height, SkColorType = kUnknown_SkColorType);
36
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.
41     void    forceInvalAll();
42     // return the bounds of the dirty/inval rgn, or [0,0,0,0] if none
43     const SkIRect& getDirtyBounds() const { return fDirtyRgn.getBounds(); }
44
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);
49
50     void    addMenu(SkOSMenu*);
51     const SkTDArray<SkOSMenu*>* getMenus() { return &fMenus; }
52
53     const char* getTitle() const { return fTitle.c_str(); }
54     void    setTitle(const char title[]);
55
56     const SkMatrix& getMatrix() const { return fMatrix; }
57     void    setMatrix(const SkMatrix&);
58     void    preConcat(const SkMatrix&);
59     void    postConcat(const SkMatrix&);
60
61     virtual SkSurface* createSurface();
62
63     virtual void onPDFSaved(const char title[], const char desc[],
64         const char path[]) {}
65 protected:
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[]) {}
76
77     // overrides from SkView
78     virtual bool handleInval(const SkRect*);
79     virtual bool onGetFocusView(SkView** focus) const;
80     virtual bool onSetFocusView(SkView* focus);
81
82 private:
83     SkColorType fColorType;
84     SkBitmap    fBitmap;
85     SkRegion    fDirtyRgn;
86
87     SkTDArray<Click*>       fClicks; // to track clicks
88
89     SkTDArray<SkOSMenu*>    fMenus;
90
91     SkView* fFocusView;
92     bool    fWaitingOnInval;
93
94     SkString    fTitle;
95     SkMatrix    fMatrix;
96
97     typedef SkView INHERITED;
98 };
99
100 ////////////////////////////////////////////////////////////////////////////////
101
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"
116 #endif
117
118 #endif