usb_ecm: Use the current configuration instead of a fixed one.
[haiku.git] / src / servers / app / View.h
blob84e2b3cf16e40c3bbf695c3c9d3622eec0173ce8
1 /*
2 * Copyright (c) 2001-2015, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
5 * Authors:
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>
15 #ifndef VIEW_H
16 #define VIEW_H
19 #include "Canvas.h"
20 #include "IntRect.h"
22 #include <GraphicsDefs.h>
23 #include <InterfaceDefs.h>
24 #include <ObjectList.h>
25 #include <Region.h>
26 #include <String.h>
28 class BList;
29 class BMessage;
31 namespace BPrivate {
32 class PortLink;
35 class DrawingEngine;
36 class Overlay;
37 class Window;
38 class ServerBitmap;
39 class ServerCursor;
40 class ServerPicture;
41 class BGradient;
43 class View: public Canvas {
44 public:
45 View(IntRect frame, IntPoint scrollingOffset,
46 const char* name, int32 token,
47 uint32 resizeMode, uint32 flags);
48 virtual ~View();
50 int32 Token() const
51 { return fToken; }
53 IntRect Frame() const
54 { return fFrame; }
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);
65 uint32 Flags() const
66 { return fFlags; }
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();
85 // tree stuff
86 void AddChild(View* view);
87 bool RemoveChild(View* view);
89 inline bool HasParent(View* candidate) const
91 return fParent == candidate
92 || (fParent != NULL
93 && fParent->HasParent(candidate));
96 inline View* Parent() const
97 { return fParent; }
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; }
108 View* TopView();
110 uint32 CountChildren(bool deep = false) const;
111 void CollectTokensForChildren(BList* tokenMap) const;
112 void FindViews(uint32 flags, BObjectList<View>& list,
113 int32& left);
115 bool HasView(View* view);
116 View* ViewAt(const BPoint& where);
118 public:
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);
151 void PushState();
152 void PopState();
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
165 { return fPicture; }
167 void BlendAllLayers();
169 // for background clearing
170 virtual void Draw(DrawingEngine* drawingEngine,
171 BRegion* effectiveClipping,
172 BRegion* windowContentClipping,
173 bool deep = false);
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
184 { return fVisible; }
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,
199 BRegion& region,
200 BRegion* windowContentClipping);
202 // clipping
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));
216 // debugging
217 void PrintToStream() const;
218 #if 0
219 bool MarkAt(DrawingEngine* engine, const BPoint& where,
220 int32 level = 0);
221 #endif
223 protected:
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,
232 bool deep);
233 Overlay* _Overlay() const;
234 void _UpdateOverlayView() const;
236 BString fName;
237 int32 fToken;
238 // area within parent coordinate space
239 IntRect fFrame;
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;
252 uint32 fResizeMode;
253 uint32 fFlags;
254 bool fHidden : 1;
255 bool fVisible : 1;
256 bool fBackgroundDirty : 1;
257 bool fIsDesktopBackground : 1;
259 uint32 fEventMask;
260 uint32 fEventOptions;
262 ::Window* fWindow;
263 View* fParent;
265 View* fFirstChild;
266 View* fPreviousSibling;
267 View* fNextSibling;
268 View* fLastChild;
270 ServerCursor* fCursor;
271 ServerPicture* fPicture;
273 // clipping
274 BRegion fLocalClipping;
276 mutable BRegion fScreenClipping;
277 mutable bool fScreenClippingValid;
279 BRegion* fUserClipping;
280 mutable BRegion* fScreenAndUserClipping;
283 #endif // VIEW_H