[Symbian project progress] How to draw an icon on the s60 indicator panel, original code + schematic

Source: Internet
Author: User

When "Real-time Monitoring" is set in system settings, an icon should appear on the cell phone screen Indicator Panel, indicating thatProgramRun in the background.
This article discusses how to draw icons on the s60 indicator panel. To display the icon near the power panel, you must encode the icon.

I wrote a cindicatoricon class that inherits from ccoecontrol.
Constructl ()CodeAs 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 setting the indicator icon to inactive
Setindicatoriconl (eindicatoriconappactive );

Activatel ();
}

Note: rwindowgroup requires the w32std. h header file, and ws32.lib must be added during connection.
In the constructor, call another function setindicatoriconl () to set the icon:


Void Cindicatoricon: setindicatoriconl (tindicatoricon aindicatoricontype, tbool aredraw)
{
Switch (Aindicatoricontype)
{
Case Eindicatoriconempty:
Iindicator = Ceikonenv: static () -> Createbitmapl (ksysiconfile, embmavkonqgn_prop_empty );
Iindicatormask = Ceikonenv: static () -> Createbitmapl (ksysiconfile, embmavkonqgn_prop_empty_mask );
Break ;

Case Eindicatoriconappactive:
Iindicator = Ceikonenv: static () -> Createbitmapl (ksysiconfile, embmavkonqgn_bt_connect_on );
Iindicatormask = Ceikonenv: static () -> Createbitmapl (ksysiconfile, embmavkonqgn_bt_connect_on_mask );
Break ;

Case Eindicatoriconappinactive:
Iindicator = Ceikonenv: static () -> Createbitmapl (ksysiconfile, embmavkonqgn_prop_bt_audio );
Iindicatormask = Ceikonenv: static () -> Createbitmapl (ksysiconfile, embmavkonqgn_prop_bt_audio_mask );
Break ;

Default:
Break;
}

Setrect (trect (tpoint (kindicatorposx, kindicatorposy), iindicator -> Sizeinpixels ()));

// If aredraw = etrue just draw the canvas again.
If (Aredraw)
{
Drawnow ();
}
}

Set the icon to be displayed on the indicator panel, but you must reload the draw () function of ccoecontrol to display the icon. The draw () code is as follows:

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 );
}

Add the following two lines of code to the constructor of the Appui class:
Iindicatoricon = cindicatoricon: newl ();
// The next line will set the icon to draw and it'll draw to the screen.
Iindicatoricon-> setindicatoriconl (cindicatoricon: eindicatoriconappinactive, etrue );

As follows:

 

Indicator icon when application is running in the foreground.

  Indicator icon when application is running in the background ..

Indicator icon when application is running in the background with the task view ..

You can download the sample programSource code:

Sample Code for showing icon on the indicatorpane
Related Article

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.