SophiaFramework UNIVERSE 5.3 |
#include <SFOTableCellReactor.h.hpp>
class SFOTableCellReactor : public SFORefObject;
SFMTYPEDEFREFOBJECT(SFOTableCellReactor)
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 | |
---|---|
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.
Table cell | |
---|---|
A table cell or merely a cell means an element of a table view (SFZTableView) which is specified by row and column. |
Table cell reactor | |
---|---|
The SFOTableCellReactor class and the inheritance are called as a table cell reactor or merely a cell reactor. |
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.
|
[ protected, explicit ] SFOTableCellReactor(Void);
This constructor does nothing.
[ protected, virtual ] ~SFOTableCellReactor(Void);
This destructor does nothing.
[ protected, static ] SFXRectangle Align( SFXRectangleConstRef src // A rectangle to be aligned SFXRectangleConstRef ref // A base rectangle UInt32 alignment // value of alignment );
Aligned rectangle.
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).
Horizontal alignment in BREW | |
---|---|
|
Vertical alignment in BREW | |
---|---|
|
Note | |
---|---|
This function does not affect the specified rectangles. |
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 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 //
BREW API IDISPLAY Flags | SFOTableCellReactor::GetAlignment | SFOTableCellImageReactor::Render | SFOTableCellImageReactor
[ protected, const ] UInt32 GetAlignment(Void);
Alignment value of UInt32 type.
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.
Horizontal alignment in BREW | |
---|---|
|
Vertical alignment in BREW | |
---|---|
|
[ protected, const ] SFXMargin GetMargin(Void);
Margin (SFXMargin).
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 | |
---|---|
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). |
SFOTableCellToggleReactor::Initialize | SFOTableCellTextReactor::Initialize | SFOTableCellReactor::GetProperty | SFXHierarchyProperty | SFXMargin
[ 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 );
Property value (SFXHierarchyProperty::ValueRec) corresponding to the specified key.
This function gets the property value corresponding to the specified key.
If the key is not found, the return value is null.
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.
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 | |
---|---|
For more details about the hierarchical property, see the SFXHierarchyProperty class of the reference. |
SFOTableCellReactor::SetProperty | SFOTableCellReactor::HasProperty | SFXHierarchyProperty::ValueRec | SFXHierarchyProperty | SFOTableViewColumn
[ protected, virtual ] Bool Handle( SFXAnyRef object // cell object SInt32 row // selected row index );
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.
[ public, const ] Bool HasProperty( UInt32 key // property key to search Bool recursive = true // whether to search ancestor properties recursively );
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.
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. |
SFOTableCellReactor::GetProperty | SFOTableCellReactor::SetProperty | SFXHierarchyProperty | SFOTableViewColumn
[ protected ] Void InvokeResultCell(Void);
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.
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. |
[ protected, const ] Bool IsEditable(Void);
This function checks if the cell reactor is editable.
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. |
[ protected, virtual, const ] Bool IsWidgetAttachable(Void);
This function checks if the cell is widget-attachable.
Default returns false.
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. |
[ protected, virtual ] Void OffFocus( SInt32 row // row index of unfocused cell SFYWidgetSmpPtr widget // widget to be delegated in focus. );
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 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 //
[ 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 );
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.
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 //
[ 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 );
This function draws the cell object into the cell area with considering the active state and the focus state.
Default does nothing.
This function sets the property value corresponding to the specified key.
The following is a code to set cell texts editable.
SFOTableCellReactorSmp rtor; rtor = SFOTableCellTextReactor::NewInstance(); rtor->SetProperty(SFLPROP_EDITABLE, true);
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |