PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFOTableViewColumn
Class which represents a column of a table view.
#include <SFOTableViewColumn.h.hpp>
class SFOTableViewColumn : public SFORefObject;
SFMTYPEDEFREFOBJECT(SFOTableViewColumn)
        

Inheritance diagram

 Inheritance diagram of SFOTableViewColumnClass

Collaboration diagram

 Collaboration diagram of SFOTableViewColumnClass

Description

This class represents a column of a table view.

This class has mainly four features.

Reference

SFZTableView | SFOTableModelBase | SFOTableCellReactor | SFXHierarchyProperty

Member

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.

SFOTableViewColumn::SFOTableViewColumn
Constructor of the SFOTableViewColumn class.
[ 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)
);

Description

This constructor will be called by the SFOTableViewColumn::NewInstance function.

Reference

SFOTableCellReactor | SFOTableViewColumn::NewInstance


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

SFOTableViewColumn::DrawHeaderColumn
Draw a title name and so on in the header of column.
[ protected, virtual, const ]
Void DrawHeaderColumn(
    SFXGraphicsPtr graphics      // graphics object
    SFXRectangleConstRef bound   // header region
);

Description

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.

Reference

SFXHierarchyProperty


SFOTableViewColumn::GetCellReactor
Get the cell reactor.
[ public, const ]
SFOTableCellReactorSmpConstRef GetCellReactor(Void);

Return value

Table cell reactor (SFOTableCellReactor) which is set in the column

Reference

SFOTableCellReactor


SFOTableViewColumn::GetModelColumnIndex
Get the table model column index.
[ public, const ]
SInt32 GetModelColumnIndex(Void);

Return value

Column index

Reference

SFOTableModelBase


SFOTableViewColumn::GetProperty
Get the property value specified by the property 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 climb up the parent tree recursively
);

Return value

SFXHierarchyProperty::ValueRec

Description

If the key is not found, the null value will be returned.

[Note] 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.

Reference

SFXHierarchyProperty | SFZTableView


SFOTableViewColumn::GetTitle
Get the title name.
[ public, const ]
SFXWideStringConstRef GetTitle(Void);

Reference

SFXWideString


SFOTableViewColumn::HasProperty
Check if the specified property key is contained.
[ public, const ]
Bool HasProperty(
    UInt32 key              // property key
    Bool recursive = true   // whether climb up the ancestors recursively
);

Return value

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

Description

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] 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.

Reference

SFXHierarchyProperty | SFOTableViewColumn::GetProperty | SFZTableView


SFOTableViewColumn::NewInstance
Create a new instance of this class.
[ 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
);

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 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

[Note] Internal processing

Internally, a new instance is created by new operator, and then it will be passed to the SFORefObject::Factory function.

Example

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) ..
}

Reference

SFORefObject::Factory | SFOTableCellReactor


SFOTableViewColumn::SetCellReactor
Set the table cell reactor.
[ public ]
Void SetCellReactor(
    SFOTableCellReactorSmpConstRef param   // table cell reactor (the cell drawing or the selected cell behavior)
);

Description

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.

Example

SFOTableViewColumnSmp vcol;
SFOTableCellReactorSmp rtor;
SFCError error;

vcol = SFOTableViewColumn::NewInstance(&error);
rtor = SFOTableCellTextReactor::NewInstance(&error);
vcol->SetCellReactor(rtor);

Reference

SFOTableCellReactor | SFOTableCellTextReactor


SFOTableViewColumn::SetModelColumnIndex
Set the table model column index.
[ public ]
Void SetModelColumnIndex(
    SInt32 index   // table model column index
);

Description

This function relates the table model index to this instance.

Example

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].

Reference

SFOTableModel | SFZTableView | SFXTableItem | SFOTableCellToggleReactor | SFOTableCellTextReactor


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

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function sets the property value of the column.

Example

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);

Reference

SFXHierarchyProperty


SFOTableViewColumn::SetTitle
Set the title of column.
[ public ]
SFCError SetTitle(
    SFXWideStringConstRef title   // title of column
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY
  • If failed: SFERR_FAILED

Description

This function sets the title of the table view column.

Default value: "" [Empty string]

Reference

SFXWideString