-/* Computes position of corners of client area (drawable area) of a window
- * based on the provided window Rect (outer position including decorations)
- * and based on the style of the window in question. If the window pointer
- * or the window handle is NULL, a fully decorated window (caption and
- * border) is assumed.
- * Furthermore, if wantPosOutside is set to true, the output client Rect
- * will follow freeGLUT's window specification convention in which the
- * top-left corner is at the outside of the window, the size
- * (rect.right-rect.left,rect.bottom-rect.top) is the size of the drawable
- * area.
- */
-void fghComputeClientAreaFromWindowRect( const SFG_Window *window, RECT *windowRect, BOOL wantPosOutside )
-{
- DWORD windowStyle = 0;
- int xBorderWidth = 0, yBorderWidth = 0;
-
- if (window && window->Window.Handle)
- windowStyle = GetWindowLong(window->Window.Handle, GWL_STYLE);
- else
- windowStyle = WS_OVERLAPPEDWINDOW;
-
- /* If window has title bar, correct rect for it */
- if (windowStyle & WS_MAXIMIZEBOX) /* Need to query for WS_MAXIMIZEBOX to see if we have a title bar, the WS_CAPTION query is also true for a WS_DLGFRAME only... */
- {
- if (wantPosOutside)
- windowRect->bottom -= GetSystemMetrics( SM_CYCAPTION );
- else
- windowRect->top += GetSystemMetrics( SM_CYCAPTION );
- }
-
- /* get width of window's borders (frame), correct rect for it.
- * Note, borders can be of zero width if style does not specify borders
- */
- fghGetBorderWidth(windowStyle, &xBorderWidth, &yBorderWidth);
- if (wantPosOutside)
- {
- windowRect->right -= xBorderWidth * 2;
- windowRect->bottom -= yBorderWidth * 2;
- }
- else
- {
- windowRect->left += xBorderWidth;
- windowRect->right -= xBorderWidth;
- windowRect->top += yBorderWidth;
- windowRect->bottom -= yBorderWidth;
- }
-}