SophiaFramework UNIVERSE 5.3 |
#include <SFOTableCellTextReactor.h.hpp>
class SFOTableCellTextReactor : public SFOTableCellReactor;
SFMTYPEDEFREFOBJECT(SFOTableCellTextReactor)
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.
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. |
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. |
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.
|
[ protected, explicit ] SFOTableCellTextReactor(Void);
[ protected, explicit ] SFOTableCellTextReactor( SFXBaseEditorPtr editor // native text input control );
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 | |
---|---|
This constructor is called by the SFOTableCellTextReactor::NewInstance function. |
SFOTableCellTextReactor::NewInstance | SFOTableCellTextReactor::SetEditor | SFYApplication::GetEditor | SFXBaseEditor | SFYResponder
This destructor does nothing.
[ protected, static ] SFCError Convert( SFXAnyConstRef object // cell object SFXWideStringPtr result // result string );
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 | |
---|---|
This operation is the reverse of the SFOTableCellTextReactor::SetString function. |
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 //
SFXAny | SFXAnsiString | SFXWideString | SFOTableCellTextReactor::SetString
[ public, const ] SFXBaseEditorPtr GetEditor(Void);
Native text input control (SFXBaseEditor).
This function gets the native text input control.
[ public, const ] AEETextInputMode GetInputMode(Void);
Input mode of the native text input control (AEETextInputMode).
Thif function gets the input mode of the native text input control.
For more details, see ITEXTCTL_GetInputMode() and AEETextInputMode of the BREW reference.
[ public, const ] UInt16 GetMaximumLength(Void);
Maximum value of the text size which is supported by the native text input control.
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.
[ public, const ] Bool GetPasswordMode(Void);
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.
SFOTableCellTextReactor::SetPasswordMode | BREW API ITEXTCTL_SetProperties | BREW API AEE ITextCtl's Properties
[ protected, virtual ] Bool Handle( SFXAnyRef object // cell object SInt32 row object // Row index of the selected cell );
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 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 //
[ protected, virtual ] SFCError Initialize(Void);
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 | |
---|---|
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 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 //
[ protected, virtual, const ] Bool IsWidgetAttachable(Void);
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".
[ public, static ] SFOTableCellTextReactorSmp NewInstance( SFCErrorPtr exception = null // error value );
[ public, static ] SFOTableCellTextReactorSmp NewInstance( SFXBaseEditorPtr editor // native text input control SFCErrorPtr exception = null // error value );
Return the error value generated inside the function.
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.
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) .. }
SFOTableCellTextReactor::SFOTableCellTextReactor | SFOTableCellTextReactor::SetEditor | SFYApplication::GetEditor | SFOTableCellTextReactor | SFXBaseEditor | SFYResponder
[ 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 );
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 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 //
[ 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 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 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 //
[ public ] Void SetEditor( SFXBaseEditorPtr param // native text input control );
This function sets a native input text control.
Default: the native text input control (SFXEditor) which is gotten by the SFYApplication::GetEditor function.
Note | |
---|---|
The control is enable only when the table cell is editable. |
SFOTableCellTextReactor::GetEditor | SFOTableCellTextReactor::NewInstance | SFOTableCellTextReactor::SFOTableCellTextReactor | SFYApplication::GetEditor | SFOTableCellReactor::IsEditable | SFXBaseEditor | SFXEditor
[ public ] Void SetInputMode( AEETextInputMode param // Input mode );
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 | |
---|---|
Enable when the table cell is editable. |
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 | |
---|---|
Enable only when the table cell is editable. |
[ public ] Void SetPasswordMode( Bool param // password mode (If display input text as ***: true, otherwise: false) );
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 | |
---|---|
Enable only when the table cell is editable. |
SFXEditProperty::GetPasswordMode | BREW API ITEXTCTL_SetProperties | BREW API AEE ITextCtl' Properties
[ protected, static ] SFCError SetString( SFXWideStringConstRef text // SFXWideString text SFXAnyPtr result // cell object );
This function sets a specified SFXWideString text to a SFXAny object.
Note | |
---|---|
This operation is the reverse of the SFOTableCellTextReactor::Convert function. |
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 //
SFXAny | SFXAnsiString | SFXWideString | SFOTableCellTextReactor::Convert
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |