Symbian C ++ title panel)

Source: Internet
Author: User

Generally, the title panel displays the applicationProgramCan be changed to a custom title or an image. If the selected title is too long and exceeds the line width, the title is displayed in two rows, if the two rows cannot be accommodated, the title will be truncated. You can also set the title to a null string, and the title will not be displayed.

The titlepane instance shows how to change the text of the title panel, how to display images in the title panel, and how to statically define the title panel in the resource file.

1. Modify the text of the title panel

Void ctitlepaneappui: handlecommandl (tint acommand)
{
Switch (acommand)
{
Case eeikcmdexit:
Case eaknsoftkeyexit:
Exit ();
Break;
// Modify the text of the title panel
Case etitlepanecmdtitletext:
{
// Define the title panel ID
Tuid titlepaneuid;
Titlepaneuid. iuid = eeikstatuspaneuidtitle;
// Obtain the status panel pointer
Ceikstatuspane * statuspane = This-> statuspane ();
/**
* Pass the panecapabilities method of the status panel and a title panel ID for it,
* Then this method returns a tpanecapabilities object.
* Tpanecapabilities is an internal or nested class of ceikstatuspane,
* It can describe sub-panels (such as title panel, context panel, navigation panel, and signal panel)
* Status (such as whether the Sub-panel exists in the status panel) and capabilities (such as whether the Sub-Panel can be changed by the application ).
*
Ceikstatuspane: tpanecapabilities subpane =
Statuspane-> panecapabilities (titlepaneuid );
/**
* Ispresent () determines whether the title panel exists
* Isappowned () check whether the title Panel can be changed by the referenced Program
*
If (subpane. ispresent () & subpane. isappowned ())
{
// Although the status panel returns the pointer of cakntitlepane, the ownership is not passed, so you do not need to clear the stack.
Cakntitlepane * titlepane = (cakntitlepane *) statuspane-> controll (titlepaneuid );
// Load the title text from the resource file
Hbufc * titletext = stringloader: loadlc (r_titlepane_title_text );
/**
* You can use settext () to set the title text,
* However, the settext () method obtains the ownership of its parameter (titletext pointer), so you do not need to delete the titletext pointer.
* You can also use settextl () to set the title text,
* However, the settextl () method copies its parameters and does not obtain the permission of the parameter. Therefore, you need to delete the titletext pointer on your own.
*
* Note: When the settextl () method is used, the input parameter should be * titletext rather than titletext-> des ()
* Because the parameters of the settextl () method are of the const tdesc & type, they cannot be modified.
*
Titlepane-> settextl (* titletext );
Cleanupstack: popanddestroy (titletext );
}
Break;
}
Default:
Panic (etitlepaneui );
Break;
}
}

2. Reset the default value of the title panel

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

// Reset the default value of the title panel
Case etitlepanecmddefaulttitle:
{
Tuid titlepaneuid;
Titlepaneuid. iuid = eeikstatuspaneuidtitle;
// Obtain the status panel
Ceikstatuspane * statuspane = This-> statuspane ();
Ceikstatuspane: tpanecapabilities subpane =
Statuspane-> panecapabilities (titlepaneuid );
If (subpane. ispresent () & subpane. isappowned ())
{
Cakntitlepane * titlepane = (cakntitlepane *) statuspane-> controll (titlepaneuid );
// Reset the default value of the title panel
Titlepane-> settexttodefaultl ();
}
Break;
}
Default:
Panic (etitlepaneui );
Break;
}
}

3. display the image in the title panel

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

// Display the image in the title panel
Case etitlepanecmdtitleimage:
{
_ Partition (ktitlebitmapfile, "\ System \ apps \ titlepane. MBM ");
Tuid titlepaneuid;
Titlepaneuid. iuid = eeikstatuspaneuidtitle;
Ceikstatuspane * statuspane = This-> statuspane ();
Ceikstatuspane: tpanecapabilities subpane =
Statuspane-> panecapabilities (titlepaneuid );

// If you can access the title panel
If (subpane. ispresent () & subpane. isappowned ())
{
Cakntitlepane * titlepane =
(Cakntitlepane *) statuspane-> controll (titlepaneuid );
Cfbsbitmap * bitmap = ieikonenv-> createbitmapl (ktitlebitmapfile, embmtitlepanetitle );

// Set the title panel Image
Titlepane-> setpicture (Bitmap );
}
Break;
}
Default:
Panic (etitlepaneui );
Break;
}
}

4. Change the text and image of the title panel in the resource file

Resource eik_app_info
{
Status_pane = r_titlepane_status_pane;
Menubar = r_titlepane_menubar;
CBA = r_avkon_softkeys_options_exit;
}

// Define the title panel containing text
Resource title_pane r_titlepane_title_pane
{
// Title text
TXT = qtn_titlepane_title_text;
}

// Define the title panel containing the image
Resource title_pane r_titlepane_title_pane
{
// Title Image
BMP id = embmtitlepanetitle;
// BMP maskid = embmtitlepanemasktitle
BMP file = "\ System \ apps \ titlepane. MBM ";
}

// Define the status panel
Resource status_pane_app_model r_titlepane_status_pane
{
Panes =
{
Spane_pane
{
Id = eeikstatuspaneuidtitle; // avkon. HR 810
Type = eakncttitlepane; // avkon. HR 415
Resource = r_titlepane_title_pane;
}
};
}

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.