3 <TITLE>Decorator.htm
</TITLE>
4 <style type=
"text/css">
6 .Default {background-color: rgb
(255,255,255); color: rgb
(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 12pt}
7 .OBOS-Function-Def {background-color: rgb
(255,255,255); color: rgb
(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 16pt}
8 .OBOS-Title {background-color: rgb
(255,255,255); color: rgb
(0,128,0); font-family: 'Dutch801 Rm BT'; font-size: 24pt}
9 .Text-Background {background-color: rgb
(255,255,255)}
14 .WP-Default {text-align: left
; text-indent: 0px; margin-left: 0px; margin-right: 0px}
18 <BODY BGCOLOR=
"#ffffff">
19 <DIV class=
"sheet" id=
"Sheet 1">
20 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Title">Decorator class
</span><span style=
"color: rgb(0,0,0); font-size: 24pt"></span></P>
21 <P class=
"Body" style=
"margin: 0px"><BR>
23 <P class=
"Body" style=
"margin: 0px">Decorators provide the actual drawing for a window's looks.
</P>
24 <P class=
"Body" style=
"margin: 0px"><BR>
28 <P class=
"Body" style=
"margin: 0px"><BR>
30 <P class=
"Body" style=
"margin: 0px"><BR>
32 <TABLE WIDTH=
617 HEIGHT=
270 BORDER=
1 CELLPADDING=
1 CELLSPACING=
2>
34 <TD WIDTH=
203 HEIGHT=
32>
35 <P class=
"Body" style=
"margin: 0px">Decorator(BRect int32 wlook, int32 wfeel, int32 wflags)
</P>
37 <TD WIDTH=
260 HEIGHT=
32>
38 <P class=
"Body" style=
"margin: 0px">~Decorator(void)
</P>
42 <TD WIDTH=
203 HEIGHT=
17>
43 <P class=
"Body" style=
"margin: 0px">void SetColors(color_set colors)
</P>
45 <TD WIDTH=
260 HEIGHT=
17>
46 <P class=
"Body" style=
"margin: 0px">void SetDriver(DisplayDriver *driver)
</P>
50 <TD WIDTH=
203 HEIGHT=
17>
51 <P class=
"Body" style=
"margin: 0px">void SetClose(bool is_down)
</P>
53 <TD WIDTH=
260 HEIGHT=
17>
54 <P class=
"Body" style=
"margin: 0px">void SetMinimize(bool is_down)
</P>
58 <TD WIDTH=
203 HEIGHT=
17>
59 <P class=
"Body" style=
"margin: 0px">void SetZoom(bool is_down)
</P>
61 <TD WIDTH=
260 HEIGHT=
17>
62 <P class=
"Body" style=
"margin: 0px">void SetFlags(int32 wflags)
</P>
66 <TD WIDTH=
203 HEIGHT=
17>
67 <P class=
"Body" style=
"margin: 0px">void SetFeel(int32 wfeel)
</P>
69 <TD WIDTH=
260 HEIGHT=
17>
70 <P class=
"Body" style=
"margin: 0px">void SetLook(int32 wlook)
</P>
74 <TD WIDTH=
203 HEIGHT=
17>
75 <P class=
"Body" style=
"margin: 0px">bool GetClose(void)
</P>
77 <TD WIDTH=
260 HEIGHT=
17>
78 <P class=
"Body" style=
"margin: 0px">bool GetMinimize(void)
</P>
82 <TD WIDTH=
203 HEIGHT=
17>
83 <P class=
"Body" style=
"margin: 0px">bool GetZoom(void)
</P>
85 <TD WIDTH=
260 HEIGHT=
17>
86 <P class=
"Body" style=
"margin: 0px">int32 GetLook(void)
</P>
90 <TD WIDTH=
203 HEIGHT=
18>
91 <P class=
"Body" style=
"margin: 0px">int32 GetFeel(void)
</P>
93 <TD WIDTH=
260 HEIGHT=
18>
94 <P class=
"Body" style=
"margin: 0px">int32 GetFlags(void)
</P>
98 <TD WIDTH=
203 HEIGHT=
17>
99 <P class=
"Body" style=
"margin: 0px">void SetTitle(const char *string)
</P>
101 <TD WIDTH=
260 HEIGHT=
17>
102 <P class=
"Body" style=
"margin: 0px">void SetFont(SFont *sf)
</P>
106 <TD WIDTH=
203 HEIGHT=
17>
107 <P class=
"Body" style=
"margin: 0px">int32 _ClipTitle(float width)
</P>
109 <TD WIDTH=
260 HEIGHT=
17>
110 <P class=
"Body" style=
"margin: 0px">void SetFocus(bool is_active)
</P>
114 <TD WIDTH=
203 HEIGHT=
17>
115 <P class=
"Body" style=
"margin: 0px">bool GetFocus(void)
</P>
117 <TD WIDTH=
260 HEIGHT=
17>
118 <P class=
"Body" style=
"margin: 0px">int32 _TitleWidth(void)
</P>
122 <P class=
"Body" style=
"margin: 0px"><BR>
125 Virtual Functions
</P>
126 <P class=
"Body" style=
"margin: 0px"><BR>
128 <TABLE WIDTH=
617 HEIGHT=
269 BORDER=
1 CELLPADDING=
1 CELLSPACING=
2>
130 <TD WIDTH=
203 HEIGHT=
17>
131 <P class=
"Body" style=
"margin: 0px">void MoveBy(float x, float y)
</P>
133 <TD WIDTH=
260 HEIGHT=
17>
134 <P class=
"Body" style=
"margin: 0px">void MoveBy(BPoint pt)
</P>
138 <TD WIDTH=
203 HEIGHT=
17>
139 <P class=
"Body" style=
"margin: 0px">void ResizeBy(float x, float y)
</P>
141 <TD WIDTH=
260 HEIGHT=
17>
142 <P class=
"Body" style=
"margin: 0px">void ResizeBy(BPoint pt)
</P>
146 <TD WIDTH=
203 HEIGHT=
17>
147 <P class=
"Body" style=
"margin: 0px">void Draw(BRect r)
</P>
149 <TD WIDTH=
260 HEIGHT=
17>
150 <P class=
"Body" style=
"margin: 0px">void Draw(void)
</P>
154 <TD WIDTH=
203 HEIGHT=
17>
155 <P class=
"Body" style=
"margin: 0px">void DrawClose(void)
</P>
157 <TD WIDTH=
260 HEIGHT=
17>
158 <P class=
"Body" style=
"margin: 0px">void DrawFrame(void)
</P>
162 <TD WIDTH=
203 HEIGHT=
17>
163 <P class=
"Body" style=
"margin: 0px">void DrawMinimize(void)
</P>
165 <TD WIDTH=
260 HEIGHT=
17>
166 <P class=
"Body" style=
"margin: 0px">void DrawTab(void)
</P>
170 <TD WIDTH=
203 HEIGHT=
17>
171 <P class=
"Body" style=
"margin: 0px">void DrawTitle(void)
</P>
173 <TD WIDTH=
260 HEIGHT=
17>
174 <P class=
"Body" style=
"margin: 0px">void DrawZoom(void)
</P>
178 <TD WIDTH=
203 HEIGHT=
17>
179 <P class=
"Body" style=
"margin: 0px">void _DrawClose(BRect r)
</P>
181 <TD WIDTH=
260 HEIGHT=
17>
182 <P class=
"Body" style=
"margin: 0px">void _DrawFrame(BRect r)
</P>
186 <TD WIDTH=
203 HEIGHT=
17>
187 <P class=
"Body" style=
"margin: 0px">void _DrawMinimize(BRect r)
</P>
189 <TD WIDTH=
260 HEIGHT=
17>
190 <P class=
"Body" style=
"margin: 0px">void _DrawTab(BRect r)
</P>
194 <TD WIDTH=
203 HEIGHT=
17>
195 <P class=
"Body" style=
"margin: 0px">void _DrawTitle(BRect r)
</P>
197 <TD WIDTH=
260 HEIGHT=
17>
198 <P class=
"Body" style=
"margin: 0px">void _DrawZoom(BRect r)
</P>
202 <TD WIDTH=
203 HEIGHT=
32>
203 <P class=
"Body" style=
"margin: 0px">SRegion GetFootprint(void)
</P>
205 <TD WIDTH=
260 HEIGHT=
32>
206 <P class=
"Body" style=
"margin: 0px">click_type Clicked(BPoint pt, int32 buttons, int32 modifiers)
</P>
210 <TD WIDTH=
203 HEIGHT=
17>
211 <P class=
"Body" style=
"margin: 0px">void _SetFocus(void)
</P>
213 <TD WIDTH=
260 HEIGHT=
17>
214 <P class=
"Body" style=
"margin: 0px">BRect SlideTab(float dx, float dy=
0)
</P>
218 <P class=
"Body" style=
"margin: 0px"><BR>
220 _ Indicates a protected member function
</P>
221 <P class=
"Body" style=
"margin: 0px"><BR>
222 Exported C Functions
</P>
223 <P class=
"Body" style=
"margin: 0px"><BR>
224 Decorator *create_decorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags)
</P>
225 <P class=
"Body" style=
"margin: 0px">float get_decorator_version(void)
</P>
226 <P class=
"Body" style=
"margin: 0px"><BR>
229 <P class=
"Body" style=
"margin: 0px"><BR>
231 <P class=
"Body" style=
"margin: 0px"> CLICK_NONE
</P>
232 <P class=
"Body" style=
"margin: 0px"> CLICK_ZOOM
</P>
233 <P class=
"Body" style=
"margin: 0px"> CLICK_CLOSE
</P>
234 <P class=
"Body" style=
"margin: 0px"> CLICK_MINIMIZE
</P>
235 <P class=
"Body" style=
"margin: 0px"> CLICK_TAB
</P>
236 <P class=
"Body" style=
"margin: 0px"> CLICK_MOVE
</P>
237 <P class=
"Body" style=
"margin: 0px"> CLICK_MOVETOBACK
</P>
238 <P class=
"Body" style=
"margin: 0px"> CLICK_MOVETOFRONT
</P>
239 <P class=
"Body" style=
"margin: 0px"> CLICK_RESIZE
</P>
240 <P class=
"Body" style=
"margin: 0px"> CLICK_RESIZE_L
</P>
241 <P class=
"Body" style=
"margin: 0px"> CLICK_RESIZE_T
</P>
242 <P class=
"Body" style=
"margin: 0px"> CLICK_RESIZE_R
</P>
243 <P class=
"Body" style=
"margin: 0px"> CLICK_RESIZE_B
</P>
244 <P class=
"Body" style=
"margin: 0px"> CLICK_RESIZE_LT
</P>
245 <P class=
"Body" style=
"margin: 0px"> CLICK_RESIZE_RT
</P>
246 <P class=
"Body" style=
"margin: 0px"> CLICK_RESIZE_LB
</P>
247 <P class=
"Body" style=
"margin: 0px"> CLICK_RESIZE_RB
</P>
248 <P class=
"Body" style=
"margin: 0px">}
</P>
249 <P class=
"Body" style=
"margin: 0px"><BR>
252 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">Decorator(BRect int32 wlook, int32 wfeel, int32 wflags)
</span></P>
253 <P class=
"Body" style=
"margin: 0px"><BR>
254 Sets up internal variables common to all decorators.
</P>
255 <P class=
"Body" style=
"margin: 0px"><BR>
256 1) Assign parameters to respective data members
</P>
257 <P class=
"Body" style=
"margin: 0px"><BR>
259 <span class=
"OBOS-Function-Def">~Decorator(void)
</span></P>
260 <P class=
"Body" style=
"margin: 0px"><BR>
262 <P class=
"Body" style=
"margin: 0px"><BR>
263 <span class=
"OBOS-Function-Def">void SetColors(color_set colors)
</span></P>
264 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void SetDriver(DisplayDriver *driver)
</span></P>
265 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void SetClose(bool is_down)
</span></P>
266 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void SetMinimize(bool is_down)
</span></P>
267 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void SetZoom(bool is_down)
</span></P>
268 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void SetFlags(int32 wflags)
</span></P>
269 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void SetFeel(int32 wfeel)
</span></P>
270 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void SetLook(int32 wlook)
</span></P>
271 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">bool GetClose(void)
</span></P>
272 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">bool GetMinimize(void)
</span></P>
273 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">bool GetZoom(void)
</span></P>
274 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">int32 GetLook(void)
</span></P>
275 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">int32 GetFeel(void)
</span></P>
276 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">int32 GetFlags(void)
</span></P>
277 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void SetTitle(const char *string)
</span></P>
278 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void SetFont(SFont *sf)
</span></P>
279 <P class=
"Body" style=
"margin: 0px"><BR>
280 These functions work with the internal members common to all Decorators - assigning them and returning them. Additionally, SetTitle() and SetFont() set the clip_font flag to true.
</P>
281 <P class=
"Body" style=
"margin: 0px"><BR>
282 <span class=
"OBOS-Function-Def">int32 _ClipTitle(float width)
</span></P>
283 <P class=
"Body" style=
"margin: 0px"><BR>
284 ClipTitle calculates how much of the title, in characters, can be displayed in the given width.
</P>
285 <P class=
"Body" style=
"margin: 0px"><BR>
286 1) Call StringWidth() on the title.
</P>
287 <P class=
"Body" style=
"margin: 0px">2) If the string's width is less than
<span style=
"font-style: italic">width
</span>, return the string's character count
</P>
288 <P class=
"Body" style=
"margin: 0px">3) while the character count to display is
> 0</P>
289 <P class=
"Body" style=
"margin: 0px"> a) calculate the string's width
</P>
290 <P class=
"Body" style=
"margin: 0px"> b) if the string's width is less than
<span style=
"font-style: italic">width
</span>, return the character count
</P>
291 <P class=
"Body" style=
"margin: 0px"> c) decrement the character count
</P>
292 <P class=
"Body" style=
"margin: 0px">4) If the loop completes itself without returning a value, it can't fit, so return
0.
</P>
293 <P class=
"Body" style=
"margin: 0px"><BR>
295 <span class=
"OBOS-Function-Def">void SetFocus(bool is_active)
</span></P>
296 <P class=
"Body" style=
"margin: 0px"><BR>
297 This is for handling color states when a window receives or loses the focus.
</P>
298 <P class=
"Body" style=
"margin: 0px"><BR>
299 1) Set focus flag to whatever is_active is.
</P>
300 <P class=
"Body" style=
"margin: 0px">2) call hook function _SetFocus()
</P>
301 <P class=
"Body" style=
"margin: 0px"><BR>
303 <span class=
"OBOS-Function-Def">bool GetFocus(void)
</span></P>
304 <P class=
"Body" style=
"margin: 0px"><BR>
305 Returns the focus state held by the decorator
</P>
306 <P class=
"Body" style=
"margin: 0px"><BR>
307 1) Return the focus flag
</P>
308 <P class=
"Body" style=
"margin: 0px"><BR>
310 <span class=
"OBOS-Function-Def">int32 _TitleWidth(void)
</span></P>
311 <P class=
"Body" style=
"margin: 0px"><BR>
312 Returns the character count of the title or
0 if it is NULL.
</P>
313 <P class=
"Body" style=
"margin: 0px"><BR>
315 <span class=
"OBOS-Function-Def">Virtual Functions
</span></P>
316 <P class=
"Body" style=
"margin: 0px"><BR>
317 Most of these functions have a default behavior which can be overridden, but are implemented to handle the more common implementations.
</P>
318 <P class=
"Body" style=
"margin: 0px"><BR>
319 <span class=
"OBOS-Function-Def">void MoveBy(float x, float y)
</span></P>
320 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void MoveBy(BPoint pt)
</span></P>
321 <P class=
"Body" style=
"margin: 0px"><BR>
322 Move all member rectangles of Decorator by the specified amount.
</P>
323 <P class=
"Body" style=
"margin: 0px"><BR>
325 <span class=
"OBOS-Function-Def">void ResizeBy(float x, float y)
</span></P>
326 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void ResizeBy(BPoint pt)
</span></P>
327 <P class=
"Body" style=
"margin: 0px"><BR>
328 Resize the client frame, window frame, and the tab frame (width only) by the specified amount. Button rectangles - close, minimize, and zoom - are not modified.
</P>
329 <P class=
"Body" style=
"margin: 0px"><BR>
331 <span class=
"OBOS-Function-Def">void Draw(BRect r)
</span></P>
332 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void Draw(void)
</span></P>
333 <P class=
"Body" style=
"margin: 0px"><BR>
334 Main drawing call which checks the intersection of the rectangle passed to it and draws all items which intersect it. Draw(void) simply performs drawing calls to draw the entire decorator's footprint area.
</P>
335 <P class=
"Body" style=
"margin: 0px"><BR>
336 1) Check for intersection with BRect which encompasses the decorator's footprint and return if no intersection.
</P>
337 <P class=
"Body" style=
"margin: 0px">2) Call _DrawFrame(intersection)
</P>
338 <P class=
"Body" style=
"margin: 0px">3) Call _DrawTab(intersection)
</P>
339 <P class=
"Body" style=
"margin: 0px"><BR>
341 <span class=
"OBOS-Function-Def">void DrawClose(void)
</span></P>
342 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">protected: void _DrawClose(BRect r)
</span></P>
343 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void DrawMinimize(void)
</span></P>
344 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">protected: void _DrawMinimize(BRect r)
</span></P>
345 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">void DrawZoom(void)
</span></P>
346 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">protected: void _DrawZoom(BRect r)
</span></P>
347 <P class=
"Body" style=
"margin: 0px"><BR>
348 Each of these is designed to utilize their respective button rectangles. The public (void) versions simply call the internal protected ones with the button rectangle. These protected versions are, by default, empty. The rectangle passed to them is the invalid area to be drawn, which is not necessarily the entire button's rectangle.
</P>
349 <P class=
"Body" style=
"margin: 0px"><BR>
351 <span class=
"OBOS-Function-Def">void DrawFrame(void)
</span></P>
352 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">protected: void _DrawFrame(BRect r)
</span></P>
353 <P class=
"Body" style=
"margin: 0px"><BR>
354 Draws the frame, if any. The public version amounts to _DrawFrame(framerect). The protected version is expected to not cover up the client frame when drawing. Any drawing within the clientrect member will end up being drawn over by the window's child views.
</P>
355 <P class=
"Body" style=
"margin: 0px"><BR>
357 <span class=
"OBOS-Function-Def">void DrawTab(void)
</span></P>
358 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">protected: void _DrawTab(BRect r)
</span></P>
359 <P class=
"Body" style=
"margin: 0px"><BR>
360 Draws the window's tab, if any. DrawTab() amounts to _DrawTab(tabrect). If window titles are displayed, the _DrawTitle call is expected to be made here. Button-drawing calls, assuming that a window's buttons are in the tab, should be made here, as well.
</P>
361 <P class=
"Body" style=
"margin: 0px"><BR>
363 <span class=
"OBOS-Function-Def">void DrawTitle(void)
</span></P>
364 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">protected: void _DrawTitle(BRect r)
</span></P>
365 <P class=
"Body" style=
"margin: 0px"><BR>
366 These cause the window's title to be drawn. DrawTitle() amounts to _DrawTitle(titlerect).
</P>
367 <P class=
"Body" style=
"margin: 0px"><BR>
369 <span class=
"OBOS-Function-Def">void _SetFocus(void)
</span></P>
370 <P class=
"Body" style=
"margin: 0px"><BR>
371 This hook function is primarily used to change colors used when a window changes focus states and is called immediately after the state is changed. If, for example, a decorator does not use OpenBeOS' GUI color set, it would change its drawing colors to reflect the change in focus.
</P>
372 <P class=
"Body" style=
"margin: 0px"><BR>
374 <span class=
"OBOS-Function-Def">SRegion GetFootprint(void)
</span></P>
375 <P class=
"Body" style=
"margin: 0px"><BR>
376 This returns the
"footprint" of the decorator, i.e. the area which is occupied by the window which is is the border surrounding the main client rectangle. It is possible to have oddly-shaped window borders, like ellipses and circles, but the resulting performance hit would reduce the said decorator to a novelty and not something useable. All versions are to construct an SRegion which the border occupies. This footprint is permitted to include the client rectangle area, but this area must not be actually drawn upon by the decorator itself. The default version returns the frame which encompasses all other rectangles - the
"frame" member which belongs to its window border.
</P>
377 <P class=
"Body" style=
"margin: 0px"><BR>
379 <span class=
"OBOS-Function-Def">click_type Clicked(BPoint pt, int32 buttons, int32 modifiers)
</span></P>
380 <P class=
"Body" style=
"margin: 0px"><BR>
381 Clicked() performs hit testing for the decorator, given input conditions. This function is required by ALL subclasses expecting to do more than display itself. The return type will cause the server to take the appropriate actions, such as close the window, get ready to move it, etc.
</P>
382 <P class=
"Body" style=
"margin: 0px"><BR>
384 <span class=
"OBOS-Function-Def">BRect SlideTab(float dx, dy=
0)
</span></P>
385 <P class=
"Body" style=
"margin: 0px"><BR>
386 SlideTab is implemented only for those decorators which allow the user to somehow slide the tab (if there is one) along the window. Currently, only the horizontal direction is supported. It returns the rectangle of the invalid region which needs redrawn as a result of the slide.
</P>
387 <P class=
"Body" style=
"margin: 0px"><BR>
388 <span class=
"OBOS-Function-Def">extern
"C" Decorator *create_decorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags)
</span></P>
389 <P class=
"Body" style=
"margin: 0px"><BR>
390 Required export function which simply allocates an instance of the decorator and returns it.
</P>
391 <P class=
"Body" style=
"margin: 0px"><BR>
392 <span class=
"OBOS-Function-Def">extern
"C" float get_decorator_version(void)
</span></P>
393 <P class=
"Body" style=
"margin: 0px"><span class=
"Default"><BR>
394 This should, for now, return
1.00.
</span></P>
395 <P class=
"Body" style=
"margin: 0px"><span class=
"Default"><BR>
397 <DIV class=
"layer" id=
"Layer 1">