2 * Copyright 2006-2007, 2011, Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT License.
10 #include "Scrollable.h"
11 #include "StateView.h"
31 class CanvasView
: public StateView
, public Scrollable
, public IconListener
{
33 CanvasView(BRect frame
);
34 virtual ~CanvasView();
36 // StateView interface
37 virtual void AttachedToWindow();
38 virtual void FrameResized(float width
, float height
);
39 virtual void Draw(BRect updateRect
);
41 virtual void MouseDown(BPoint where
);
42 virtual void MouseUp(BPoint where
);
43 virtual void MouseMoved(BPoint where
, uint32 transit
,
44 const BMessage
* dragMessage
);
45 virtual void FilterMouse(BPoint
* where
) const;
47 virtual bool MouseWheelChanged(BPoint where
,
50 // Scrollable interface
52 virtual void SetScrollOffset(BPoint newOffset
);
53 virtual void ScrollOffsetChanged(BPoint oldOffset
,
55 virtual void VisibleSizeChanged(float oldWidth
,
56 float oldHeight
, float newWidth
,
58 // IconListener interface
60 virtual void AreaInvalidated(const BRect
& area
);
63 void SetIcon(Icon
* icon
);
65 inline float ZoomLevel() const
66 { return fZoomLevel
; }
68 void SetMouseFilterMode(uint32 mode
);
69 uint32
MouseFilterMode() const
70 { return fMouseFilterMode
; }
72 void ConvertFromCanvas(BPoint
* point
) const;
73 void ConvertToCanvas(BPoint
* point
) const;
75 void ConvertFromCanvas(BRect
* rect
) const;
76 void ConvertToCanvas(BRect
* rect
) const;
79 // StateView interface
80 virtual bool _HandleKeyDown(uint32 key
, uint32 modifiers
);
81 virtual bool _HandleKeyUp(uint32 key
, uint32 modifiers
);
84 BRect
_CanvasRect() const;
86 void _AllocBackBitmap(float width
,
88 void _FreeBackBitmap();
89 void _DrawInto(BView
* view
,
92 void _MakeBackground();
94 void _UpdateToolCursor();
97 double _NextZoomInLevel(double zoom
) const;
98 double _NextZoomOutLevel(double zoom
) const;
99 void _SetZoom(double zoomLevel
,
100 bool mouseIsAnchor
= true);
101 BRect
_LayoutCanvas();
105 BBitmap
* fBackground
;
108 IconRenderer
* fRenderer
;
109 BRect fDirtyIconArea
;
111 BPoint fCanvasOrigin
;
116 bool fScrollTracking
;
117 BPoint fScrollTrackingStart
;
118 BPoint fScrollOffsetStart
;
120 uint32 fMouseFilterMode
;
123 #endif // CANVAS_VIEW_H