/* RedrawFocusOutline redraws the focus rectangle as appropriate for the current focus, activation, and drawing state. This routine ensures the focus rectangle drawing is only performed once in any particular focus state. */ static void RedrawFocusOutline(YASTControlVars *varsp) { if (varsp->fDrawFocusBox) { /* drawing is on */ if (varsp->fFocusDrawState != (varsp->fIsActive && varsp->fInFocus)) { /* state changed */ varsp->fFocusDrawState = (varsp->fIsActive && varsp->fInFocus); SetPort(varsp->fGrafPtr); DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fFocusDrawState); } } else if (varsp->fFocusDrawState) { /* was drawn, but drawing has been turned off */ varsp->fFocusDrawState = false; SetPort(varsp->fGrafPtr); DrawThemeFocusRect(&varsp->fRFocusOutline, false); } }
// -------------------------------------------------------------------------------------- static void drawFrameAndFocus(ListHandle list, Boolean active, WindowRef window) { Rect borderRect; GetListViewBounds(list, &borderRect); borderRect.right += kScrollBarWidth; if (active) { SetThemeWindowBackground(window, kThemeBrushModelessDialogBackgroundActive, false); DrawThemeListBoxFrame(&borderRect, kThemeStateActive); DrawThemeFocusRect(&borderRect, true); } else { SetThemeWindowBackground(window, kThemeBrushModelessDialogBackgroundInactive, false); DrawThemeFocusRect(&borderRect, false); DrawThemeListBoxFrame(&borderRect, kThemeStateInactive); } }
// -------------------------------------------------------------------------------------- void AdjustControls(WindowRef prefsWindow) { Rect contentRect, listViewRect; ControlRef rootControl, userPane; SInt16 userPaneWidth, userPaneHeight; UInt16 panelIndex; ListHandle iconList; short oldListHeight, newListHeight; GetWindowBounds(prefsWindow, kWindowContentRgn, &contentRect); userPaneWidth = (contentRect.right - contentRect.left) - (gWindowEdgeSpacing + kListWidth + kScrollBarWidth + kControlSpacing) - (kSizeBoxWidth + gMinimumSpacing); userPaneHeight = (contentRect.bottom - contentRect.top) - gWindowEdgeSpacing - (kSizeBoxWidth + gMinimumSpacing); GetRootControl(prefsWindow, &rootControl); for (panelIndex = 1; panelIndex <= kNumberOfRows; panelIndex++) { GetIndexedSubControl(rootControl, panelIndex, &userPane); SizeControl(userPane, userPaneWidth, userPaneHeight); } GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, &iconList); GetListViewBounds(iconList, &listViewRect); oldListHeight = listViewRect.bottom - listViewRect.top; newListHeight = (contentRect.bottom - contentRect.top) - gWindowEdgeSpacing - gWindowEdgeSpacing; newListHeight -= newListHeight % kCellHeight; // make the list height a multiple if (newListHeight > kMaxListHeight) // of the cell height and don't make newListHeight = kMaxListHeight; // it bigger than we have cells for if (newListHeight != oldListHeight) { Rect invalRect; listViewRect.right += kScrollBarWidth; // we will need to redraw the scroll bar as well // we need to invalidate the area where a cell will be drawn or erased if (newListHeight > oldListHeight) SetRect(&invalRect, listViewRect.left - 5, listViewRect.bottom - 5, listViewRect.right + 5, contentRect.bottom); // the extra 5 pixels are // to cause the bottom of the list box frame to get erased else SetRect(&invalRect, listViewRect.left - 5, gWindowEdgeSpacing + newListHeight - 5, listViewRect.right + 5, contentRect.bottom); // the drawing section is as far down as possible to avoid any screen flickering DrawThemeFocusRect(&listViewRect, false); // erase the focus rectangle LSize(kListWidth, newListHeight, iconList); // resize the List drawFrameAndFocus(iconList, true, prefsWindow); // draw the focus rectangle back InvalWindowRect(prefsWindow, &invalRect); } #if TARGET_API_MAC_OS8 CalculateBalloonHelpRects(prefsWindow); #endif } // AdjustControls