💾 Archived View for lofi.haiku-os.org › docs › develop › servers › app_server › Decorator.gmi captured on 2024-08-25 at 00:21:35. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-28)
-=-=-=-=-=-=-
Decorators provide the actual drawing for a window’s looks.
_ Indicates a protected member function
Sets up internal variables common to all decorators.
1. Assign parameters to respective data members
Empty.
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.
ClipTitle calculates how much of the title, in characters, can be displayed in the given width.
1. Call StringWidth() on the title.
2. If the string’s width is less thanwidth, return the string’s character count
3. while the character count to display is > 0
1. calculate the string’s width
2. if the string’s width is less than width, return the character count
3. decrement the character count
4. If the loop completes itself without returning a value, it can’t fit, so return 0.
This is for handling color states when a window receives or loses the focus.
1. Set focus flag to whatever is_active is.
2. call hook function _SetFocus()
Returns the focus state held by the decorator
1. Return the focus flag
Returns the character count of the title or 0 if it is NULL.
Most of these functions have a default behavior which can be overridden, but are implemented to handle the more common implementations.
Move all member rectangles of Decorator by the specified amount.
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.
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.
1. Check for intersection with BRect which encompasses the decorator’s footprint and return if no intersection.
2. Call _DrawFrame(intersection)
3. Call _DrawTab(intersection)
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.
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.
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.
These cause the window’s title to be drawn. DrawTitle() amounts to _DrawTitle(titlerect).
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.
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.
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.
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.
Required export function which simply allocates an instance of the decorator and returns it.
This should, for now, return 1.00.