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