Class FlexContainer

GEOS-SC:  Library toolkit_lib: Class FlexContainer


FlexContainer is the base class for all Toolkit objects that can have children.

#include <toolkit/containr.h>


Class Data and Methods

public:
// FlexContainer members
FlexContainer(Boolean isVisible );
~FlexContainer(void);
Result Add(FlexComponent *child);
Result Add(FlexComponent *child, uint32 position);
Result Add(LayoutTagType tag, FlexComponent *child);
Result AddContainerListener(ContainerListenerInterface& listener);
void DoLayout(void);
uint32 FindFlexComponent(FlexComponent *child);
FlexComponent *GetFlexComponent(uint32 position);
FlexComponent *GetFlexComponent(uint32 position, LayoutTagType& tag);
uint32 GetFlexComponentCount(void);
FlexComponent** GetFlexComponents(void);
FocusManagerInterface *GetFocusManager(void);
LayoutManagerInterface *GetLayout(void);
LayoutTagType GetLayoutTag(uint32 position);
Insets GetInsets(void);
Result GetRelativeBounds(FlexComponent *descendant, WinRectangle &bounds);
Result GetRelativeLocation(FlexComponent *descendant, WinXYPoint point, WinXYPoint &location);
Boolean IsAncestorOf(FlexComponent *child);
FlexComponent *Remove(FlexComponent *child);
FlexComponent *Remove(uint32 position);
void RemoveAll(void);
void RemoveContainerListener(ContainerListenerInterface& listener);
FocusManagerInterface *RemoveFocusManager(void);
LayoutManagerInterface *RemoveLayout(void);
void SetFocusManager(FocusManagerInterface *focusManager);
void SetLayout(LayoutManagerInterface *layoutManager);
void SetLayoutTag(LayoutTagType tag, uint32 position);
void Validate(void);
// Event processing methods
void ProcessContainerEvent(ContainerEvent& containerEvent);
protected:

Inherited Data and Methods:

public:
// FlexComponent members
enum HorizontalSizePreference;
enum VerticalSizePreference;
Result AddComponentListener(ComponentListenerInterface& listener);
Result AddFocusListener(FocusListenerInterface& listener);
Result AddKeyListener(KeyListenerInterface& listener);
Result AddMouseListener(MouseListenerInterface& listener);
Result AddMouseMotionListener(MouseMotionListenerInterface& listener);
void AddNotify(void);
Boolean Contains(WinCoord x, WinCoord y);
Boolean Contains(WinXYPoint& point);
void DelayedDelete(void);
void DoLayout(void);
Colorant GetBackground(void);
WinRectangle GetBounds(void) const;
FlexComponent *GetComponentAt(WinCoord x, WinCoord y, Boolean visibleOnly );
FlexComponent *GetComponentAt(WinXYPoint& point, Boolean visibleOnly );
Colorant GetForeground(void);
FlexComponentID GetID(void);
WinXYPoint GetLocation(void);
Dimension GetMinimumSize(void);
FlexContainer *GetParent(void) const;
FlexWindow *GetFlexWindowAncestor(void);
Dimension GetPreferredSize(void);
Dimension GetSize(void) const;
void GetSizePreference(HorizontalSizePreference &horizontalSizePref, VerticalSizePreference &verticalSizePref);
void Invalidate(void);
Boolean IsEnabled(void) const;
Boolean IsFocusTraversable(void);
Boolean IsShowing(void) const;
Boolean IsGeometryValid(void) const;
Boolean IsVisible(void) const;
void Paint(void);
void RemoveComponentListener(ComponentListenerInterface& listener);
void RemoveFocusListener(FocusListenerInterface& listener);
void RemoveKeyListener(KeyListenerInterface& listener);
void RemoveMouseListener(MouseListenerInterface& listener);
void RemoveMouseMotionListener(MouseMotionListenerInterface& listener);
void RemoveNotify(void);
void Repaint(void);
void Repaint(WinCoord x, WinCoord y, uint16 width, uint16 height);
void RequestFocus(void);
Result SetBackground(Colorant color);
void SetBounds(WinCoord x, WinCoord y, uint16 width, uint16 height);
void SetBounds(WinRectangle& rect);
void SetEnabled(Boolean enable);
Result SetForeground(Colorant color);
void SetID(FlexComponentID id);
void SetLocation(WinCoord x, WinCoord y);
void SetLocation(const WinXYPoint& point);
void SetSize(const Dimension& dimension);
void SetSize(uint16 width, uint16 height);
void SetSizePreference(HorizontalSizePreference horizontalSizePref, VerticalSizePreference verticalSizePref);
Result SetVisible(Boolean visible);
void TransferFocus(void);
void Update(WinCoord x, WinCoord y, uint16 width, uint16 height);
void Validate(void);
// Event processing methods
void ProcessActionEvent(ActionEvent& actionEvent);
void ProcessComponentEvent(ComponentEvent& componentEvent);
void ProcessFocusEvent(FocusEvent& focusEvent);
void ProcessKeyEvent(KeyEvent& keyEvent);
void ProcessMouseEvent(MouseEvent& mouseEvent);
void ProcessMouseMotionEvent(MouseEvent& mouseEvent);
// Graphical rendering methods
void *CopyArea(const WinRectangle *bounds) const;
WinCoord FontMetric( FontMetricInfo info, const TextState& textState ) const;
void BrushLine( WinXYPoint p1, WinXYPoint p2, Colorant lineCOlor, WinCoord penWidth );
void DrawLine( WinXYPoint p1, WinXYPoint p2, Colorant lineColor );
void DrawHLine( WinCoord xStart, WinCoord xEnd, WinCoord yCoord, Colorant lineColor );
void DrawVLine( WinCoord xCoord, WinCoord yStart, WinCoord yEnd, Colorant lineColor);
void DrawBitmap(const Bitmap& bitmap, WinXYPoint destUpLeft, Colorant color);
void DrawBitmap(const Bitmap& bitmap, WinXYPoint destUpLeft);
void DrawPoint( WinCoord xPos, WinCoord yPos, Colorant dotColor );
void DrawPoint( WinXYPoint point, Colorant dotColor );
void DrawString( const TCHAR string[], TextState& textState );
void DrawString( const TCHAR string[], int32 numChars, TextState& textState );
void DrawUIShape( const UIShape srcUIShape, const WinXYPoint& basePoint, Colorant fgColor, int16 parm0 , int16 parm1 , int16 parm2 , int16 parm3 );
void InvertUIShape( const UIShape srcUIShape, const WinXYPoint& basePoint, int16 parm0 , int16 parm1 , int16 parm2 , int16 parm3 );
void FillRect( WinCoord leftCorner, WinCoord topCorner, WinCoord rightCorner, WinCoord bottomCorner, Colorant fillColor );
void InvertRect( WinCoord leftCorner, WinCoord topCorner, WinCoord rightCorner, WinCoord bottomCorner );
void InvertLine( WinXYPoint p1, WinXYPoint p2 );
void InvertLine( WinCoord x1, WinCoord y1, WinCoord x2, WinCoord y2 );
void SetClipRect( const WinXYPoint& clipUpLeft, const WinXYPoint& clipLowRight );
void ClearClipRect(void);
void Render(Renderer& renderer);
WinCoord StringWidth( const TCHAR string[], const TextState& textState ) const;
WinCoord StringWidth( const TCHAR string[], int32 numChars, const TextState& textState ) const;
protected:
EC (static void EnsureInAppThread(void));

Back to the top of FlexContainer


Ancestors

Inheritance tree for FlexContainer:

Back to the top of FlexContainer


Descendants

Back to the top of FlexContainer


USAGE

The FlexContainer destructor invokes SetVisible(FALSE) on each child and removes it from the linkage, then invokes "delete" on each child. This implies that if you have statically defined Flex objects under a FlexContainer, you should manually remove them before the parent FlexContainer is deleted, as otherwise the FlexContainer will try to invoke "delete" on the statically defined object, yielding a run-time error, a memory corruption, or some other undesirable result.

Back to the top of FlexContainer


Descriptions of Class Data and Methods


FlexContainer(Boolean isVisible );

Class constructor.

Parameters:

in isVisible
Set this to TRUE to make the FlexContainer visible.

Prototype:

    FlexContainer(Boolean isVisible = TRUE);

Back to the top of FlexContainer


~FlexContainer(void);

Class destructor. This calls RemoveLayout() to unlink the layout manager if any (without deleting it). It also removes AND deletes all of the external children (children added via the public API).

If a subclass supports internal children, the destructor for the subclass should take care of removing and deleting them.

Prototype:

    virtual ~FlexContainer(void);

Back to the top of FlexContainer


Result Add(FlexComponent *child);

Appends a child object to this container.

A child object can be added until the system runs out of memory or the maximun number of children (2^32-1) is reached.

This will invalidate the geometry of the container.

Parameters:

in child
The FlexComponent class object to add.

Return value: SUCCESS if child added; otherwise FAILURE.

See also: Remove(), RemoveAll()

Prototype:

    virtual Result Add(FlexComponent *child);

Back to the top of FlexContainer


Result Add(FlexComponent *child, uint32 position);

Adds a child object to this container at the specified position. If the position is larger than the number of components in the container, the new child is appended.

A child object can be added until the system runs out of memory or the maximun number of children (2^32-1) is reached.

This will invalidate the geometry of the container.

Parameters:

in child
The component to add.
in position
The child`s index (zero-based).

Return value: SUCCESS if child added; otherwise FAILURE.

See also: Remove(), RemoveAll()

Prototype:

    virtual Result Add(FlexComponent *child, uint32 position);

Back to the top of FlexContainer


Result Add(LayoutTagType tag, FlexComponent *child);

Adds a child object to this container using the specified layout tag.

Parameters:

in layoutTag
Enumerated type that tells the associated layout manager how to lay out this object.
in child
The component to add.

Return value: SUCCESS if child added; otherwise FAILURE.

See also: Remove(), RemoveAll()

Prototype:

    virtual Result Add(LayoutTagType tag, FlexComponent *child);

Back to the top of FlexContainer


Result AddContainerListener(ContainerListenerInterface& listener);

Add a container listener to the FlexContainer object. The listener must be derived from ContainerListenerInterface in some form.

Parameters:

in listener
A ContainerListenerInterface object that is subclassed to intercept ContainerEvents.

Return value: FAILURE if there was not enough memory to store the reference to the listener in the container.

See also: RemoveContainerListener()

Prototype:

    Result AddContainerListener(ContainerListenerInterface& listener);

Back to the top of FlexContainer


void DoLayout(void);

Lays out the container using the associated layout manager. This method has no effect if the container does not have a layout manager.

Application writers should avoid calling this method because it can interfere with the correct operation of the Geometry Management System.

This method is called when the container is validated as part of the Geometry Management Mechanism (an automated mechanism for keeping the UI properly laid out).

Specific UI writers may call this if a layout must be forced in order to solve some visual nuance problem.

See also: SetLayout(), GetLayout(), Validate()

Prototype:

    virtual void DoLayout(void);

Back to the top of FlexContainer


uint32 FindFlexComponent(FlexComponent *child);

Finds the index of the specified child.

Parameters:

in child
A pointer to a FlexComponent class object.

Return value: Index of child or FC_CHILD_NOT_FOUND.

Prototype:

    uint32 FindFlexComponent(FlexComponent *child);

Back to the top of FlexContainer


FlexComponent *GetFlexComponent(uint32 position);

Returns the component at the specified position.

Parameters:

in position
The child`s index (zero-based).

Return value: A pointer to the child at the index, or NULL if the container has no child at that index.

See also: GetFlexComponents()

Prototype:

    virtual FlexComponent *GetFlexComponent(uint32 position);

Back to the top of FlexContainer


FlexComponent *GetFlexComponent(uint32 position, LayoutTagType& tag);

Returns the component at the specified position.

The tag output parameter will contain the layout tag associated with the returned child. If there is no child at the specified position, the tag parameter will be NT_NULL (which is not to be interpreted as an error value).

Parameters:

out tag
The layout tag of the returned component.
in position
The child`s index (zero-based).

Return value: A pointer to the child at the index, or NULL if the container has no child at the specified index.

See also: GetFlexComponents()

Prototype:

    virtual FlexComponent *GetFlexComponent(uint32 position,
                        LayoutTagType& tag);

Back to the top of FlexContainer


uint32 GetFlexComponentCount(void);

Gets the number of children in this container.

Return value: The number of children.

Prototype:

    virtual uint32 GetFlexComponentCount(void);

Back to the top of FlexContainer


FlexComponent** GetFlexComponents(void);

Gets a list of all children in the container. This list is in the form of an array of FlexComponent pointers. The caller must free the array.

Return value: The array of FlexComponent pointers, or NULL if the container has no children.

See also: GetFlexComponent()

Prototype:

    virtual FlexComponent** GetFlexComponents(void);

Back to the top of FlexContainer


FocusManagerInterface *GetFocusManager(void);

Gets the focus manager used by this container.

Return value: A pointer to the focus manager, or NULL if no focus manager is in use by the container.

Prototype:

    FocusManagerInterface *GetFocusManager(void);

Back to the top of FlexContainer


LayoutManagerInterface *GetLayout(void);

Gets the layout manager used by this container.

Return value: A pointer to the layout manager, or NULL if no layout manager is in use.

See also: SetLayout(), DoLayout()

Prototype:

    LayoutManagerInterface *GetLayout(void);

Back to the top of FlexContainer


LayoutTagType GetLayoutTag(uint32 position);

Returns the layout tag for the component at the specified position.

Parameters:

in position
Index of the component.

Return value: The layout tag associated with the component, or LT_NULL if no component is at the specified position (not an error value, since components have LT_NULL by default).

See also: SetLayoutTag(), Add()

Prototype:

    LayoutTagType GetLayoutTag(uint32 position);

Back to the top of FlexContainer


Insets GetInsets(void);

Gets the Insets used by this container. Insets are the border spaces at the top, left, right, and bottom edges of a container. These spaces are usually reserved for the FlexUI to draw the container`s title bar, menu bar, and visible borders.

Note: The insets value is set by the specific user interface and cannot be changed by the application writer.

Return value: Insets object.

Prototype:

    virtual Insets GetInsets(void);

Back to the top of FlexContainer


Result GetRelativeBounds(FlexComponent *descendant, WinRectangle &bounds);

Converts the bounds of a descendant into bounds relative to this container. A descendant is a component that is our child or a descendant of a child.

Parameters:

in descendant
A descendant within this container.
out bounds
Bounds of the component with respect to our coordinate system.

Return value: FAILURE if conversion was not possible (descendant was not really a descendant).

Prototype:

    Result GetRelativeBounds(FlexComponent *descendant,
                 WinRectangle &bounds);

Back to the top of FlexContainer


Result GetRelativeLocation(FlexComponent *descendant, WinXYPoint point, WinXYPoint &location);

Converts a location relative to a descendant into a location relative to this container. A descendant is a component that is our child or a descendant of a child.

Parameters:

in descendant
A descendant within this container.
in point
A point in the descendant coordinates.
out location
The location of the point with respect to our coordinate system.

Return value: FAILURE if conversion was not possible (descendant was not really a descendant).

Prototype:

    Result GetRelativeLocation(FlexComponent *descendant,
                   WinXYPoint point,
                   WinXYPoint &location);

Back to the top of FlexContainer


Boolean IsAncestorOf(FlexComponent *child);

Finds out if the specified component lies somewhere within this container`s child hierarchy (not necessarily as a direct child).

Parameters:

in child
Pointer to the component to test for.

Return value: TRUE if the container is an ancestor. A container is not an ancestor of itself, so container->IsAncestorOf(container) == FALSE.

Prototype:

    virtual Boolean IsAncestorOf(FlexComponent *child);

Back to the top of FlexContainer


FlexComponent *Remove(FlexComponent *child);

Removes a child from this container. This will invalidate the geometry of the container and the removed child.

Parameters:

in child
Pointer to component we`re removing.

Return value: A pointer to the child that was removed, or NULL if no child was removed.

See also: Add(), RemoveAll()

Prototype:

    virtual FlexComponent *Remove(FlexComponent *child);

Back to the top of FlexContainer


FlexComponent *Remove(uint32 position);

Removes the child at the specified position from this container. This will invalidate the geometry of the container and the removed child.

Parameters:

in position
Index of child to remove (zero-based).

Return value: A pointer to the child that was removed, or NULL if no child was removed.

See also: Add(), RemoveAll()

Prototype:

    virtual FlexComponent *Remove(uint32 position);

Back to the top of FlexContainer


void RemoveAll(void);

Removes all children from this container. This will invalidate the geometry of the container and the removed children.

See also: Add(), Remove()

Prototype:

    virtual void RemoveAll(void);

Back to the top of FlexContainer


void RemoveContainerListener(ContainerListenerInterface& listener);

Remove a container listener that has been added to this FlexContainer.

Parameters:

in listener
The container listener object that is being removed from this container.

Return value: void

See also: AddContainerListener()

Prototype:

    void RemoveContainerListener(ContainerListenerInterface& listener);

Back to the top of FlexContainer


FocusManagerInterface *RemoveFocusManager(void);

If this container has a focus manager, this method removes it and returns a pointer to it. This method does not delete the focus manager. It is the responsibility of the client using a container to free any focus managers allocated by that client.

Containers created through the UI factory might have a default focus manager. A client can remove this focus manager and replace it without having to delete the default focus manager. The UI factory will track and delete any focus managers that are provided by default.

Return value: A pointer to the focus manager that was removed, or NULL if the container does not have one.

Prototype:

    FocusManagerInterface *RemoveFocusManager(void);

Back to the top of FlexContainer


LayoutManagerInterface *RemoveLayout(void);

If this container has a layout manager, this method removes it and returns a pointer to it. This method does not delete the layout manager. It is the responsibility of the client using a container to free any layout managers allocated by that client.

Containers created through the UI factory might have a default layout manager. A client can remove this layout manager and replace it without having to delete the default layout manager. The UI factory will track and delete any layout managers that are provided by default.

Return value: A pointer to the layout manager that was removed, or NULL if the container does not have one.

See also: SetLayout(), GetLayout(), DoLayout()

Prototype:

    LayoutManagerInterface *RemoveLayout(void);

Back to the top of FlexContainer


void SetFocusManager(FocusManagerInterface *focusManager);

Sets the focus manager used by this container. This has no effect if the container already has a focus manager. You must remove an existing focus manager before setting a new one.

Parameters:

in focusManager
A pointer to the focus manager.

Prototype:

    void SetFocusManager(FocusManagerInterface *focusManager);

Back to the top of FlexContainer


void SetLayout(LayoutManagerInterface *layoutManager);

Sets the layout manager used by this container. This has no effect if the container already has a layout manager. You must remove an existing layout manager before setting a new one.

Parameters:

in layoutManager
A pointer to the layout manager.

See also: GetLayout(), RemoveLayout(), DoLayout()

Prototype:

    void SetLayout(LayoutManagerInterface *layoutManager);

Back to the top of FlexContainer


void SetLayoutTag(LayoutTagType tag, uint32 position);

Sets the layout tag for the component at the specified position.

Parameters:

in tag
Layout tag to set.
in position
Index of the affected child.

See also: SetLayoutTag(), Add()

Prototype:

    void SetLayoutTag(LayoutTagType tag, uint32 position);

Back to the top of FlexContainer


void Validate(void);

Validates this FlexContainer and all of its children. When a container is validated, its DoLayout() method is called.

Application writers should avoid calling this method because it can interfere with the correct operation of the Geometry Management System.

This method is called by the Geometry Management Mechanism (an automated mechanism for keeping the UI laid out properly).

See also: FlexComponent::Invalidate(), DoLayout()

Prototype:

    virtual void Validate(void);

Back to the top of FlexContainer


void ProcessContainerEvent(ContainerEvent& containerEvent);

Process the container event for this container, passing the events to any registered ContainerEvent listeners.

Parameters:

in containerEvent
ContainerEvent object to describe the event.

Prototype:

    virtual void ProcessContainerEvent(ContainerEvent& containerEvent);

Back to the top of FlexContainer


Generated from source by Geoworks on Sat Dec 12 18:31:14 1998 .