SkWindow.h revision 671cd656785de5e84564b6ffe4831625d7016ded
18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Copyright (C) 2006 The Android Open Source Project 38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Licensed under the Apache License, Version 2.0 (the "License"); 58a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * you may not use this file except in compliance with the License. 68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * You may obtain a copy of the License at 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * http://www.apache.org/licenses/LICENSE-2.0 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Unless required by applicable law or agreed to in writing, software 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * distributed under the License is distributed on an "AS IS" BASIS, 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * See the License for the specific language governing permissions and 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * limitations under the License. 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkWindow_DEFINED 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkWindow_DEFINED 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkView.h" 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkBitmap.h" 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkRegion.h" 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkEvent.h" 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkKey.h" 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkTDArray.h" 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_BUILD_FOR_WINCEx 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com #define SHOW_FPS 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//#define USE_GX_SCREEN 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkOSMenu; 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkWindow : public SkView { 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkWindow(); 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~SkWindow(); 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkBitmap& getBitmap() const { return fBitmap; } 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setConfig(SkBitmap::Config); 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void resize(int width, int height, SkBitmap::Config config = SkBitmap::kNo_Config); 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b); 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void eraseRGB(U8CPU r, U8CPU g, U8CPU b); 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool isDirty() const { return !fDirtyRgn.isEmpty(); } 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool update(SkIRect* updateArea); 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool handleClick(int x, int y, Click::State); 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool handleChar(SkUnichar); 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool handleKey(SkKey); 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool handleKeyUp(SkKey); 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool handleMenu(uint32_t os_cmd); 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addMenu(SkOSMenu*); 550ae6b245f2b79bc04f0801b08fcf05abcf98fd6creed@android.com 560ae6b245f2b79bc04f0801b08fcf05abcf98fd6creed@android.com const char* getTitle() const { return fTitle.c_str(); } 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setTitle(const char title[]); 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool onEvent(const SkEvent&); 618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // called if part of our bitmap is invalidated 638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void onHandleInval(const SkIRect&); 648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool onHandleChar(SkUnichar); 658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool onHandleKey(SkKey); 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool onHandleKeyUp(SkKey); 678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void onAddMenu(const SkOSMenu*) {} 688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void onSetTitle(const char title[]) {} 698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // overrides from SkView 718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool handleInval(const SkRect&); 728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool onGetFocusView(SkView** focus) const; 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool onSetFocusView(SkView* focus); 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBitmap::Config fConfig; 778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBitmap fBitmap; 788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkRegion fDirtyRgn; 798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Click* fClick; // to track clicks 808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkTDArray<SkOSMenu*> fMenus; 828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkView* fFocusView; 848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool fWaitingOnInval; 850ae6b245f2b79bc04f0801b08fcf05abcf98fd6creed@android.com 860ae6b245f2b79bc04f0801b08fcf05abcf98fd6creed@android.com SkString fTitle; 878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com typedef SkView INHERITED; 898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////// 928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 93671cd656785de5e84564b6ffe4831625d7016dedreed@android.com#ifdef SK_USE_WXWIDGETS 94671cd656785de5e84564b6ffe4831625d7016dedreed@android.com #include "SkOSWindow_wxwidgets.h" 95671cd656785de5e84564b6ffe4831625d7016dedreed@android.com#elif defined(SK_BUILD_FOR_MAC) 968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com #include "SkOSWindow_Mac.h" 978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#elif defined(SK_BUILD_FOR_WIN) 988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com #include "SkOSWindow_Win.h" 998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#elif defined(SK_BUILD_FOR_UNIXx) 1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com #include "SkOSWindow_Unix.h" 101671cd656785de5e84564b6ffe4831625d7016dedreed@android.com#elif defined(SK_BUILD_FOR_SDL) 102671cd656785de5e84564b6ffe4831625d7016dedreed@android.com #include "SkOSWindow_SDL.h" 1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 107