wks_set_label_text_control

 

Contents

Description

Change worksheet label text style control.

Syntax

bool wks_set_label_text_control( Worksheet & wks, int nLabel, int nStyle )

Parameters

wks
[input] target worksheet
nLabel
[input] typedef enum{
RCLT_LONG_NAME,
RCLT_UNIT,
RCLT_COMMENT,
RCLT_UDL ( RCLT_UDL + 1, RCLT_UDL + 2 stands for the 2rd, 3th user defined parameter ),
...
}ROWCOLLABELTYPE;
The maximum count of user defined paramters is 128.
Only parameters listed above are useful in this function. Others can be found in OC_const.h file.
bByType
[input] text style control:
WKS_LABEL_TEXT_CONTROL_ORIGIN_TEXT // escape character like '\', '%' will be converted.
WKS_LABEL_TEXT_CONTROL_EDIT // normal text

Return

Returns true on success and false on failure.

Examples

EX1

void wks_set_label_text_control_ex1()
{
    WorksheetPage pg;
    pg.Create("Origin");
    if ( !pg )
    {
        out_str("Failed to create new worksheet!");
        return;
    }
    
    string buf = "C:\\abc.txt"; // C:\abc.txt
    
    Worksheet wks = pg.Layers();
    if ( !wks_set_label_text_control(wks, RCLT_COMMENT, WKS_LABEL_TEXT_CONTROL_EDIT) )
    {
        out_str("Failed to change worksheet label text style control!");
        return;
    }
        
    wks.Columns(0).SetComments(buf);
    // .. see result of column A comments, it will be :
    //    +------------+
    //    | C:\abc.txt |
    //    +------------+
}

EX2

void Grid_SetUserDefinedLabelNames_ex()
{
    Worksheet wks = Project.ActiveLayer();
    if(wks)
    {
        Worksheet wks;
        wks.Create("Origin", CREATE_VISIBLE);
        wks.AddCol();
        Grid gg;
        gg.Attach(wks);  // attach the grid to the worksheet
        vector<string> vsUDLs = {"Decay Rate"};
        gg.SetUserDefinedLabelNames(vsUDLs);   // Add two user defined labels. 
        vector<int> vnTypes;
        gg.GetShowLabels(vnTypes, TRUE);   // Get the current showing column label list 
        vnTypes.Add(RCLT_UDL);             // update the showing column label list
        gg.SetShowLabels(vnTypes);             // Set the showing column labels
        wks.GetPage().Refresh();   
        
        wks_set_label_text_control(wks, RCLT_LONG_NAME, WKS_LABEL_TEXT_CONTROL_ORIGIN_TEXT);
        wks_set_label_text_control(wks, RCLT_UNIT, WKS_LABEL_TEXT_CONTROL_ORIGIN_TEXT);
        wks_set_label_text_control(wks, RCLT_COMMENT, WKS_LABEL_TEXT_CONTROL_ORIGIN_TEXT);
        wks_set_label_text_control(wks, RCLT_UDL, WKS_LABEL_TEXT_CONTROL_ORIGIN_TEXT);                
                
        StringArray LongNames= {"H\-(2)", "Si", "N\-(2)"};
        StringArray UnitNames= {"\g(m)mol/s", "\g(m)mol/s", "\g(m)mol/s"};
        StringArray CommentNames= {"H\-(2)O", "SiO\-(2)", "NO"};
        StringArray UDPNames= {"e\+(-t)", "e\+(-2t)", "e\+(-3t)"};

        for( int ii = 0 ; ii < 3 ; ii++ )
        {
            wks.Columns(ii).SetExtendedLabel(LongNames[ii], RCLT_LONG_NAME);
            wks.Columns(ii).SetExtendedLabel(UnitNames[ii], RCLT_UNIT);
            wks.Columns(ii).SetExtendedLabel(CommentNames[ii], RCLT_COMMENT); 
            wks.Columns(ii).SetExtendedLabel(UDPNames[ii], RCLT_UDL);
        }    
    }  
}

Wks set label text control img.png

Remark

See Also

Column::SetExtendedLabel Grid::SetUserDefinedLabelNames Grid::GetShowLabels Grid::SetShowLabels

header to Include

origin.h

Reference