2 * Copyright (c) 2001-2015, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
6 * DarkWyrm <bpmagic@columbus.rr.com>
7 * Adi Oanca <adioanca@gmail.com>
8 * Axel Dörfler, axeld@pinc-software.de
9 * Stephan Aßmus <superstippi@gmx.de>
10 * Marcus Overhagen <marcus@overhagen.de>
11 * Adrien Destugues <pulkomandy@pulkomandy.tk>
12 * Julian Harnath <julian.harnath@rwth-aachen.de>
13 * Joseph Groover <looncraz@looncraz.net>
22 #include <GraphicsDefs.h>
23 #include <InterfaceDefs.h>
24 #include <ObjectList.h>
43 class View
: public Canvas
{
45 View(IntRect frame
, IntPoint scrollingOffset
,
46 const char* name
, int32 token
,
47 uint32 resizeMode
, uint32 flags
);
55 virtual IntRect
Bounds() const;
57 void SetResizeMode(uint32 resizeMode
)
58 { fResizeMode
= resizeMode
; }
60 void SetName(const char* string
);
61 const char* Name() const
62 { return fName
.String(); }
64 void SetFlags(uint32 flags
);
68 inline IntPoint
ScrollingOffset() const
69 { return fScrollingOffset
; }
71 // converts the given frame up the view hierarchy and
72 // clips to each views bounds
73 void ConvertToVisibleInTopView(IntRect
* bounds
) const;
75 virtual void AttachedToWindow(::Window
* window
);
76 virtual void DetachedFromWindow();
77 ::Window
* Window() const { return fWindow
; }
79 // Shorthands for opaque Window access
80 DrawingEngine
* GetDrawingEngine() const;
81 ServerPicture
* GetPicture(int32 token
) const;
82 void ResyncDrawState();
83 void UpdateCurrentDrawingRegion();
86 void AddChild(View
* view
);
87 bool RemoveChild(View
* view
);
89 inline bool HasParent(View
* candidate
) const
91 return fParent
== candidate
93 && fParent
->HasParent(candidate
));
96 inline View
* Parent() const
99 inline View
* FirstChild() const
100 { return fFirstChild
; }
101 inline View
* LastChild() const
102 { return fLastChild
; }
103 inline View
* PreviousSibling() const
104 { return fPreviousSibling
; }
105 inline View
* NextSibling() const
106 { return fNextSibling
; }
110 uint32
CountChildren(bool deep
= false) const;
111 void CollectTokensForChildren(BList
* tokenMap
) const;
112 void FindViews(uint32 flags
, BObjectList
<View
>& list
,
115 bool HasView(View
* view
);
116 View
* ViewAt(const BPoint
& where
);
119 void MoveBy(int32 dx
, int32 dy
,
120 BRegion
* dirtyRegion
);
122 void ResizeBy(int32 dx
, int32 dy
,
123 BRegion
* dirtyRegion
);
125 void ScrollBy(int32 dx
, int32 dy
,
126 BRegion
* dirtyRegion
);
128 void ParentResized(int32 dx
, int32 dy
,
129 BRegion
* dirtyRegion
);
131 void CopyBits(IntRect src
, IntRect dst
,
132 BRegion
& windowContentClipping
);
134 const BRegion
& LocalClipping() const { return fLocalClipping
; }
136 const rgb_color
& ViewColor() const
137 { return fViewColor
; }
138 void SetViewColor(const rgb_color
& color
)
139 { fViewColor
= color
; }
141 void ColorUpdated(color_which which
, rgb_color color
);
142 void SetViewUIColor(color_which which
, float tint
);
143 color_which
ViewUIColor(float* tint
);
145 ServerBitmap
* ViewBitmap() const
146 { return fViewBitmap
; }
147 void SetViewBitmap(ServerBitmap
* bitmap
,
148 IntRect sourceRect
, IntRect destRect
,
149 int32 resizingMode
, int32 options
);
154 void SetEventMask(uint32 eventMask
, uint32 options
);
155 uint32
EventMask() const
156 { return fEventMask
; }
157 uint32
EventOptions() const
158 { return fEventOptions
; }
160 void SetCursor(ServerCursor
* cursor
);
161 ServerCursor
* Cursor() const { return fCursor
; }
163 void SetPicture(ServerPicture
* picture
);
164 ServerPicture
* Picture() const
167 void BlendAllLayers();
169 // for background clearing
170 virtual void Draw(DrawingEngine
* drawingEngine
,
171 BRegion
* effectiveClipping
,
172 BRegion
* windowContentClipping
,
175 virtual void MouseDown(BMessage
* message
, BPoint where
);
176 virtual void MouseUp(BMessage
* message
, BPoint where
);
177 virtual void MouseMoved(BMessage
* message
, BPoint where
);
179 void SetHidden(bool hidden
);
180 bool IsHidden() const;
182 // takes into account parent views hidden status
183 bool IsVisible() const
185 // update visible status for this view and all children
186 // according to the parents visibility
187 void UpdateVisibleDeep(bool parentVisible
);
189 void UpdateOverlay();
191 void MarkBackgroundDirty();
192 bool IsBackgroundDirty() const
193 { return fBackgroundDirty
; }
195 bool IsDesktopBackground() const
196 { return fIsDesktopBackground
; }
198 void AddTokensForViewsInRegion(BPrivate::PortLink
& link
,
200 BRegion
* windowContentClipping
);
203 void RebuildClipping(bool deep
);
204 BRegion
& ScreenAndUserClipping(
205 BRegion
* windowContentClipping
,
206 bool force
= false) const;
207 void InvalidateScreenClipping();
208 inline bool IsScreenClippingValid() const
210 return fScreenClippingValid
211 && (fUserClipping
== NULL
212 || (fUserClipping
!= NULL
213 && fScreenAndUserClipping
!= NULL
));
217 void PrintToStream() const;
219 bool MarkAt(DrawingEngine
* engine
, const BPoint
& where
,
224 virtual void _LocalToScreenTransform(
225 SimpleTransform
& transform
) const;
226 virtual void _ScreenToLocalTransform(
227 SimpleTransform
& transform
) const;
229 BRegion
& _ScreenClipping(BRegion
* windowContentClipping
,
230 bool force
= false) const;
231 void _MoveScreenClipping(int32 x
, int32 y
,
233 Overlay
* _Overlay() const;
234 void _UpdateOverlayView() const;
238 // area within parent coordinate space
240 // offset of the local area (bounds)
241 IntPoint fScrollingOffset
;
243 rgb_color fViewColor
;
244 color_which fWhichViewColor
;
245 float fWhichViewColorTint
;
246 ServerBitmap
* fViewBitmap
;
247 IntRect fBitmapSource
;
248 IntRect fBitmapDestination
;
249 int32 fBitmapResizingMode
;
250 int32 fBitmapOptions
;
256 bool fBackgroundDirty
: 1;
257 bool fIsDesktopBackground
: 1;
260 uint32 fEventOptions
;
266 View
* fPreviousSibling
;
270 ServerCursor
* fCursor
;
271 ServerPicture
* fPicture
;
274 BRegion fLocalClipping
;
276 mutable BRegion fScreenClipping
;
277 mutable bool fScreenClippingValid
;
279 BRegion
* fUserClipping
;
280 mutable BRegion
* fScreenAndUserClipping
;