| 1 | /* $Id: winnonclient.cpp,v 1.3 2000-01-01 14:57:38 cbratschi Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 menu API functions for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998 Sander van Leeuwen (Port from Wine)
|
|---|
| 6 | *
|
|---|
| 7 | * Parts ported from Wine: (window\nonclient.c)
|
|---|
| 8 | * Copyright 1994 Alexandre Julliard
|
|---|
| 9 | *
|
|---|
| 10 | *
|
|---|
| 11 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 12 | *
|
|---|
| 13 | */
|
|---|
| 14 | #include <os2win.h>
|
|---|
| 15 |
|
|---|
| 16 | /* Some useful macros */
|
|---|
| 17 | #define HAS_DLGFRAME(style,exStyle) \
|
|---|
| 18 | (((exStyle) & WS_EX_DLGMODALFRAME) || \
|
|---|
| 19 | (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
|
|---|
| 20 |
|
|---|
| 21 | #define HAS_THICKFRAME(style) \
|
|---|
| 22 | (((style) & WS_THICKFRAME) && \
|
|---|
| 23 | !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
|
|---|
| 24 |
|
|---|
| 25 | #define HAS_FIXEDFRAME(style,exStyle) \
|
|---|
| 26 | (((((exStyle) & WS_EX_DLGMODALFRAME) || \
|
|---|
| 27 | ((style) & WS_DLGFRAME)) && ((style) & WS_BORDER)) && \
|
|---|
| 28 | !((style) & WS_THICKFRAME))
|
|---|
| 29 |
|
|---|
| 30 | /* win31 style (simple border) in win95 look */
|
|---|
| 31 | #define HAS_CLASSICBORDER(style,exStyle) \
|
|---|
| 32 | (!((exStyle) & WS_EX_STATICEDGE) && !((exStyle) & WS_EX_CLIENTEDGE) && \
|
|---|
| 33 | !((style) & WS_THICKFRAME) && !((style) & WS_DLGFRAME) && \
|
|---|
| 34 | ((style) & WS_BORDER))
|
|---|
| 35 |
|
|---|
| 36 | #define HAS_SIZEFRAME(style) \
|
|---|
| 37 | (((style) & WS_THICKFRAME) && \
|
|---|
| 38 | !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
|
|---|
| 39 |
|
|---|
| 40 | #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
|
|---|
| 41 |
|
|---|
| 42 | #define ON_LEFT_BORDER(hit) \
|
|---|
| 43 | (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
|
|---|
| 44 | #define ON_RIGHT_BORDER(hit) \
|
|---|
| 45 | (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
|
|---|
| 46 | #define ON_TOP_BORDER(hit) \
|
|---|
| 47 | (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
|
|---|
| 48 | #define ON_BOTTOM_BORDER(hit) \
|
|---|
| 49 | (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
|
|---|
| 50 |
|
|---|
| 51 | /******************************************************************************
|
|---|
| 52 | * NC_AdjustRectOuter95
|
|---|
| 53 | *
|
|---|
| 54 | * Computes the size of the "outside" parts of the window based on the
|
|---|
| 55 | * parameters of the client area.
|
|---|
| 56 | *
|
|---|
| 57 | + PARAMS
|
|---|
| 58 | * LPRECT16 rect
|
|---|
| 59 | * DWORD style
|
|---|
| 60 | * BOOL32 menu
|
|---|
| 61 | * DWORD exStyle
|
|---|
| 62 | *
|
|---|
| 63 | * NOTES
|
|---|
| 64 | * "Outer" parts of a window means the whole window frame, caption and
|
|---|
| 65 | * menu bar. It does not include "inner" parts of the frame like client
|
|---|
| 66 | * edge, static edge or scroll bars.
|
|---|
| 67 | *
|
|---|
| 68 | * Revision history
|
|---|
| 69 | * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
|
|---|
| 70 | * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
|
|---|
| 71 | *
|
|---|
| 72 | * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
|---|
| 73 | * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
|
|---|
| 74 | * NC_AdjustRectInner95 and added handling of Win95 styles.
|
|---|
| 75 | *
|
|---|
| 76 | *****************************************************************************/
|
|---|
| 77 |
|
|---|
| 78 | static void
|
|---|
| 79 | NC_AdjustRectOuter95 (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle)
|
|---|
| 80 | {
|
|---|
| 81 | if(style & WS_ICONIC) return;
|
|---|
| 82 |
|
|---|
| 83 | /* Decide if the window will be managed (see CreateWindowEx) */
|
|---|
| 84 | #if 0
|
|---|
| 85 | if (!(Options.managed && !(style & WS_CHILD) &&
|
|---|
| 86 | ((style & (WS_DLGFRAME | WS_THICKFRAME)) ||
|
|---|
| 87 | (exStyle & WS_EX_DLGMODALFRAME))))
|
|---|
| 88 | #else
|
|---|
| 89 | if (!(style & WS_CHILD) &&
|
|---|
| 90 | ((style & (WS_DLGFRAME | WS_THICKFRAME)) ||
|
|---|
| 91 | (exStyle & WS_EX_DLGMODALFRAME)))
|
|---|
| 92 | #endif
|
|---|
| 93 | {
|
|---|
| 94 | if (HAS_FIXEDFRAME( style, exStyle ))
|
|---|
| 95 | InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
|
|---|
| 96 | else
|
|---|
| 97 | {
|
|---|
| 98 | if (HAS_SIZEFRAME(style))
|
|---|
| 99 | InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
|
|---|
| 100 | #if 0
|
|---|
| 101 | if (style & WS_BORDER)
|
|---|
| 102 | InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
|---|
| 103 | #endif
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | if ((style & WS_CAPTION) == WS_CAPTION)
|
|---|
| 107 | {
|
|---|
| 108 | if (exStyle & WS_EX_TOOLWINDOW)
|
|---|
| 109 | rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
|
|---|
| 110 | else
|
|---|
| 111 | rect->top -= GetSystemMetrics(SM_CYCAPTION);
|
|---|
| 112 | }
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | if (menu)
|
|---|
| 116 | rect->top -= GetSystemMetrics(SM_CYMENU);
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | /******************************************************************************
|
|---|
| 121 | * NC_AdjustRectInner95
|
|---|
| 122 | *
|
|---|
| 123 | * Computes the size of the "inside" part of the window based on the
|
|---|
| 124 | * parameters of the client area.
|
|---|
| 125 | *
|
|---|
| 126 | + PARAMS
|
|---|
| 127 | * LPRECT16 rect
|
|---|
| 128 | * DWORD style
|
|---|
| 129 | * DWORD exStyle
|
|---|
| 130 | *
|
|---|
| 131 | * NOTES
|
|---|
| 132 | * "Inner" part of a window means the window frame inside of the flat
|
|---|
| 133 | * window frame. It includes the client edge, the static edge and the
|
|---|
| 134 | * scroll bars.
|
|---|
| 135 | *
|
|---|
| 136 | * Revision history
|
|---|
| 137 | * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
|
|---|
| 138 | * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
|
|---|
| 139 | *
|
|---|
| 140 | * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
|---|
| 141 | * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
|
|---|
| 142 | * NC_AdjustRectInner95 and added handling of Win95 styles.
|
|---|
| 143 | *
|
|---|
| 144 | *****************************************************************************/
|
|---|
| 145 |
|
|---|
| 146 | static void
|
|---|
| 147 | NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle)
|
|---|
| 148 | {
|
|---|
| 149 | if(style & WS_ICONIC) return;
|
|---|
| 150 |
|
|---|
| 151 | if (exStyle & WS_EX_CLIENTEDGE)
|
|---|
| 152 | InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
|
|---|
| 153 |
|
|---|
| 154 | if (exStyle & WS_EX_STATICEDGE)
|
|---|
| 155 | InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
|---|
| 156 |
|
|---|
| 157 | if (HAS_CLASSICBORDER(style, exStyle))
|
|---|
| 158 | InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER ));
|
|---|
| 159 |
|
|---|
| 160 | if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
|
|---|
| 161 | if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | /***********************************************************************
|
|---|
| 165 | * AdjustWindowRectEx (USER.454)
|
|---|
| 166 | */
|
|---|
| 167 | BOOL WIN32API AdjustWindowRectEx(LPRECT rect, DWORD style,
|
|---|
| 168 | BOOL menu, DWORD exStyle )
|
|---|
| 169 | {
|
|---|
| 170 | /* Correct the window style */
|
|---|
| 171 | if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
|
|---|
| 172 | style |= WS_CAPTION;
|
|---|
| 173 | style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
|
|---|
| 174 | exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
|
|---|
| 175 | WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
|
|---|
| 176 | if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
|
|---|
| 177 |
|
|---|
| 178 | NC_AdjustRectOuter95( rect, style, menu, exStyle );
|
|---|
| 179 | NC_AdjustRectInner95( rect, style, exStyle );
|
|---|
| 180 |
|
|---|
| 181 | return TRUE;
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | /***********************************************************************
|
|---|
| 185 | * AdjustWindowRect (USER32.2)
|
|---|
| 186 | */
|
|---|
| 187 | BOOL WIN32API AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
|
|---|
| 188 | {
|
|---|
| 189 | return AdjustWindowRectEx( rect, style, menu, 0 );
|
|---|
| 190 | }
|
|---|