×

Discussion Board

Page 1 of 4 1234 LastLast
Results 1 to 15 of 46
  1. #1
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Hamburg
    Posts
    58

    own CCoeControl to realize an always on top icon

    hi all,

    i tried to implement a custom control, to realize an always on top icon on the entire screen of series60 phones. The icon should indicate that my app runs in the background.

    my control:

    Code:
    COnTopIcon* COnTopIcon::NewL() {
        COnTopIcon* self = new (ELeave)COnTopIcon();
        CleanupStack::PushL(self);
        self->ConstructL();
        CleanupStack::Pop(self);
        return self;		
    }
    
    COnTopIcon::COnTopIcon() {}
    
    COnTopIcon::~COnTopIcon() {
        delete iRect;
    }
    
    void COnTopIcon::ConstructL() {
        iRect = new TRect(140,10,156,26);	       
        CreateWindowL();
        SetRect(*iRect);
        EnableDragEvents();
        ActivateL();
    }
    
    void COnTopIcon::Draw(const TRect& aRect) const {
       CWindowGc& gc = SystemGc();
       gc.SetPenStyle(CGraphicsContext::ENullPen);
       gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       gc.SetBrushColor(KRgbBlue);
       gc.DrawRect(aRect);
    }
    In this way i create an instance of the custom control in the ConstrutL of the Container of the app.

    Code:
    COnTopIcon* iOnTopIcon = COnTopIcon::NewL();
    The component works: a blue rectangle will be shown on top of the screen, but only if my app have the focus.

    My idea is to call CreateWindowL() with the entire screen as parent window, to show the component on the phone screen. But how can i do this?

    Thx a lot...

  2. #2
    Registered User
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747

    Re: own CCoeControl to realize an always on top icon

    Use this code in your control class's (COnTopIcon) ConstructL:

    Code:
    iMyWindowGroup = RWindowGroup(iCoeEnv->WsSession());
            User::LeaveIfError(iMyWindowGroup.Construct((TUint32)&iMyWindowGroup));
    
            iMyWindowGroup.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
            iMyWindowGroup.EnableReceiptOfFocus(EFalse);
    
            CreateWindowL(&iMyWindowGroup);
    You may refer my article here: How to draw an Icon on the IndicatorPane of Series 60.

    More over this thread from FN is also a good reference: Custom window in ALL screen modes.

  3. #3
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Hamburg
    Posts
    58

    Thumbs up Re: own CCoeControl to realize an always on top icon

    Thank you very much, vin2ktalks!

    Your article is great and your solution works fantastic.

    Thx

  4. #4
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Hamburg
    Posts
    58

    Re: own CCoeControl to realize an always on top icon

    Hmmm,

    now i have an indicator icon that is always on top.

    But the icon is ALWAYS on top - in every screen, in every app, ...

    I think that is not userfriendly enough, is there a way to get focus events from other app's to check, which app have the focus?

    In this way i could hide the icon, if the focus is not on the entire screen, the phonebook or the calling history.

    Any ideas an implementation?

  5. #5
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Hamburg
    Posts
    58

    Re: own CCoeControl to realize an always on top icon

    Ok,

    i found some information:

    With TApaTaskList::FindByPos(0) in combination with wgId() and AppUid() the UID of the application on foreground will be delivered.

    But i need an event on every focus change!

    Maybe i can ask the window server for a focus change event...

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: own CCoeControl to realize an always on top icon

    Search for HandleForegroundEventL in the SDK Help. But I cannot really see why is it a problem that an icon supposed to be always-on-top is actually always-on-top.

  7. #7
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: own CCoeControl to realize an always on top icon

    Quote Originally Posted by wizard_hu_
    Search for HandleForegroundEventL in the SDK Help. But I cannot really see why is it a problem that an icon supposed to be always-on-top is actually always-on-top.
    I think he means to say the icon is on top even when it should not be.Like when the some application is full screen,then this "always-on-top" should be hidden.
    --Mayur.

  8. #8
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Hamburg
    Posts
    58

    Re: own CCoeControl to realize an always on top icon

    That's exactly what i mean mayur_24...

    The always on top icon overlaps fullscreen apps, too. On the other hand some context pane title texts will be hidden by the icon.

    I think thats not user freindly and it could be difficult in a symbian signing process.

    Thanks wizard_hu_ for the tipp that i can use HandleForegroundEvenL. I read the SDK doc, but if i understand this method, it handles only a focus change to my application (my app comes to the foreground). I need all focus change events - from other apps too.

    Does anybody know a way to realize this?

  9. #9
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: own CCoeControl to realize an always on top icon

    Basically you just need to keep the icon on the top only when the standby application is on foreground and that is when it will really make sense and all the info related icons of the system are all shown one time only when this application is in the foreground.Otherwise its nearly impossible to know whether the application in the foreground in a full screen application or not.
    --Mayur.

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: own CCoeControl to realize an always on top icon

    If you type window server event to the search field of SDK Help, you will find some "how to ..." hits (order topics by title :-). Some of them are dealing with focus events. Although it does not explicitly say if you can get focus events for other applications, I suppose so (since the Window Server does not deal with applications, it deals with window groups).

  11. #11
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Hamburg
    Posts
    58

    Re: own CCoeControl to realize an always on top icon

    Thx,

    i don't want to disable the on top icon only in fullscreen apps. I want to hide the icon if the user is not on the entire screen, phonebook or calling history.

    In this case i need to get events on every focus change.

    Do you know if i can realize a solution with the CAknWsEventMonitor?

  12. #12
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: own CCoeControl to realize an always on top icon

    Quote Originally Posted by grapentin
    I want to hide the icon if the user is not on the entire screen, phonebook or calling history.
    Did not understand,please elaborate?
    --Mayur.

  13. #13
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Hamburg
    Posts
    58

    Re: own CCoeControl to realize an always on top icon

    I can explicit hide the on top icon:

    Code:
    iOnTopIcon->MakeVisible(EFalse);
    I need the icon to indicate that my software runs in the background. This is interesting for the user only in three states:

    1. The user is on the start screen (telephony or entire screen).
    2. The user has opened the phonebook.
    3. The user is in the calling history.

    I want to hide the icon, if an other application is in foreground and have the focus.

    In this case i need the possibility to get global focus change events.

    If a global focus change event occurs, my idea is to check the UID of the application that have the focus. I will do this with TApaTaskList::FindByPos(0) in combination with wgId() and AppUid().

    If the UID equals the UID of the entire screen, the phonebook or the calling history i will set the icon visible. Otherwise i will hide the icon.

    That's the plan - the problem is to get gloabl focus change events :-(.

    Do you understand hat i mean?

  14. #14
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: own CCoeControl to realize an always on top icon

    Yup got it.
    Well just check out RWindow::EnableFocusChangeEvents and RWindow::EnableGroupChangeEvents.This will notify you whenever there is a change in focus or if a new application is launched.So on that just check if the app on top is the one you are looking for.
    And as for thw window you can get it from CCoeControl::Window().
    Hope this helps.
    --Mayur.

  15. #15
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Hamburg
    Posts
    58

    Re: own CCoeControl to realize an always on top icon

    Thx mayur,

    that is an absolutely great idea to solve the problem in this way.

    But i have some trouble with the implementation... :-(

    The on top icon derives from CCoeControl. In the ContructL a window will be created and i call EnableFocusChangeEvents() and EnableGroupChangeEvents() on the regarding window group:

    Code:
    ...
    
    void COnTopIcon::ConstructL() {
    
        iWindowGroup = RWindowGroup(iCoeEnv->WsSession());
        User::LeaveIfError(iWindowGroup.Construct((TUint32)&iWindowGroup));
    
        iWindowGroup.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
        iWindowGroup.EnableReceiptOfFocus(EFalse);
    
        iWindowGroup.EnableFocusChangeEvents();
        iWindowGroup.EnableGroupChangeEvents();
    
        CreateWindowL(&iWindowGroup);
    	
        iIndicator = CEikonEnv::Static()->CreateBitmapL(iDataManager->GetMbmFile(), EMbmLogo12x12);
        iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(iDataManager->GetMbmFile(), EMbmLogo12x12_mask);    
    
        SetRect(TRect(TPoint(KIndicatorPosX, KIndicatorPosY), iIndicator->SizeInPixels()));
        DrawNow();
    
        iFocusObserver = CFocusObserver::NewL(this, iCoeEnv->WsSession());
        iFocusObserver->StartL();
    
        ActivateL();    
    }
    
    ...
    Furthermore a CActive should handle the focus event listening (iFocusObserver):

    Code:
    ...
    
    void CFocusObserver::StartL() {
        iWs.EventReady(&iStatus);
        SetActive();
    }
    
    void CFocusObserver::RunL() {
        
        const TUid KUidPhone = { 0x100058b3 };
        
        TInt wgid = iWs.GetFocusWindowGroup();
        CApaWindowGroupName* gn = CApaWindowGroupName::NewLC(iWs, wgid);
        TUid uid = gn->AppUid();
        
        iOnTopIcon->MakeVisible((uid == KUidPhone));
        
        StartL();
    }
    
    void CFocusObserver::DoCancel() {
        iWs.EventReadyCancel();
    }
    
    ...
    The app will crash without an specific error.

    If i not call the StartL() of the focus observer the app works fine (without the focus change handling).

    I tried to debug this, but the app crashes at any point in the EIKCORE.DLL after the ConstructL() of my AppUI class.

    Does anybody have an idea, where i make a mistake?

    Thank you all...

Similar Threads

  1. Replies: 7
    Last Post: 2007-09-05, 10:38
  2. N80 midlet icon problem revisited... questions
    By kounapuu in forum Mobile Java General
    Replies: 1
    Last Post: 2006-10-07, 20:15
  3. Displaying a small icon in the top right corner
    By nrc_freak in forum Symbian
    Replies: 1
    Last Post: 2005-11-17, 12:47
  4. FullCanvas icon at the top left corner
    By msezgin in forum Mobile Java General
    Replies: 2
    Last Post: 2003-08-28, 07:33
  5. Replies: 2
    Last Post: 2002-08-16, 10:39

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×