the new value should be set *before* the listener is called.
> On a simular note, how should the listener find out what has changed? Should
> it remember itself the old value, or should the prefs be able to tell it
> somehow?
i think it'd be reasonable for the specific listener to remember
in some private/object storage the last value (or an internalized
form of the last value) for each keyword that it cares about.
for example, somewhere in the frame or tool bar code there should
be a "enum { text, icon, both } m_eToolbarAppearance" member variable
which records how the toolbars are currently being drawn and also
the last know value of the of the "ToolbarAppearance" preferences
value. when the frame or toolbar's pref listener is called, it can
do the right thing. [i suggest having one listener for the frame
or toolbar so that it can deal with all of the relevant keys (such
as toolbar on/off, toolbar language, toolbar appearance, etc) in
one call.]
for values with arbitrary strings, the listener should just keep
a copy of it.
> One possibility is a hash table of all the keys that have changed. That way,
> when each listener is called, it can lookup the key it's interested in in the
> hash table to see if it's changed.
we do notification typing and cacheing like this for changes to the
document -- but this code gets called on every keystroke and mouse
movement. here we're dealing with preferences which change very
seldom and aren't critical path. besides, the computational cost
of running thru this hash and testing for a "hasChanged" and then
doing the getValue() is just as expensive (more so in case of a
changed value) as calling getValue() (which is a hashed lookup) and
testing the actual value with the listeners internal copy...
hope this helps,
jeff