Implementation of multi-view setting list

Source: Internet
Author: User

Recently, I have read a list of multi-view settings in some programs. I learned how to implement it and recorded it briefly to avoid future reference. The main functions are as follows:

Main Program Interface

Select Settings in the menu

Open settings view 1

Open settings view 2

1. The UI class inherits from the makntabobserver class and implements its void tabchangedl (tint aindex); function (for detailed implementation, see below ).

2. Define the pointer of the navigation indicator in the UI class

Caknnavigationdecorator * inavidecorator;

3. Implement the following in the UI function:

Void cs60uiexampleappui: handlecommandl (tint acommand)
{
Switch (acommand)
{
Case eeikcmdexit:
Case eaknsoftkeyexit:
Exit ();
Break;

// Select the settings menu
Case es60uiexamplesettings:
{
Tuid navipaneuid;
Navipaneuid. iuid = eeikstatuspaneuidnavi;

Ceikstatuspane * statuspane = statuspane ();

Ceikstatuspanebase: tpanecapabilities subpane =
Statuspane-> panecapabilities (navipaneuid );

// If we can access the Navigation Pane
If (subpane. ispresent () & subpane. isappowned ())
{

Caknnavigationcontrolcontainer * navipane =
(Caknnavigationcontrolcontainer *) statuspane-> controll (navipaneuid );

Delete inavidecorator;
Inavidecorator = NULL;

// Ownership is transferred to us here
Inavidecorator = navipane-> createtabgroupl ();

// Ownership not transferred
Cakntabgroup * tabgroup = (cakntabgroup *) inavidecorator-> decoratedcontrol ();

// Display two tabs of normal length on the Navigation Pane at a time
Tabgroup-> settabfixedwidthl (ktabwidthwithonetab); // you can specify whether one or more labels are displayed in the View bar.
Tabgroup-> setobserver (this );

// Add two views and titles to be displayed. You can also add multiple

Hbufc * tab1text = stringloader: loadlc (r_s60uiexample_highscore_title_text );
Tabgroup-> addtabl (es60uiexamplesettingsviewid1, * tab1text );
Cleanupstack: popanddestroy (tab1text );

Hbufc * tab2text = stringloader: loadlc (r_s60uiexample_resetting_text );
Tabgroup-> addtabl (es60uiexamplesettingsviewid2, * tab2text );
Cleanupstack: popanddestroy (tab2text );

// Highlight the first tab
Tabgroup-> setactivetabbyindex (0 );
Navipane-> pushl (* inavidecorator );

// Activate the first view
Activatelocalviewl (tuid: UID (tabgroup-> tabidfromindex (0 )));
}
Break;
}

// Destroy the navigation bar when the returned view is set
Case es60uiexampledelnavi:
{
Tuid navipaneuid;
Navipaneuid. iuid = eeikstatuspaneuidnavi;
Ceikstatuspane * statuspane = statuspane ();
Ceikstatuspanebase: tpanecapabilities subpane =
Statuspane-> panecapabilities (navipaneuid );

// If we can access the Navigation Pane
If (subpane. ispresent () & subpane. isappowned ())
{

Caknnavigationcontrolcontainer * navipane =
(Caknnavigationcontrolcontainer *) statuspane-> controll (navipaneuid );
Delete inavidecorator;
Inavidecorator = NULL;
Navipane-> pushdefaultl ();
}
Break;
}
Default:
Panic (es60uiexamplebasicui );
Break;
}
}

// Response from the acceptance button in the navigation bar

Tkeyresponse cs60uiexampleappui: handlekeyeventl (const tkeyevent & akeyevent, teventcode Atype)
{
If (inavidecorator = NULL)
{
Return ekeywasnotconsumed;
}

Cakntabgroup * tabgroup = (cakntabgroup *) inavidecorator-> decoratedcontrol ();

If (tabgroup = NULL)
{
Return ekeywasnotconsumed;
}

// If we 've got a tab group, then offer the key event to it.
Return tabgroup-> offerkeyeventl (akeyevent, Atype );
}

// Display different views based on the buttons

Void cs60uiexampleappui: tabchangedl (tint aindex)
{
If (inavidecorator! = NULL)
{
Cakntabgroup * tabgroup = (cakntabgroup *) inavidecorator-> decoratedcontrol ();
Activatelocalviewl (tuid: UID (tabgroup-> tabidfromindex (aindex )));
}
}

// Delete the corresponding navigation bar indicator from the UI class destructor

Cs60uiexampleappui ::~ Cs60uiexampleappui ()
{
Delete inavidecorator;
Inavidecorator = NULL;
}

4. Implement the offerkeyeventl function in the settings list class from caknsettingitemlist to avoid left and right navigation failures.

Tkeyresponse cs60uiexamplelist: offerkeyeventl (const tkeyevent & akeyevent, teventcode Atype)
{
If (Atype! = Eeventkey) // is not key event?
{
Return ekeywasnotconsumed;
}
Switch (akeyevent. icode)
{
Case ekeyleftarrow:
Case ekeyrightarrow:
Return ekeywasnotconsumed;
Break;
Default:
Break;
}

}

5. Destroy the navigation indicator created in the UI when pressing the return button in the View class of each setting list

Void cs60uiexamplesettingsview: handlecommandl (tint acommand)
Add the following code to the function:
Case eaknsoftkeyback:
{
Appui ()-> handlecommandl (es60uiexampledelnavi );
Appui ()-> activatelocalviewl (tuid: UID (es60uiexampleinitialviewid ));
Break;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.