CComponent Class Reference

The abstract base class for all components. More...

#include <CComponent.h>

Inheritance diagram for CComponent:
CButton CComboBox CForm CIPAddressBox CLabel CListBox CPanel CTextBox

List of all members.

Public Member Functions

 CComponent ()
 Constructs a new component.
 CComponent (const CComponent &c)
 Copy constructor to throw a exception.
void DispatchEvent (SKeyEvent *e)
 Dispatches an event to this component or one of its sub components.
void SetCommandAction (void *obj, void(*action)(void *, CComponent *))
 Sets the object and it's function to process a action.
void PerformAction ()
 Executes business function, if it is set.
BOOL IsFocusOwner ()
 Returns true if this Component is the focus owner.
BOOL IsFocusable ()
 Returns whether this Component can be focused.
void SetFocusable (BOOL focusable)
 Sets the focusable state of this Component to the specified value.
void TransferFocus ()
 Transfers the focus to the next component.
void TransferFocusBackward ()
 Transfers the focus to the previous component.
void TransferFocusUpCycle ()
 Transfers the focus up one focus traversal cycle.
virtual void OnTimer ()
 This function is called in the GUI loop for making regular actions like timer actions.
void Repaint ()
 Repaints this component.
void Redraw (CGraphics *g)
 Does default paint operations for the component.
virtual void Paint (CGraphics *g)
 Paints the component.
void Bordered (BOOL b)
 Sets whether showing border for this component.
virtual void SetSize (INT16 width, INT16 height)
 Resizes this object so that it has width and height.
virtual void SetLocation (INT16 x, INT16 y)
 Sets the location of the object relative to the parent.
SPoint GetScreenPosition ()
 Returns the location of the object on the screen.
CFontGetFont ()
 Gets the font of this component.
void SetFont (CFont *font)
 Sets the font of this component.
CComponentGetParent ()
 Gets the parent of this component.
void SetLayout (ILayoutManager *layout)
 Sets the layout manager for this component.
virtual void Add (CComponent *component)
 Appends the specified component to the end of this component.
INT8 GetComponentCount ()
 Gets the number of components in this panel.
virtual void Invalidate ()
 Invalidates the component.
void Validate ()
 Validates this component and all of its subcomponents.
BOOL IsValid ()
 Determines whether this component is valid.

Protected Member Functions

virtual void PreviewProcessComponentKeyEvent (SKeyEvent *e)
 Processes events occurring on this component before this event will processed by focus component.
virtual void ProcessComponentKeyEvent (SKeyEvent *e)
 Processes events occurring on this component,.
void PaintBorder (CGraphics *g)
 Paints the component's border, if the component is bordered.
void Remove (CComponent *component)
 Removes the specified component from this component.
void ValidateTree ()
 Recursively descends the component tree and recomputes the layout for any subtrees marked as needing it (those marked as invalid).

Protected Attributes

INT32 m_background
 The background color for this component.
INT32 m_foreground
 The foreground color for this component.
BOOL m_bordered
 Whether the component is bordered.
INT16 m_x
 The x position of the component in the parent's coordinate system.
INT16 m_y
 The y position of the component in the parent's coordinate system.
INT16 m_sx
 The x position of the component in the screen coordinate system.
INT16 m_sy
 The y position of the component in the screen coordinate system.
INT16 m_width
 The width of the component.
INT16 m_height
 The height of the component.
INT16 m_swidth
 The clip screen width of the component.
INT16 m_sheight
 The clip screen height of the component.

Detailed Description

The abstract base class for all components.

To use a component that inherits from CComponent, you must place the component in a containment hierarchy whose root is a top-level component. Top-level components are inheritors of the CForm.

SetKey and GetKey is not implemented. Use the pointer to a component for identification of a object.


Constructor & Destructor Documentation

CComponent::CComponent (  ) 

Constructs a new component.

Class CComponent can be extended directly to create another component.


Member Function Documentation

void CComponent::Add ( CComponent component  )  [virtual]

Appends the specified component to the end of this component.

Note: If a component has been added to a component that has been displayed, Validate must be called on that component to display the new component. If multiple components are being added, you can improve efficiency by calling Validate only once, after all the components have been added.

Parameters:
component - the component to be added
Bug:
need inform, if component is not added (exception for example)

Reimplemented in CWindow.

void CComponent::Bordered ( BOOL  b  )  [inline]

Sets whether showing border for this component.

Parameters:
b - true, if component is bordered.
void CComponent::DispatchEvent ( SKeyEvent *  e  ) 

Dispatches an event to this component or one of its sub components.

Calls ProcessComponentKeyEvent for the CComponent.

Parameters:
e - the event
INT8 CComponent::GetComponentCount (  ) 

Gets the number of components in this panel.

Returns:
the number of components in this panel.
CFont * CComponent::GetFont (  ) 

Gets the font of this component.

Returns:
this component's font; if a font has not been set for this component, the font of its parent is returned
See also:
SetFont
CComponent * CComponent::GetParent (  ) 

Gets the parent of this component.

Returns:
the parent component of this component
SPoint CComponent::GetScreenPosition (  ) 

Returns the location of the object on the screen.

Returns:
location of object on screen

TODO can be null if this object is not on the screen

void CComponent::Invalidate (  )  [virtual]

Invalidates the component.

The component and all parents above it are marked as needing to be laid out. This method can be called often, so it needs to execute quickly.

See also:
Validate
ILayoutManager

Reimplemented in CForm.

BOOL CComponent::IsFocusable (  ) 

Returns whether this Component can be focused.

Returns:
true if this Component is focusable; false otherwise.
See also:
SetFocusable
BOOL CComponent::IsFocusOwner (  ) 

Returns true if this Component is the focus owner.

Returns:
true if this Component is the focus owner; false otherwise
BOOL CComponent::IsValid (  ) 

Determines whether this component is valid.

A component is valid when it is correctly sized and positioned within its parent container and all its children are also valid.

Returns:
true if the component is valid, false otherwise
See also:
Validate
Invalidate
void CComponent::OnTimer (  )  [virtual]

This function is called in the GUI loop for making regular actions like timer actions.

Main GUI loop:

 while( 1 )
 {
     while( CTerminal::NextAction() )
     {
         CTerminal::ProcessUserActions();
     }
     CTerminal::OnTimer();// this will be call OnTimer for every Component
     CTerminal::Paint();
     usleep( REFRESH_PERIOD_MKS );
 }
 
void CComponent::Paint ( CGraphics g  )  [virtual]

Paints the component.

This forwards the paint to any components that are children of this component. If this method is reimplemented, Paint(g) of base class should be called so components are properly rendered.

Parameters:
g - the specified Graphics context
See also:
Redraw

Reimplemented in CButton, CComboBox, CIPAddressBox, CLabel, CListBox, and CTextBox.

void CComponent::PaintBorder ( CGraphics g  )  [protected]

Paints the component's border, if the component is bordered.

Parameters:
g 
void CComponent::PreviewProcessComponentKeyEvent ( SKeyEvent *  e  )  [protected, virtual]

Processes events occurring on this component before this event will processed by focus component.

Parameters:
e - the event
See also:
DispatchEvent
void CComponent::ProcessComponentKeyEvent ( SKeyEvent *  e  )  [protected, virtual]

Processes events occurring on this component,.

Parameters:
e - the event
See also:
DispatchEvent

Reimplemented in CButton, CComboBox, CForm, CIPAddressBox, and CTextBox.

void CComponent::Redraw ( CGraphics g  ) 

Does default paint operations for the component.

TODO If a child component is entirely clipped by the current clipping setting in g, paint() will not be forwarded to that child.

don't call directly! only for system call.

Parameters:
g - the specified Graphics context
See also:
Paint
void CComponent::Remove ( CComponent component  )  [protected]

Removes the specified component from this component.

Note: If a component has been removed from a component that had been displayed, Validate must be called on that container to reflect changes. If multiple components are being removed, you can improve efficiency by calling Validate only once, after all the components have been removed.

Parameters:
component - the component to be removed
See also:
Add
Validate
void CComponent::SetCommandAction ( void *  obj,
void(*)(void *, CComponent *)  action 
)

Sets the object and it's function to process a action.

Parameters:
obj - a object with a business function
action - a function of a business object
void CComponent::SetFocusable ( BOOL  focusable  ) 

Sets the focusable state of this Component to the specified value.

This value overrides the Component's default focusability.

Parameters:
focusable indicates whether this Component is focusable
See also:
IsFocusable
void CComponent::SetFont ( CFont font  ) 

Sets the font of this component.

Parameters:
font - The font to become this container's font.
See also:
GetFont
void CComponent::SetLayout ( ILayoutManager layout  ) 

Sets the layout manager for this component.

Parameters:
layout - the specified layout manager
void CComponent::SetLocation ( INT16  x,
INT16  y 
) [virtual]

Sets the location of the object relative to the parent.

Note: Validate must be called on that component for compile new layout, if ILayoutManager is defined

Parameters:
x - X coordinate of the object
y - Y coordinate of the object
See also:
Validate

Reimplemented in CForm.

void CComponent::SetSize ( INT16  width,
INT16  height 
) [virtual]

Resizes this object so that it has width and height.

Note: Validate must be called on that component for compile new layout, if ILayoutManager is defined

Parameters:
width - the new width of the object
height - the new height of the object
See also:
Validate

Reimplemented in CForm, and CWindow.

void CComponent::TransferFocusUpCycle (  ) 

Transfers the focus up one focus traversal cycle.

Typically, the focus owner is set to this Component's focus cycle root, and the current focus cycle root is set to the new focus owner's focus cycle root. If, however, this Component's focus cycle root is a Window, then the focus owner is set to the focus cycle root's default Component to focus, and the current focus cycle root is unchanged.

void CComponent::Validate (  ) 

Validates this component and all of its subcomponents.

The Validate method is used to cause a component to lay out its subcomponents again. It should be invoked when this container's subcomponents are modified (added to or removed from the container, or layout-related information changed) after the component has been displayed.

If this component is not valid, this method invokes the ValidateTree method and marks this component as valid. Otherwise, no action is performed.

See also:
Invalidate
ValidateTree
void CComponent::ValidateTree (  )  [protected]

Recursively descends the component tree and recomputes the layout for any subtrees marked as needing it (those marked as invalid).

Synchronization should be provided by the method that calls this one: Validate.

See also:
Validate

The documentation for this class was generated from the following files:
Generated on Tue Jun 29 18:34:06 2010 for guilib by  doxygen 1.6.3