00001 /* 00002 * Copyright (C) 2006 The Android Open Source Project 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef SkWindow_DEFINED 00018 #define SkWindow_DEFINED 00019 00020 #include "SkView.h" 00021 #include "SkBitmap.h" 00022 #include "SkRegion.h" 00023 #include "SkEvent.h" 00024 #include "SkKey.h" 00025 #include "SkTDArray.h" 00026 00027 #ifdef SK_BUILD_FOR_WINCEx 00028 #define SHOW_FPS 00029 #endif 00030 //#define USE_GX_SCREEN 00031 00032 class SkOSMenu; 00033 00034 class SkWindow : public SkView { 00035 public: 00036 SkWindow(); 00037 virtual ~SkWindow(); 00038 00039 const SkBitmap& getBitmap() const { return fBitmap; } 00040 00041 void setConfig(SkBitmap::Config); 00042 void resize(int width, int height, SkBitmap::Config config = SkBitmap::kNo_Config); 00043 void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b); 00044 void eraseRGB(U8CPU r, U8CPU g, U8CPU b); 00045 00046 bool isDirty() const { return !fDirtyRgn.isEmpty(); } 00047 bool update(SkIRect* updateArea); 00048 bool handleClick(int x, int y, Click::State); 00049 bool handleChar(SkUnichar); 00050 bool handleKey(SkKey); 00051 bool handleKeyUp(SkKey); 00052 bool handleMenu(uint32_t os_cmd); 00053 00054 void addMenu(SkOSMenu*); 00055 00056 const char* getTitle() const { return fTitle.c_str(); } 00057 void setTitle(const char title[]); 00058 00059 protected: 00060 virtual bool onEvent(const SkEvent&); 00061 00062 // called if part of our bitmap is invalidated 00063 virtual void onHandleInval(const SkIRect&); 00064 virtual bool onHandleChar(SkUnichar); 00065 virtual bool onHandleKey(SkKey); 00066 virtual bool onHandleKeyUp(SkKey); 00067 virtual void onAddMenu(const SkOSMenu*) {} 00068 virtual void onSetTitle(const char title[]) {} 00069 00070 // overrides from SkView 00071 virtual bool handleInval(const SkRect&); 00072 virtual bool onGetFocusView(SkView** focus) const; 00073 virtual bool onSetFocusView(SkView* focus); 00074 00075 private: 00076 SkBitmap::Config fConfig; 00077 SkBitmap fBitmap; 00078 SkRegion fDirtyRgn; 00079 Click* fClick; // to track clicks 00080 00081 SkTDArray<SkOSMenu*> fMenus; 00082 00083 SkView* fFocusView; 00084 bool fWaitingOnInval; 00085 00086 SkString fTitle; 00087 00088 typedef SkView INHERITED; 00089 }; 00090 00092 00093 #ifdef SK_USE_WXWIDGETS 00094 #include "SkOSWindow_wxwidgets.h" 00095 #elif defined(SK_BUILD_FOR_MAC) 00096 #include "SkOSWindow_Mac.h" 00097 #elif defined(SK_BUILD_FOR_WIN) 00098 #include "SkOSWindow_Win.h" 00099 #elif defined(SK_BUILD_FOR_UNIXx) 00100 #include "SkOSWindow_Unix.h" 00101 #elif defined(SK_BUILD_FOR_SDL) 00102 #include "SkOSWindow_SDL.h" 00103 #endif 00104 00105 #endif 00106