Using theme in an application

Source: Internet
Author: User

Using theme in an application
This article can tell you how to write a enable skins application. you can use theme in an application after version in Series 60 Platform 2.0. the following content will tell you how to do these step by step.


Link against aknskins. lib and include filesAdd the libray named aknskins. Lib in skinsample. MMP 

Code:Library aknskins. Lib // link against aknskins. Lib

Add two include files in skinexamplecontainer. h

 

Code:# Include <aknsdrawutils. h> // Add this inlcude file skin
# Include <aknsbasicbackgroundcontrolcontext. h> // Add this inlcude file skin Enabling skins in Appui

Code:/* In skinexampleappui. cpp */

Void cskinexampleappui: constructl ()
{
Baseconstructl (eaknenableskin); // construct a enalbe skin...} new and delete a maknscontrolcontext class in container class

Add a maknscontrolcontext class in container class

Code:/* In skinexamplecontainer. H */

Class cskinexamplecontainer: Public ccoecontrol, mcoecontrolobserver {.... PRIVATE: maknscontrolcontext * ibackground; // For skins support}/* In skinexaplecontainer. CPP */void cskinexamplecontainer: constructl (const trect & arect)
{
Createmediawl (); ilabel = new (eleave) ceiklabel;
Ilabel-> setcontainer1_wl (* This );
Ilabel-> settextl (_ L ("skin example"); setrect (arect );
Ibackground = caknsbasicbackgroundcontrolcontext: newl (kaknsiidqsnbgareamain, rect (), efalse); // new a background activatel ();
} Delete ibackgroud

Code:// Destructor
Cskinexamplecontainer ::~ Cskinexamplecontainer ()
{
.....

Delete ibackground;
} Draw the background Bitmap Using Skin Library Code:/* In skinexaplecontainer. cpp */

Void cskinexamplecontainer: Draw (const trect & arect) const
{
Cwindowgc & GC = systemgc ();
// Draw background
Maknsskininstance * Skin = aknsutils: skininstance (); // new
Maknscontrolcontext * Cc = aknsdrawutils: controlcontext (this); // new
Aknsdrawutils: background (skin, CC, this, GC, arect); // new
} Mobjectprovider chainsmobjectprovider interface can be used to make object instances available to child controls. mopsupplyobject returns a pointer Based on the given uid. Code:/* In skinexaplecontainer. cpp */

Ttypeuid: PTR cskinexamplecontainer: mopsupplyobject (ttypeuid aid)
{
If (AID. iuid = maknscontrolcontext: etypeid & ibackground)
{
Return maknscontrolcontext: supplymopobject (aid, ibackground );
} Return ccoecontrol: mopsupplyobject (aid );
} Note: If you want to get the source code about this article, plz contact me.

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 751487

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.