Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

calcclrc.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: calcclrc.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * History: 00007 * 10-22-90 MikeHar Ported functions from Win 3.0 sources. 00008 * 01-Feb-1991 mikeke Added Revalidation code 00009 \***************************************************************************/ 00010 00011 #include "precomp.h" 00012 #pragma hdrstop 00013 00014 00015 /****************************** Module Header ******************************\ 00016 * xxxCalcClientRect 00017 * 00018 * 10-22-90 MikeHar Ported functions from Win 3.0 sources. 00019 \****************************** Module Header ******************************/ 00020 00021 void xxxCalcClientRect( 00022 PWND pwnd, 00023 LPRECT lprc, 00024 BOOL fHungRedraw) 00025 { 00026 int cxFrame, yTopOld; 00027 RECT rcTemp; 00028 PMENU pMenu; 00029 TL tlpmenu; 00030 int cBorders; 00031 BOOL fEmptyClient; 00032 BYTE bFramePresent; 00033 00034 CheckLock(pwnd); 00035 UserAssert(IsWinEventNotifyDeferredOK()); 00036 00037 bFramePresent = TestWF(pwnd, WFFRAMEPRESENTMASK); 00038 00039 /* 00040 * Clear all the frame bits. NOTE: The HIBYTE of all these #defines 00041 * must stay the same for this line to work. 00042 */ 00043 ClrWF(pwnd, WFFRAMEPRESENTMASK); 00044 00045 // 00046 // We need to clear the client border bits also. Otherwise, when the 00047 // window gets really small, the client border will draw over the menu 00048 // and caption. 00049 // 00050 ClrWF(pwnd, WFCEPRESENT); 00051 00052 /* 00053 * If the window is iconic, the client area is empty. 00054 */ 00055 if (TestWF(pwnd, WFMINIMIZED)) { 00056 // SetRectEmpty(lprc); 00057 // We must make it an empty rectangle. 00058 // But, that empty rectangle should be at the top left corner of the 00059 // window rect. Else, ScreenToClient() will return bad values. 00060 lprc->right = lprc->left; 00061 lprc->bottom = lprc->top; 00062 goto CalcClientDone; 00063 } 00064 00065 // Save rect into rcTemp for easy local calculations. 00066 CopyRect(&rcTemp, lprc); 00067 00068 // Save the top so we'll know how tall the caption was 00069 yTopOld = rcTemp.top; 00070 00071 // Adjustment for the caption 00072 if (TestWF(pwnd, WFBORDERMASK) == LOBYTE(WFCAPTION)) 00073 { 00074 SetWF(pwnd, WFCPRESENT); 00075 00076 rcTemp.top += GetCaptionHeight(pwnd); 00077 } 00078 00079 // Subtract out window borders 00080 cBorders = GetWindowBorders(pwnd->style, pwnd->ExStyle, TRUE, FALSE); 00081 cxFrame = cBorders * SYSMETFROMPROCESS(CXBORDER); 00082 InflateRect(&rcTemp, -cxFrame, -cBorders * SYSMETFROMPROCESS(CYBORDER)); 00083 00084 if (!TestwndChild(pwnd) && (pMenu = pwnd->spmenu)) { 00085 SetWF(pwnd, WFMPRESENT); 00086 if (!fHungRedraw) { 00087 ThreadLockAlways(pMenu, &tlpmenu); 00088 rcTemp.top += xxxMenuBarCompute(pMenu, pwnd, rcTemp.top - yTopOld, 00089 cxFrame, rcTemp.right - rcTemp.left); 00090 ThreadUnlock(&tlpmenu); 00091 } 00092 } 00093 /* 00094 * We should have cleared WFMPRESENT in the else case here. Win9x doesn't do 00095 * it either. Any code checking this flag will do the wrong thing... 00096 * It seems that it's pretty unsual for apps to remove the menu.... 00097 * No code checking this flag can assume that pwnd->spmenu is not NULL -- we 00098 * would need to clear it way earlier (at unlock time) for such assumption to hold true. 00099 */ 00100 00101 // 00102 // Fix for B#1425 -- Sizing window really small used to move children's 00103 // rects because the client calculations were wrong. So we make the 00104 // bottom of the client match up with the top (the bottom of the menu 00105 // bar). 00106 // 00107 fEmptyClient = FALSE; 00108 00109 if (rcTemp.top >= rcTemp.bottom) { 00110 rcTemp.bottom = rcTemp.top; 00111 fEmptyClient = TRUE; 00112 } 00113 00114 // 00115 // BOGUS BOGUS BOGUS 00116 // Hack for Central Point PC Tools. 00117 // Possibly for M5 only. 00118 // B#8445 00119 // 00120 // They check for div-by-zero all over, but they jump to the wrong place 00121 // if a zero divisor is encountered, and end up faulting anyway. So this 00122 // code path was never tested basically. There's a period when starting 00123 // up where the window rect of their drives ribbon is empty. In Win3.x, 00124 // the client would be shrunk to account for the border it had, and it 00125 // would look like it wasn't empty because the width would be negative, 00126 // signed! So we version-switch this code, since other apps have 00127 // reported the non-emptiness as an annoying bug. 00128 // 00129 if (TestWF(pwnd, WFWIN40COMPAT) && (rcTemp.left >= rcTemp.right)) { 00130 rcTemp.right = rcTemp.left; 00131 fEmptyClient = TRUE; 00132 } 00133 00134 if (fEmptyClient) 00135 goto ClientCalcEnd; 00136 00137 // 00138 // Subtract client edge if we have space 00139 // 00140 if ( TestWF(pwnd, WEFCLIENTEDGE) && 00141 (rcTemp.right - rcTemp.left >= (2 * SYSMETFROMPROCESS(CXEDGE))) && 00142 (rcTemp.bottom - rcTemp.top >= (2 * SYSMETFROMPROCESS(CYEDGE))) ) { 00143 SetWF(pwnd, WFCEPRESENT); 00144 InflateRect(&rcTemp, -SYSMETFROMPROCESS(CXEDGE), -SYSMETFROMPROCESS(CYEDGE)); 00145 } 00146 00147 // 00148 // Subtract scrollbars 00149 // Note compatibility with 3.1: 00150 // * You don't get a horizontal scrollbar unless you have MORE 00151 // space (> ) in your client than you need for one. 00152 // * You get a vertical scrollbar if you have AT LEAST ENOUGH 00153 // space (>=) in your client for one. 00154 // 00155 if (TestWF(pwnd, WFHSCROLL) && (rcTemp.bottom - rcTemp.top > SYSMETFROMPROCESS(CYHSCROLL))) { 00156 SetWF(pwnd, WFHPRESENT); 00157 if (!fHungRedraw) { 00158 rcTemp.bottom -= SYSMETFROMPROCESS(CYHSCROLL); 00159 } 00160 } 00161 00162 if (TestWF(pwnd, WFVSCROLL) && (rcTemp.right - rcTemp.left >= SYSMETFROMPROCESS(CXVSCROLL))) { 00163 SetWF(pwnd, WFVPRESENT); 00164 if (!fHungRedraw) { 00165 #ifdef USE_MIRRORING 00166 if ((!!TestWF(pwnd, WEFLEFTSCROLL)) ^ (!!TestWF(pwnd, WEFLAYOUTRTL))) 00167 #else 00168 if (TestWF(pwnd, WEFLEFTSCROLL)) 00169 #endif 00170 rcTemp.left += SYSMETFROMPROCESS(CXVSCROLL); 00171 else 00172 rcTemp.right -= SYSMETFROMPROCESS(CXVSCROLL); 00173 } 00174 } 00175 00176 ClientCalcEnd: 00177 00178 CopyRect(lprc, &rcTemp); 00179 00180 CalcClientDone: 00181 if (FWINABLE() && (bFramePresent != TestWF(pwnd, WFFRAMEPRESENTMASK))) { 00182 xxxWindowEvent(EVENT_OBJECT_REORDER, pwnd, OBJID_WINDOW, 0, WEF_USEPWNDTHREAD); 00183 } 00184 } 00185 00186 /***************************************************************************\ 00187 * 00188 * UpdateClientRect() 00189 * 00190 * Make sure the client rect reflects the window styles correctly 00191 * 00192 \***************************************************************************/ 00193 00194 void xxxUpdateClientRect( 00195 PWND pwnd) 00196 { 00197 RECT rc; 00198 00199 CopyRect(&rc, &pwnd->rcWindow); 00200 xxxCalcClientRect(pwnd, &rc, FALSE); 00201 CopyRect(&pwnd->rcClient, &rc); 00202 }

Generated on Sat May 15 19:39:19 2004 for test by doxygen 1.3.7