uiacceltk/hitchcock/AlfHintPlugin/src/alfhintplugin.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   interface for creating custom extensions
       
    15 *
       
    16 */
       
    17  
       
    18 
       
    19 #include <s32mem.h> //RDesReadStream
       
    20 #include <graphics/commandbuffer.h>
       
    21 #include <alfhintpluginuids.h>
       
    22 #include <alf/alfhintplugin.h>
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // constructor
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CAlfHintGraphic::CAlfHintGraphic()
       
    29 	{
       
    30 	}
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // destructor
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 EXPORT_C CAlfHintGraphic::~CAlfHintGraphic()
       
    37 	{
       
    38 	iMsgDataBuf.Close();
       
    39 	}
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // NewL
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 EXPORT_C CAlfHintGraphic* CAlfHintGraphic::NewL(  )
       
    46 	{
       
    47 	CAlfHintGraphic* self = new(ELeave) CAlfHintGraphic;
       
    48 	CleanupStack::PushL(self);
       
    49 	self->ConstructL();
       
    50 	CleanupStack::Pop(self);
       
    51 	return self;
       
    52 	}
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // ConstructL
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void CAlfHintGraphic::ConstructL()
       
    59     {
       
    60     /*iMsgDataBuf.ReAllocL(0x100);
       
    61     RDesWriteStream out(iMsgDataBuf);
       
    62     TPckgBuf<TInt32> tag(aWindowHandle);
       
    63     out.WriteL( tag );
       
    64     out.CommitL();*/
       
    65     
       
    66     BaseConstructL( KAlfHintDrawerInstanceUid,  KAlfHintDrawerTypeUid, iMsgDataBuf );
       
    67     //iGc = aGc;
       
    68     
       
    69 
       
    70     }
       
    71 EXPORT_C void CAlfHintGraphic::SetGc( CWindowGc* aGc )
       
    72     {
       
    73     iGc = aGc;
       
    74     }
       
    75 // ---------------------------------------------------------------------------
       
    76 // HandleMessage
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C void CAlfHintGraphic::HandleMessage(const TDesC8& /*aData*/)
       
    80 	{
       
    81 	}
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // OnReplace
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 EXPORT_C void CAlfHintGraphic::OnReplace()
       
    88 	{
       
    89 	}
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // ShareGlobally
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C TInt CAlfHintGraphic::ShareGlobally()
       
    96 	{
       
    97 	return CWsGraphic::ShareGlobally();
       
    98 	}
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // UnShareGlobally
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 EXPORT_C TInt CAlfHintGraphic::UnShareGlobally()
       
   105 	{
       
   106 	return CWsGraphic::UnShareGlobally();
       
   107 	}
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // Share
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 EXPORT_C TInt CAlfHintGraphic::Share(TSecureId aClientId)
       
   114 	{
       
   115 	return CWsGraphic::Share(aClientId);
       
   116 	}
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // UnShare
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 EXPORT_C TInt CAlfHintGraphic::UnShare(TSecureId aClientId)
       
   123 	{
       
   124 	return CWsGraphic::UnShare(aClientId);
       
   125 	}
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // InsertTagL
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 TInt CAlfHintGraphic::InsertTagL( TInt aTag  )
       
   132     {
       
   133     TRect aBoundingRectangle(0,0,360,640);
       
   134     TInt aLayerId = 0;
       
   135     if ( aTag >= 0 && aTag < EAlfContentLastTag )
       
   136         {
       
   137         iMsgDataBuf.ReAllocL(0x100);
       
   138         RDesWriteStream out(iMsgDataBuf);
       
   139         TPckgBuf<TUint8> tag(aTag);
       
   140         TPckgBuf<TUint8> zero(0);
       
   141         TPckgBuf<TRect> rect(aBoundingRectangle); 
       
   142         TPckgBuf<TInt32> layerId(aLayerId);
       
   143         out.WriteL( tag );
       
   144         out.WriteL( zero );
       
   145         out.WriteL( rect );
       
   146         out.WriteL( layerId );
       
   147         out.CommitL();
       
   148         const TUid drawerCrpUid = KAlfHintDrawerInstanceUid;
       
   149         const TWsGraphicId KDrawerCrpId(drawerCrpUid);
       
   150 
       
   151         static_cast<CWindowGc*>(iGc)->DrawWsGraphic(KDrawerCrpId, TRect(0,0,360,640), iMsgDataBuf );
       
   152         out.Close();
       
   153         }
       
   154     else
       
   155         {
       
   156         return KErrNotSupported;
       
   157         }
       
   158     return KErrNone;
       
   159     }
       
   160 
       
   161 //
       
   162 // This version of InsertTagL() is meant for subwindow effects. 
       
   163 //
       
   164 TInt CAlfHintGraphic::InsertTagL( TInt aTag, TRect aBoundingRectangle, TInt aLayerId )
       
   165     {
       
   166     if ( aTag >= 0 && aTag < EAlfContentLastTag )
       
   167         {
       
   168         iMsgDataBuf.ReAllocL(0x100);
       
   169         RDesWriteStream out(iMsgDataBuf);
       
   170         TPckgBuf<TUint8> tag(aTag);
       
   171         TPckgBuf<TUint8> zero((TInt)1);
       
   172         TPckgBuf<TRect> rect(aBoundingRectangle); 
       
   173         TPckgBuf<TInt32> layerId(aLayerId);
       
   174         out.WriteL( tag );
       
   175         out.WriteL( zero );
       
   176         out.WriteL( rect );
       
   177         out.WriteL( layerId );
       
   178         out.CommitL();
       
   179         const TUid drawerCrpUid = KAlfHintDrawerInstanceUid;
       
   180         const TWsGraphicId KDrawerCrpId(drawerCrpUid);
       
   181         static_cast<CWindowGc*>(iGc)->DrawWsGraphic(KDrawerCrpId, TRect(0,0,360,640), iMsgDataBuf );
       
   182         out.Close();
       
   183         }
       
   184     else
       
   185         {
       
   186         return KErrNotSupported;
       
   187         }
       
   188     return KErrNone;
       
   189     
       
   190     }
       
   191 
       
   192 EXPORT_C TInt CAlfHintGraphic::InsertTag( TInt aTag, TRect aBoundingRectangle, TInt aLayerId )
       
   193     {
       
   194     TInt result(KErrNone);
       
   195     TRAPD( err, result = InsertTagL( aTag, aBoundingRectangle, aLayerId ) );
       
   196     if (err )
       
   197         {
       
   198         return err;
       
   199         }
       
   200     else
       
   201         {
       
   202         return result;        
       
   203         }
       
   204     
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // InsertTag
       
   209 // ---------------------------------------------------------------------------
       
   210 //
       
   211 EXPORT_C TInt CAlfHintGraphic::InsertTag( TInt aTag  )
       
   212     {// TODO; trap or change name
       
   213     TInt result(KErrNone);
       
   214     TRAPD( err, result = InsertTagL( aTag ) );
       
   215     if (err )
       
   216         {
       
   217         return err;
       
   218         }
       
   219     else
       
   220         {
       
   221         return result;        
       
   222         }
       
   223     }