camera_plat/active_palette_2_api/tsrc/src/ActivePaletteContainer.cpp
branchRCL_3
changeset 54 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2009 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: CCActivePaletteContainer implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <w32std.h>
       
    19 #include <coeaui.h>
       
    20 #include <apgwgnam.h>
       
    21 //#include <eikenv.h>
       
    22 //#include <eikapp.h>
       
    23 //#include <eikappui.h>
       
    24 
       
    25 
       
    26 #include <StifLogger.h>
       
    27 
       
    28 #include <activepalette2ui.h>
       
    29 #include <activepalette2factory.h>
       
    30 #include <activepalette2genericpluginint.h>
       
    31 #include <activepalette2eventdata.h>
       
    32 #include <activepalette2itemvisible.h>
       
    33 #include <activepalette2navigationkeys.h>
       
    34 
       
    35 #include <ActivePalette2ApiTest.mbg>
       
    36 
       
    37 #include "activepalette2apitest.h"
       
    38 #include "ActivePaletteContainer.h"
       
    39 
       
    40 
       
    41 #define LOG(text) iTest->Log()->Log(_L(text))
       
    42 #define LOG1(text, param) iTest->Log()->Log(_L(text), param)
       
    43 #define LOG2(text, param1, param2) iTest->Log()->Log(_L(text), param1, param2)
       
    44 #define LOG3(text, param1, param2, param3) iTest->Log()->Log(_L(text), param1, param2, param3)
       
    45 
       
    46 namespace 
       
    47     {
       
    48     _LIT( KTrueString,  "true"  );
       
    49     _LIT( KFalseString, "false" );
       
    50     }    
       
    51 
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CActivePaletteContainer::~CActivePaletteContainer
       
    55 // Destructor.
       
    56 // (other items were commented in a header).
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CActivePaletteContainer::~CActivePaletteContainer()
       
    60     {
       
    61     if( iActivePalette != NULL )
       
    62         {
       
    63         iActivePalette->SetPaletteVisibility(ETrue, EFalse);
       
    64         delete iActivePalette;
       
    65         iActivePalette = NULL;
       
    66         }
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CActivePaletteContainer::ConstructL
       
    71 // Second phase constructor.
       
    72 // (other items were commented in a header).
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void 
       
    76 CActivePaletteContainer::ConstructL(CActivePalette2ApiTest* aTest)
       
    77     {
       
    78     iTest = aTest;
       
    79 
       
    80     LOG("=> CActivePaletteContainer::ConstructL");
       
    81     CreateWindowL();    
       
    82 
       
    83     TVwsViewId viewId;
       
    84     CCoeEnv::Static()->AppUi()->GetDefaultViewId(viewId);    
       
    85     iAppUid = viewId.iAppUid;
       
    86     LOG1("<> CActivePalette2ApiTest::ConstructL: GetDefaultViewId() appuid: %d", iAppUid.iUid );
       
    87     LOG("<> CActivePaletteContainer::ConstructL 1");
       
    88     SetRect(CCoeEnv::Static()->ScreenDevice()->SizeInPixels());
       
    89     LOG("<> CActivePaletteContainer::ConstructL 2");
       
    90     CreateActivePaletteL();
       
    91     LOG("<> CActivePaletteContainer::ConstructL 3");
       
    92     ActivateL();
       
    93     LOG("<= CActivePaletteContainer::ConstructL");
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CActivePaletteContainer::CountComponentControls
       
    98 // From CCoeControl.
       
    99 // (other items were commented in a header).
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TInt 
       
   103 CActivePaletteContainer::CountComponentControls() const
       
   104     {
       
   105     if( iActivePalette != NULL )
       
   106         return 1;
       
   107     else
       
   108         return 0;
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CActivePaletteContainer::ComponentControl
       
   113 // From CCoeControl.
       
   114 // (other items were commented in a header).
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 CCoeControl* 
       
   118 CActivePaletteContainer::ComponentControl(TInt aIndex) const
       
   119     {
       
   120     if( aIndex == 0 )
       
   121         return iActivePalette != NULL ? iActivePalette->CoeControl() : NULL;
       
   122     else
       
   123         return NULL;            
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CActivePaletteContainer::Draw
       
   128 // From CCoeControl.
       
   129 // (other items were commented in a header).
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 void 
       
   133 CActivePaletteContainer::Draw(const TRect &aRect) const 
       
   134     {
       
   135     LOG("=> CActivePaletteContainer::Draw");
       
   136     
       
   137     CWindowGc& gc = SystemGc();
       
   138     gc.Reset();
       
   139     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   140     gc.SetBrushColor(TRgb(0xE0,0xE0,0xFF));
       
   141     gc.Clear(aRect);    
       
   142 
       
   143     LOG("<> CActivePaletteContainer::Draw 1");
       
   144     
       
   145     //iActivePalette->RenderActivePalette( TRect(iPosition,iSize) );
       
   146 
       
   147     LOG("<= CActivePaletteContainer::Draw");
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CActivePaletteContainer::OfferKeyEventL
       
   152 // From CCoeControl.
       
   153 // (other items were commented in a header).
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 TKeyResponse 
       
   157 CActivePaletteContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) 
       
   158     {
       
   159     LOG3("=> CActivePaletteContainer::OfferKeyEventL - keycode[%d] scancode[%d] type[%d]", 
       
   160           aKeyEvent.iCode, aKeyEvent.iScanCode, aType);
       
   161     
       
   162     TKeyResponse response = EKeyWasNotConsumed; 
       
   163     if( iActivePalette 
       
   164      && iActivePalette->CoeControl() )
       
   165         {
       
   166         response = iActivePalette->CoeControl()->OfferKeyEventL(aKeyEvent,aType);
       
   167         LOG1("<> CActivePaletteContainer::OfferKeyEventL - Active Palette consumed ? %S", 
       
   168              response == EKeyWasConsumed ? &KTrueString : &KFalseString );
       
   169         }
       
   170     if( EKeyWasNotConsumed == response )
       
   171         {
       
   172         response = CCoeControl::OfferKeyEventL(aKeyEvent, aType);        
       
   173         }
       
   174 
       
   175     LOG("<= CActivePaletteContainer::OfferKeyEventL");
       
   176     return response;
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CActivePaletteContainer::SizeChanged
       
   181 // From CCoeControl.
       
   182 // (other items were commented in a header).
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void 
       
   186 CActivePaletteContainer::SizeChanged()
       
   187     {
       
   188     LOG("=> CActivePaletteContainer::SizeChanged");
       
   189     CCoeControl::SizeChanged();    
       
   190     LOG("<= CActivePaletteContainer::SizeChanged");
       
   191     }
       
   192 
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CActivePaletteContainer::ViewId
       
   196 // From MCoeView.
       
   197 // (other items were commented in a header).
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 TVwsViewId 
       
   201 CActivePaletteContainer::ViewId() const
       
   202     {
       
   203     LOG("=> CActivePaletteContainer::ViewId");    
       
   204     TVwsViewId id;
       
   205     id.iAppUid  = iAppUid;
       
   206     id.iViewUid = TUid::Uid(1234567890);
       
   207     LOG("<= CActivePaletteContainer::ViewId");
       
   208     return id;
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CActivePaletteContainer::ViewActivatedL
       
   213 // From MCoeView.
       
   214 // (other items were commented in a header).
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void 
       
   218 CActivePaletteContainer::ViewActivatedL(
       
   219         const TVwsViewId& /*aPrevViewId*/, 
       
   220               TUid        /*aCustomMessageId*/, 
       
   221         const TDesC8&     /*aCustomMessage*/ )
       
   222     {
       
   223     LOG("=><= CActivePaletteContainer::ViewActivatedL");    
       
   224     }
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // CActivePaletteContainer::ViewDeactivated
       
   228 // From MCoeView.
       
   229 // (other items were commented in a header).
       
   230 // -----------------------------------------------------------------------------
       
   231 //
       
   232 void 
       
   233 CActivePaletteContainer::ViewDeactivated()
       
   234     {
       
   235     LOG("=><= CActivePaletteContainer::ViewDeactivated");    
       
   236     }
       
   237 
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // CActivePaletteContainer::NotifyItemFocused
       
   241 // From MActivePalette2Observer.
       
   242 // (other items were commented in a header).
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 void 
       
   246 CActivePaletteContainer::NotifyItemFocused(TInt /*aPrevItem*/, TInt /*aFocusedItem*/)
       
   247     {    
       
   248     LOG("=><= CActivePaletteContainer::NotifyItemFocused");    
       
   249     }
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // CActivePaletteContainer::NotifyItemSelected
       
   253 // From MActivePalette2Observer.
       
   254 // (other items were commented in a header).
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 void 
       
   258 CActivePaletteContainer::NotifyItemSelected(const TActivePalette2EventData& aEvent)
       
   259     {
       
   260     LOG("=> CActivePaletteContainer::NotifyItemSelected");
       
   261     CheckActivePaletteEvent(aEvent);
       
   262     LOG("<= CActivePaletteContainer::NotifyItemSelected");
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CActivePaletteContainer::NotifyItemComplete
       
   267 // From MActivePalette2Observer.
       
   268 // (other items were commented in a header).
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 void 
       
   272 CActivePaletteContainer::NotifyItemComplete(const TActivePalette2EventData& aEvent,
       
   273                                             const TDesC8& aDataDes,
       
   274                                             TInt aDataInt)
       
   275     {
       
   276     LOG ("=> CActivePaletteContainer::NotifyItemComplete");
       
   277     CheckActivePaletteEvent(aEvent);
       
   278     LOG1("<> CActivePaletteContainer::NotifyItemComplete - data descr: %S", &aDataDes);
       
   279     LOG1("<> CActivePaletteContainer::NotifyItemComplete - data int: %d", aDataInt);
       
   280     LOG ("<= CActivePaletteContainer::NotifyItemComplete");
       
   281     }
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // CActivePaletteContainer::NotifyMessage
       
   285 // From MActivePalette2Observer.
       
   286 // (other items were commented in a header).
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 void 
       
   290 CActivePaletteContainer::NotifyMessage(const TActivePalette2EventData& aEvent,
       
   291                                        TInt aMessageID,
       
   292                                        const TDesC8& aDataDes,
       
   293                                        TInt aDataInt)
       
   294     {
       
   295     LOG ("=> CActivePaletteContainer::NotifyMessage");
       
   296     CheckActivePaletteEvent(aEvent);
       
   297     LOG1("<> CActivePaletteContainer::NotifyMessage - message id: %d", aMessageID);
       
   298     LOG1("<> CActivePaletteContainer::NotifyMessage - data descr: %S", &aDataDes);
       
   299     LOG1("<> CActivePaletteContainer::NotifyMessage - data int: %d", aDataInt);
       
   300     LOG ("<= CActivePaletteContainer::NotifyMessage");
       
   301     }
       
   302 
       
   303 // -----------------------------------------------------------------------------
       
   304 // CActivePaletteContainer::Redraw
       
   305 // From MActivePalette2Observer.
       
   306 // (other items were commented in a header).
       
   307 // -----------------------------------------------------------------------------
       
   308 //
       
   309 void 
       
   310 CActivePaletteContainer::Redraw(const TRect& aArea)
       
   311     {
       
   312     LOG("=> CActivePaletteContainer::Redraw");    
       
   313     /*
       
   314     CWindowGc& gc = SystemGc();
       
   315     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   316     gc.SetBrushColor(TRgb(0x00,0x00,0xFF));
       
   317     gc.Clear(aArea);
       
   318     */
       
   319     Draw(aArea);
       
   320     LOG("<= CActivePaletteContainer::Redraw");    
       
   321     }
       
   322 
       
   323 // -----------------------------------------------------------------------------
       
   324 // CActivePaletteContainer::ActivePaletteUpdated
       
   325 // From MActivePalette2Observer.
       
   326 // (other items were commented in a header).
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 void 
       
   330 CActivePaletteContainer::ActivePaletteUpdated(void)
       
   331     {
       
   332     LOG("=> CActivePaletteContainer::ActivePaletteUpdated");    
       
   333     DrawDeferred();    
       
   334     LOG("<= CActivePaletteContainer::ActivePaletteUpdated");    
       
   335     }
       
   336 
       
   337 
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // CActivePaletteContainer::CreateActivePaletteL
       
   341 // Helper method for creating ActivePalette.
       
   342 // (other items were commented in a header).
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 void
       
   346 CActivePaletteContainer::CreateActivePaletteL()
       
   347     {
       
   348     delete iActivePalette;
       
   349     iActivePalette = NULL;
       
   350 
       
   351     iActivePalette = ActivePalette2Factory::CreateActivePaletteUIL( EAP2DrawModeSemiTransparent );
       
   352 
       
   353     iActivePalette->SetObserver( this );
       
   354     iActivePalette->CoeControl()->SetContainerWindowL( *this );
       
   355     iActivePalette->CoeControl()->SetMopParent( this );  
       
   356     iActivePalette->SetPaletteVisibility(ETrue, EFalse);
       
   357     TRect rect( Rect() );
       
   358     iActivePalette->LocateTo( TPoint(rect.Width()/4, rect.Height()/4) );
       
   359     }
       
   360 
       
   361 // -----------------------------------------------------------------------------
       
   362 // CActivePaletteContainer::ActivePalette
       
   363 // Get the Active Palette instance.
       
   364 // (other items were commented in a header).
       
   365 // -----------------------------------------------------------------------------
       
   366 //
       
   367 MActivePalette2UI* 
       
   368 CActivePaletteContainer::ActivePalette() const 
       
   369     {
       
   370     return iActivePalette;
       
   371     }
       
   372 
       
   373 
       
   374 // -----------------------------------------------------------------------------
       
   375 // CActivePaletteContainer::CheckActivePaletteEvent
       
   376 // (other items were commented in a header).
       
   377 // -----------------------------------------------------------------------------
       
   378 //
       
   379 void 
       
   380 CActivePaletteContainer::CheckActivePaletteEvent( const TActivePalette2EventData& aEvent )
       
   381     {
       
   382     TInt resultCode( aEvent.Result() );
       
   383     TInt currentItem( aEvent.CurItem() );
       
   384     TInt previousItem( aEvent.PrevItem() );
       
   385     TInt servingItem( aEvent.ServingItem() );
       
   386     TUid servingPluginUid( aEvent.ServingPlugin() );
       
   387     
       
   388     iTest->Log()->Log( _L("=><= CActivePaletteContainer::CheckActivePaletteEvent - got: code[%d] items[current:%d previous:%d serving:%d] plugin[%d]"),
       
   389                        resultCode, currentItem, previousItem, servingItem, servingPluginUid.iUid);
       
   390     }
       
   391 
       
   392 
       
   393