PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFOTableCellReactor
Abstract class which provides the interfaces about the drawing of table cells and the behavior of selected cells.
#include <SFOTableCellReactor.h.hpp>
class SFOTableCellReactor : public SFORefObject;
SFMTYPEDEFREFOBJECT(SFOTableCellReactor)
        

Inheritance diagram

 Inheritance diagram of SFOTableCellReactorClass

Collaboration diagram

 Collaboration diagram of SFOTableCellReactorClass

Description

The SFOTableCellReactor class is an abstract class which provides the interfaces about the drawing of table cells and the behavior of selected cells.

The SFOTableCellTextReactor, SFOTableCellToggleReactor and SFOTableCellImageReactor classes are defined as the default table cell reactors. The default reactors can display texts, checkboxes, and images in cells of a table view per column. Among them, texts and checkboxes cells can be editable.

A table cell reactor needs to be connected to a table view column (SFOTableViewColumn).

[Note] Note

To connect a table cell reactor to a table view column, call the SFOTableViewColumn::NewInstance function or the SFOTableViewColumn::SetCellReactor function.

SFOTableCellReactor class provides mainly the following functions or interfaces.

  • Function of hierarchical properties.
  • Interface of the drawing table cells.
  • Interface of the selected table cells behavior.
  • Interface of the focused or unfocused table cells behavior.
[Note] Table cell

A table cell or merely a cell means an element of a table view (SFZTableView) which is specified by row and column.

[Note] Table cell reactor

The SFOTableCellReactor class and the inheritance are called as a table cell reactor or merely a cell reactor.

Reference

SFXHierarchyProperty

Member

Constructor/Destructor
SFOTableCellReactor( Void )
Constructor of the SFOTableCellReactor class.
~SFOTableCellReactor( Void )
Destructor of the SFOTableCellReactor class.
Public Functions
ValueRec GetProperty( UInt32 key , BoolPtr found = null , Bool recursive = true )
Get the property value corresponding to the specified key.
Bool HasProperty( UInt32 key , Bool recursive = true )
Check if the specified key is contained.
SFCError SetProperty( UInt32 key , ValueRec value )
Set the property value corresponding to the specified key.
Protected Functions
static
SFXRectangle
Align( SFXRectangleConstRef src , SFXRectangleConstRef ref , UInt32 alignment )
Align the specified rectangle with the base rectangle.
UInt32 GetAlignment( Void )
Get the alignment.
SFXMargin GetMargin( Void )
Get the margin between the table cell area and the cell drawing area.
Bool Handle( SFXAnyRef object , SInt32 row )
Handle the selected table cell.
Void InvokeResultCell( Void )
Notify that selecting a table cell is performed.
Bool IsEditable( Void )
Check if the cell reactor is editable.
Bool IsWidgetAttachable( Void )
Checks if the cell is widget-attachable.
Void OffFocus( SInt32 row , SFYWidgetSmpPtr widget )
Handle a table cell which has been unfocused.
Void OnFocus( SFXRectangleConstRef bound , SFXAnyConstRef object , SInt32 row , SFYWidgetSmpPtr widget )
Handle a table cell which has been focused.
Void Render( SFXGraphicsPtr graphics , SFXRectangleConstRef bound , SFXAnyConstRef object , SInt32 row , Bool active , Bool focus )
Draw a table cell.
static
SFORefObjectSmp
Factory( SFORefObjectPtr object , SFCErrorPtr exception ) (inherits from SFORefObject)
This function is used to implement the NewInstance function.
SFCError Initialize( Void ) (inherits from SFORefObject)
Make the initialization which may raise an error.

SFOTableCellReactor::SFOTableCellReactor
Constructor of the SFOTableCellReactor class.
[ protected, explicit ]
SFOTableCellReactor(Void);

Description

This constructor does nothing.


SFOTableCellReactor::~SFOTableCellReactor
Destructor of the SFOTableCellReactor class.
[ protected, virtual ]
~SFOTableCellReactor(Void);

Description

This destructor does nothing.


SFOTableCellReactor::Align
Align the specified rectangle with the base rectangle.
[ protected, static ]
SFXRectangle Align(
    SFXRectangleConstRef src   // A rectangle to be aligned
    SFXRectangleConstRef ref   // A base rectangle
    UInt32 alignment           // value of alignment
);

Return value

Aligned rectangle.

Description

This function aligns the specified rectangle with the base rectangle, and returns the aligned rectangle.

A rectangle to be aligned is to be specified as the "src" argument.

A base rectangle is to be specified as the "ref" argument.

Bitwise OR of IDF_ALIGN_*** flags (horizontal or vertical alignment) which are defined in BREW (IDISPLAY) are to be specified as the "alignment" argument.

If neither IDF_ALIGN_LEFT nor IDF_ALIGN_RIGHT is specified, the horizontal alignment will be IDF_ALIGN_CENTER. If neither IDF_ALIGN_TOP nor IDF_ALIGN_BOTTOM is specified, the vertical alignment will be IDF_ALIGN_MIDDLE.

For example, if you want to align with "left and top alignment", specify (IDF_ALIGN_LEFT | IDF_ALIGN_TOP).

[Note] Horizontal alignment in BREW

  • IDF_ALIGN_LEFT: left align.
  • IDF_ALIGN_RIGHT: right align.
  • IDF_ALIGN_CENTER, or neither IDF_ALIGN_LEFT nor IDF_ALIGN_RIGHT: center align.

[Note] Vertical alignment in BREW

  • IDF_ALIGN_TOP: top align.
  • IDF_ALIGN_BOTTOM: bottom align.
  • IDF_ALIGN_MIDDLE, or neither IDF_ALIGN_TOP nor IDF_ALIGN_BOTTOM: middle align.

[Note] Note

This function does not affect the specified rectangles.

Example

The following is an example which is used in the SFOTableCellImageReactor::Render function.

/*public virtual */Void SFOTableCellImageReactor::Render(SFXGraphicsPtr graphics, SFXRectangleConstRef bound, SFXAnyConstRef object, SInt32 row, Bool active, Bool focus) const
{
    AEEImageInfo                                info;
    SFXRectangle                                rx;
    SFXRectangle                                content;
    SFXRectangle                                clip;
    SFBImageSmpPtr                              ptr;
    SFBImageSmp                                 image;

    unused(row); unused(active); unused(focus);
    if ((ptr = any_cast<SFBImageSmp>(const_cast<SFXAnyPtr>(&object))) != null) {
        if ((image = *ptr) != null) {
            image->GetInfo(&info);
            if (info.cx > 0 && info.cy > 0) {
                clip.Set(graphics->GetClip());
                content.Set(SFXRectangle(bound).Deflate(GetMargin()));
                graphics->SetClip(SFXRectangle(content).Intersection(clip));
                rx.SetSize(info.cx, info.cy);
                rx.Set(Align(rx, content, GetAlignment()));
                graphics->DrawImage(image, rx.GetOrigin());
                graphics->SetClip(clip);
            }
        }
    }
    return;
}// SFOTableCellImageReactor::Render //

Internal implementation

Internal implementation of this function is as follows.

/*public static */SFXRectangle SFOTableCellReactor::Align(SFXRectangleConstRef src, SFXRectangleConstRef ref, UInt32 alignment)
{
    SFXRectangle                                result;

    result.Set(src);
    if (alignment & IDF_ALIGN_LEFT) {
        result.SnapLeft(ref.GetLeft());
    }
    else if (alignment & IDF_ALIGN_RIGHT) {
        result.SnapRight(ref.GetRight());
    }
    else {
        result.SnapCenter(ref.GetCenter());
    }
    if (alignment & IDF_ALIGN_TOP) {
        result.SnapTop(ref.GetTop());
    }
    else if (alignment & IDF_ALIGN_BOTTOM) {
        result.SnapBottom(ref.GetBottom());
    }
    else {
        result.SnapMiddle(ref.GetMiddle());
    }
    return result;
}// SFOTableCellReactor::Align //

Reference

BREW API IDISPLAY Flags | SFOTableCellReactor::GetAlignment | SFOTableCellImageReactor::Render | SFOTableCellImageReactor


SFOTableCellReactor::GetAlignment
Get the alignment.
[ protected, const ]
UInt32 GetAlignment(Void);

Return value

Alignment value of UInt32 type.

Description

This function gets the alignment (UInt32 type) by searching the SFLPROP_ALIGNMENT property key from the internal hierarchical property (SFXHierarchyProperty).

The alignment value is represented by Bitwise OR of horizontal alignment and vertical alignment in BREW.

If the property key is not found, the value (IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE) will be returned.

[Note] Horizontal alignment in BREW

  • IDF_ALIGN_NONE: no alignment is specified.
  • IDF_ALIGN_LEFT: left align.
  • IDF_ALIGN_CENTER: center align.
  • IDF_ALIGN_RIGHT: right align.

[Note] Vertical alignment in BREW

  • IDF_ALIGN_NONE: no alignment is specified.
  • IDF_ALIGN_TOP: top align.
  • IDF_ALIGN_MIDDLE: middle align.
  • IDF_ALIGN_BOTTOM: bottom align.

Reference

SFOTableCellReactor::GetProperty | SFXHierarchyProperty


SFOTableCellReactor::GetMargin
Get the margin between the table cell area and the cell drawing area.
[ protected, const ]
SFXMargin GetMargin(Void);

Return value

Margin (SFXMargin).

Description

This function gets the margin (SFXMargin type) between the table cell area and the cell drawing area by searching the SFLPROP_LEFTTOP_MARGIN_SIZE key [left top margin size] and the SFLPROP_RIGHTBOTTOM_MARGIN_SIZE key [right bottom margin size] from the internal hierarchical property (SFXHierarchyProperty).

If the either key is not found, the size is (0, 0).

If neither key is not found, the margin is SFXMargin(0, 0, 0, 0).

[Note] Note

In the SFOTableCellToggleReactor class, the both SFLPROP_LEFTTOP_MARGIN_SIZE property and SFLPROP_RIGHTBOTTOM_MARGIN_SIZE are initialized as (1, 1).

In the SFOTableCellTextReactor class, the both SFLPROP_LEFTTOP_MARGIN_SIZE property and SFLPROP_RIGHTBOTTOM_MARGIN_SIZE are initialized as (2, 1).

Reference

SFOTableCellToggleReactor::Initialize | SFOTableCellTextReactor::Initialize | SFOTableCellReactor::GetProperty | SFXHierarchyProperty | SFXMargin


SFOTableCellReactor::GetProperty
Get the property value corresponding to the specified key.
[ public, const ]
ValueRec GetProperty(
    UInt32 key              // property key to search
    BoolPtr found = null    // whether the key is found or not
    Bool recursive = true   // whether to search ancestor properties recursively
);

Return value

Property value (SFXHierarchyProperty::ValueRec) corresponding to the specified key.

Description

This function gets the property value corresponding to the specified key.

If the key is not found, the return value is null.

[Note] null value of the SFXHierarchyProperty::ValueRec

SFXHierarchyProperty::ValueRec is a union at most 4 bytes. The null value means that it is filled with 0 bits. If the union type is SFXRGBColor, the null value is SFXRGBColor(0x00, 0x00, 0x00, 0x00) that is black. If Bool, it is false.

When the "found" arugment without null is specified, whether the key is found is returned as a Bool value. If you want to only check the key existence, use the SFOTableCellReactor::HasProperty function.

When the "recursive" argument is specified as true, if this class property does not contain the key, the ancestor properties will be searched in order and the first match value (in nearest ancestor) will be returned.

[Note] Parent property

The parent of this class property is the SFOTableViewColumn class property. The parent of SFOTableViewColumn class is the SFZTableView class property.

If the key is not found in this class property, the SFOTableViewColumn class property will be searched, and if not found either, the SFZTableView class property will be.

When the key is found, the searching terminates.

[Note] Note

For more details about the hierarchical property, see the SFXHierarchyProperty class of the reference.

Reference

SFOTableCellReactor::SetProperty | SFOTableCellReactor::HasProperty | SFXHierarchyProperty::ValueRec | SFXHierarchyProperty | SFOTableViewColumn


SFOTableCellReactor::Handle
Handle the selected table cell.
[ protected, virtual ]
Bool Handle(
    SFXAnyRef object   // cell object
    SInt32 row         // selected row index
);

Return value

  • If the value of the table cell has been changed or will be changed: true
  • Otherwise: false

Description

This function handles the selected table cell.

When the value of the table cell is changed or something is performed, true must be returned.

When nothing is performed except calling the SFOTableCellReactor::InvokeResultCell function, false must be returned.

In default, this function calls the SFOTableCellReactor::InvokeResultCell function and returns false.

Reference

SFOTableCellReactor::InvokeResultCell


SFOTableCellReactor::HasProperty
Check if the specified key is contained.
[ public, const ]
Bool HasProperty(
    UInt32 key              // property key to search
    Bool recursive = true   // whether to search ancestor properties recursively
);

Return value

  • If the key is found: true
  • Otherwise: false

Description

This function checks if the specified key is contained.

When the "recursive" argument is specified as true, if this class property does not contain the key, the ancestor properties will be searched in order and the first match value (in nearest ancestor) will be returned.

[Note] Parent property

The parent of this class property is the SFOTableViewColumn class property. The parent of SFOTableViewColumn class is the SFZTableView class property.

If the key is not found in this class property, the SFOTableViewColumn class property will be searched, and if not found either, SFZTableView class property will be.

When the key is found, the searching terminates.

Reference

SFOTableCellReactor::GetProperty | SFOTableCellReactor::SetProperty | SFXHierarchyProperty | SFOTableViewColumn


SFOTableCellReactor::InvokeResultCell
Notify that selecting a table cell is performed.
[ protected ]
Void InvokeResultCell(Void);

Description

This function should be called when the handling of a selected table cell is performed.

Usually, the SFOTableCellReactor::Handle function calls this function at the end.

[Caution] Where and when the SFOTableCellReactor::InvokeResult() function is called.

In editable mode of the SFOTableCellTextReactor class, the selection handling is not instantly performed just after invoking the SFOTableCellReactor::Handle function because the FEP transition will be occured. In this case, this function is called when the FEP is finished.

Reference

SFOTableCellReactor::Handle | SFOTableCellTextReactor


SFOTableCellReactor::IsEditable
Check if the cell reactor is editable.
[ protected, const ]
Bool IsEditable(Void);

Return value

  • If editable: true
  • Otherwise: false

Description

This function checks if the cell reactor is editable.

[Note] Note

Checks if the table cell reactor is editable by searching the SFLPROP_EDITABLE key from the internal hierarchical property.

If the key is not found, false is returned.

Reference

SFOTableCellReactor::GetProperty | SFXHierarchyProperty


SFOTableCellReactor::IsWidgetAttachable
Checks if the cell is widget-attachable.
[ protected, virtual, const ]
Bool IsWidgetAttachable(Void);

Return value

  • If attachable: true
  • Otherwise: false

Description

This function checks if the cell is widget-attachable.

Default returns false.

[Note] When true is returned.

For example, the SFOTableCellTextReactor class returns true when the SFLPROP_TEXT_SCROLLABLE property is true because the class uses the SFYSingleTextWidget widget for text scrolling.

Reference

SFOTableCellTextReactor | SFYSingleTextWidget


SFOTableCellReactor::OffFocus
Handle a table cell which has been unfocused.
[ protected, virtual ]
Void OffFocus(
    SInt32 row               // row index of unfocused cell
    SFYWidgetSmpPtr widget   // widget to be delegated in focus.
);

Description

This function handles a table cell which has been unfocused.

If the "widget" argument is specified, the SFYResponder::Terminate function is called and the widget is dereferenced.

Internal implementation

Internal implementation of this function is as below.

/*protected virtual */Void SFOTableCellReactor::OffFocus(SInt32 row, SFYWidgetSmpPtr widget)
{
    unused(row);
    if (widget != null) {
        if (*widget != null) {
            (*widget)->Terminate();
        }
        widget->Release();
    }
    return;
}// SFOTableCellReactor::OffFocus //

Reference

SFYWidget | SFOTableCellReactor::OnFocus


SFOTableCellReactor::OnFocus
Handle a table cell which has been focused.
[ protected, virtual ]
Void OnFocus(
    SFXRectangleConstRef bound   // cell area
    SFXAnyConstRef object        // cell object
    SInt32 row                   // row index of focused cell
    SFYWidgetSmpPtr widget       // widget to be delgated in focus
);

Description

This function handles a table cell which has been focused.

To delegate the fucused behavior to widget, set the instance of the widget to the "widget" argument.

Default does nothing.

Example

Internal implementation of this function.

/*protected virtual */Void SFOTableCellReactor::OnFocus(SFXRectangleConstRef bound, SFXAnyConstRef object, SInt32 row, SFYWidgetSmpPtr widget)
{
    unused(bound); unused(object); unused(row); unused(widget);
    return;
}// SFOTableCellReactor::OnFocus //

Reference

SFYWidget | SFOTableCellReactor::OffFocus


SFOTableCellReactor::Render
Draw a table cell.
[ protected, virtual, const ]
Void Render(
    SFXGraphicsPtr graphics      // graphics object
    SFXRectangleConstRef bound   // table cell area
    SFXAnyConstRef object        // cell object
    SInt32 row                   // row index of cell to draw
    Bool active                  // active state of cell
    Bool focus                   // focus state of cell
);

Description

This function draws the cell object into the cell area with considering the active state and the focus state.

Default does nothing.


SFOTableCellReactor::SetProperty
Set the property value corresponding to the specified key.
[ public ]
SFCError SetProperty(
    UInt32 key       // property key
    ValueRec value   // property value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

This function sets the property value corresponding to the specified key.

Example

The following is a code to set cell texts editable.

SFOTableCellReactorSmp rtor;

rtor = SFOTableCellTextReactor::NewInstance();
rtor->SetProperty(SFLPROP_EDITABLE, true);

Reference

SFOTableCellReactor::GetProperty | SFOTableCellReactor::HasProperty | SFXHierarchyProperty::ValueRec | SFXHierarchyProperty | SFOTableCellTextReactor