Class: MDelegatingFloatControl

Declaration: FloatControls.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

None.

Inherited By:

TSliderControl

Purpose:

MDelegatingFloatControl is a mixin class that defines the protocol for adopting a float control state and for delegating to that state. This class also defines protocol for establishing a notification connection between a float control and its adopted state. This class is the base class for all float controls.

Instantiation:

Abstract base class; do not allocate.

Deriving Classes:

MDelegatingFloatControl is a mixin class--it cannot be instantiated and must be derived from. Classes deriving from MDelegatingFloatControl provide the request processor and override HandleStateChanged.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: MDelegatingFloatControl::MDelegatingFloatControl

  1. MDelegatingFloatControl ()
  2. MDelegatingFloatControl (MFloatControlState * delegate)
  3. MDelegatingFloatControl (const MDelegatingFloatControl & state)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Creates a new MDelegatingFloatControl object and adopts the specified state object.
  3. Copy constructor. If the control being copied had adopted its state object, then the state object is cloned, otherwise a pointer to the state object is copied and marked as not adopted. Non-adopted state objects are not flattened and resurrected. This function also copies the pointer to the request processor.

Calling Context:

  1. Called by the stream-in operators.
  2. Called when you want to adopt a state at construction time. You can also use AdoptState and SetState at any time.
  3. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

MDelegatingFloatControl is a mixin class and cannot be instantiated.

Member Function: MDelegatingFloatControl::~MDelegatingFloatControl

virtual ~ MDelegatingFloatControl ()

Interface Category:

API.

Purpose:

Destructor. This function also breaks the notification connection with the existing state object and deletes the state object if it was adopted.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::operator=

MDelegatingFloatControl & operator =(const MDelegatingFloatControl & state)

Interface Category:

Interface Category:

API.

Purpose:

Assignment operator. If the control being copied had adopted its state object, then the state object is cloned, otherwise a pointer to the state object is copied and marked as not adopted. Non-adopted state objects are not flattened and resurrected. This function also copies the pointer to the request processor. This function breaks the notification connection with the existing state object and deletes the state object if it was adopted. This function then tries to establish a connection with the new state object.

Calling Context:

Call this function by using the operator in an assignment statement.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::operator>>=

virtual TStream & operator >>=(TStream &) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::operator<<=

virtual TStream & operator <<= (TStream &)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::AdoptState

virtual void AdoptState (MFloatControlState * state)

Interface Category:

API.

Purpose:

Adopts the specified state object. This class can only contain a single state object at a time, so the new state object replaces any state object previously adopted in AdoptState or set by SetState. If the previous state object had been adopted by this control, this function deletes it. If this control has a request processor, this function attempts to establish a notification connection with the new state object. This control uses the new state object for subsequent function calls.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::SetState

virtual void SetState (MFloatControlState * state)

Interface Category:

API.

Purpose:

Sets this control's state object. This function is the same as AdoptState, except the new state object is not adopted. This class can only contain a single state object at a time, so the new state object replaces any state object previously adopted in AdoptState or set by SetState. If the previous state object had been adopted by this control, this function deletes it. When a control has a state object that is not adopted: (1) the state object is not automatically deleted, (2) the state object is not streamed out, and (3) if this MDelegatingFloatControl is copied, the state object is copied, not cloned.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::GetState

virtual MFloatControlState * GetState () const

Interface Category:

API.

Purpose:

Returns a pointer to the state object that was set in SetState or adopted in AdoptState.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a pointer to the current state object. This function never returns NIL, because it creates (and adopts) a simple float state object if none has been previously set or adopted.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::OrphanState

virtual MFloatControlState * OrphanState ()

Interface Category:

API.

Purpose:

Removes this control's reference to the currently adopted state object so that it's no longer owned by the MDelegatingFloatControl. This function does not delete the orphaned state object.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a pointer to the orphaned state object. This function returns NIL if no state object was adopted. Note: if no state object was explicitly set or adopted and you call GetState, and then you call OrphanState, this function returns the simple float state object created by GetState. If you then call GetState again, GetState creates another simple float state object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::GetFloatValue

virtual double GetFloatValue () const

Interface Category:

API.

Purpose:

Returns the current value for this control's state object by calling GetFloatValue on the state object. This is primarily a convenience function for calling GetFloatValue on this control's state object. State object functions can be called directly by calling the appropriate function on the object returned by GetState.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the value of this control's state object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::SetFloatValue

virtual void SetFloatValue (double newValue)

Interface Category:

API.

Purpose:

Sets the value of this control's state object by calling SetFloatValue on its state object. This is primarily a convenience function for calling SetFloatValue on this control's state object. State object functions can be called directly by calling the appropriate function on the object returned by GetState.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::GetFloatConstraints

virtual void GetFloatConstraints (double & minimum, double & maximum, double & intervalSize) const

Interface Category:

API.

Purpose:

Gets the constraints currently applied to the value of this control's state. The first two parameters indicate the range within which this float control state's value must fall. The third parameter indicates the discrete interval by which to constrain this float control state's value. For example, if the interval is 1.0, then the float control state's value is constrained to whole numbers. An interval of 0.0 indicates that there is no interval constraint. This is primarily a convenience function for calling GetFloatConstraints on this control's state object. State object functions can be called directly by calling the appropriate function on the object returned by GetState.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::IsEnabled

virtual bool IsEnabled () const

Interface Category:

API.

Purpose:

Determines whether this control's state object is enabled by calling IsEnabled on the state object. This is primarily a convenience function for calling IsEnabled on this control's state object. State object functions can be called directly by calling the appropriate function on the object returned by GetState.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns true if the state object is enabled, false otherwise.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::StartInteraction

virtual void StartInteraction ()

Interface Category:

API.

Purpose:

Called when the user begins an interaction with this floating-point control--usually by clicking the mouse down on the control. This is primarily a convenience function for calling StartInteraction on this control's state object. State object functions can be called directly by calling the appropriate function on the object returned by GetState.

Calling Context:

Called by the event handling functions in the interactors associated with floating-point control objects.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::EndInteraction

virtual void EndInteraction (bool cancelled)

Interface Category:

API.

Purpose:

Called when the interaction started with StartInteraction ends--usually by releasing the mouse button over this float control. The Boolean flag indicates whether the interaction was canceled by the user. This is primarily a convenience function for calling EndInteraction on this control's state object. State object functions can be called directly by calling the appropriate function on the object returned by GetState.

Calling Context:

Called by the event handling functions in the interactors associated with floating-point control objects.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::SetRequestProcessor

virtual void SetRequestProcessor (TRequestProcessor * proc)

Interface Category:

API.

Purpose:

Sets the request processor that is required to establish a notification connection with the state object. This function must be called in order to establish the notification connection with the state object because a TRequestBasedMemberFunctionConnectionTo connection is used.

Calling Context:

This function must be called before HandleStateChanged is called.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::StateChanged

virtual void StateChanged (const TNotification &)

Interface Category:

API.

Purpose:

Notifies this control that its state object has changed state and enables this control to participate in a member function connection to the state object. This function calls HandleStateChanged.

Calling Context:

Called when an object sends a notification containing an interest that the state object returned from AddInterests.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is protected.

Member Function: MDelegatingFloatControl::HandleStateChanged

virtual void HandleStateChanged ()

Interface Category:

API.

Purpose:

Handles notification that the state object's state has changed. Classes deriving from MDelegatingFloatControl override this function to update their presentation of the state.

Calling Context:

Called from StateChanged.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is protected.

Member Function: MDelegatingFloatControl::GetControlView

virtual TView * GetControlView ()

Interface Category:

API.

Purpose:

Gets the control view set for this control's state object by calling GetControlView on the state object. This is primarily a convenience function for calling GetControlView on this control's state object. State object functions can be called directly by calling the appropriate function on the object returned by GetState.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a pointer to the control's view, or NIL if there is no control.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::SetControlView

virtual void SetControlView (const TViewHandle & owner)

Interface Category:

API.

Purpose:

Provides this control's state object with a handle to the specified control view by calling SetControlView on its state object. This is primarily a convenience function for calling SetControlView on this control's state object. State object functions can be called directly by calling the appropriate function on the object returned by GetState.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: MDelegatingFloatControl::GetLabel

virtual const TLabel * GetLabel () const

Interface Category:

API.

Purpose:

Gets a label for this control by calling GetLabel on the state object. This is primarily a convenience function for calling GetLabel on this control's state object. State object functions can be called directly by calling the appropriate function on the object returned by GetState.

Calling Context:

Called only when a client wants to dynamically change the label at runtime.

Parameters:

Return Value:

Returns a pointer to the label.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.