Setting toolbar properties

Use the following methods and flags to set toolbar properties:

  • Vertical orientation: use the method CAknToolbar::SetOrientation() with the values EAknOrientationVertical or EAknOrientationHorizontal in TAknOrientation (floating toolbar).

  • Semi-transparent outlook: use the KAknToolbarTransparent flag.

  • Flexible positioning: use the KAknToolbarFlexiblePosition flag (floating toolbar).

  • To set the focus on the middle item by default, use the flag KAknToolbarMiddleItemFocused (floating toolbar).

  • To set the toolbar always focusing, use the flag KAknToolbarAlwaysFocusing (floating toolbar).

  • To set the focus on the last used item by default, use the flag KAknToolbarLastUsedItemFocused flag (floating toolbar).

  • To set the toolbar to use no softkeys but still have the focus, use the flag KAknToolbarWithoutCba (floating toolbar).

  • Small toolbar: use the flag KAknToolbarSmall flag (floating toolbar).

  • Fixed toolbar: use the flag KAknToolbarFixed .

  • Toolbar with no skin background: use the flag KAknToolbarNoBackground .

Below is an example of a fixed toolbar with three buttons. One of the fixed toolbar buttons is a toolbar extension with three buttons.

       RESOURCE AVKON_TOOLBAR r_myapp_fixed_toolbar 
    { 
    flags = KAknToolbarFixed; 
    items = 
        { 
        TBAR_CTRL 
            { 
            type = EAknCtToolbarExtension; 
            id = ECmdExtExample; 

            control = AVKON_TOOLBAR_EXTENSION 
                { 
                items = 
                    { 
                    TBAR_CTRL 
                        { 
                        type = EAknCtButton; 
                        id = ECmdExtExample1; 
                        control = AVKON_BUTTON 
                            { 
                            flags = 0; 
                            states = 
                                { 
                                AVKON_BUTTON_STATE 
                                    { 
                                    txt = STRING_r_myapp_ext_example1_text; 
                                    helptxt = STRING_r_myapp_ext_example1_help; 
                                    } 
                                }; 
                            }; 
                        }, 
                    TBAR_CTRL 
                        { 
                        type = EAknCtButton; 
                        id = ECmdExtExample2; 
                        control = AVKON_BUTTON 
                            { 
                            flags = 0; 
                            states = 
                                { 
                                AVKON_BUTTON_STATE 
                                    { 
                                    txt = STRING_r_myapp_ext_example2_text; 
                                    helptxt = STRING_r_myapp_ext_example2_help; 
                                    } 
                                }; 
                            }; 
                        }, 
                    TBAR_CTRL 
                        { 
                        type = EAknCtButton; 
                        id = ECmdExtExample3; 
                        control = AVKON_BUTTON 
                            { 
                            flags = 0; 
                            states = 
                                { 
                                AVKON_BUTTON_STATE 
                                    { 
                                    txt = STRING_r_myapp_ext_example3_text; 
                                    helptxt = STRING_r_myapp_ext_example3_help; 
                                    } 
                                }; 
                            }; 
                        } 
                    }; 
                }; 
            }, 
        TBAR_CTRL 
            { 
            type = EAknCtButton; 
            id = ECmdExample1; 
            control = AVKON_BUTTON 
                { 
                flags = 0; 
                states = 
                    { 
                    AVKON_BUTTON_STATE 
                        { 
                        txt = STRING_r_myapp_example1_text; 
                        helptxt = STRING_r_myapp_example1_help; 
                        }  
                    }; 
                }; 
            }, 
        TBAR_CTRL 
            { 
            type = EAknCtButton; 
            id = ECmdExample2; 
            control = AVKON_BUTTON 
                { 
                flags = 0; 
                states = 
                    { 
                    AVKON_BUTTON_STATE 
                        { 
                        txt = STRING_r_myapp_example2_text; 
                        helptxt = STRING_r_myapp_example2_help; 
                        }  
                    }; 
                }; 
            } 
        }; 
    }
      

Example of a floating toolbar without CBA buttons:

       RESOURCE AVKON_TOOLBAR r_myapp_floating_toolbar 
    { 
    flags = KAknToolbarWithoutCba; 
    items = 
        { 
        TBAR_CTRL 
            { 
            type = EAknCtButton; 
            id = ECmdExample3; 
            // A button with two states ("on" and "off") 
            control = AVKON_BUTTON 
                { 
                flags = 0; 
                states = 
                    { 
                    AVKON_BUTTON_STATE 
                        { 
                        txt = STRING_r_myapp_example3_off_text; 
                        helptxt = STRING_r_myapp_example3_off_help; 
                        }, 
                    AVKON_BUTTON_STATE 
                        { 
                        flags = KAknButtonStateHasLatchedFrame; 
                        txt = STRING_r_myapp_example3_on_text; 
                        helptxt = STRING_r_myapp_example3_on_help; 
                        }  
                    }; 
                }; 
            }, 
        TBAR_CTRL 
            { 
            type = EAknCtButton; 
            id = ECmdExample4; 
            control = AVKON_BUTTON 
                { 
                flags = 0; 
                states = 
                    { 
                    AVKON_BUTTON_STATE 
                        { 
                        txt = STRING_r_myapp_example4_text; 
                        helptxt = STRING_r_myapp_example4_help; 
                        } 
                    }; 
                }; 
            }, 
        TBAR_CTRL 
            { 
            type = EAknCtButton; 
            id = ECmdExample5; 
            control = AVKON_BUTTON 
                { 
                flags = 0; 
                states = 
                    { 
                    AVKON_BUTTON_STATE 
                        { 
                        txt = STRING_r_myapp_example5_text; 
                        helptxt = STRING_r_myapp_example5_help; 
                        } 
                    }; 
                }; 
            } 
        }; 
    }