class IColorSwatchRenamer
- Description:
- This class is an interface for changing the name of a color
swatch. Previously the only way to change the name of a swatch was
to reinitialize it with a new GetIColorSwatch call, and this would
not help with swatches that were already being displayed in a color
selector dialog. Using this new interface, developers can change
the name of a swatch and
simultaneously change the name of a color selector dialog that's
associated with the swatch. An example of its usage can be seen
below :-
It's used in Editable Poly as follows - when the user changes the
radio button that affects whether our swatch is used as a "Select
by Color" or a "Select by Illumination" swatch, the following code
is used to update the swatch.
These first three lines are adequate when the color selector is not
being displayed:
mpEPoly->getParamBlock()->GetValue (ep_vert_sel_color, t,
selByColor,
mpEPoly->FOREVER); getParamBlock()->GetValue
(ep_vert_color_selby, t,
mpEPoly->byIllum, FOREVER);
iCol = GetIColorSwatch (GetDlgItem (hWnd, IDC_VERT_SELCOLOR),
selByColor,
GetString (byIllum ? IDS_SEL_BY_ILLUM :
IDS_SEL_BY_COLOR));
That will update the swatch to the correct name and color. However,
if the
color selector is being displayed, we need to use the new interface
to ensure
that the name is promptly updated in the UI:
pInterface = iCol->GetInterface
(COLOR_SWATCH_RENAMER_INTERFACE_51);
if (pInterface) {
IColorSwatchRenamer *pRenamer =
(IColorSwatchRenamer *)
pInterface;
pRenamer->SetName (GetString (byIllum ? IDS_SEL_BY_ILLUM :
IDS_SEL_BY_COLOR));
}
Finally, don't forget to release the swatch: ReleaseIColorSwatch
(iCol);