SophiaFramework UNIVERSE 5.3 |
#include <SFOTableViewColumn.h.hpp>
class SFOTableViewColumn : public SFORefObject;
SFMTYPEDEFREFOBJECT(SFOTableViewColumn)
This class represents a column of a table view.
This class has mainly four features.
SFZTableView | SFOTableModelBase | SFOTableCellReactor | SFXHierarchyProperty
Constructor/Destructor |
---|
SFOTableViewColumn( Void ) Constructor of the SFOTableViewColumn class.
|
SFOTableViewColumn(
SFXWideStringConstRef title
, SInt32 modelColumnIndex
, SFOTableCellReactorSmpConstRef reactor
) Constructor of the SFOTableViewColumn class.
|
~SFOTableViewColumn( Void ) Destructor of the SFOTableViewColumn class.
|
Public Functions | |
---|---|
SFOTableCellReactorSmpConstRef |
GetCellReactor( Void ) Get the cell reactor.
|
SInt32 |
GetModelColumnIndex( Void ) Get the table model column index.
|
ValueRec |
GetProperty(
UInt32 key
, BoolPtr found = null
, Bool recursive = true
) Get the property value specified by the property key.
|
SFXWideStringConstRef |
GetTitle( Void ) Get the title name.
|
Bool |
HasProperty(
UInt32 key
, Bool recursive = true
) Check if the specified property key is contained.
|
static SFOTableViewColumnSmp |
NewInstance(
SFCErrorPtr exception = null
) Create a new instance of this class.
|
static SFOTableViewColumnSmp |
NewInstance(
SFXWideStringConstRef title
, SInt32 modelColumnIndex
, SFOTableCellReactorSmpConstRef reactor
, SFCErrorPtr exception = null
) Create a new instance of this class.
|
Void |
SetCellReactor(
SFOTableCellReactorSmpConstRef param
) Set the table cell reactor.
|
Void |
SetModelColumnIndex(
SInt32 index
) Set the table model column index.
|
SFCError |
SetProperty(
UInt32 key
, ValueRec value
) Set the property value coppresponding to the specified property key.
|
SFCError |
SetTitle(
SFXWideStringConstRef title
) Set the title of column.
|
Protected Functions | |
---|---|
Void |
DrawHeaderColumn(
SFXGraphicsPtr graphics
, SFXRectangleConstRef bound
) Draw a title name and so on in the header of column.
|
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 ] SFOTableViewColumn(Void);
[ protected, explicit ] SFOTableViewColumn( SFXWideStringConstRef title // column title name SInt32 modelColumnIndex // related table model index SFOTableCellReactorSmpConstRef reactor // table cell reactor (the cell drawing or the selected cell behavior) );
This constructor will be called by the SFOTableViewColumn::NewInstance function.
[ protected, virtual ] ~SFOTableViewColumn(Void);
[ protected, virtual, const ] Void DrawHeaderColumn( SFXGraphicsPtr graphics // graphics object SFXRectangleConstRef bound // header region );
This function draws a title name in the header area with considering an alignment property (SFLPROP_ALIGNMENT), a font property (SFLPROP_FONT), and a foreground color property (SFLPROP_FOREGROUND_COLOR) of the hierarchical property.
[ public, const ] SFOTableCellReactorSmpConstRef GetCellReactor(Void);
Table cell reactor (SFOTableCellReactor) which is set in the column
[ public, const ] SInt32 GetModelColumnIndex(Void);
Column index
[ public, const ] ValueRec GetProperty( UInt32 key // property key to search BoolPtr found = null // whether the key is found or not Bool recursive = true // whether climb up the parent tree recursively );
If the key is not found, the null value will be returned.
null value of the SFXHierarchyProperty::ValueRec | |
---|---|
SFXHierarchyProperty::ValueRec is a union whose members size is at most 4 byte. The null value of the union means that all the bits are zero. Therefore, the null value of SFXRGBColor means black [SFXRGBColor(0x00, 0x00, 0x00, 0x00)] and that of Bool means false. |
The "found" argument will be set to true if the key is fuond. Otherwise, false. If you want to only search the key, use the SFOTableViewColumn::HasProperty function.
If the "recursive" argument is true, searching will be continued with climbing up the parent tree until the key is hit. Otherwise, performed only in this property.
Usually, the parent property is the property of the SFZTableView class.
[ public, const ] SFXWideStringConstRef GetTitle(Void);
[ public, const ] Bool HasProperty( UInt32 key // property key Bool recursive = true // whether climb up the ancestors recursively );
This function checks if the property value is set.
If the "recursive" argument is true, searching will be continued with climbing up the ancestors until the key is hit.
Note | |
---|---|
If you want to also get the property value at the same time, calling the SFOTableViewColumn::GetProperty function will be better because the searching is the once. |
Usually, the parent property is the property of SFZTableView class.
SFXHierarchyProperty | SFOTableViewColumn::GetProperty | SFZTableView
[ public, static ] SFOTableViewColumnSmp NewInstance( SFCErrorPtr exception = null // error value );
[ public, static ] SFOTableViewColumnSmp NewInstance( SFXWideStringConstRef title // column title name SInt32 modelColumnIndex // table model column index SFOTableCellReactorSmpConstRef reactor // table cell reactor (the cell drawing or the selected cell behavior) SFCErrorPtr exception = null // error value );
Return the error value generated inside the function
This function creates a new instance of the SFOTableViewColumn class.
If succeeds, a not null pointer will be returned, and the "exception" argument is SFERR_NO_ERROR. If fails such as insufficient memory, a null pointer will be returned, and the "exception" argument holds the error value
Internal processing | |
---|---|
Internally, a new instance is created by new operator, and then it will be passed to the SFORefObject::Factory function. |
The following is a code to create a new instance of the SFOTableViewColumn class.
// Create a new instance of SFOTableViewColumn SFOTableViewColumnSmp vcol; SFCError error; if ((vcol = SFOTableViewColumn::NewInstance(&error)) == SFERR_NO_ERROR) { // .. (omitted) .. }
[ public ] Void SetCellReactor( SFOTableCellReactorSmpConstRef param // table cell reactor (the cell drawing or the selected cell behavior) );
One table view column (SFOTableViewColumn) accepts one table cell reactor (SFOTableCellReactor).
A table cell reactor can be shared between table view columns. In this cace, the property of the table cell reactor is also shared.
SFOTableViewColumnSmp vcol; SFOTableCellReactorSmp rtor; SFCError error; vcol = SFOTableViewColumn::NewInstance(&error); rtor = SFOTableCellTextReactor::NewInstance(&error); vcol->SetCellReactor(rtor);
This function relates the table model index to this instance.
SFZTableViewSmp view; SFOTableModelSmp model; SFXTableItem<2> item; SFOTableViewColumnSmp vcol; view = SFZTableView::NewInstance(); model = SFOTableModel::NewInstance(); // Creates a table model which consists of 10 rows and 2 columns [String | Bool]. for (SInt32 row = 0; row < 10; row++) { item.data[0] = SFXAnsiString::Format("item: %d", row); item.data[1] = static_cast<Bool>(row % 2); model->InsertLast(item); } vcol = SFOTableViewColumn::NewInstance(); vcol->SetTitle("Toggle"); vcol->SetCellReactor(SFOTableCellToggleReactor::NewInstance()); // Relates the Bool column to this column. vcol->SetModelColumnIndex(1); view->AddColumn(vcol); vcol = SFOTableViewColumn::NewInstance(); vcol->SetTitle("Text"); vcol->SetCellReactor(SFOTableCellTextReactor::NewInstance()); // Relates the String column to this column. vcol->SetModelColumnIndex(0); view->AddColumn(vcol); // ..(omitted).. // The appearance of the table view is [Checkbox | Text].
SFOTableModel | SFZTableView | SFXTableItem | SFOTableCellToggleReactor | SFOTableCellTextReactor
This function sets the property value of the column.
A code to fix the length of column
SFOTableViewColumnSmp vcol;
vcol = SFOTableViewColumn::NewInstance();
// Fix the length of thw column to 20 pixel.
vcol->SetProperty(SFLPROP_FIXED_WIDTH, 20);
[ public ] SFCError SetTitle( SFXWideStringConstRef title // title of column );
This function sets the title of the table view column.
Default value: "" [Empty string]
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |