2 * Copyright 2001-2015 Haiku, Inc.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus, superstippi@gmx.de
7 * DarkWyrm, bpmagic@columbus.rr.com
8 * John Scipione, jscipione@gmail.com
9 * Ingo Weinhold, ingo_weinhold@gmx.de
10 * Clemens Zeidler, haiku@clemens-zeidler.de
11 * Joseph Groover <looncraz@looncraz.net>
22 #include "DrawState.h"
25 class DesktopSettings
;
44 bool closePressed
: 1;
46 bool minimizePressed
: 1;
58 BString truncatedTitle
;
59 int32 truncatedTitleLength
;
63 bool isHighlighted
: 1;
68 ServerBitmap
* closeBitmaps
[4];
69 ServerBitmap
* minimizeBitmaps
[4];
70 ServerBitmap
* zoomBitmaps
[4];
80 REGION_MINIMIZE_BUTTON
,
87 REGION_LEFT_TOP_CORNER
,
88 REGION_LEFT_BOTTOM_CORNER
,
89 REGION_RIGHT_TOP_CORNER
,
90 REGION_RIGHT_BOTTOM_CORNER
,
97 HIGHLIGHT_RESIZE_BORDER
,
99 HIGHLIGHT_USER_DEFINED
102 Decorator(DesktopSettings
& settings
,
105 virtual ~Decorator();
107 virtual Decorator::Tab
* AddTab(DesktopSettings
& settings
,
108 const char* title
, window_look look
,
109 uint32 flags
, int32 index
= -1,
110 BRegion
* updateRegion
= NULL
);
111 virtual bool RemoveTab(int32 index
,
112 BRegion
* updateRegion
= NULL
);
113 virtual bool MoveTab(int32 from
, int32 to
, bool isMoving
,
114 BRegion
* updateRegion
= NULL
);
116 virtual int32
TabAt(const BPoint
& where
) const;
117 Decorator::Tab
* TabAt(int32 index
) const
118 { return fTabList
.ItemAt(index
); }
119 int32
CountTabs() const
120 { return fTabList
.CountItems(); }
121 void SetTopTab(int32 tab
);
123 void SetDrawingEngine(DrawingEngine
*driver
);
124 inline DrawingEngine
* GetDrawingEngine() const
125 { return fDrawingEngine
; }
127 void FontsChanged(DesktopSettings
& settings
,
128 BRegion
* updateRegion
= NULL
);
129 void ColorsChanged(DesktopSettings
& settings
,
130 BRegion
* updateRegion
= NULL
);
132 virtual void UpdateColors(DesktopSettings
& settings
) = 0;
134 void SetLook(int32 tab
, DesktopSettings
& settings
,
136 BRegion
* updateRegion
= NULL
);
137 void SetFlags(int32 tab
, uint32 flags
,
138 BRegion
* updateRegion
= NULL
);
140 window_look
Look(int32 tab
) const;
141 uint32
Flags(int32 tab
) const;
143 BRect
BorderRect() const;
144 BRect
TitleBarRect() const;
145 BRect
TabRect(int32 tab
) const;
146 BRect
TabRect(Decorator::Tab
* tab
) const;
148 void SetClose(int32 tab
, bool pressed
);
149 void SetMinimize(int32 tab
, bool pressed
);
150 void SetZoom(int32 tab
, bool pressed
);
152 const char* Title(int32 tab
) const;
153 const char* Title(Decorator::Tab
* tab
) const;
154 void SetTitle(int32 tab
, const char* string
,
155 BRegion
* updateRegion
= NULL
);
157 void SetFocus(int32 tab
, bool focussed
);
158 bool IsFocus(int32 tab
) const;
159 bool IsFocus(Decorator::Tab
* tab
) const;
161 virtual float TabLocation(int32 tab
) const;
162 bool SetTabLocation(int32 tab
, float location
,
164 BRegion
* updateRegion
= NULL
);
165 /*! \return true if tab location updated, false if out of
166 bounds or unsupported */
168 virtual Region
RegionAt(BPoint where
, int32
& tab
) const;
170 const BRegion
& GetFootprint();
171 ::Desktop
* GetDesktop();
173 void MoveBy(float x
, float y
);
174 void MoveBy(BPoint offset
);
175 void ResizeBy(float x
, float y
, BRegion
* dirty
);
176 void ResizeBy(BPoint offset
, BRegion
* dirty
);
178 virtual bool SetRegionHighlight(Region region
,
179 uint8 highlight
, BRegion
* dirty
,
181 inline uint8
RegionHighlight(Region region
,
182 int32 tab
= -1) const;
184 bool SetSettings(const BMessage
& settings
,
185 BRegion
* updateRegion
= NULL
);
186 virtual bool GetSettings(BMessage
* settings
) const;
188 virtual void GetSizeLimits(int32
* minWidth
, int32
* minHeight
,
189 int32
* maxWidth
, int32
* maxHeight
) const;
190 virtual void ExtendDirtyRegion(Region region
, BRegion
& dirty
);
192 virtual void Draw(BRect updateRect
) = 0;
193 virtual void Draw() = 0;
195 virtual void DrawTab(int32 tab
);
196 virtual void DrawTitle(int32 tab
);
198 virtual void DrawClose(int32 tab
);
199 virtual void DrawMinimize(int32 tab
);
200 virtual void DrawZoom(int32 tab
);
202 rgb_color
UIColor(color_which which
);
208 virtual Decorator::Tab
* _AllocateNewTab();
210 virtual void _DoLayout() = 0;
211 //! method for calculating layout for the decorator
213 virtual void _DrawFrame(BRect rect
) = 0;
214 virtual void _DrawTabs(BRect rect
);
216 virtual void _DrawTab(Decorator::Tab
* tab
, BRect rect
) = 0;
217 virtual void _DrawTitle(Decorator::Tab
* tab
,
220 virtual void _DrawButtons(Decorator::Tab
* tab
,
221 const BRect
& invalid
) = 0;
222 virtual void _DrawClose(Decorator::Tab
* tab
, bool direct
,
224 virtual void _DrawMinimize(Decorator::Tab
* tab
, bool direct
,
226 virtual void _DrawZoom(Decorator::Tab
* tab
, bool direct
,
229 virtual void _SetTitle(Decorator::Tab
* tab
,
231 BRegion
* updateRegion
= NULL
) = 0;
232 int32
_TitleWidth(Decorator::Tab
* tab
) const
233 { return tab
->title
.CountChars(); }
235 virtual void _SetFocus(Decorator::Tab
* tab
);
236 virtual bool _SetTabLocation(Decorator::Tab
* tab
,
237 float location
, bool isShifting
,
238 BRegion
* updateRegion
= NULL
);
240 virtual Decorator::Tab
* _TabAt(int32 index
) const;
242 virtual void _FontsChanged(DesktopSettings
& settings
,
243 BRegion
* updateRegion
= NULL
);
244 virtual void _UpdateFont(DesktopSettings
& settings
) = 0;
246 virtual void _SetLook(Decorator::Tab
* tab
,
247 DesktopSettings
& settings
,
249 BRegion
* updateRegion
= NULL
);
250 virtual void _SetFlags(Decorator::Tab
* tab
, uint32 flags
,
251 BRegion
* updateRegion
= NULL
);
253 virtual void _MoveBy(BPoint offset
);
254 virtual void _ResizeBy(BPoint offset
, BRegion
* dirty
) = 0;
256 virtual bool _SetSettings(const BMessage
& settings
,
257 BRegion
* updateRegion
= NULL
);
259 virtual bool _AddTab(DesktopSettings
& settings
,
261 BRegion
* updateRegion
= NULL
) = 0;
262 virtual bool _RemoveTab(int32 index
,
263 BRegion
* updateRegion
= NULL
) = 0;
264 virtual bool _MoveTab(int32 from
, int32 to
, bool isMoving
,
265 BRegion
* updateRegion
= NULL
) = 0;
267 virtual void _GetFootprint(BRegion
*region
);
268 void _InvalidateFootprint();
270 void _InvalidateBitmaps();
272 DrawingEngine
* fDrawingEngine
;
273 DrawState fDrawState
;
275 // Individual rects for handling window frame
276 // rendering the proper way
289 Decorator::Tab
* fTopTab
;
290 BObjectList
<Decorator::Tab
> fTabList
;
295 bool fFootprintValid
: 1;
297 uint8 fRegionHighlights
[REGION_COUNT
- 1];
302 Decorator::RegionHighlight(Region region
, int32 tab
) const
304 int32 index
= (int32
)region
- 1;
305 return index
>= 0 && index
< REGION_COUNT
- 1
306 ? fRegionHighlights
[index
] : 0;
310 #endif // DECORATOR_H