textinput/peninputhwrboxcn/ctrlsrc/peninputhwrbxctrlbar.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:  Implementation of HWR ctonrol bar
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // system includes
       
    20 #include <barsread.h>
       
    21 #include <peninputhwrbxcn.rsg>
       
    22 #include <aknfeppeninputenums.h>
       
    23 
       
    24 #include <peninputlayoutbutton.h>
       
    25 #include <peninputrangebar.h>
       
    26 //#include <peninputmultimodebutton.h>
       
    27 #include <peninputeventbutton.h>
       
    28 #include <AknLayoutDef.h>
       
    29 #include <AknUtils.h>
       
    30 #include <AknsUtils.h>
       
    31 #include <peninputpluginutils.h>
       
    32 
       
    33 // user includes
       
    34 #include "peninputhwrbxlayout.h"
       
    35 #include "peninputhwrbxctrlbar.h"
       
    36 #include "peninputhwrctrlid.h"
       
    37 #include "peninputhwrevent.h"
       
    38 #include "aknlayoutscalable_avkon.cdl.h"
       
    39 
       
    40 
       
    41 
       
    42  
       
    43 
       
    44 
       
    45 
       
    46 
       
    47 const TInt KDefaultStrokeEndMarkX = -65536;
       
    48 const TInt KDefaultStrokeEndMarkY = -65536;
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // Two-phased constructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //    
       
    54 CAknFepHwrBxCtrlBar* CAknFepHwrBxCtrlBar::NewL(CFepUiLayout* aUiLayout, TInt aControlId)
       
    55     {
       
    56     CAknFepHwrBxCtrlBar* self = NewLC(aUiLayout,aControlId);
       
    57     CleanupStack::Pop(self);
       
    58     
       
    59     return self;
       
    60     }
       
    61     
       
    62 // ---------------------------------------------------------------------------
       
    63 // Two-phased constructor
       
    64 // ---------------------------------------------------------------------------
       
    65 //    
       
    66 CAknFepHwrBxCtrlBar* CAknFepHwrBxCtrlBar::NewLC(CFepUiLayout* aUiLayout, TInt aControlId)
       
    67     {
       
    68     CAknFepHwrBxCtrlBar* self = new (ELeave) CAknFepHwrBxCtrlBar(aUiLayout, aControlId);
       
    69     CleanupStack::PushL(self);
       
    70     self->ConstructL();
       
    71     
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // C++ default constructor
       
    77 // ---------------------------------------------------------------------------
       
    78 //    
       
    79 CAknFepHwrBxCtrlBar::CAknFepHwrBxCtrlBar(CFepUiLayout* aUiLayout,TInt aControlId)
       
    80     :CControlGroup(aUiLayout,aControlId, EFalse)
       
    81     {
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // Symbian 2nd phase constructor
       
    86 // ---------------------------------------------------------------------------
       
    87 //    
       
    88 void CAknFepHwrBxCtrlBar::ConstructL()
       
    89     {
       
    90     CControlGroup::ConstructL();
       
    91 
       
    92     CAknFepHwrBxLayout* layout = static_cast<CAknFepHwrBxLayout*>(UiLayout());
       
    93     
       
    94     ASSERT(layout != NULL);
       
    95     
       
    96     iRangeBar = CAknFepCtrlRangeBar::NewL(layout, EHwrCtrlIdControlBar, 
       
    97                                           CAknFepCtrlRangeBar::EBtnGroupVertical);
       
    98     iRangeBar->SetActionStyle( CAknFepCtrlRangeBar::ERangeBarActionStyleHighLight );
       
    99     iRangeBar->SetEventIdForRange(EHwrEventSetRange);
       
   100     iRangeBar->SetEventIdForCase(EHwrEventSetCase);
       
   101     AddControlL(iRangeBar);
       
   102     iRangeBar->AddEventObserver(layout);
       
   103     
       
   104     iVkb = CAknFepCtrlCommonButton::NewL( layout, 
       
   105     									  EHwrCtrlIdVkb,
       
   106     									  KAknsIIDQsnFrFunctionButtonNormal,
       
   107     									  KAknsIIDQsnFrFunctionButtonPressed,
       
   108     									  KAknsIIDQsnFrFunctionButtonInactive );      
       
   109     AddControlL(iVkb);
       
   110     iVkb->AddEventObserver(layout);
       
   111 
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // Destructor
       
   116 // ---------------------------------------------------------------------------
       
   117 //    
       
   118 CAknFepHwrBxCtrlBar::~CAknFepHwrBxCtrlBar()
       
   119     {
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------
       
   123 // ConstructFromResourceL
       
   124 // ---------------------------------------------------------
       
   125 //
       
   126 void CAknFepHwrBxCtrlBar::ConstructFromResourceL(TResourceReader& aReader)
       
   127     {
       
   128     const TInt32 rangebarResId = aReader.ReadInt32();
       
   129     const TInt32 vkbResId = aReader.ReadInt32();
       
   130 
       
   131     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   132     TResourceReader reader;
       
   133     coeEnv->CreateResourceReaderLC(reader, rangebarResId);
       
   134     iRangeBar->ConstructFromResourceL(reader);
       
   135     CleanupStack::PopAndDestroy(); // reader
       
   136     
       
   137     iVkb->SetResourceId(vkbResId);
       
   138     iVkb->ConstructFromResourceL();
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------
       
   142 // ConstructFromResourceL
       
   143 // ---------------------------------------------------------
       
   144 //
       
   145 void CAknFepHwrBxCtrlBar::ConstructFromResourceL()
       
   146     {
       
   147     CControlGroup::ConstructFromResourceL();
       
   148     }
       
   149 // ---------------------------------------------------------------------------
       
   150 // Handles the SizeChanged event
       
   151 // ---------------------------------------------------------------------------
       
   152 //    
       
   153 void CAknFepHwrBxCtrlBar::SizeChangedL(const TRect& aRect, const TRect& aGridRect)
       
   154     {
       
   155     SetRect(aRect);
       
   156 
       
   157     // range bar  
       
   158     TPoint startPos = TPoint(aGridRect.iTl);
       
   159     // range bar grid
       
   160     TRect rangeBarGridRect = TRect(startPos,
       
   161                                TPoint(startPos.iX + aGridRect.Width(),
       
   162                                       startPos.iY + aGridRect.Height()));
       
   163     iRangeBar->SizeChanged(rangeBarGridRect);
       
   164     // whole range bar
       
   165     TRect rangeBarRect = TRect(startPos,
       
   166                               TPoint(startPos.iX + aGridRect.Width(),
       
   167                                      startPos.iY + aGridRect.Height()*iRangeBar->NumOfControls()));
       
   168     
       
   169     iRangeBar->RefreshUI();
       
   170     // vkb
       
   171     startPos = TPoint(rangeBarRect.iTl.iX, rangeBarRect.iBr.iY);
       
   172     
       
   173     TRect vkbRect = TRect(startPos,
       
   174                           TPoint(startPos.iX + aGridRect.Width(),
       
   175                                  startPos.iY + aGridRect.Height()));
       
   176     TRect vkbInnerRect;
       
   177     AknPenImageUtils::CalculateGraphicRect(vkbRect, vkbInnerRect);                            
       
   178     iVkb->SizeChanged(vkbRect, vkbInnerRect, ETrue);
       
   179     }
       
   180 
       
   181 // ---------------------------------------------------------------------------
       
   182 // Set active input range
       
   183 // ---------------------------------------------------------------------------
       
   184 //    
       
   185 TBool CAknFepHwrBxCtrlBar::SetRange(const TInt aRange)
       
   186     {
       
   187     if (iRangeBar)
       
   188         {
       
   189         return iRangeBar->SetRange(aRange);
       
   190         }
       
   191         
       
   192     return EFalse;
       
   193     }
       
   194     
       
   195 // ---------------------------------------------------------------------------
       
   196 // Set permitted input ranges
       
   197 // ---------------------------------------------------------------------------
       
   198 //    
       
   199 void CAknFepHwrBxCtrlBar::SetPermittedRanges(const TInt aPermitted)
       
   200     {
       
   201     if (iRangeBar)
       
   202         {
       
   203         iRangeBar->SetPermittedRanges(aPermitted);
       
   204         }
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // Set case of given range
       
   209 // ---------------------------------------------------------------------------
       
   210 //    
       
   211 void CAknFepHwrBxCtrlBar::SetCaseL(const TInt aCase)
       
   212     {
       
   213     if (iRangeBar)
       
   214         {
       
   215         iRangeBar->SetCaseL(ERangeEnglish, aCase);
       
   216         }
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // Set case of given range
       
   221 // ---------------------------------------------------------------------------
       
   222 //    
       
   223 void CAknFepHwrBxCtrlBar::SetPermittedCasesL(TInt aPermittedCases)
       
   224     {
       
   225     if (iRangeBar)
       
   226         {
       
   227         //
       
   228         iRangeBar->SetPermittedCase(ERangeEnglish, ECaseUpper, 
       
   229                             (aPermittedCases & ECaseUpper) != 0 );
       
   230         iRangeBar->SetPermittedCase(ERangeEnglish, ECaseLower, 
       
   231                             (aPermittedCases & ECaseLower) != 0 );
       
   232         iRangeBar->SetPermittedCase(ERangeEnglish, ECaseText, 
       
   233                             (aPermittedCases & ECaseText) != 0 );
       
   234         }
       
   235     }
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // Set property
       
   239 // ---------------------------------------------------------------------------
       
   240 //    
       
   241 void CAknFepHwrBxCtrlBar::SetPropertyL(
       
   242                               const MAknFepHwrPropertySubscriber::TAknFepHwrProperty aPropertyName,
       
   243                               const TDesC& aPropertyValue)
       
   244     {
       
   245     const TInt value = *(TInt*)aPropertyValue.Ptr();
       
   246     
       
   247     switch (aPropertyName) 
       
   248         {
       
   249         case MAknFepHwrPropertySubscriber::EAknFepHwrPropertyPermittedCases:
       
   250             SetPermittedCasesL(value);
       
   251             break;
       
   252         case MAknFepHwrPropertySubscriber::EAknFepHwrPropertyCase:
       
   253             SetCaseL(value);
       
   254             break;
       
   255         case MAknFepHwrPropertySubscriber::EAknFepHwrPropertyRange:
       
   256             SetRange(value);
       
   257             break;
       
   258         case MAknFepHwrPropertySubscriber::EAknFepHwrPropertyPermittedRange:
       
   259             SetPermittedRanges(value);
       
   260             break;
       
   261         default:
       
   262             break;
       
   263         }
       
   264     }
       
   265     
       
   266 // ---------------------------------------------------------------------------
       
   267 // Stroke End Mark
       
   268 // ---------------------------------------------------------------------------
       
   269 //    
       
   270 TPoint CAknFepHwrBxCtrlBar::StrokeEndMark()
       
   271     {
       
   272     return TPoint(KDefaultStrokeEndMarkX, KDefaultStrokeEndMarkY);
       
   273     }
       
   274     
       
   275 // End Of File