bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappui.cpp
changeset 0 f63038272f30
child 9 a42ed326b458
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <avkon.hrh>
       
    20 #include <eikmenup.h>
       
    21 #include <e32property.h>
       
    22 #include <paintcursor.rsg>
       
    23 
       
    24 #include "paintcursorapp.h"
       
    25 #include "paintcursorappui.h"
       
    26 #include "paintcursorapp.h"
       
    27 #include "paintcursorappview.h"
       
    28 #include "debug.h"
       
    29 #include "bthidPsKey.h"
       
    30 
       
    31 void CPaintCursorAppUi::ConstructL()
       
    32     {
       
    33     TRACE_INFO(_L("[PaintCursor]\t CPaintCursorAppUi::ConstructL()"));
       
    34     BaseConstructL();
       
    35 
       
    36     iAppView = CPaintCursorAppView::NewL(ClientRect());
       
    37 
       
    38     iAppView->SetMopParent(this);   //  so view can update scroll bars
       
    39 
       
    40     AddToStackL(iAppView);
       
    41 
       
    42     
       
    43     iPsKeyWatcher = CBTMouseCursorStatusObserver::NewL();
       
    44     
       
    45     iPsKeyWatcher->SubscribeMouseCursorStatusL(this);
       
    46     }
       
    47 
       
    48 CPaintCursorAppUi::~CPaintCursorAppUi()
       
    49     {
       
    50 
       
    51     if (iAppView)
       
    52         {
       
    53         RemoveFromStack(iAppView);
       
    54 
       
    55         delete iAppView;
       
    56         iAppView = 0;
       
    57         }
       
    58 
       
    59     if (iPsKeyWatcher)
       
    60         delete iPsKeyWatcher;
       
    61     }
       
    62 
       
    63 
       
    64 
       
    65 // ------------------------------------------------------------------------------
       
    66 // CPaintCursorAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
    67 //  This function is called by the EIKON framework just before it displays
       
    68 //  a menu pane. Its default implementation is empty, and by overriding it,
       
    69 //  the application can set the state of menu items dynamically according
       
    70 //  to the state of application data.
       
    71 // ------------------------------------------------------------------------------
       
    72 //
       
    73 void CPaintCursorAppUi::DynInitMenuPaneL(
       
    74     TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
       
    75     {}
       
    76 
       
    77 TKeyResponse CPaintCursorAppUi::HandleKeyEventL(
       
    78     const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
    79     {
       
    80     return EKeyWasNotConsumed;
       
    81     }
       
    82 
       
    83 void CPaintCursorAppUi::HandleCommandL(TInt aCommand)
       
    84     {
       
    85     TRACE_INFO((_L("[PaintCursor]\t CPaintCursorAppUi::HandleCommandL(%d)"),aCommand));
       
    86     switch ( aCommand )
       
    87         {
       
    88         case EEikCmdExit :
       
    89         case EAknSoftkeyExit:
       
    90             {
       
    91             Exit();
       
    92             break;
       
    93             }
       
    94 
       
    95         case EAknSoftkeyBack:
       
    96             {
       
    97             SendToBackground();
       
    98             break;
       
    99             }
       
   100 
       
   101         default:
       
   102         break;
       
   103         }
       
   104     }
       
   105 
       
   106 void CPaintCursorAppUi::SendToBackground()
       
   107     {
       
   108     // Construct en empty TApaTask object
       
   109     // giving it a reference to the Window Server session
       
   110     TApaTask task(CEikonEnv::Static()->WsSession( ));
       
   111 
       
   112     // Initialise the object with the window group id of
       
   113     // our application (so that it represent our app)
       
   114     task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
       
   115 
       
   116     // Request window server to bring our application
       
   117     // to background
       
   118     task.SendToBackground();
       
   119     }
       
   120 
       
   121 void CPaintCursorAppUi::MouseCursorStatusChangedL(TInt aStatus)
       
   122     {
       
   123     
       
   124     switch (aStatus)
       
   125         {
       
   126         case ECursorShow:
       
   127             {
       
   128             iAppView->ShowCursor();
       
   129             break; 
       
   130             }
       
   131         case ECursorHide:
       
   132             {
       
   133             iAppView->HideCursor();
       
   134             break;
       
   135             }
       
   136         case ECursorNotInitialized:
       
   137             {
       
   138             EndTask();
       
   139             }
       
   140         default:
       
   141             {
       
   142             break;
       
   143             }
       
   144         }
       
   145     }
       
   146 
       
   147 
       
   148 void CPaintCursorAppUi::EndTask()
       
   149     {
       
   150     // Construct en empty TApaTask object
       
   151     // giving it a reference to the Window Server session
       
   152     TApaTask task(CEikonEnv::Static()->WsSession( ));
       
   153 
       
   154     // Initialise the object with the window group id of
       
   155     // our application (so that it represent our app)
       
   156     task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
       
   157 
       
   158     // Request window server to end our application
       
   159     task.EndTask();
       
   160     }
       
   161