1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #ifndef CANVAS_VIEW_H 10 #define CANVAS_VIEW_H 11 12 #include "StateView.h" 13 14 class BBitmap; 15 class Icon; 16 class IconRenderer; 17 18 class CanvasView : public StateView { 19 public: 20 CanvasView(BRect frame); 21 virtual ~CanvasView(); 22 23 // StateView interface 24 virtual void AttachedToWindow(); 25 virtual void FrameResized(float width, float height); 26 virtual void Draw(BRect updateRect); 27 28 // CanvasView 29 void SetIcon(Icon* icon); 30 31 inline float ZoomLevel() const 32 { return fZoomLevel; } 33 34 void ConvertFromCanvas(BPoint* point) const; 35 void ConvertToCanvas(BPoint* point) const; 36 37 void ConvertFromCanvas(BRect* rect) const; 38 void ConvertToCanvas(BRect* rect) const; 39 40 protected: 41 // StateView interface 42 virtual bool _HandleKeyDown(uint32 key, uint32 modifiers); 43 44 // CanvasView 45 BRect _CanvasRect() const; 46 47 void _AllocBackBitmap(float width, 48 float height); 49 void _FreeBackBitmap(); 50 void _DrawInto(BView* view, 51 BRect updateRect); 52 53 private: 54 BBitmap* fBitmap; 55 IconRenderer* fRenderer; 56 57 BPoint fCanvasOrigin; 58 float fZoomLevel; 59 60 BBitmap* fOffsreenBitmap; 61 BView* fOffsreenView; 62 }; 63 64 #endif // CANVAS_VIEW_H 65