Applicable version
S60 2nd Edition FP3, S60 3rd Edition
This article describes how to draw a front-end icon prompt in Series60. The actual effect is shown in, the icons of a single note are always visible. This can serve as a prompt for some applications. For example, in an IM software, it can be used to prompt for unread messages.
1. Build the following build process based on the sample program provided by me: Build a CIndicatorIcon class to represent this prompt icon, which is inherited from CCoeControl. Its second-stage ConstructL () ConstructL is as follows:
Void CIndicatorIcon: ConstructL () {iMyWindowGroup = RWindowGroup (iCoeEnv-> WsSession (); User: LeaveIfError (iMyWindowGroup. construct (TUint32) & iMyWindowGroup); iMyWindowGroup. setOrdinalPosition (0, ECoeWinPriorityAlwaysAtFront); iMyWindowGroup. enableReceiptOfFocus (EFalse); createmediawl (& iMyWindowGroup); // by default, the prompt icon is set to inactive SetIndicatorIconL (EIndicatorIconAppActive); ActivateL ();}
In ConstructL (), SetIndicatorIconL () is called to set the icon. The following describes the specific implementation of this function:
Void CIndicatorIcon: Adjust (TIndicatorIcon release, TBool aRedraw) {switch (release) {case when: iIndicator = CEikonEnv: Static ()-> CreateBitmapL (KSysIconFile, release ); response = CEikonEnv: Static ()-> CreateBitmapL (KSysIconFile, callback); break; case when: iIndicator = CEikonEnv: Static ()-> CreateBitmapL (KSysIconFile, callback ); response = CEikonEnv: Static ()-> CreateBitmapL (KSysIconFile, callback); break; case when: iIndicator = CEikonEnv: Static ()-> CreateBitmapL (KSysIconFile, callback ); iIndicatorMask = CEikonEnv: Static ()-> CreateBitmapL (KSysIconFile, secret); break; default: break;} SetRect (TRect (TPoint (KIndicatorPosX, dickinatorposy ), iIndicator-> SizeInPixels (); // when aRedraw = ETrue, only if (aRedraw) {DrawNow ();}}
At the same time, you must rewrite the Draw () function of CCoeControl to Draw a prompt icon at the appropriate position.
void CIndicatorIcon::Draw(const TRect& aRect) const { CWindowGc& gc = SystemGc(); gc.Clear(); gc.SetBrushStyle(CGraphicsContext::ENullBrush); gc.BitBltMasked(TPoint(aRect.iTl.iX, aRect.iTl.iY), iIndicator, TRect(TPoint(0, 0), iIndicator->SizeInPixels()), iIndicatorMask, ETrue); }
By now, you have completed the construction of the CIndicatorIcon class.
2. Add the following statement to the ConstructL () of the AppUi of your program:
IIndicatorIcon = CIndicatorIcon: NewL (); // set the iIndicatorIcon icon to be drawn in the following row-> SetIndicatorIconL (CIndicatorIcon: EIndicatorIconAppInactive, ETrue );
Yes, it's that simple.