How can we give the shadow on the textbox background like this? Flash lite application runs on Symbian phones, so they must have done some kind of tricks using Symbian. In my application, I was required to do the same thing. There is a way to put custom drawed background on the CEikEdwin. I dont know if it is the way that flashlite used to show shadow on TextBox background, but it surely works.The things is , you have to implement MFormCustomDraw interface. Just take a Class which looks like
#include
#include
class CMyCustomDraw : public MFormCustomDraw
{
public: // Constructors and destructor
virtual void DrawBackground(const TParam &aParam, const TRgb &aBackground, TRect &aDrawn) const;
virtual void DrawLineGraphics(const TParam &aParam, const TLineInfo &aLineInfo) const;
};
The MFormCustomDraw has two some virtual functions (Drawbackground() and DrawLineGraphics()). We have to implement these two functions (Or preferrably only the first one) in order to get a custom shadow on the CEikEdwin background.
So, we have to just write the implementation of DrawBackground() function. The implementation is straight forward - you have the graphics Conrtext (aParam.iGc), you have the CEikEdwin Background Rectangle (aParam.iDrawRect), so you have everything. So, just put your code in
CMyCustomDraw::DrawBackground(const TParam &aParam, const TRgb &aBackground, TRect &aDrawn) const{} function.
Now, how do we use it with our CEikEdwin. Lets say, you have a CEikEdwin in your container.So, you create your CEikEdwin in the natural way and after constructing you write,
CMyCustomDraw* iCustomDraw = new (ELeave) CMyCustomDraw();
and iTextField->TextLayout()->SetCustomDraw(iCustomDraw);
and not only that. In the containers draw function, you have to set it everytime.
iTextField->TextLayout()->SetCustomDraw(iCustomDraw);
This is how we do it !!!!

0 comments:
Post a Comment