textinput/peninputarc/gsplugin/gspeninputplugin/src/gspeninputplugin.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  GSPenInputPlugin implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <gspeninputpluginrsc.rsg>
       
    20 #include <gslistbox.h>
       
    21 #include <gsprivatepluginproviderids.h>
       
    22 #include <aknViewAppUi.h>
       
    23 #include <StringLoader.h>
       
    24 #include <hlplch.h> // HlpLauncher
       
    25 #include <peninputpluginutils.h>
       
    26 #include <eikmenup.h>
       
    27 #include <akntitle.h> 
       
    28 #include <eikapp.h>
       
    29 #include <gspeninputplugin.mbg>
       
    30 #include <AknsUtils.h>
       
    31 
       
    32 #include "gspeninputplugin.h"
       
    33 #include "gspeninputcontainer.h"
       
    34 #include "gspeninputmodel.h"
       
    35 
       
    36 _LIT( KPeninputIconFileName, "gspeninputplugin_aif.mif" );
       
    37 
       
    38 const TUid KUidPenInputSettingApp = { 0x2001959B };
       
    39 
       
    40 const TUid KUidCalibrationApp = { 0x102828BC };
       
    41 
       
    42 
       
    43 // ======== MEMBER FUNCTIONS ========
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // Constructor
       
    47 // ---------------------------------------------------------
       
    48 //
       
    49 CGSPenInputPlugin::CGSPenInputPlugin()
       
    50     {
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // Destructor
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 CGSPenInputPlugin::~CGSPenInputPlugin()
       
    58     {
       
    59     REComSession::DestroyedImplementation( iDestrouctorIDKey );
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // Constructor
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 void CGSPenInputPlugin::ConstructL()
       
    67     {
       
    68     OpenLocalizedResourceFileL(KGSInputPenPluginResourceFileName,
       
    69                                iResourceLoader);
       
    70     BaseConstructL(R_GS_INPUT_VIEW);
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------
       
    74 // Constructor
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 CGSPenInputPlugin* CGSPenInputPlugin::NewL(TAny* /*aInitParams*/)
       
    78     {
       
    79     CGSPenInputPlugin* self = new (ELeave) CGSPenInputPlugin();
       
    80 
       
    81     CleanupStack::PushL(self);
       
    82     self->ConstructL();
       
    83     CleanupStack::Pop(self);
       
    84 
       
    85     return self;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------
       
    89 // Returns views id
       
    90 // ---------------------------------------------------------
       
    91 //
       
    92 TUid CGSPenInputPlugin::Id() const
       
    93     {
       
    94     return KGSInputPenPluginUID;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------
       
    98 // Handle client area change
       
    99 // ---------------------------------------------------------
       
   100 //
       
   101 void CGSPenInputPlugin::HandleClientRectChange()
       
   102     {
       
   103     if (iContainer)
       
   104         {
       
   105         iContainer->SetRect(ClientRect());
       
   106         }
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------
       
   110 // Activate GsPenInputPlugin view
       
   111 // ---------------------------------------------------------
       
   112 //
       
   113 void CGSPenInputPlugin::DoActivateL(const TVwsViewId& aPrevViewId,
       
   114                                        TUid aCustomMessageId,
       
   115                                        const TDesC8& aCustomMessage)
       
   116     {
       
   117     CGSBaseView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
       
   118     CEikStatusPane* statusPane = StatusPane();
       
   119     CEikStatusPaneBase::TPaneCapabilities titlePaneCapability =
       
   120         statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidTitle ) );
       
   121         
       
   122     TUid appUid = AppUi()->Application()->AppDllUid();   
       
   123     if ( appUid == KUidPenInputSettingApp )
       
   124         {
       
   125         TResourceReader reader;
       
   126         iEikonEnv->CreateResourceReaderLC( reader, R_GS_INPUTPEN_PLUGIN_TITLE );
       
   127         if ( titlePaneCapability.IsPresent() && titlePaneCapability.IsAppOwned() )
       
   128             {
       
   129             CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
       
   130                 ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   131             titlePane->SetFromResourceL( reader );
       
   132             }
       
   133         CleanupStack::PopAndDestroy(); // reader    
       
   134         }
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------
       
   138 // Deactivation of GsPenInputPlugin view
       
   139 // ---------------------------------------------------------
       
   140 //
       
   141 void CGSPenInputPlugin::DoDeactivate()
       
   142     {
       
   143     CGSBaseView::DoDeactivate();
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------
       
   147 // Command handling function called by application frame work
       
   148 // ---------------------------------------------------------
       
   149 //
       
   150 void CGSPenInputPlugin::HandleCommandL(TInt aCommand)
       
   151     {
       
   152     switch (aCommand)
       
   153         {
       
   154         case EGSCmdAppChange:
       
   155         case EGSMSKCmdAppChange:
       
   156             {
       
   157             HandleListBoxSelectionL();
       
   158             }
       
   159             break;
       
   160         case EAknSoftkeyBack:
       
   161             {
       
   162             TUid appUid = AppUi()->Application()->AppDllUid();   
       
   163             
       
   164             if( appUid == KUidPenInputSettingApp )
       
   165                 {                
       
   166                 AppUi()->HandleCommandL( EEikCmdExit );
       
   167                 }                
       
   168             else
       
   169                 {
       
   170                 AppUi()->ActivateLocalViewL( KGSGenPluginUid );
       
   171                 }                
       
   172             }
       
   173             break;
       
   174         case EAknCmdHelp:
       
   175             {
       
   176             HlpLauncher::LaunchHelpApplicationL(
       
   177                     iEikonEnv->WsSession(), AppUi()->AppHelpContextL() );            
       
   178             }
       
   179             break;
       
   180         default:
       
   181             {
       
   182             AppUi()->HandleCommandL(aCommand);
       
   183             }
       
   184             break;
       
   185         }
       
   186     }
       
   187 
       
   188 // ---------------------------------------------------------
       
   189 // Method for getting caption of this plugin
       
   190 // ---------------------------------------------------------
       
   191 //
       
   192 void CGSPenInputPlugin::GetCaptionL(TDes& aCaption) const
       
   193     {
       
   194     HBufC* result = StringLoader::LoadL(R_CP_INPUTPEN_PLUGIN_CAPTION);
       
   195 
       
   196     CleanupStack::PushL(result);
       
   197     
       
   198     aCaption.Copy(*result);
       
   199     
       
   200     CleanupStack::PopAndDestroy(result);
       
   201     }
       
   202 
       
   203 // ---------------------------------------------------------
       
   204 // Read the ID of the plugin provider category
       
   205 // ---------------------------------------------------------
       
   206 //
       
   207 TInt CGSPenInputPlugin::PluginProviderCategory() const
       
   208     {
       
   209     //This plugin is created by 3rd party.
       
   210     return KGSPluginProviderInternal;
       
   211     }
       
   212 
       
   213 // ---------------------------------------------------------
       
   214 // Functionality for creating a container
       
   215 // ---------------------------------------------------------
       
   216 //
       
   217 void CGSPenInputPlugin::NewContainerL()
       
   218     {
       
   219     iContainer = new (ELeave) CGSPenInputContainer;
       
   220     }
       
   221 
       
   222 // ---------------------------------------------------------
       
   223 // Handles listbox selection
       
   224 // ---------------------------------------------------------
       
   225 //
       
   226 void CGSPenInputPlugin::HandleListBoxSelectionL()
       
   227     {
       
   228     const TInt currentFeatureId = Container()->CurrentSelectedId();
       
   229     
       
   230     switch (currentFeatureId)
       
   231         {
       
   232         case EGSInputpenIdHwrTraining:
       
   233             {
       
   234             _LIT(KPeninputHwrTrainingUI, "z:\\sys\\bin\\trui.exe" );
       
   235             AknPenInputUtils::StartAppL( KPeninputHwrTrainingUI );            
       
   236             }
       
   237             break;
       
   238         case EGSInputpenIdInputLanguage:
       
   239             {
       
   240             Container()->ShowInputLanguagePageL();
       
   241             }
       
   242             break; 
       
   243         case EGSDefaultChineseOnscreenKeyboard:
       
   244             {
       
   245             Container()->ShowInputModePageL();
       
   246             }
       
   247             break;
       
   248         case EGSInputpenIdWritingSpeed:
       
   249             {
       
   250             Container()->ShowWritingSpeedPageL();
       
   251             }
       
   252             break;
       
   253         case EGSInputpenIdGuidLine:
       
   254             {
       
   255             Container()->ShowGuideLinePageL();
       
   256             }
       
   257             break;
       
   258         case EGSInputpenIdRecognitionWithDictionary:
       
   259             {
       
   260             Container()->ShowRecognitionWithDictionaryL();
       
   261             }
       
   262             break;             
       
   263         case EGSInputpenIdPenTrailWidth:
       
   264             {
       
   265             Container()->ShowTrailWidthPageL();    
       
   266             }
       
   267             break;
       
   268         case EGSInputpenIdPenTrailColour:
       
   269             {
       
   270             Container()->ShowTrailColourPageL(); 
       
   271             }
       
   272             break;
       
   273         case EGSInputpenIdTouchScrCalib:
       
   274             {            
       
   275             Container()->LaunchAppL( KUidCalibrationApp );
       
   276             }
       
   277             break;
       
   278         case EGSInputpenIdInputMethodForFind:
       
   279             {
       
   280             Container()->ShowInputMethodForFindPageL(); 
       
   281             }
       
   282             break;
       
   283         case EGSInputpenIdChineseFindMethod:
       
   284             {
       
   285             Container()->ShowChineseFindMethodPageL(); 
       
   286             }
       
   287             break;
       
   288        default:
       
   289             break;
       
   290         }
       
   291      }
       
   292 
       
   293 // ---------------------------------------------------------
       
   294 // Returns the container this view has
       
   295 // ---------------------------------------------------------
       
   296 //
       
   297 CGSPenInputContainer* CGSPenInputPlugin::Container() const
       
   298     {
       
   299     CGSPenInputContainer* container = static_cast<CGSPenInputContainer*>(iContainer);
       
   300 
       
   301     return container;
       
   302     }
       
   303     
       
   304 void CGSPenInputPlugin::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane)
       
   305     {
       
   306     if ( aResourceId != R_GS_INPUT_ITEM_CHANGE )
       
   307     	{
       
   308     	return;
       
   309     	}
       
   310     	
       
   311     const TInt currentId = Container()->CurrentSelectedId();
       
   312     
       
   313     if ( currentId == EGSInputpenIdHwrTraining || currentId == EGSInputpenIdTouchScrCalib )
       
   314     	{
       
   315     	aMenuPane->SetItemTextL( EGSCmdAppChange, R_GS_INPUT_ITEM_TXT_OPEN );
       
   316     	}
       
   317     else
       
   318     	{
       
   319         aMenuPane->SetItemTextL( EGSCmdAppChange, R_GS_INPUT_ITEM_TXT_CHANGE );
       
   320     	}
       
   321     }
       
   322 // ---------------------------------------------------------
       
   323 // Creates a new icon of desired type.
       
   324 // ---------------------------------------------------------
       
   325 //
       
   326 CGulIcon* CGSPenInputPlugin::CreateIconL( const TUid aIconType )
       
   327     {    
       
   328     TParse iconFilePar;    
       
   329     iconFilePar.Set( KPeninputIconFileName, &KDC_BITMAP_DIR, 
       
   330                         NULL );
       
   331     TFileName fileName = iconFilePar.FullName();
       
   332     //delete iconFilePar;
       
   333     //iconFilePar = NULL;
       
   334     CGulIcon* icon = NULL;    
       
   335     if ( aIconType == KGSIconTypeLbxItem )
       
   336         {
       
   337         icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), 
       
   338             KAknsIIDQgnPropCpDevPen,
       
   339             fileName,
       
   340             EMbmGspeninputpluginQgn_prop_cp_dev_pen,
       
   341             EMbmGspeninputpluginQgn_prop_cp_dev_pen_mask );
       
   342         }
       
   343     else
       
   344         {
       
   345         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   346         }
       
   347     return icon;
       
   348     }
       
   349 
       
   350 // End Of File