michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkWindow_DEFINED michael@0: #define SkWindow_DEFINED michael@0: michael@0: #include "SkView.h" michael@0: #include "SkBitmap.h" michael@0: #include "SkMatrix.h" michael@0: #include "SkRegion.h" michael@0: #include "SkEvent.h" michael@0: #include "SkKey.h" michael@0: #include "SkTDArray.h" michael@0: michael@0: #ifdef SK_BUILD_FOR_WINCEx michael@0: #define SHOW_FPS michael@0: #endif michael@0: //#define USE_GX_SCREEN michael@0: michael@0: class SkCanvas; michael@0: michael@0: class SkOSMenu; michael@0: michael@0: class SkWindow : public SkView { michael@0: public: michael@0: SkWindow(); michael@0: virtual ~SkWindow(); michael@0: michael@0: const SkBitmap& getBitmap() const { return fBitmap; } michael@0: michael@0: void setColorType(SkColorType); michael@0: void resize(int width, int height, SkColorType = kUnknown_SkColorType); michael@0: michael@0: bool isDirty() const { return !fDirtyRgn.isEmpty(); } michael@0: bool update(SkIRect* updateArea); michael@0: // does not call through to onHandleInval(), but does force the fDirtyRgn michael@0: // to be wide open. Call before update() to ensure we redraw everything. michael@0: void forceInvalAll(); michael@0: // return the bounds of the dirty/inval rgn, or [0,0,0,0] if none michael@0: const SkIRect& getDirtyBounds() const { return fDirtyRgn.getBounds(); } michael@0: michael@0: bool handleClick(int x, int y, Click::State, void* owner, unsigned modi = 0); michael@0: bool handleChar(SkUnichar); michael@0: bool handleKey(SkKey); michael@0: bool handleKeyUp(SkKey); michael@0: michael@0: void addMenu(SkOSMenu*); michael@0: const SkTDArray* getMenus() { return &fMenus; } michael@0: michael@0: const char* getTitle() const { return fTitle.c_str(); } michael@0: void setTitle(const char title[]); michael@0: michael@0: const SkMatrix& getMatrix() const { return fMatrix; } michael@0: void setMatrix(const SkMatrix&); michael@0: void preConcat(const SkMatrix&); michael@0: void postConcat(const SkMatrix&); michael@0: michael@0: virtual SkCanvas* createCanvas(); michael@0: michael@0: virtual void onPDFSaved(const char title[], const char desc[], michael@0: const char path[]) {} michael@0: protected: michael@0: virtual bool onEvent(const SkEvent&); michael@0: virtual bool onDispatchClick(int x, int y, Click::State, void* owner, unsigned modi); michael@0: // called if part of our bitmap is invalidated michael@0: virtual void onHandleInval(const SkIRect&); michael@0: virtual bool onHandleChar(SkUnichar); michael@0: virtual bool onHandleKey(SkKey); michael@0: virtual bool onHandleKeyUp(SkKey); michael@0: virtual void onAddMenu(const SkOSMenu*) {}; michael@0: virtual void onUpdateMenu(const SkOSMenu*) {}; michael@0: virtual void onSetTitle(const char title[]) {} michael@0: michael@0: // overrides from SkView michael@0: virtual bool handleInval(const SkRect*); michael@0: virtual bool onGetFocusView(SkView** focus) const; michael@0: virtual bool onSetFocusView(SkView* focus); michael@0: michael@0: private: michael@0: SkColorType fColorType; michael@0: SkBitmap fBitmap; michael@0: SkRegion fDirtyRgn; michael@0: michael@0: SkTDArray fClicks; // to track clicks michael@0: michael@0: SkTDArray fMenus; michael@0: michael@0: SkView* fFocusView; michael@0: bool fWaitingOnInval; michael@0: michael@0: SkString fTitle; michael@0: SkMatrix fMatrix; michael@0: michael@0: typedef SkView INHERITED; michael@0: }; michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: #if defined(SK_BUILD_FOR_NACL) michael@0: #include "SkOSWindow_NaCl.h" michael@0: #elif defined(SK_BUILD_FOR_MAC) michael@0: #include "SkOSWindow_Mac.h" michael@0: #elif defined(SK_BUILD_FOR_WIN) michael@0: #include "SkOSWindow_Win.h" michael@0: #elif defined(SK_BUILD_FOR_ANDROID) michael@0: #include "SkOSWindow_Android.h" michael@0: #elif defined(SK_BUILD_FOR_UNIX) michael@0: #include "SkOSWindow_Unix.h" michael@0: #elif defined(SK_BUILD_FOR_SDL) michael@0: #include "SkOSWindow_SDL.h" michael@0: #elif defined(SK_BUILD_FOR_IOS) michael@0: #include "SkOSWindow_iOS.h" michael@0: #endif michael@0: michael@0: #endif