How to Draw a Horizontal Line on the Middle Grid Point in a 9-Grid Proxy Widget (InDesign SDK)
Hi all,
I’m working on a custom plugin for InDesign using the SDK and am trying to customize the behavior of a 9-grid reference point proxy widget (similar to the one used in the Transform panel). My goal is to display a vertical line spanning the middle column (Top Center, Center, Bottom Center points: 1, 4, 7) when one mode is active ("Height Only"), and a horizontal line spanning the middle row (Center Left, Center, Center Right points: 3, 4, 5) when another mode is active ("Width Only"). Currently, the proxy widget consistently activates only the middle column (1, 4, 7) in both modes, and I can’t get the horizontal line to activate the middle row.
I’m using the IProxyWidgetAttributes interface to set the appearance (e.g., kLine, kRow, or kColumn) and the active position (e.g., kCenterReferencePoint). I’ve implemented a custom method to handle the orientation, but it only works for the vertical (middle column) case. Here’s a generalized version of my approach:
private:
void SetCustomProxyOrientation(const WidgetID& widgetId, bool16 isVertical, const bool16 doEnable) {
do {
InterfacePtr<IPanelControlData> panelControl(this, UseDefaultIID());
InterfacePtr<IControlView> widgetView = panelControl->FindWidget(widgetId);
ASSERT(widgetView);
InterfacePtr<IProxyWidgetAttributes> proxyAttrs(widgetView, UseDefaultIID());
// Set to line appearance with center as anchor
proxyAttrs->SetProxyAppearance(IReferencePointData::kLine);
proxyAttrs->SetProxyPosition(IReferencePointData::kCenterReferencePoint);
// Attempt to adjust orientation
if (isVertical) {
// Vertical alignment (middle column: 1, 4, 7) works fine
// Currently active in both modes
} else {
// Horizontal alignment (middle row: 3, 4, 5) fails, still activates middle column
// Need help to reposition or reorient the line
}
// Notify UI update
InterfacePtr<ISubject> subject(widgetView, UseDefaultIID());
if (subject) {
subject->Change(kWidgetPositionChangedMessage, IID_IPROXYWIDGETATTRIBUTES, widgetView);
}
} while (false);
// Enable/disable the widget
// [EnableWidget logic omitted for brevity]
}
Questions:
- Is there a method in IProxyWidgetAttributes or another interface that allows repositioning or reorienting the kLine appearance to activate the middle row (3, 4, 5) instead of the middle column (1, 4, 7)?
- If not supported natively, what would be the recommended approach to achieve a horizontal line on the middle row? For example, would creating a custom widget with individual controls be the best solution, and how might I implement it?
I’ve tested this with kLine and kCenterReferencePoint, and the middle column (1, 4, 7) is active in both modes, but I need the middle row (3, 4, 5) for the horizontal case. Any insights, documentation references, or sample approaches to fix the horizontal alignment would be greatly appreciated!
