| 10160 | |
| 10161 | |
| 10162 | void GuiType::GetTabDisplayAreaRect(HWND aTabControlHwnd, RECT &aRect) |
| 10163 | // Gets coordinates of tab control's display area relative to parent window's client area. |
| 10164 | { |
| 10165 | RECT rect; |
| 10166 | GetClientRect(aTabControlHwnd, &rect); // Used because the coordinates of its upper-left corner are (0,0). |
| 10167 | DWORD style = GetWindowLong(aTabControlHwnd, GWL_STYLE); |
| 10168 | if (style & TCS_BUTTONS) // Workarounds are needed for TCS_BUTTONS. |
| 10169 | { |
| 10170 | RECT item_rect; |
| 10171 | TabCtrl_GetItemRect(aTabControlHwnd, 0, &item_rect); |
| 10172 | int row_count = TabCtrl_GetRowCount(aTabControlHwnd); |
| 10173 | const int offset = 3; // The margin between buttons seems to be 3 pixels. |
| 10174 | if (style & TCS_VERTICAL) |
| 10175 | { |
| 10176 | // TabCtrl_AdjustRect would not work for these cases. |
| 10177 | int width = (item_rect.right - item_rect.left + offset) * row_count; |
| 10178 | if (style & TCS_RIGHT) |
| 10179 | rect.right -= width; |
| 10180 | else |
| 10181 | rect.left += width; |
| 10182 | } |
| 10183 | else |
| 10184 | { |
| 10185 | int height = (item_rect.bottom - item_rect.top + offset) * row_count; |
| 10186 | if (style & TCS_BOTTOM) |
| 10187 | // TabCtrl_AdjustRect would not work for this case. |
| 10188 | rect.bottom -= height; |
| 10189 | else |
| 10190 | // TabCtrl_AdjustRect plus an adjustment of bottom += 3 would work, |
| 10191 | // but it's easier to handle this case alongside TCS_BOTTOM (above). |
| 10192 | rect.top += height; |
| 10193 | } |
| 10194 | } |
| 10195 | else |
| 10196 | { |
| 10197 | TabCtrl_AdjustRect(aTabControlHwnd, FALSE, &rect); // Retrieve the area beneath the tabs. |
| 10198 | rect.left -= 2; // Testing shows that X (but not Y) is off by exactly 2. |
| 10199 | } |
| 10200 | MapWindowPoints(aTabControlHwnd, mHwnd, (LPPOINT)&rect, 2); // Convert tab-control-relative coordinates to Gui-relative. |
| 10201 | aRect.left = rect.left; |
| 10202 | aRect.right = rect.right; |
| 10203 | aRect.top = rect.top; |
| 10204 | aRect.bottom = rect.bottom; |
| 10205 | } |
| 10206 | |
| 10207 | |
| 10208 |
nothing calls this directly
no outgoing calls
no test coverage detected