InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PreviewableColorListObserver Class Reference
Inheritance diagram for PreviewableColorListObserver:
CObserverIObserverIPMUnknown

Public Member Functions

 PreviewableColorListObserver (IPMUnknown *boss)
 
virtual ~PreviewableColorListObserver ()
 
virtual void AutoAttach ()
 
virtual void AutoDetach ()
 
virtual void Update (const ClassID &theChange, ISubject *theSubject, const PMIID &protocol, void *changedBy)
 
- Public Member Functions inherited from CObserver
 CObserver (IPMUnknown *boss, PMIID interfaceID=IID_IOBSERVER)
 
IChangeManagerGetChangeManager () const
 
virtual void SetAttachIID (PMIID iid)
 
virtual PMIID GetAttachIID () const
 
virtual void SetEnabled (bool16 state)
 
virtual bool16 IsEnabled () const
 
virtual void LazyUpdate (ISubject *theSubject, const PMIID &protocol, const LazyNotificationData *data)
 

Additional Inherited Members

- Public Types inherited from IObserver
enum  { kDefaultIID = IID_IOBSERVER }
 
- Protected Attributes inherited from CObserver
bool16 fDetachSubjectsOnDelete
 
PMIID fAttachIID
 
const UIDRef fThisRef
 
bool16 fEnabled
 

Detailed Description

Implements IObserver based on the partial implementation CObserver.

Because our dialog has a Preview button, we need to know immediately when data changes for a widget. Normally, when an attached widget's value is changed, the dialog observer's Update() method is called, and then widget observers are updated.

For dropdown menus, the call to the dialog observer's Update comes after a particular menu item is selected. This works fine for all the color dropdown's menu items except for the 'custom' item. When the 'custom' item is chosen, first the dialog observer's Update method gets called as normal, then the color dropdown widget observer's Update method gets called. Inside the color dropdown observer's Update method, if the 'custom' items was selected, a system dialog is displayed to allow the user to select their custom color.

After this system dialog is dismissed, the color list data is updated, and the dropdown menu is redrawn using the selected color, but there is no message sent to the color dropdown's observers indicating the custom color has been changed. This leaves the previewed document out of sync with the dialog.

To deal with this issue, an additional observer was added to the color list dropdown. This was implemented by aggregating both IControlViewObservers and PreviewableColorListObserver onto kColorListDropDownWidgetBoss. IControlViewObservers implements a list of observers, and PreviewableColorListObserver implements the new observer.

PreviewableColorListObserver responds to the same kPopupChangeStateMessage that the color dropdown observer responds to, but because it gets updated AFTER the color dropdown observer is updated, we can safely notify attached items (namely, our dialog) that the IID_ICOLORLISTCONTROLDATA has been modified. Our dialog, then, can properly sync the document to the dialog when a custom color is chosen.

Constructor & Destructor Documentation

Binds the C implementation class onto its ImplementationID making the C code callable by the application * PreviewableColorListObserver::PreviewableColorListObserver (IPMUnknownboss)

Constructor.

Parameters
bossinterface ptr from boss object on which this interface is aggregated.
virtual PreviewableColorListObserver::~PreviewableColorListObserver ()
inlinevirtual

Destructor.

Member Function Documentation

void PreviewableColorListObserver::AutoAttach (void )
virtual

Called by the application to allow the observer to attach to the subjects to be observed, in this case the dialog's color widget.

Reimplemented from CObserver.

void PreviewableColorListObserver::AutoDetach (void )
virtual

Called by the application to allow the observer to detach from the subjects being observed.

Reimplemented from CObserver.

void PreviewableColorListObserver::Update (const ClassIDtheChange,
ISubjecttheSubject,
const PMIIDprotocol,
void * changedBy 
)
virtual

Called by the host when the observed object changes.

Parameters
theChangespecifies the class ID of the change to the subject. Frequently this is a command ID.
theSubjectpoints to the ISubject interface for the subject that has changed.
protocolspecifies the ID of the changed interface on the subject boss.
changedBypoints to additional data about the change. Often this pointer indicates the class ID of the command that has caused the change.

Implements IObserver.