• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SkWindow_DEFINED
18 #define SkWindow_DEFINED
19 
20 #include "SkView.h"
21 #include "SkBitmap.h"
22 #include "SkRegion.h"
23 #include "SkEvent.h"
24 #include "SkKey.h"
25 #include "SkTDArray.h"
26 
27 #ifdef SK_BUILD_FOR_WINCEx
28     #define SHOW_FPS
29 #endif
30 //#define USE_GX_SCREEN
31 
32 class SkOSMenu;
33 
34 class SkWindow : public SkView {
35 public:
36             SkWindow();
37     virtual ~SkWindow();
38 
getBitmap()39     const SkBitmap& getBitmap() const { return fBitmap; }
40 
41     void    setConfig(SkBitmap::Config);
42     void    resize(int width, int height, SkBitmap::Config config = SkBitmap::kNo_Config);
43     void    eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
44     void    eraseRGB(U8CPU r, U8CPU g, U8CPU b);
45 
isDirty()46     bool    isDirty() const { return !fDirtyRgn.isEmpty(); }
47     bool    update(SkIRect* updateArea);
48     bool    handleClick(int x, int y, Click::State);
49     bool    handleChar(SkUnichar);
50     bool    handleKey(SkKey);
51     bool    handleKeyUp(SkKey);
52     bool    handleMenu(uint32_t os_cmd);
53 
54     void    addMenu(SkOSMenu*);
55 
getTitle()56     const char* getTitle() const { return fTitle.c_str(); }
57     void    setTitle(const char title[]);
58 
59 protected:
60     virtual bool onEvent(const SkEvent&);
61 
62     // called if part of our bitmap is invalidated
63     virtual void onHandleInval(const SkIRect&);
64     virtual bool onHandleChar(SkUnichar);
65     virtual bool onHandleKey(SkKey);
66     virtual bool onHandleKeyUp(SkKey);
onAddMenu(const SkOSMenu *)67     virtual void onAddMenu(const SkOSMenu*) {}
onSetTitle(const char title[])68     virtual void onSetTitle(const char title[]) {}
69 
70     // overrides from SkView
71     virtual bool handleInval(const SkRect&);
72     virtual bool onGetFocusView(SkView** focus) const;
73     virtual bool onSetFocusView(SkView* focus);
74 
75 private:
76     SkBitmap::Config    fConfig;
77     SkBitmap    fBitmap;
78     SkRegion    fDirtyRgn;
79     Click*      fClick; // to track clicks
80 
81     SkTDArray<SkOSMenu*>    fMenus;
82 
83     SkView* fFocusView;
84     bool    fWaitingOnInval;
85 
86     SkString    fTitle;
87 
88     typedef SkView INHERITED;
89 };
90 
91 ///////////////////////////////////////////////////////////
92 
93 #ifdef SK_USE_WXWIDGETS
94     #include "SkOSWindow_wxwidgets.h"
95 #elif defined(SK_BUILD_FOR_MAC)
96     #include "SkOSWindow_Mac.h"
97 #elif defined(SK_BUILD_FOR_WIN)
98     #include "SkOSWindow_Win.h"
99 #elif defined(SK_BUILD_FOR_UNIXx)
100   #include "SkOSWindow_Unix.h"
101 #elif defined(SK_BUILD_FOR_SDL)
102     #include "SkOSWindow_SDL.h"
103 #endif
104 
105 #endif
106 
107