PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFOTableCellTextReactor
Class which provides the drawing and editing text functions of table cells.
#include <SFOTableCellTextReactor.h.hpp>
class SFOTableCellTextReactor : public SFOTableCellReactor;
SFMTYPEDEFREFOBJECT(SFOTableCellTextReactor)
        

Inheritance diagram

 Inheritance diagram of SFOTableCellTextReactorClass

Collaboration diagram

 Collaboration diagram of SFOTableCellTextReactorClass

Description

The SFOTableCellTextReactor class is a table cell reactor which provides the text functions to cells whose object type are the SFXAnsiString type or the SFXWideString type.

Cell texts are edited by native text input control which is set by the SFOTableCellTextReactor::NewInstance function or the SFOTableCellTextReactor::SetEditor function.

If the text length of the focused table cell is bigger than the width of the cell, the text is scrolled by the SFYSingleTextWidget class functions.

[Note] How to edit text

To edit texts, set the SFLPROP_EDITABLE property to true. When the property is not set, the value is handled as false and the text is non-editable.

[Note] How to suppress text scrolling

To suppress the text scrolling, set the SFLPROP_TEXT_SCROLLABLE property to "false". When the property is not set, the value is handled as "true" and the text is scrollable.

Reference

SFOTableCellReactor | SFYSingleTextWidget

Member

Constructor/Destructor
SFOTableCellTextReactor( Void )
Constructor of the SFOTableCellTextReactor class.
SFOTableCellTextReactor( SFXBaseEditorPtr editor )
Constructor of the SFOTableCellTextReactor class.
~SFOTableCellTextReactor
Destructor of the SFOTableCellTextReactor class
Public Functions
SFXBaseEditorPtr GetEditor( Void )
Get the native text input control.
AEETextInputMode GetInputMode( Void )
Get the input mode of the native text input control.
UInt16 GetMaximumLength( Void )
Get the miximum value of the text size which is supported by the native input text control.
Bool GetPasswordMode( Void )
Get the password mode of the native text input control.
static
SFOTableCellTextReactorSmp
NewInstance( SFCErrorPtr exception = null )
Create a new instance of this class.
static
SFOTableCellTextReactorSmp
NewInstance( SFXBaseEditorPtr editor , SFCErrorPtr exception = null )
Create a new instance of this class.
Void SetEditor( SFXBaseEditorPtr param )
Set a native text input control.
Void SetInputMode( AEETextInputMode param )
Set a input mode of the native text input control.
SFCError SetMaximumLength( UInt16 param )
Set a miximum value of the text size which is supported by the native input text control.
Void SetPasswordMode( Bool param )
Set a password mode of the native text input control.
ValueRec GetProperty( UInt32 key , BoolPtr found = null , Bool recursive = true ) (inherits from SFOTableCellReactor)
Get the property value corresponding to the specified key.
Bool HasProperty( UInt32 key , Bool recursive = true ) (inherits from SFOTableCellReactor)
Check if the specified key is contained.
SFCError SetProperty( UInt32 key , ValueRec value ) (inherits from SFOTableCellReactor)
Set the property value corresponding to the specified key.
Protected Functions
static
SFCError
Convert( SFXAnyConstRef object , SFXWideStringPtr result )
Convert the specified SFXAny object to SFXWideString string.
Bool Handle( SFXAnyRef object , SInt32 row object )
Edit the text of the selected table cell.
SFCError Initialize( Void )
Make the initialization which may raise an error.
Bool IsWidgetAttachable( Void )
Checks if the cell is widget-attachable.
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 text to a table cell.
static
SFCError
SetString( SFXWideStringConstRef text , SFXAnyPtr result )
Set a specified SFXWideString text to a SFXAny object.
static
SFXRectangle
Align( SFXRectangleConstRef src , SFXRectangleConstRef ref , UInt32 alignment ) (inherits from SFOTableCellReactor)
Align the specified rectangle with the base rectangle.
static
SFORefObjectSmp
Factory( SFORefObjectPtr object , SFCErrorPtr exception ) (inherits from SFORefObject)
This function is used to implement the NewInstance function.
UInt32 GetAlignment( Void ) (inherits from SFOTableCellReactor)
Get the alignment.
SFXMargin GetMargin( Void ) (inherits from SFOTableCellReactor)
Get the margin between the table cell area and the cell drawing area.
Void InvokeResultCell( Void ) (inherits from SFOTableCellReactor)
Notify that selecting a table cell is performed.
Bool IsEditable( Void ) (inherits from SFOTableCellReactor)
Check if the cell reactor is editable.
Void OffFocus( SInt32 row , SFYWidgetSmpPtr widget ) (inherits from SFOTableCellReactor)
Handle a table cell which has been unfocused.

SFOTableCellTextReactor::SFOTableCellTextReactor
Constructor of the SFOTableCellTextReactor class.
[ protected, explicit ]
SFOTableCellTextReactor(Void);
[ protected, explicit ]
SFOTableCellTextReactor(
    SFXBaseEditorPtr editor   // native text input control
);

Description

The "editor" argument can specify the own native text input control for table cells.

When the "editor" argument is not specified, the editor control gotten by the SFYApplication::GetEditor function is used for text edit.

[Note] Note

This constructor is called by the SFOTableCellTextReactor::NewInstance function.

Reference

SFOTableCellTextReactor::NewInstance | SFOTableCellTextReactor::SetEditor | SFYApplication::GetEditor | SFXBaseEditor | SFYResponder


SFOTableCellTextReactor::~SFOTableCellTextReactor
Destructor of the SFOTableCellTextReactor class

Description

This destructor does nothing.


SFOTableCellTextReactor::Convert
Convert the specified SFXAny object to SFXWideString string.
[ protected, static ]
SFCError Convert(
    SFXAnyConstRef object     // cell object
    SFXWideStringPtr result   // result string
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If "result" argument is null or "object" argument is not convertible type: SFERR_INVALID_PARAM
  • If insuffcient memory: SFERR_NO_MEMORY

Description

This function converts the specified SFXAny object to the SFXWideString string.

The source SFXAny object must hold the value of the SFXAnsiString or the SFXWideString.

[Note] Note

This operation is the reverse of the SFOTableCellTextReactor::SetString function.

Internal implementation

Internal implementation of this function is as follows.

/*protected static */SFCError SFOTableCellTextReactor::Convert(SFXAnyConstRef object, SFXWideStringPtr result)
{
    SFCError                                    error(SFERR_INVALID_PARAM);

    if (result != null) {
        if (SFXAny::Contains(object, (SFXAnsiStringPtr)(null))) {
            error = result->Set(any_cast<SFXAnsiString>(object));
        }
        else if (SFXAny::Contains(object, (SFXWideStringPtr)(null))) {
            error = result->Set(any_cast<SFXWideString>(object));
        }
    }
    return error;
}// SFOTableCellTextReactor::Convert //

Reference

SFXAny | SFXAnsiString | SFXWideString | SFOTableCellTextReactor::SetString


SFOTableCellTextReactor::GetEditor
Get the native text input control.
[ public, const ]
SFXBaseEditorPtr GetEditor(Void);

Return value

Native text input control (SFXBaseEditor).

Description

This function gets the native text input control.

Reference

SFOTableCellTextReactor::SetEditor | SFXBaseEditor


SFOTableCellTextReactor::GetInputMode
Get the input mode of the native text input control.
[ public, const ]
AEETextInputMode GetInputMode(Void);

Return value

Input mode of the native text input control (AEETextInputMode).

Description

Thif function gets the input mode of the native text input control.

For more details, see ITEXTCTL_GetInputMode() and AEETextInputMode of the BREW reference.

Reference

SFOTableCellTextReactor::SetInputMode | BREW API ITEXTCTL_GetInputMode | AEETextInputMode


SFOTableCellTextReactor::GetMaximumLength
Get the miximum value of the text size which is supported by the native input text control.
[ public, const ]
UInt16 GetMaximumLength(Void);

Return value

Maximum value of the text size which is supported by the native text input control.

Description

This function gets the maximum value of the text size which is supported by the native text input control.

For more details, see ITEXTCTL_SetMaxSize() of the BREW reference.

Reference

SFOTableCellTextReactor::SetMaximumLength | BREW API ITEXTCTL_SetMaxSize


SFOTableCellTextReactor::GetPasswordMode
Get the password mode of the native text input control.
[ public, const ]
Bool GetPasswordMode(Void);

Return value

  • If the password mode is active: true
  • Otherwise: false

Description

This function gets the password mode of the native text input control.

For more details, see ITEXTCTL_SetProperties() and AEE ITextCtl's Properties of the BREW reference.

Reference

SFOTableCellTextReactor::SetPasswordMode | BREW API ITEXTCTL_SetProperties | BREW API AEE ITextCtl's Properties


SFOTableCellTextReactor::Handle
Edit the text of the selected table cell.
[ protected, virtual ]
Bool Handle(
    SFXAnyRef object    // cell object
    SInt32 row object   // Row index of the selected cell
);

Return value

  • If the text is edited: true
  • Otherwise: false

Description

This function edits the text of the selected table cell if the text is editable.

In the end of the function, the SFOTableCellReactor::InvokeResultCell function is called. But if the native text input control is invoked, the call is postponed until the termination of the input.

Internal implemenataion

Internal implemenation of this function is as follows.

/*protected virtual */Bool SFOTableCellTextReactor::Handle(SFXAnyRef object, SInt32 row)
{
    SFXWideString                               text;
    Bool                                        result(false);

    unused(row);
    if (_editor != null) {
        if (IsEditable()) {
            if (Convert(object, &text) == SFERR_NO_ERROR) {
                if (_editProperty.SetText(text) == SFERR_NO_ERROR) {
                    if (_editor->Open(&_editProperty, XALLBACK_INTERNAL(OnEditor)) == SFERR_NO_ERROR) {
                        _text = &object;
                        result = true;
                    }
                }
            }
        }
    }
    if (!result) {
        InvokeResultCell();
    }
    return result;
}// SFOTableCellTextReactor::Handle //

Reference

SFOTableCellReactor::InvokeResultCell


SFOTableCellTextReactor::Initialize
Make the initialization which may raise an error.
[ protected, virtual ]
SFCError Initialize(Void);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insuffcient memory: SFERR_NO_MEMOERY

Description

This function makes the initialization which may raise an error.

In default, the SFLPROP_LEFTTOP_MARGIN_SIZE property (left top margin size) and the SFLPROP_RIGHTBOTTOM_MARGIN_SIZE property (right bottom margin size) are set to (2, 1).

[Note] Note

This function is called by the SFORefObject::Factory function.

If a concrete class specific initialization code may raise an error, you must override this function.

This function calls the parent Initialize() function first.

Internal implementaition

Internal implementation of this function is as follows.

/*protected */SFCError SFOTableCellTextReactor::Initialize(Void)
{
    static SFXSize::AtomRecConst                MARGINSIZE = {
        2, 1
    };
    SFCError                                    error;

    if ((error = SFOTableCellReactor::Initialize()) == SFERR_NO_ERROR) {
        if ((error = SetProperty(SFLPROP_LEFTTOP_MARGIN_SIZE, MARGINSIZE)) == SFERR_NO_ERROR) {
            error = SetProperty(SFLPROP_RIGHTBOTTOM_MARGIN_SIZE, MARGINSIZE);
        }
    }
    return error;
}// SFOTableCellTextReactor::Initialize //

Reference

SFORefObject::Factory | SFOTableCellReactor::GetMargin


SFOTableCellTextReactor::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.

If the SFLPROP_TEXT_SCROLLABLE property is true or not be set, "true" is returned because this class uses the SFYSingleTextWidget widget for text scrolling. Otherwise, "false".

Reference

SFYSingleTextWidget


SFOTableCellTextReactor::NewInstance
Create a new instance of this class.
[ public, static ]
SFOTableCellTextReactorSmp NewInstance(
    SFCErrorPtr exception = null   // error value
);
[ public, static ]
SFOTableCellTextReactorSmp NewInstance(
    SFXBaseEditorPtr editor        // native text input control
    SFCErrorPtr exception = null   // error value
);

Argument

exception

Return the error value generated inside the function.

Return value

  • If succeeds: not null pointer
  • Otherwise: null pointer

Description

This function creates a new instance of the SFOTableCellTextReactor class.

If succeeds, a not null pointer will be returned, and the "exception" argument is SFERR_NO_ERROR. If fails, a null pointer will be returned, and the "exception" argument holds the error value.

The "editor" argument can specify the own native text input control for table cells.

When the "editor" argument is not specified, the editor control gotten by the SFYApplication::GetEditor function is used for text edit.

Example

The following is a code to create a SFOTableCellTextReactor instance.

SFOTableCellReactorSmp rtor;
SFCError error;

if ((rtor = SFOTableCellTextReactor::NewInstance(&error)) != null) {

    // Set editable
    rtor->SetProperty(SFLPROP_EDITABLE, true);

    // Set non-scrollable
    rtor->SetProperty(SFLPROP_TEXT_SCROLLABLE, false);

    // .. (omitted) ..
}

Reference

SFOTableCellTextReactor::SFOTableCellTextReactor | SFOTableCellTextReactor::SetEditor | SFYApplication::GetEditor | SFOTableCellTextReactor | SFXBaseEditor | SFYResponder


SFOTableCellTextReactor::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 delegated in focus
);

Description

This function handles a table cell which has been focused.

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

If the SFLPROP_TEXT_SCROLLABLE property is true or not set, this class delegates scroll processing to the SFYSingleTextWidget class.

Internal implementation

Internal implementation of this function is as follows.

/*protected virtual */Void SFOTableCellTextReactor::OnFocus(SFXRectangleConstRef bound, SFXAnyConstRef object, SInt32 row, SFYWidgetSmpPtr widget)
{
    UInt32                                      alignment;
    SFXWideString                               text;
    SFYSingleTextWidgetSmp                      txwidget;
    SFCError                                    error(SFERR_NO_ERROR);

    unused(row);
    if (widget != null) {
        if (IsWidgetAttachable()) {
            if (Convert(object, &text) == SFERR_NO_ERROR) {
                alignment = GetAlignment();
                txwidget = SFYSingleTextWidget::NewInstance(&error);
                if (txwidget != null) {
                    if ((error = txwidget->SetText(text)) == SFERR_NO_ERROR) {
                        txwidget->SetPropertyTransparent(true);
                        txwidget->SetFont(GetFont());
                        txwidget->SetTextColor(GetSelectedForegroundColor());
                        txwidget->SetHorizontalAlign(ConvertHorizontalAlign(alignment));
                        txwidget->SetVerticalAlign(ConvertVerticalAlign(alignment));
                        txwidget->SetScrollDirection(GetScrollDirection());
                        txwidget->SetScrollInterval(GetScrollInterval());
                        txwidget->SetScrollStep(GetScrollStep());
                        txwidget->SetWaitInterval(GetWaitInterval());
                        txwidget->SetRealBound(SFXRectangle(bound).Deflate(GetMargin()));
                        txwidget->SetState(true, true, true, true);
                        txwidget->StartScroll();
                    }
                }
                if (error == SFERR_NO_ERROR) {
                    *widget = txwidget;
                }
                else {
                    widget->Release();
                }
            }
        }
    }
    else {
        error = SFERR_INVALID_PARAM;
    }
    return;
}// SFOTableCellTextReactor::OnFocus //

Reference

SFYSingleTextWidget


SFOTableCellTextReactor::Render
Draw a text to 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 text in the cell area with considering the active state and the focus state.

The color of the text is changed by the status.

Internal implementation

Internal implemantaion of this function is as follows.

/*protected virtual */Void SFOTableCellTextReactor::Render(SFXGraphicsPtr graphics, SFXRectangleConstRef bound, SFXAnyConstRef object, SInt32 row, Bool active, Bool focus) const
{
    SFXRGBColor                                 foreColor;
    SFXWideString                               text;

    unused(row);
    if (Convert(object, &text) == SFERR_NO_ERROR) {
        foreColor.Set(focus ? GetSelectedForegroundColor() : GetForegroundColor());
        if (!active) {
            if (foreColor.GetBrightness() > 0x7F) {
                foreColor.SubRGB(0x44);
            }
            else {
                foreColor.AddRGB(0x44);
            }
        }
        graphics->SetFont(GetFont());
        graphics->DrawSingleText(text, SFXRectangle(bound).Deflate(GetMargin()), foreColor, GetAlignment());
    }
    return;
}// SFOTableCellTextReactor::Render //

/*private */SFXRGBColor SFOTableCellTextReactor::GetForegroundColor(Void) const
{
    static SFXRGBColor::AtomRecConst            BLACK = {
        {{0x00, 0x00, 0x00, 0x00}}
    };
    Bool                                        found;
    SFXRGBColor                                 result;

    result = GetProperty(SFLPROP_FOREGROUND_COLOR, &found).color;
    if (!found) {
        result.Set(BLACK);
    }
    return result;
}// SFOTableCellTextReactor::GetForegroundColor //

/*private */SFXRGBColor SFOTableCellTextReactor::GetSelectedForegroundColor(Void) const
{
    static SFXRGBColor::AtomRecConst            WHITE = {
        {{0x00, 0xFF, 0xFF, 0xFF}}
    };
    Bool                                        found;
    SFXRGBColor                                 result;

    result = GetProperty(SFLPROP_SELECTED_FOREGROUND_COLOR, &found).color;
    if (!found) {
        result.Set(WHITE);
    }
    return result;
}// SFOTableCellTextReactor::GetSelectedForegroundColor //

SFOTableCellTextReactor::SetEditor
Set a native text input control.
[ public ]
Void SetEditor(
    SFXBaseEditorPtr param   // native text input control
);

Description

This function sets a native input text control.

Default: the native text input control (SFXEditor) which is gotten by the SFYApplication::GetEditor function.

[Note] Note

The control is enable only when the table cell is editable.

Reference

SFOTableCellTextReactor::GetEditor | SFOTableCellTextReactor::NewInstance | SFOTableCellTextReactor::SFOTableCellTextReactor | SFYApplication::GetEditor | SFOTableCellReactor::IsEditable | SFXBaseEditor | SFXEditor


SFOTableCellTextReactor::SetInputMode
Set a input mode of the native text input control.
[ public ]
Void SetInputMode(
    AEETextInputMode param   // Input mode
);

Description

This function sets a input mode of the native text input control.

For more details, see ITEXTCTL_SetInputMode() and AEETextInputMode of the BREW reference.

Default value: AEE_TM_CURRENT.

[Note] Note

Enable when the table cell is editable.

Reference

SFOTableCellTextReactor::GetInputMode | BREW API ITEXTCTL_SetInputMode | AEETextInputMode


SFOTableCellTextReactor::SetMaximumLength
Set a miximum value of the text size which is supported by the native input text control.
[ public ]
SFCError SetMaximumLength(
    UInt16 param   // text length
);

Description

This function sets a maximum value of the text size which is supported by the native text input control.

For more details, set ITEXTCTL_SetMaxSize() of the BREW reference.

Default value: SINT16_MAXIMUM - 1

[Note] Note

Enable only when the table cell is editable.

Reference

SFOTableCellTextReactor::GetMaximumLength | BREW API ITEXTCTL_SetMaxSize


SFOTableCellTextReactor::SetPasswordMode
Set a password mode of the native text input control.
[ public ]
Void SetPasswordMode(
    Bool param   // password mode (If display input text as ***: true, otherwise: false)
);

Description

When the "param" argument is true, this function sets the value of the native text input control property to TP_PASSWORD.

And then, the input text characters are diplayed as '*' (asterisk).

Fore more details, set ITEXTCTL_SetProperties() or AEE ITextCtl's Properties of the BREW reference.

Default value: false

[Note] Note

Enable only when the table cell is editable.

Reference

SFXEditProperty::GetPasswordMode | BREW API ITEXTCTL_SetProperties | BREW API AEE ITextCtl' Properties


SFOTableCellTextReactor::SetString
Set a specified SFXWideString text to a SFXAny object.
[ protected, static ]
SFCError SetString(
    SFXWideStringConstRef text   // SFXWideString text
    SFXAnyPtr result             // cell object
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the "result" argument is null or not convertible type: SFERR_INVALID_PARAM
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function sets a specified SFXWideString text to a SFXAny object.

[Note] Note

This operation is the reverse of the SFOTableCellTextReactor::Convert function.

Internal implemantation

Internal implemantation of this function is as follows.

/*protected static */SFCError SFOTableCellTextReactor::SetString(SFXWideStringConstRef text, SFXAnyPtr result)
{
    SFCError                                    error(SFERR_INVALID_PARAM);

    if (result != null) {
        if (SFXAny::Contains(*result, (SFXAnsiStringPtr)(null))) {
            error = any_cast<SFXAnsiString>(result)->Set(text);
        }
        else if (SFXAny::Contains(*result, (SFXWideStringPtr)(null))) {
            error = any_cast<SFXWideString>(result)->Set(text);
        }
    }
    return error;
}// SFOTableCellTextReactor::SetString //

Reference

SFXAny | SFXAnsiString | SFXWideString | SFOTableCellTextReactor::Convert